All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xincheng Zhang" <zhangxincheng@ultrarisc.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 2/2] PCI: ultrarisc: Skip MEM outbound iATU setup on DP1000
Date: Sat, 05 Sep 2026 03:10:43 +0000	[thread overview]
Message-ID: <20260905031043.875211F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260905025635.211390-3-zhangxincheng@ultrarisc.com>

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

Pre-existing issues:
- [High] Missing `.remove` callback in platform driver causes memory leaks, use-after-free, and unbalanced clocks on module unload.
- [High] Ignored return value of `dw_pcie_setup_rc()` during resume leads to unconditionally accessing uninitialized hardware.
- [High] Missing `dw_pcie_dbi_ro_wr_dis()` on the error path leaves DBI read-only registers writable.
--

commit c554fce09754058c518d7827f376e2e64ea19f5a
Author: Xincheng Zhang <zhangxincheng@ultrarisc.com>

PCI: ultrarisc: Skip MEM outbound iATU setup on DP1000

This patch sets the bypass_ob_mem_iatu flag for the DP1000 controller to
skip generic DWC MEM outbound iATU setup. This avoids the 16-window limit
and allows for a larger 64-bit MEM aperture.

> diff --git a/drivers/pci/controller/dwc/pcie-ultrarisc.c b/drivers/pci/controller/dwc/pcie-ultrarisc.c
> --- a/drivers/pci/controller/dwc/pcie-ultrarisc.c
> +++ b/drivers/pci/controller/dwc/pcie-ultrarisc.c
[ ... ]
>  static struct platform_driver ultrarisc_pcie_driver = {
>  	.driver = {
>  		.name	= "ultrarisc-pcie",
>  		.of_match_table = ultrarisc_pcie_of_match,
>  		.suppress_bind_attrs = true,
>  		.pm = &ultrarisc_pcie_pm_ops,
>  	},
>  	.probe = ultrarisc_pcie_probe,
>  };
>  module_platform_driver(ultrarisc_pcie_driver);

[Severity: High]
This isn't a bug introduced by this patch, but is it safe to leave out
the .remove callback in the platform driver?

Since dw_pcie_host_init() is not devres-managed, unloading the module 
triggers devres release which frees driver memory and disables clocks, but
leaves the PCI host bridge and devices registered. Could this cause a
use-after-free and hardware hang if those devices are accessed later?

> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
[ ... ]
>  	if (pp->bridge->child_ops == &dw_child_pcie_ops || pp->ecam_enabled) {
>  		ret = dw_pcie_iatu_setup(pp);
>  		if (ret)
>  			return ret;
>  	}
>  
>  	dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, 0);
[ ... ]
>  	dw_pcie_dbi_ro_wr_dis(pci);

[Severity: High]
This is a pre-existing issue, but does this error path bypass restoring the 
read-only write protection? 

The function dw_pcie_setup_rc() disables read-only protection at the 
beginning via dw_pcie_dbi_ro_wr_en(). If dw_pcie_iatu_setup() fails, it 
returns immediately. Does this permanently leave critical PCI hardware 
configuration registers writable?

[ ... ]
>  	if (pci->pp.ops->init) {
>  		ret = pci->pp.ops->init(&pci->pp);
>  		if (ret) {
>  			dev_err(pci->dev, "Host init failed: %d\n", ret);
>  			return ret;
>  		}
>  	}
>  
>  	dw_pcie_setup_rc(&pci->pp);
>  
>  	ret = dw_pcie_start_link(pci);
>  	if (ret)
>  		goto err_deinit;

[Severity: High]
This is a pre-existing issue, but what happens if dw_pcie_setup_rc() fails
during resume?

It appears the return value of dw_pcie_setup_rc() is completely ignored. 
If it encounters an error like an ATU enable timeout returning -EBUSY, the 
driver proceeds to call dw_pcie_start_link() and re-enable endpoints while 
the Root Complex hardware is incorrectly initialized. Could this lead to 
accessing uninitialized hardware and causing a synchronous external abort?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260905025635.211390-1-zhangxincheng@ultrarisc.com?part=2

  reply	other threads:[~2026-09-05  3:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-05  2:56 [PATCH v2 0/2] PCI: dwc: Support large BARs on UltraRISC DP1000 Xincheng Zhang
2026-09-05  2:56 ` [PATCH v2 1/2] PCI: dwc: Allow drivers to skip MEM outbound iATU setup Xincheng Zhang
2026-09-05  3:04   ` sashiko-bot
2026-10-14  8:27   ` Niklas Cassel
2026-09-05  2:56 ` [PATCH v2 2/2] PCI: ultrarisc: Skip MEM outbound iATU setup on DP1000 Xincheng Zhang
2026-09-05  3:10   ` sashiko-bot [this message]
2026-10-14  6:03 ` [PATCH v2 0/2] PCI: dwc: Support large BARs on UltraRISC DP1000 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=20260905031043.875211F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhangxincheng@ultrarisc.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.