From: Damien Le Moal Date: Thu, 17 Oct 2024 01:58:38 +0000 (+0900) Subject: PCI: rockchip-ep: Improve rockchip_pcie_ep_unmap_addr() X-Git-Tag: microblaze-v6.16~472^2~5^2~10 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=57ed93fe799b3564388fd61279fc274ae2716508;p=linux-2.6-microblaze.git 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 Signed-off-by: Krzysztof WilczyƄski Signed-off-by: Bjorn Helgaas --- diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c index 65014681d859..b4db5459727f 100644 --- a/drivers/pci/controller/pcie-rockchip-ep.c +++ b/drivers/pci/controller/pcie-rockchip-ep.c @@ -259,13 +259,9 @@ static void rockchip_pcie_ep_unmap_addr(struct pci_epc *epc, u8 fn, u8 vfn, { struct rockchip_pcie_ep *ep = epc_get_drvdata(epc); struct rockchip_pcie *rockchip = &ep->rockchip; - u32 r; - - for (r = 0; r < ep->max_regions; r++) - if (ep->ob_addr[r] == addr) - break; + u32 r = rockchip_ob_region(addr); - if (r == ep->max_regions) + if (addr != ep->ob_addr[r] || !test_bit(r, &ep->ob_region_map)) return; rockchip_pcie_clear_ep_ob_atu(rockchip, r);