[PATCH 1/2] PCI: dwc: Correct iATU index increment for MSG TLP region

Krishna Chaitanya Chundru posted 2 patches 2 weeks, 2 days ago
[PATCH 1/2] PCI: dwc: Correct iATU index increment for MSG TLP region
Posted by Krishna Chaitanya Chundru 2 weeks, 2 days ago
Commit e1a4ec1a9520 ("PCI: dwc: Add generic MSG TLP support for sending
PME_Turn_Off when system suspend") introduced a mechanism to reserve an
iATU window for MSG TLP transactions. However, the code incorrectly
assigned pp->msg_atu_index = i without incrementing i first, causing
the MSG TLP region to reuse the last configured outbound window instead
of the next available one. This can cause issue with IO transfers as
this can over write iATU configured for IO memory.

Fix this by incrementing i before assigning it to msg_atu_index so
that the MSG TLP region uses a dedicated iATU entry.

Fixes: e1a4ec1a9520 ("PCI: dwc: Add generic MSG TLP support for sending PME_Turn_Off when system suspend")
Cc: stable@vger.kernel.org
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index e92513c5bda51bde3a7157033ddbd73afa370d78..4fb6331fbc2b322c1a1b6a8e4fe08f92e170da19 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -942,7 +942,7 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)
 		dev_warn(pci->dev, "Ranges exceed outbound iATU size (%d)\n",
 			 pci->num_ob_windows);
 
-	pp->msg_atu_index = i;
+	pp->msg_atu_index = ++i;
 
 	i = 0;
 	resource_list_for_each_entry(entry, &pp->bridge->dma_ranges) {

-- 
2.34.1
Re: [PATCH 1/2] PCI: dwc: Correct iATU index increment for MSG TLP region
Posted by Maciej W. Rozycki 2 weeks, 1 day ago
On Wed, 3 Dec 2025, Krishna Chaitanya Chundru wrote:

> Fix this by incrementing i before assigning it to msg_atu_index so
> that the MSG TLP region uses a dedicated iATU entry.

Tested-by: Maciej W. Rozycki <macro@orcam.me.uk>

  Maciej
Re: [PATCH 1/2] PCI: dwc: Correct iATU index increment for MSG TLP region
Posted by Frank Li 2 weeks, 2 days ago
On Wed, Dec 03, 2025 at 11:50:14AM +0530, Krishna Chaitanya Chundru wrote:
> Commit e1a4ec1a9520 ("PCI: dwc: Add generic MSG TLP support for sending
> PME_Turn_Off when system suspend") introduced a mechanism to reserve an
> iATU window for MSG TLP transactions. However, the code incorrectly
> assigned pp->msg_atu_index = i without incrementing i first, causing
> the MSG TLP region to reuse the last configured outbound window instead
> of the next available one. This can cause issue with IO transfers as
> this can over write iATU configured for IO memory.
>
> Fix this by incrementing i before assigning it to msg_atu_index so
> that the MSG TLP region uses a dedicated iATU entry.
>
> Fixes: e1a4ec1a9520 ("PCI: dwc: Add generic MSG TLP support for sending PME_Turn_Off when system suspend")
> Cc: stable@vger.kernel.org
> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>

Thank you fix it.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
>  drivers/pci/controller/dwc/pcie-designware-host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index e92513c5bda51bde3a7157033ddbd73afa370d78..4fb6331fbc2b322c1a1b6a8e4fe08f92e170da19 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -942,7 +942,7 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)
>  		dev_warn(pci->dev, "Ranges exceed outbound iATU size (%d)\n",
>  			 pci->num_ob_windows);
>
> -	pp->msg_atu_index = i;
> +	pp->msg_atu_index = ++i;
>
>  	i = 0;
>  	resource_list_for_each_entry(entry, &pp->bridge->dma_ranges) {
>
> --
> 2.34.1
>