public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] PCI: xilinx-nwl: Avoid crashing if configuring when the link is down
@ 2026-01-06 22:08 Sean Anderson
  2026-01-07  8:20 ` Stefan Roese
  2026-01-12  9:33 ` Michal Simek
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Anderson @ 2026-01-06 22:08 UTC (permalink / raw)
  To: Stefan Roese, Michal Simek, u-boot
  Cc: Venkatesh Yadav Abbarapu, Sean Anderson, Tom Rini

The ECAM will return a slave error if we access non-root devices while
the link is down. Add a check for this like Linux does so we don't
crash.

Fixes: 2f5ad77cfea ("PCI: zynqmp: Add ZynqMP NWL PCIe root port driver")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---

 drivers/pci/pcie-xilinx-nwl.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/pcie-xilinx-nwl.c b/drivers/pci/pcie-xilinx-nwl.c
index e03ab3be912..ab597c83e47 100644
--- a/drivers/pci/pcie-xilinx-nwl.c
+++ b/drivers/pci/pcie-xilinx-nwl.c
@@ -135,6 +135,13 @@ struct nwl_pcie {
 	u32 ecam_value;
 };
 
+static bool nwl_pcie_link_up(struct nwl_pcie *pcie)
+{
+	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PCIE_PHY_LINKUP_BIT)
+		return true;
+	return false;
+}
+
 static int nwl_pcie_config_address(const struct udevice *bus,
 				   pci_dev_t bdf, uint offset,
 				   void **paddress)
@@ -142,6 +149,9 @@ static int nwl_pcie_config_address(const struct udevice *bus,
 	struct nwl_pcie *pcie = dev_get_priv(bus);
 	void *addr;
 
+	if (PCI_BUS(bdf) != dev_seq(bus) && !nwl_pcie_link_up(pcie))
+		return -EIO;
+
 	addr = pcie->ecam_base;
 	addr += PCIE_ECAM_OFFSET(PCI_BUS(bdf) - dev_seq(bus),
 				 PCI_DEV(bdf), PCI_FUNC(bdf), offset);
@@ -181,13 +191,6 @@ static inline void nwl_bridge_writel(struct nwl_pcie *pcie, u32 val, u32 off)
 	writel(val, pcie->breg_base + off);
 }
 
-static bool nwl_pcie_link_up(struct nwl_pcie *pcie)
-{
-	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PCIE_PHY_LINKUP_BIT)
-		return true;
-	return false;
-}
-
 static bool nwl_phy_link_up(struct nwl_pcie *pcie)
 {
 	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PHY_RDY_LINKUP_BIT)
-- 
2.35.1.1320.gc452695387.dirty

base-commit: beab3fe49e1e9209dd32fe2791e7ac706038460f
branch: pcie_nwl_ecam

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: xilinx-nwl: Avoid crashing if configuring when the link is down
  2026-01-06 22:08 [PATCH] PCI: xilinx-nwl: Avoid crashing if configuring when the link is down Sean Anderson
@ 2026-01-07  8:20 ` Stefan Roese
  2026-01-12  9:33 ` Michal Simek
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2026-01-07  8:20 UTC (permalink / raw)
  To: Sean Anderson, Michal Simek, u-boot; +Cc: Venkatesh Yadav Abbarapu, Tom Rini

Hi Sean,

On 1/6/26 23:08, Sean Anderson wrote:
> The ECAM will return a slave error if we access non-root devices while
> the link is down. Add a check for this like Linux does so we don't
> crash.
> 
> Fixes: 2f5ad77cfea ("PCI: zynqmp: Add ZynqMP NWL PCIe root port driver")
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>

Reviewed-by: Stefan Roese <stefan.roese@mailbox.org>

Thanks,
Stefan

> ---
> 
>   drivers/pci/pcie-xilinx-nwl.c | 17 ++++++++++-------
>   1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pci/pcie-xilinx-nwl.c b/drivers/pci/pcie-xilinx-nwl.c
> index e03ab3be912..ab597c83e47 100644
> --- a/drivers/pci/pcie-xilinx-nwl.c
> +++ b/drivers/pci/pcie-xilinx-nwl.c
> @@ -135,6 +135,13 @@ struct nwl_pcie {
>   	u32 ecam_value;
>   };
>   
> +static bool nwl_pcie_link_up(struct nwl_pcie *pcie)
> +{
> +	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PCIE_PHY_LINKUP_BIT)
> +		return true;
> +	return false;
> +}
> +
>   static int nwl_pcie_config_address(const struct udevice *bus,
>   				   pci_dev_t bdf, uint offset,
>   				   void **paddress)
> @@ -142,6 +149,9 @@ static int nwl_pcie_config_address(const struct udevice *bus,
>   	struct nwl_pcie *pcie = dev_get_priv(bus);
>   	void *addr;
>   
> +	if (PCI_BUS(bdf) != dev_seq(bus) && !nwl_pcie_link_up(pcie))
> +		return -EIO;
> +
>   	addr = pcie->ecam_base;
>   	addr += PCIE_ECAM_OFFSET(PCI_BUS(bdf) - dev_seq(bus),
>   				 PCI_DEV(bdf), PCI_FUNC(bdf), offset);
> @@ -181,13 +191,6 @@ static inline void nwl_bridge_writel(struct nwl_pcie *pcie, u32 val, u32 off)
>   	writel(val, pcie->breg_base + off);
>   }
>   
> -static bool nwl_pcie_link_up(struct nwl_pcie *pcie)
> -{
> -	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PCIE_PHY_LINKUP_BIT)
> -		return true;
> -	return false;
> -}
> -
>   static bool nwl_phy_link_up(struct nwl_pcie *pcie)
>   {
>   	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PHY_RDY_LINKUP_BIT)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: xilinx-nwl: Avoid crashing if configuring when the link is down
  2026-01-06 22:08 [PATCH] PCI: xilinx-nwl: Avoid crashing if configuring when the link is down Sean Anderson
  2026-01-07  8:20 ` Stefan Roese
@ 2026-01-12  9:33 ` Michal Simek
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2026-01-12  9:33 UTC (permalink / raw)
  To: Sean Anderson, Stefan Roese, u-boot; +Cc: Venkatesh Yadav Abbarapu, Tom Rini



On 1/6/26 23:08, Sean Anderson wrote:
> The ECAM will return a slave error if we access non-root devices while
> the link is down. Add a check for this like Linux does so we don't
> crash.
> 
> Fixes: 2f5ad77cfea ("PCI: zynqmp: Add ZynqMP NWL PCIe root port driver")
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> ---
> 
>   drivers/pci/pcie-xilinx-nwl.c | 17 ++++++++++-------
>   1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pci/pcie-xilinx-nwl.c b/drivers/pci/pcie-xilinx-nwl.c
> index e03ab3be912..ab597c83e47 100644
> --- a/drivers/pci/pcie-xilinx-nwl.c
> +++ b/drivers/pci/pcie-xilinx-nwl.c
> @@ -135,6 +135,13 @@ struct nwl_pcie {
>   	u32 ecam_value;
>   };
>   
> +static bool nwl_pcie_link_up(struct nwl_pcie *pcie)
> +{
> +	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PCIE_PHY_LINKUP_BIT)
> +		return true;
> +	return false;
> +}
> +
>   static int nwl_pcie_config_address(const struct udevice *bus,
>   				   pci_dev_t bdf, uint offset,
>   				   void **paddress)
> @@ -142,6 +149,9 @@ static int nwl_pcie_config_address(const struct udevice *bus,
>   	struct nwl_pcie *pcie = dev_get_priv(bus);
>   	void *addr;
>   
> +	if (PCI_BUS(bdf) != dev_seq(bus) && !nwl_pcie_link_up(pcie))
> +		return -EIO;
> +
>   	addr = pcie->ecam_base;
>   	addr += PCIE_ECAM_OFFSET(PCI_BUS(bdf) - dev_seq(bus),
>   				 PCI_DEV(bdf), PCI_FUNC(bdf), offset);
> @@ -181,13 +191,6 @@ static inline void nwl_bridge_writel(struct nwl_pcie *pcie, u32 val, u32 off)
>   	writel(val, pcie->breg_base + off);
>   }
>   
> -static bool nwl_pcie_link_up(struct nwl_pcie *pcie)
> -{
> -	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PCIE_PHY_LINKUP_BIT)
> -		return true;
> -	return false;
> -}
> -
>   static bool nwl_phy_link_up(struct nwl_pcie *pcie)
>   {
>   	if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PHY_RDY_LINKUP_BIT)

Applied.
M

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-12  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-06 22:08 [PATCH] PCI: xilinx-nwl: Avoid crashing if configuring when the link is down Sean Anderson
2026-01-07  8:20 ` Stefan Roese
2026-01-12  9:33 ` Michal Simek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox