Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maulik Shah" <maulik.shah@oss.qualcomm.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH] gpio: Use IRQ trigger mask helpers
Date: Sun, 02 Aug 2026 14:32:44 +0000	[thread overview]
Message-ID: <20260802143244.C76AB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260802-b4b4-irq-trigger-mask-gpio-v1-1-948973636c84@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing spinlock serialization for shared bank registers in IRQ chip callbacks.
--

--- Patch [1]: [PATCH] gpio: Use IRQ trigger mask helpers ---
commit a6c81ea868de6b9a08df67a583f7641fb4809834
Author: Maulik Shah <maulik.shah@oss.qualcomm.com>

    gpio: Use IRQ trigger mask helpers
    
    Use IRQ_TYPE_LEVEL_MASK and IRQ_TYPE_EDGE_BOTH instead of open-coded
    trigger type combinations in irqchip callbacks.
    
    No functional change intended.

[ ... ]

> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
> index 5d61053e0596a..2b5da973f51fe 100644
> --- a/drivers/gpio/gpio-pxa.c
> +++ b/drivers/gpio/gpio-pxa.c
> @@ -406,7 +406,7 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type)
>  		if (__gpio_is_occupied(pchip, gpio))
>  			return 0;
>  
> -		type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
> +		type = IRQ_TYPE_EDGE_BOTH;
>  	}
>  
>  	gpdr = readl_relaxed(c->regbase + GPDR_OFFSET);
>  
>  	if (__gpio_is_inverted(gpio))
>  		writel_relaxed(gpdr | mask,  c->regbase + GPDR_OFFSET);
>  	else
>  		writel_relaxed(gpdr & ~mask, c->regbase + GPDR_OFFSET);

[Severity: High]
This is a pre-existing issue, but since you are touching this function,
is it safe to perform these read-modify-write operations on the GPDR register 
without a spinlock? 

It seems this could race with other IRQs in the same bank and with 
gpio_direction operations. For instance, pxa_gpio_irq_type() races with 
pxa_gpio_direction_input() and pxa_gpio_direction_output() over the GPDR 
register, as the latter use gpio_lock but the former does not.

A similar issue appears in pxa_mask_muxed_gpio():

pxa_mask_muxed_gpio() {
    ...
    b->irq_mask &= ~GPIO_bit(gpio);

    grer = readl_relaxed(base + GRER_OFFSET) & ~GPIO_bit(gpio);
    gfer = readl_relaxed(base + GFER_OFFSET) & ~GPIO_bit(gpio);
    writel_relaxed(grer, base + GRER_OFFSET);
    writel_relaxed(gfer, base + GFER_OFFSET);
    ...
}

and pxa_unmask_muxed_gpio():

pxa_unmask_muxed_gpio() {
    ...
    c->irq_mask |= GPIO_bit(gpio);
    update_edge_detect(c);
    ...
}

Can this lack of serialization lead to data corruption of the GPIO direction
configuration (GPDR) and interrupt edge detection configuration, potentially
causing improperly configured pins or permanent loss of interrupts on SMP
systems when called concurrently for different GPIOs within the same bank?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260802-b4b4-irq-trigger-mask-gpio-v1-1-948973636c84@oss.qualcomm.com?part=1

  reply	other threads:[~2026-08-02 14:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02 14:10 [PATCH] gpio: Use IRQ trigger mask helpers Maulik Shah
2026-08-02 14:32 ` sashiko-bot [this message]
2026-08-06 21:50 ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260802143244.C76AB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=maulik.shah@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox