]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
PCI: dwc: Clean up iATU index usage in dw_pcie_iatu_setup()
authorNiklas Cassel <cassel@kernel.org>
Tue, 27 Jan 2026 15:10:40 +0000 (16:10 +0100)
committerManivannan Sadhasivam <mani@kernel.org>
Thu, 5 Feb 2026 12:53:19 +0000 (18:23 +0530)
commitb5dab9b38da0a05949458276dde9227c38aa1b39
treee3ca1354104b5f0624e69b44609bac9aff49fba3
parent58fbf08935d9c4396417e5887df89a4e681fa7e3
PCI: dwc: Clean up iATU index usage in dw_pcie_iatu_setup()

The current iATU index usage in dw_pcie_iatu_setup() is a mess.

For outbound address translation the index is incremented before usage.
For inbound address translation the index is incremented after usage.

Incrementing the index after usage make much more sense, and make the
index usage consistent for both outbound and inbound address translation.

Most likely, the overly complicated logic for the outbound address
translation is because the iATU at index 0 is reserved for CFG IOs
(dw_pcie_other_conf_map_bus()), however, we should be able to use the
exact same logic for the indexing of the outbound and inbound iATUs.
(Only the starting index should be different.)

Create two new variables ob_iatu_index and ib_iatu_index, which makes
it more clear from the name itself that it is a zeroes based index,
and only increment the index if the iATU configuration call succeeded.

Since we always check if there is an index available immediately before
programming the iATU, we can remove the useless "ranges exceed outbound
iATU size" warnings, as the code is already unreachable. For the same
reason, we can also remove the useless breaks outside of the while loops.

No functional changes intended.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Tested-by: Maciej W. Rozycki <macro@orcam.me.uk>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hans Zhang <zhanghuabing@ecosda.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260127151038.1484881-7-cassel@kernel.org
drivers/pci/controller/dwc/pcie-designware-host.c