Skip to content

Commit 57ed93f

Browse files
Damien Le Moalbjorn-helgaas
authored andcommitted
PCI: rockchip-ep: Improve rockchip_pcie_ep_unmap_addr()
There is no need to loop over all regions to find the memory window used to map an address. We can use rockchip_ob_region() to determine the region index, together with a check that the address passed as argument is the address used to create the mapping. Furthermore, the ob_region_map bitmap should also be checked to ensure that we are not attempting to unmap an address that is not mapped. Link: https://lore.kernel.org/r/20241017015849.190271-4-dlemoal@kernel.org Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 739e25f commit 57ed93f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/pci/controller/pcie-rockchip-ep.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,9 @@ static void rockchip_pcie_ep_unmap_addr(struct pci_epc *epc, u8 fn, u8 vfn,
259259
{
260260
struct rockchip_pcie_ep *ep = epc_get_drvdata(epc);
261261
struct rockchip_pcie *rockchip = &ep->rockchip;
262-
u32 r;
263-
264-
for (r = 0; r < ep->max_regions; r++)
265-
if (ep->ob_addr[r] == addr)
266-
break;
262+
u32 r = rockchip_ob_region(addr);
267263

268-
if (r == ep->max_regions)
264+
if (addr != ep->ob_addr[r] || !test_bit(r, &ep->ob_region_map))
269265
return;
270266

271267
rockchip_pcie_clear_ep_ob_atu(rockchip, r);

0 commit comments

Comments
 (0)