[V1,2/4] irqchip/loongson-pch-pic: Fix potential incorrect hwirq assignment

Message ID 20230520063818.27208-3-lvjianmin@loongson.cn
State New
Headers
Series irqchip/loongson: Fix some loongson irqchip drivers |

Commit Message

吕建民 May 20, 2023, 6:38 a.m. UTC
  From: Liu Peibao <liupeibao@loongson.cn>

In DeviceTree path, when ht_vec_base is not zero, the hwirq of PCH PIC will
be assigned incorrectly. Because when pch_pic_domain_translate() adds the
ht_vec_base to hwirq, the hwirq dose not subtract the ht_vec_base when
calling irq_domain_set_info().

The ht_vec_base is designed for the parent irq chip/domain of the PCH PIC.
It seems not proper to deal this in callbacks of the PCH PIC domain and
let's put this back like the initial commit ef8c01eb64ca ("irqchip: Add
Loongson PCH PIC controller").

Fixes: bcdd75c596c8 ("irqchip/loongson-pch-pic: Add ACPI init support")
Cc: stable@vger.kernel.org
Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
---
 drivers/irqchip/irq-loongson-pch-pic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

WANG Xuerui May 21, 2023, 10:31 a.m. UTC | #1
On 2023/5/20 14:38, Jianmin Lv wrote:
> From: Liu Peibao <liupeibao@loongson.cn>
> 
> In DeviceTree path, when ht_vec_base is not zero, the hwirq of PCH PIC will
> be assigned incorrectly. Because when pch_pic_domain_translate() adds the
> ht_vec_base to hwirq, the hwirq dose not subtract the ht_vec_base when

"does not have the ht_vec_base subtracted"?

> calling irq_domain_set_info().
> 
> The ht_vec_base is designed for the parent irq chip/domain of the PCH PIC.
> It seems not proper to deal this in callbacks of the PCH PIC domain and
> let's put this back like the initial commit ef8c01eb64ca ("irqchip: Add
> Loongson PCH PIC controller").
> 
> Fixes: bcdd75c596c8 ("irqchip/loongson-pch-pic: Add ACPI init support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
> Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
> ---
>   drivers/irqchip/irq-loongson-pch-pic.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-loongson-pch-pic.c b/drivers/irqchip/irq-loongson-pch-pic.c
> index 921c5c0190d1..93a71f66efeb 100644
> --- a/drivers/irqchip/irq-loongson-pch-pic.c
> +++ b/drivers/irqchip/irq-loongson-pch-pic.c
> @@ -164,7 +164,7 @@ static int pch_pic_domain_translate(struct irq_domain *d,
>   		if (fwspec->param_count < 2)
>   			return -EINVAL;
>   
> -		*hwirq = fwspec->param[0] + priv->ht_vec_base;
> +		*hwirq = fwspec->param[0];
>   		*type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK;
>   	} else {
>   		if (fwspec->param_count < 1)
> @@ -196,7 +196,7 @@ static int pch_pic_alloc(struct irq_domain *domain, unsigned int virq,
>   
>   	parent_fwspec.fwnode = domain->parent->fwnode;
>   	parent_fwspec.param_count = 1;
> -	parent_fwspec.param[0] = hwirq;
> +	parent_fwspec.param[0] = hwirq + priv->ht_vec_base;
>   
>   	err = irq_domain_alloc_irqs_parent(domain, virq, 1, &parent_fwspec);
>   	if (err)
  
吕建民 May 22, 2023, 8:49 a.m. UTC | #2
On 2023/5/21 下午6:31, WANG Xuerui wrote:
> On 2023/5/20 14:38, Jianmin Lv wrote:
>> From: Liu Peibao <liupeibao@loongson.cn>
>>
>> In DeviceTree path, when ht_vec_base is not zero, the hwirq of PCH PIC 
>> will
>> be assigned incorrectly. Because when pch_pic_domain_translate() adds the
>> ht_vec_base to hwirq, the hwirq dose not subtract the ht_vec_base when
> 
> "does not have the ht_vec_base subtracted"?
> 

Ok, I'll change it as your suggestion, thanks.

>> calling irq_domain_set_info().
>>
>> The ht_vec_base is designed for the parent irq chip/domain of the PCH 
>> PIC.
>> It seems not proper to deal this in callbacks of the PCH PIC domain and
>> let's put this back like the initial commit ef8c01eb64ca ("irqchip: Add
>> Loongson PCH PIC controller").
>>
>> Fixes: bcdd75c596c8 ("irqchip/loongson-pch-pic: Add ACPI init support")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
>> Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
>> ---
>>   drivers/irqchip/irq-loongson-pch-pic.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/irqchip/irq-loongson-pch-pic.c 
>> b/drivers/irqchip/irq-loongson-pch-pic.c
>> index 921c5c0190d1..93a71f66efeb 100644
>> --- a/drivers/irqchip/irq-loongson-pch-pic.c
>> +++ b/drivers/irqchip/irq-loongson-pch-pic.c
>> @@ -164,7 +164,7 @@ static int pch_pic_domain_translate(struct 
>> irq_domain *d,
>>           if (fwspec->param_count < 2)
>>               return -EINVAL;
>> -        *hwirq = fwspec->param[0] + priv->ht_vec_base;
>> +        *hwirq = fwspec->param[0];
>>           *type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK;
>>       } else {
>>           if (fwspec->param_count < 1)
>> @@ -196,7 +196,7 @@ static int pch_pic_alloc(struct irq_domain 
>> *domain, unsigned int virq,
>>       parent_fwspec.fwnode = domain->parent->fwnode;
>>       parent_fwspec.param_count = 1;
>> -    parent_fwspec.param[0] = hwirq;
>> +    parent_fwspec.param[0] = hwirq + priv->ht_vec_base;
>>       err = irq_domain_alloc_irqs_parent(domain, virq, 1, 
>> &parent_fwspec);
>>       if (err)
>
  

Patch

diff --git a/drivers/irqchip/irq-loongson-pch-pic.c b/drivers/irqchip/irq-loongson-pch-pic.c
index 921c5c0190d1..93a71f66efeb 100644
--- a/drivers/irqchip/irq-loongson-pch-pic.c
+++ b/drivers/irqchip/irq-loongson-pch-pic.c
@@ -164,7 +164,7 @@  static int pch_pic_domain_translate(struct irq_domain *d,
 		if (fwspec->param_count < 2)
 			return -EINVAL;
 
-		*hwirq = fwspec->param[0] + priv->ht_vec_base;
+		*hwirq = fwspec->param[0];
 		*type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK;
 	} else {
 		if (fwspec->param_count < 1)
@@ -196,7 +196,7 @@  static int pch_pic_alloc(struct irq_domain *domain, unsigned int virq,
 
 	parent_fwspec.fwnode = domain->parent->fwnode;
 	parent_fwspec.param_count = 1;
-	parent_fwspec.param[0] = hwirq;
+	parent_fwspec.param[0] = hwirq + priv->ht_vec_base;
 
 	err = irq_domain_alloc_irqs_parent(domain, virq, 1, &parent_fwspec);
 	if (err)