Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "William Bright" <william.bright@imd-tec.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] power: sequencing: pcie-m2: Drive the Key E SDIO_RESET# signal
Date: Mon, 26 Oct 2026 12:11:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-185177@kernel.org> (raw)
In-Reply-To: <20261026-pwrseq-pcie-m2-sdio-reset-v1-1-02ecdafce518@imd-tec.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] pwrseq: pcie-m2: regulator enable leak in pwrseq_pcie_m2_vregs_enable()
- [Medium] pwrseq: pcie-m2: missing rollback on error in pwrseq_pcie_m2_vregs_disable()
--

commit e3e29ad909cb95485a7ebf63430d7d702095bb39
Author: William Bright <william.bright@imd-tec.com>

power: sequencing: pcie-m2: Drive the Key E SDIO_RESET# signal

This commit requests the optional sdio-reset-gpios line asserted during probe,
deasserts it after enabling the M.2 connector supplies, and asserts it again
before disabling the supplies.

> diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c
> index 56c5d51293c10..f8791e8080bdd 100644
> --- a/drivers/power/sequencing/pwrseq-pcie-m2.c
> +++ b/drivers/power/sequencing/pwrseq-pcie-m2.c
> @@ -39,6 +39,7 @@ struct pwrseq_pcie_m2_ctx {
>  	struct notifier_block nb;
>  	struct gpio_desc *w_disable1_gpio;
>  	struct gpio_desc *w_disable2_gpio;
> +	struct gpio_desc *sdio_reset_gpio;
>  	struct device *dev;
>  	struct list_head pci_devices;
>  	struct mutex list_lock;
> @@ -47,13 +48,23 @@ struct pwrseq_pcie_m2_ctx {
>  static int pwrseq_pcie_m2_vregs_enable(struct pwrseq_device *pwrseq)
>  {
>  	struct pwrseq_pcie_m2_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);
> +	int ret;
> +
> +	ret = regulator_bulk_enable(ctx->num_vregs, ctx->regs);
> +	if (ret)
> +		return ret;
>  
> -	return regulator_bulk_enable(ctx->num_vregs, ctx->regs);
> +	return gpiod_set_value_cansleep(ctx->sdio_reset_gpio, 0);
>  }

[Severity: Medium]
Does pwrseq_pcie_m2_vregs_enable() leak the regulator enable reference counts
in ctx->regs if gpiod_set_value_cansleep() fails (for example, when
sdio-reset-gpios is backed by an I2C GPIO expander)?

In drivers/power/sequencing/core.c, pwrseq_unit_enable() only disables
unit->deps when unit->enable() returns an error and does not increment
unit->enable_count or invoke unit->disable():

drivers/power/sequencing/core.c:pwrseq_unit_enable() {
	...
	if (unit->enable) {
		ret = unit->enable(pwrseq);
		if (ret) {
			dev_err(&pwrseq->dev,
				"Failed to enable target '%s': %d\n",
				unit->name, ret);
			pwrseq_unit_disable_deps(pwrseq, &unit->deps);
			return ret;
		}
	}

	unit->enable_count++;
	...
}

Should pwrseq_pcie_m2_vregs_enable() call regulator_bulk_disable(ctx->num_vregs,
ctx->regs) before returning when gpiod_set_value_cansleep() fails?

>  
>  static int pwrseq_pcie_m2_vregs_disable(struct pwrseq_device *pwrseq)
>  {
>  	struct pwrseq_pcie_m2_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);
> +	int ret;
> +
> +	ret = gpiod_set_value_cansleep(ctx->sdio_reset_gpio, 1);
> +	if (ret)
> +		return ret;
>  
>  	return regulator_bulk_disable(ctx->num_vregs, ctx->regs);
>  }

[Severity: Medium]
Similarly, in pwrseq_pcie_m2_vregs_disable(), what happens if
regulator_bulk_disable(ctx->num_vregs, ctx->regs) fails after
ctx->sdio_reset_gpio has been asserted?

When unit->disable() fails in drivers/power/sequencing/core.c,
pwrseq_unit_disable() aborts without decrementing unit->enable_count and rolls
back the dependent unit by calling its unit->enable() callback, leaving the
regulators and power sequencer state enabled while ctx->sdio_reset_gpio remains
asserted.

Should ctx->sdio_reset_gpio be deasserted again if regulator_bulk_disable()
returns an error?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261026-pwrseq-pcie-m2-sdio-reset-v1-1-02ecdafce518@imd-tec.com?part=1

  reply	other threads:[~2026-10-26 12:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 11:38 [PATCH] power: sequencing: pcie-m2: Drive the Key E SDIO_RESET# signal William Bright
2026-10-26 12:11 ` sashiko-bot [this message]
2026-10-26 12:46 ` Manivannan Sadhasivam
2026-10-26 13:56   ` William Bright
2026-10-27 11:59     ` Manivannan Sadhasivam

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=sashiko-outbox-185177@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=william.bright@imd-tec.com \
    /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