All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v3] PCI: exynos: Handle PCIe PHY initialization errors
Date: Fri, 30 Oct 2026 15:40:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-191182@kernel.org> (raw)
In-Reply-To: <20261030151701.3100-1-sreekuttan2156239@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] PCI: exynos: return of int in void exynos_pcie_remove() and regulator leak
- [Medium] PCI: exynos: regulator leak in exynos_pcie_resume_noirq() on PHY exit error
- [Medium] PCI: exynos: unrecovered hardware state on exynos_pcie_suspend_noirq() error
--

commit 0c8cd2248f61d9e01add8f3a5e1b399c6f9c0fd4
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

PCI: exynos: Handle PCIe PHY initialization errors

This commit checks the return values of phy_init() and phy_power_on() in
exynos_pcie_host_init() and tracks PHY and regulator state across probe,
remove, suspend, and resume paths.

> diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c
> index e3c05ade381bb..d7504b0e5d96c 100644
> --- a/drivers/pci/controller/dwc/pci-exynos.c
> +++ b/drivers/pci/controller/dwc/pci-exynos.c

[ ... ]

> @@ -332,22 +381,42 @@ static int exynos_pcie_probe(struct platform_device *pdev)
>  static void exynos_pcie_remove(struct platform_device *pdev)
>  {
>  	struct exynos_pcie *ep = platform_get_drvdata(pdev);
> +	int ret;
>  
>  	dw_pcie_host_deinit(&ep->pci.pp);
>  	exynos_pcie_assert_core_reset(ep);
> -	phy_power_off(ep->phy);
> -	phy_exit(ep->phy);
> -	regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies);
> +
> +	ret = exynos_pcie_phy_exit(ep);
> +	if (ret)
> +		return ret;
> +
> +	if (ep->supplies_enabled) {
> +		ret = regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies);
> +		if (ret)
> +			dev_err(&pdev->dev, "failed to disable regulators: %d\n", ret);
> +		else
> +			ep->supplies_enabled = false;
> +	}
>  }

[Severity: High]
In drivers/pci/controller/dwc/pci-exynos.c, exynos_pcie_remove() has a void
return type, so returning ret when exynos_pcie_phy_exit(ep) fails causes a
build error.

Also, if exynos_pcie_phy_exit(ep) returns a non-zero error during driver
removal, doesn't returning early here skip regulator_bulk_disable() and leave
the vdd18 and vdd10 supplies in ep->supplies enabled? Should this log an
error and continue to disable ep->supplies, similar to the fail_probe path in
exynos_pcie_probe()?

>  
>  static int exynos_pcie_suspend_noirq(struct device *dev)
>  {
>  	struct exynos_pcie *ep = dev_get_drvdata(dev);
> +	int ret;
>  
>  	exynos_pcie_assert_core_reset(ep);
> -	phy_power_off(ep->phy);
> -	phy_exit(ep->phy);
> -	regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies);
> +
> +	ret = exynos_pcie_phy_exit(ep);
> +	if (ret)
> +		return ret;
> +
> +	if (ep->supplies_enabled) {
> +		ret = regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies);
> +		if (ret)
> +			return ret;
> +
> +		ep->supplies_enabled = false;
> +	}
>  
>  	return 0;
>  }

[Severity: Medium]
In exynos_pcie_suspend_noirq(), exynos_pcie_assert_core_reset(ep) is called
before exynos_pcie_phy_exit(ep) and regulator_bulk_disable().

If exynos_pcie_phy_exit(ep) or regulator_bulk_disable() returns an error,
device_suspend_noirq() in the PM core aborts before setting
dev->power.is_noirq_suspended, which means device_resume_noirq() will not
call exynos_pcie_resume_noirq() during suspend-abort recovery.

Would that leave the Exynos PCIe controller held in core reset (and with its
PHY powered off or regulators still enabled) when the system aborts suspend?

> @@ -358,13 +427,33 @@ static int exynos_pcie_resume_noirq(struct device *dev)
>  	struct dw_pcie *pci = &ep->pci;
>  	struct dw_pcie_rp *pp = &pci->pp;
>  	int ret;
> +	int err;
>  
>  	ret = regulator_bulk_enable(ARRAY_SIZE(ep->supplies), ep->supplies);
>  	if (ret)
>  		return ret;
>  
> +	ep->supplies_enabled = true;
> +
>  	/* exynos_pcie_host_init controls ep->phy */
> -	exynos_pcie_host_init(pp);
> +	ret = exynos_pcie_host_init(pp);
> +	if (ret) {
> +		err = exynos_pcie_phy_exit(ep);
> +		if (err)
> +			return err;
> +
> +		if (ep->supplies_enabled) {
> +			err = regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies);
> +			if (err)
> +				return err;
> +
> +			ep->supplies_enabled = false;
> +		}
> +
> +		return ret;
> +
> +	}

[Severity: Medium]
In exynos_pcie_resume_noirq(), regulator_bulk_enable() enables ep->supplies
before calling exynos_pcie_host_init(pp).

If exynos_pcie_host_init(pp) fails (for instance, when phy_init() succeeds
and phy_power_on() fails) and the subsequent cleanup call to
exynos_pcie_phy_exit(ep) also returns an error, won't returning err early
bypass regulator_bulk_disable() and leak the regulator enable reference on
ep->supplies?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261030151701.3100-1-sreekuttan2156239@gmail.com?part=1

  reply	other threads:[~2026-10-30 15:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 13:10 [PATCH] PCI: exynos: Handle PHY initialization errors Sreeraj S Kurup
2026-10-29 13:17 ` sashiko-bot
2026-10-29 17:54 ` [PATCH v2] PCI: exynos: Handle PCIe " Sreeraj S Kurup
2026-10-29 18:07   ` sashiko-bot
2026-10-30 15:17 ` [PATCH v3] " Sreeraj S Kurup
2026-10-30 15:40   ` sashiko-bot [this message]
2026-10-30 16:36 ` [PATCH v4] " Sreeraj S Kurup
2026-10-30 16:48   ` sashiko-bot
2026-10-30 17:23 ` [PATCH v5] " Sreeraj S Kurup
2026-10-30 17:38   ` sashiko-bot
2026-10-30 18:09 ` [PATCH v6] " Sreeraj S Kurup
2026-10-30 18:25   ` sashiko-bot

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-191182@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sreekuttan2156239@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.