Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexander Stein" <alexander.stein@ew.tq-group.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 2/2] gpio: mxc: use BIT() macro
Date: Fri, 22 May 2026 07:40:53 +0000	[thread overview]
Message-ID: <20260522074053.7AF901F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260522070118.800671-2-alexander.stein@ew.tq-group.com>

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

Pre-existing issues:
- [High] Unchecked return value from `enable_irq_wake()` leads to permanently corrupted wakeup state.
- [High] Missing locking causes a data race on the shared `port->wakeup_pads` state.
--

commit bd0f86527c727096d8a5aca0060d7d08ddaeda28
Author: Alexander Stein <alexander.stein@ew.tq-group.com>

gpio: mxc: use BIT() macro

This commit updates the gpio-mxc driver to use the BIT() macro instead of
open-coding bit shifts.

> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
> --- a/drivers/gpio/gpio-mxc.c
> +++ b/drivers/gpio/gpio-mxc.c

[ ... ]

> @@ -330,13 +330,13 @@ static int gpio_set_wake_irq(struct irq_data *d, u32 enable)
>  			ret = enable_irq_wake(port->irq_high);
>  		else
>  			ret = enable_irq_wake(port->irq);
> -		port->wakeup_pads |= (1 << gpio_idx);
> +		port->wakeup_pads |= BIT(gpio_idx);

[Severity: High]
This is a pre-existing issue, but does this function properly handle
failures from enable_irq_wake()?

It appears that port->wakeup_pads is modified before validating the return
value of enable_irq_wake() or disable_irq_wake(). If enable_irq_wake() fails
(for instance, if the parent IRQ does not support wakeup), the bit remains
erroneously set.

The irq subsystem core reacts to the failure by leaving the child IRQ's
wake_depth at 0. As a result, subsequent calls to disable_irq_wake() by the
driver will be ignored (triggering an unbalanced irq wake disable warning)
and will never invoke gpio_set_wake_irq() to clear the bit. This causes the
bit to become permanently stuck. 

During system suspend, mxc_gpio_noirq_suspend() could then erroneously
program the SCU to enable pad wakeup for this pin, leading to unintended
system wakeups.

[Severity: High]
This is also a pre-existing issue, but is there a data race when modifying
port->wakeup_pads?

This callback is invoked by irq_set_irq_wake(), which only holds the
desc->lock of the specific child IRQ (the individual GPIO pin). It does not
seem to hold the shared GPIO chip's gc->lock.

Since port->wakeup_pads tracks the wakeup state of all 32 pins on the
port, if multiple drivers concurrently configure wakeup for different pins on
the same port, they would hold independent child locks and concurrently
modify port->wakeup_pads. Could this lead to lost updates, potentially
resulting in the system failing to wake up from suspend?

>  	} else {
>  		if (port->irq_high && (gpio_idx >= 16))
>  			ret = disable_irq_wake(port->irq_high);
>  		else
>  			ret = disable_irq_wake(port->irq);
> -		port->wakeup_pads &= ~(1 << gpio_idx);
> +		port->wakeup_pads &= ~BIT(gpio_idx);
>  	}
>  
>  	return ret;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260522070118.800671-1-alexander.stein@ew.tq-group.com?part=2

  reply	other threads:[~2026-05-22  7:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  7:01 [PATCH 1/2] gpio: mxc: fix irq_high handling Alexander Stein
2026-05-22  7:01 ` [PATCH 2/2] gpio: mxc: use BIT() macro Alexander Stein
2026-05-22  7:40   ` sashiko-bot [this message]
2026-05-22 18:09   ` Frank Li
2026-05-22  7:30 ` [PATCH 1/2] gpio: mxc: fix irq_high handling sashiko-bot
2026-05-22 18:21 ` Frank Li

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=20260522074053.7AF901F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=imx@lists.linux.dev \
    --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