From: sashiko-bot@kernel.org
To: "Fil Dunsky" <filipp.dunsky@gmail.com>
Cc: linux-pci@vger.kernel.org, linux-clk@vger.kernel.org,
linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH 7/8] PCI: cs7542: Add CS7542 PCIe host support
Date: Mon, 23 Nov 2026 19:11:10 +0000 [thread overview]
Message-ID: <sashiko-outbox-229914@kernel.org> (raw)
In-Reply-To: <20261123-b4-cs7542-pcie-v1-7-4cde5201d404@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] PCI: cs7542: PCI_MSI_FLAGS_ENABLE in cortina_pcie_host_init()
cleared on probe
- [High] PCI: cs7542: undisposed INTx virq mappings before
irq_domain_remove()
- [Medium] PCI: cs7542: cortina_pcie_read_dbi() ~0U return masks iATU
failure on link loss
- [Medium] PCI: cs7542: missing link_lost and IRQ sync in
cortina_pcie_shutdown()
--
commit cd2c931b6a3541fd8734c17e2a7332622247b319
Author: Fil Dunsky <filipp.dunsky@gmail.com>
PCI: cs7542: Add CS7542 PCIe host support
This commit adds a DesignWare PCIe host controller driver for Cortina
Systems CS7542 SoCs, handling clock/reset/PHY setup, multiplexed INTx and
MSI interrupts, root configuration filtering, and link-loss blocking.
> diff --git a/drivers/pci/controller/dwc/pcie-cs7542.c b/drivers/pci/controller/dwc/pcie-cs7542.c
> new file mode 100644
> index 0000000000000..19225e9a292ef
> --- /dev/null
> +++ b/drivers/pci/controller/dwc/pcie-cs7542.c
[ ... ]
> +static int cortina_pcie_host_init(struct dw_pcie_rp *pp)
> +{
> + struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> + u8 cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI);
> + u16 flags;
> +
> + pp->bridge->ops = &cortina_own_pci_ops;
> + pp->keep_rp_msi_en = true;
> + if (cap) {
> + flags = dw_pcie_readw_dbi(pci, cap + PCI_MSI_FLAGS);
> + dw_pcie_writew_dbi(pci, cap + PCI_MSI_FLAGS, flags | PCI_MSI_FLAGS_ENABLE);
> + }
> + return 0;
> +}
[Severity: High]
Will pci_host_probe() clear PCI_MSI_FLAGS_ENABLE right after
cortina_pcie_host_init() sets it?
dw_pcie_host_init() runs pp->ops->init(pp) before calling
pci_host_probe(bridge). Because pp->keep_rp_msi_en keeps PCI_CAP_ID_MSI
visible on the Root Port, enumerating the Root Port calls
pci_init_capabilities() -> pci_msi_init(), which clears
PCI_MSI_FLAGS_ENABLE via cortina_pcie_wr_own_conf() and leaves the Root
Port MSI receiver disabled. Setting PCI_MSI_FLAGS_ENABLE in
pp->ops->post_init (or after dw_pcie_host_init() returns) would avoid
this.
[ ... ]
> +/* Standard RC configuration above 512 bytes wedges the CS7542 bus.
> + * The DesignWare private register bank at 0x700 and above remains accessible.
> + */
> +static u32 cortina_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base,
> + u32 reg, size_t size)
> +{
> + struct cortina_pcie *cp = to_cortina_pcie(pci);
> + u32 value = 0;
> +
> + if (READ_ONCE(cp->link_lost))
> + return ~0U;
> + if (base == pci->dbi_base && reg < 0x700 && reg + size > RC_CFG_LIMIT)
> + return 0;
> + dw_pcie_read(base + reg, size, &value);
> + return value;
> +}
[Severity: Medium]
Can returning ~0U from cortina_pcie_read_dbi() when cp->link_lost is set
trick dw_pcie_prog_outbound_atu() into reporting success?
CPU0 CPU1
dw_pcie_other_conf_map_bus()
dw_pcie_link_up() -> true
cortina_pcie_irq_handler()
cp->link_lost = true
dw_pcie_prog_outbound_atu()
dw_pcie_writel_atu_ob() (dropped)
dw_pcie_readl_atu_ob(..., ATU_REGION_CTRL2)
cortina_pcie_read_dbi() -> ~0U
val & ATU_ENABLE -> true
return 0
return pp->va_cfg0_base + where <-- accesses downstream cfg window
Because ATU_ENABLE is BIT(31), ~0U satisfies the poll in
dw_pcie_prog_outbound_atu() even though cortina_pcie_write_dbi() dropped
the iATU writes, allowing downstream config accesses to proceed after link
loss.
[ ... ]
> + ret = dw_pcie_host_init(&pci->pp);
> + if (ret) {
> + writel(0, cp->app + APP_INT_ENABLE);
> + irq_set_chained_handler_and_data(cp->irq, NULL, NULL);
> + irq_domain_remove(cp->intx_domain);
> + goto power_off;
> + }
> + platform_set_drvdata(pdev, cp);
> + return 0;
> +
> +power_off:
> + gpiod_set_value_cansleep(cp->perst, 1);
> + reset_control_assert(cp->reset);
> + phy_power_off(cp->phy);
> +exit_phy:
> + phy_exit(cp->phy);
> +disable_clk:
> + reset_control_assert(cp->reset);
> + clk_disable_unprepare(cp->clk);
> + return dev_err_probe(dev, ret, "host initialization\n");
> +}
> +
> +static void cortina_pcie_remove(struct platform_device *pdev)
> +{
> + struct cortina_pcie *cp = platform_get_drvdata(pdev);
> +
> + dw_pcie_host_deinit(&cp->pci.pp);
> + irq_set_chained_handler_and_data(cp->irq, NULL, NULL);
> + irq_domain_remove(cp->intx_domain);
> + cortina_pcie_power_off(cp);
> +}
[Severity: High]
Does removing cp->intx_domain without disposing of its mapped virtual IRQs
leak IRQ descriptors and leave dangling pointers to cp and
cortina_intx_chip?
During pci_host_probe(), pci_assign_irq() maps INTx interrupts in
cp->intx_domain (including for the Root Port itself, where
dw_pcie_setup_rc() sets PCI_INTERRUPT_PIN = 1), and the PCI core does not
unmap shared INTx lines on bus removal. Both cortina_pcie_remove() and
the dw_pcie_host_init() error path call irq_domain_remove(cp->intx_domain)
without first calling irq_dispose_mapping(irq_find_mapping(cp->intx_domain, i))
for each INTx line, leaving allocated irq_desc entries referencing the
freed domain and driver state.
> +static void cortina_pcie_shutdown(struct platform_device *pdev)
> +{
> + struct cortina_pcie *cp = platform_get_drvdata(pdev);
> +
> + writel(0, cp->app + APP_INT_ENABLE);
> + cortina_pcie_stop_link(&cp->pci);
> + gpiod_set_value_cansleep(cp->perst, 1);
> + reset_control_assert(cp->reset);
> +}
[Severity: Medium]
Can cortina_pcie_shutdown() race with in-flight interrupts or subsequent
DBI accesses while asserting controller reset?
CPU0 CPU1
cortina_pcie_shutdown()
writel(0, cp->app + APP_INT_ENABLE)
cortina_pcie_irq_handler()
dw_handle_msi_irq()
cortina_pcie_stop_link()
reset_control_assert(cp->reset)
dw_pcie_readl_dbi() <-- DBI access in reset
cortina_pcie_shutdown() does not take cp->lock, set cp->link_lost = true,
or call synchronize_irq(cp->irq). An in-flight IRQ handler or a
concurrent config/DBI access (which checks cp->link_lost) can access DBI
after the link is stopped and cp->reset is asserted, and a concurrent
cortina_intx_unmask() can also re-enable bits in APP_INT_ENABLE.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-b4-cs7542-pcie-v1-0-4cde5201d404@gmail.com?part=7
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-11-23 19:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 18:43 [PATCH 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
2026-11-23 18:43 ` [PATCH 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
2026-11-23 18:52 ` sashiko-bot
2026-11-23 18:43 ` [PATCH 2/8] dt-bindings: clock: Describe CS7542 PCIe gates and resets Fil Dunsky via B4 Relay
2026-11-23 18:49 ` sashiko-bot
2026-11-23 18:43 ` [PATCH 3/8] clk: Add " Fil Dunsky via B4 Relay
2026-11-23 18:43 ` [PATCH 4/8] dt-bindings: phy: Describe CS7542 PCIe SerDes Fil Dunsky via B4 Relay
2026-11-23 18:43 ` [PATCH 5/8] phy: Add CS7542 PCIe SerDes support Fil Dunsky via B4 Relay
2026-11-23 18:43 ` [PATCH 6/8] dt-bindings: PCI: Describe the CS7542 host controller Fil Dunsky via B4 Relay
2026-11-23 18:48 ` sashiko-bot
2026-11-23 18:43 ` [PATCH 7/8] PCI: cs7542: Add CS7542 PCIe host support Fil Dunsky via B4 Relay
2026-11-23 19:11 ` sashiko-bot [this message]
2026-11-23 18:43 ` [PATCH 8/8] MAINTAINERS: Add CS7542 PCIe support Fil Dunsky via B4 Relay
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-229914@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=filipp.dunsky@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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