Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Inochi Amaoto" <inochiama@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v3 6/6] PCI: spacemit-k1: Add Spacemit K3 PCIe host controller support
Date: Fri, 03 Jul 2026 02:20:57 +0000	[thread overview]
Message-ID: <20260703022058.1FD001F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703020003.485436-7-inochiama@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Unclocked MMIO access during probe triggers a synchronous bus abort.
- [High] Incorrect `.deinit` callback for K3 prevents PERST# assertion on teardown.
- [High] AXI cache coherency initialization is bypassed when MSIs are disabled.
- [Medium] Misleading comment and potential missing initialization for Root Complex mode.
--

commit 93fac4ee5b6c6ef1d779cae9b2ff5efed7a8fb39
Author: Inochi Amaoto <inochiama@gmail.com>

PCI: spacemit-k1: Add Spacemit K3 PCIe host controller support

The PCIe controller on Spacemit K3 is almost a standard Synopsys
DesignWare PCIe IP with extra link and reset control. Unlike
the PCIe controller on K1, this controller supports external MSI
interrupt controller and can use multiple PHYs at the same time.

Add driver to support PCIe controller on Spacemit K3 PCIe.

> diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
> index 31aac056b68ed..680acc93f5395 100644
> --- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
> +++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
[ ... ]
> @@ -340,6 +354,109 @@ static int k1_pcie_parse_port(struct k1_pcie *k1)
>  	return ret;
>  }
>  
> +static int k3_pcie_init(struct dw_pcie_rp *pp)
> +{
[ ... ]
> +	/*
> +	 * Put the controller in root complex mode, and indicate that
> +	 * Vaux (3.3v) is present.
> +	 */
> +	regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CONTROL_LOGIC,
> +			PCIE_PERSTN_OUT | PCIE_PERSTN_OE);

[Severity: Medium]
Will this omit initializing the controller into root complex mode?

Unlike k1_pcie_init(), this code block only drives the PERST# reset pins and
seems to skip setting DEVICE_TYPE_RC.

> +
> +	val = dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF);
[ ... ]
> +static int k3_pcie_msi_host_init(struct dw_pcie_rp *pp)
> +{
> +	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> +	u32 val;
> +
> +	dw_pcie_dbi_ro_wr_en(pci);
> +
> +	val = dw_pcie_readl_dbi(pci, COHERENCY_CONTROL_3_OFF);
> +	val = u32_replace_bits(val, K3_CACHE_MSTR_AWCACHE_BEHAVIOR,
> +			       K3_CACHE_MSTR_AWCACHE_MODE);
> +	dw_pcie_writel_dbi(pci, COHERENCY_CONTROL_3_OFF, val);
> +
> +	dw_pcie_dbi_ro_wr_dis(pci);
> +
> +	return 0;
> +}

[Severity: High]
Does this code miss initializing AXI cache coherency when MSIs are disabled?

Since k3_pcie_msi_host_init() is only called if pci_msi_enabled() is true,
booting with pci=nomsi would skip this callback, silently skipping general
cache coherency initialization for the controller.

> +
> +static const struct dw_pcie_host_ops k3_pcie_host_ops = {
> +	.init		= k3_pcie_init,
> +	.deinit		= k1_pcie_deinit,

[Severity: High]
Can reusing k1_pcie_deinit() prevent PERST# assertion on teardown?

During initialization, k3_pcie_init() bypasses the K1 mechanism by setting
PCIE_IGNORE_PERSTN in PCIE_CONTROL_LOGIC. Since k1_pcie_deinit() attempts to
toggle PCIE_RC_PERST, won't the K3 hardware ignore it?

> +	.msi_init	= k3_pcie_msi_host_init,
> +};
> +
> +static const struct dw_pcie_ops k3_pcie_ops = {
> +	.link_up	= k1_pcie_link_up,
> +	.start_link	= k1_pcie_start_link,
> +	.stop_link	= k1_pcie_stop_link,
> +};
> +
> +static void k3_pcie_clear_irq_status(struct k1_pcie *k1,
> +				     u32 *status0, u32 *status1, u32 *status2)
> +{
> +	*status0 = readl_relaxed(k1->link + K3_PHY_AHB_IRQSTATUS_INTX);
> +	*status1 = readl_relaxed(k1->link + INTR_STATUS);
> +	*status2 = readl_relaxed(k1->link + K3_ADDR_INTR_STATUS1);

[Severity: High]
Could this read unclocked MMIO memory and trigger a synchronous bus abort?

In k1_pcie_probe(), data->parse_port() is called before dw_pcie_host_init():

k1_pcie_probe() {
    ...
    ret = data->parse_port(k1);
    ...
    ret = dw_pcie_host_init(&k1->pci.pp);
}

This means k3_pcie_parse_port() and k3_pcie_clear_irq_status() are executed
before the required hardware clocks are enabled, accessing hardware registers
while their backing clocks are gated.

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

  reply	other threads:[~2026-07-03  2:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03  1:59 [PATCH v3 0/6] riscv: spacemit: Add PCIe RC controller support for K3 Inochi Amaoto
2026-07-03  1:59 ` [PATCH v3 1/6] PCI: spacemit-k1: Add device data support Inochi Amaoto
2026-07-03  2:15   ` sashiko-bot
2026-07-03  1:59 ` [PATCH v3 2/6] PCI: spacemit-k1: Add multiple PHY handles support Inochi Amaoto
2026-07-03  2:15   ` sashiko-bot
2026-07-03  1:59 ` [PATCH v3 3/6] PCI: spacemit-k1: Add device id update helper Inochi Amaoto
2026-07-03  2:13   ` sashiko-bot
2026-07-03  2:00 ` [PATCH v3 4/6] dt-bindings: PCI: snps,dw-pcie: Add msi-parent for MSI handle check Inochi Amaoto
2026-07-03  2:13   ` sashiko-bot
2026-07-03  2:00 ` [PATCH v3 5/6] dt-bindings: PCI: spacemit: Introduce Spacemit K3 PCIe host controller Inochi Amaoto
2026-07-03  2:15   ` sashiko-bot
2026-07-03  2:00 ` [PATCH v3 6/6] PCI: spacemit-k1: Add Spacemit K3 PCIe host controller support Inochi Amaoto
2026-07-03  2:20   ` sashiko-bot [this message]
2026-07-05  1:52     ` Inochi Amaoto
2026-07-03 17:15 ` [PATCH v3 0/6] riscv: spacemit: Add PCIe RC controller support for K3 Aurelien Jarno

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=20260703022058.1FD001F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=inochiama@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=robh@kernel.org \
    --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