diff mbox series

[3/5] irqchip: loongson-liointc: Fix misuse of gc->mask_cache

Message ID 1596000130-8689-3-git-send-email-chenhc@lemote.com (mailing list archive)
State Superseded
Headers show
Series [1/5] dt-bindings: interrupt-controller: Update Loongson HTVEC description | expand

Commit Message

Huacai Chen July 29, 2020, 5:22 a.m. UTC
In gc->mask_cache bits, 1 means enabled and 0 means disabled, but in the
loongson-liointc driver mask_cache is misused by reverting its meaning.
This patch fix the bug and update the comments as well.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 drivers/irqchip/irq-loongson-liointc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Jiaxun Yang July 29, 2020, 5:26 a.m. UTC | #1
在 2020/7/29 13:22, Huacai Chen 写道:
> In gc->mask_cache bits, 1 means enabled and 0 means disabled, but in the
> loongson-liointc driver mask_cache is misused by reverting its meaning.
> This patch fix the bug and update the comments as well.

Suprisingly it even works with the wrong usage of mask_cache.
Thanks for catching that!

Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

>
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> ---
>   drivers/irqchip/irq-loongson-liointc.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
> index 63b6147..08165c5 100644
> --- a/drivers/irqchip/irq-loongson-liointc.c
> +++ b/drivers/irqchip/irq-loongson-liointc.c
> @@ -60,7 +60,7 @@ static void liointc_chained_handle_irq(struct irq_desc *desc)
>   	if (!pending) {
>   		/* Always blame LPC IRQ if we have that bug */
>   		if (handler->priv->has_lpc_irq_errata &&
> -			(handler->parent_int_map & ~gc->mask_cache &
> +			(handler->parent_int_map & gc->mask_cache &
>   			BIT(LIOINTC_ERRATA_IRQ)))
>   			pending = BIT(LIOINTC_ERRATA_IRQ);
>   		else
> @@ -131,11 +131,11 @@ static void liointc_resume(struct irq_chip_generic *gc)
>   	irq_gc_lock_irqsave(gc, flags);
>   	/* Disable all at first */
>   	writel(0xffffffff, gc->reg_base + LIOINTC_REG_INTC_DISABLE);
> -	/* Revert map cache */
> +	/* Restore map cache */
>   	for (i = 0; i < LIOINTC_CHIP_IRQ; i++)
>   		writeb(priv->map_cache[i], gc->reg_base + i);
> -	/* Revert mask cache */
> -	writel(~gc->mask_cache, gc->reg_base + LIOINTC_REG_INTC_ENABLE);
> +	/* Restore mask cache */
> +	writel(gc->mask_cache, gc->reg_base + LIOINTC_REG_INTC_ENABLE);
>   	irq_gc_unlock_irqrestore(gc, flags);
>   }
>   
> @@ -243,7 +243,7 @@ int __init liointc_of_init(struct device_node *node,
>   	ct->chip.irq_mask_ack = irq_gc_mask_disable_reg;
>   	ct->chip.irq_set_type = liointc_set_type;
>   
> -	gc->mask_cache = 0xffffffff;
> +	gc->mask_cache = 0;
>   	priv->gc = gc;
>   
>   	for (i = 0; i < LIOINTC_NUM_PARENT; i++) {
Marc Zyngier July 29, 2020, 3:04 p.m. UTC | #2
Huacai,

On 2020-07-29 06:26, Jiaxun Yang wrote:
> 在 2020/7/29 13:22, Huacai Chen 写道:
>> In gc->mask_cache bits, 1 means enabled and 0 means disabled, but in 
>> the
>> loongson-liointc driver mask_cache is misused by reverting its 
>> meaning.
>> This patch fix the bug and update the comments as well.
> 
> Suprisingly it even works with the wrong usage of mask_cache.
> Thanks for catching that!
> 
> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

Does any of this series need to be backported to a previous revision
of the kernel? If so, please provide Fixes: tags for the relevant
patches, and potentially a Cc: stable if required.

Also, please add a cover letter when posting such a series,
as it makes it easier to track.

Thanks,

         M.
Huacai Chen July 30, 2020, 1:16 a.m. UTC | #3
Hi, Marc

On Wed, Jul 29, 2020 at 11:04 PM Marc Zyngier <maz@kernel.org> wrote:
>
> Huacai,
>
> On 2020-07-29 06:26, Jiaxun Yang wrote:
> > 在 2020/7/29 13:22, Huacai Chen 写道:
> >> In gc->mask_cache bits, 1 means enabled and 0 means disabled, but in
> >> the
> >> loongson-liointc driver mask_cache is misused by reverting its
> >> meaning.
> >> This patch fix the bug and update the comments as well.
> >
> > Suprisingly it even works with the wrong usage of mask_cache.
> > Thanks for catching that!
> >
> > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>
> Does any of this series need to be backported to a previous revision
> of the kernel? If so, please provide Fixes: tags for the relevant
> patches, and potentially a Cc: stable if required.
>
> Also, please add a cover letter when posting such a series,
> as it makes it easier to track.
OK, I will send V2, thanks.

>
> Thanks,
>
>          M.
> --
> Jazz is not dead. It just smells funny...
diff mbox series

Patch

diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
index 63b6147..08165c5 100644
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -60,7 +60,7 @@  static void liointc_chained_handle_irq(struct irq_desc *desc)
 	if (!pending) {
 		/* Always blame LPC IRQ if we have that bug */
 		if (handler->priv->has_lpc_irq_errata &&
-			(handler->parent_int_map & ~gc->mask_cache &
+			(handler->parent_int_map & gc->mask_cache &
 			BIT(LIOINTC_ERRATA_IRQ)))
 			pending = BIT(LIOINTC_ERRATA_IRQ);
 		else
@@ -131,11 +131,11 @@  static void liointc_resume(struct irq_chip_generic *gc)
 	irq_gc_lock_irqsave(gc, flags);
 	/* Disable all at first */
 	writel(0xffffffff, gc->reg_base + LIOINTC_REG_INTC_DISABLE);
-	/* Revert map cache */
+	/* Restore map cache */
 	for (i = 0; i < LIOINTC_CHIP_IRQ; i++)
 		writeb(priv->map_cache[i], gc->reg_base + i);
-	/* Revert mask cache */
-	writel(~gc->mask_cache, gc->reg_base + LIOINTC_REG_INTC_ENABLE);
+	/* Restore mask cache */
+	writel(gc->mask_cache, gc->reg_base + LIOINTC_REG_INTC_ENABLE);
 	irq_gc_unlock_irqrestore(gc, flags);
 }
 
@@ -243,7 +243,7 @@  int __init liointc_of_init(struct device_node *node,
 	ct->chip.irq_mask_ack = irq_gc_mask_disable_reg;
 	ct->chip.irq_set_type = liointc_set_type;
 
-	gc->mask_cache = 0xffffffff;
+	gc->mask_cache = 0;
 	priv->gc = gc;
 
 	for (i = 0; i < LIOINTC_NUM_PARENT; i++) {