[PATCH 6/7] xen/arm: rcar4: add simple optimization to avoid ATU reprogramming

Mykyta Poturai posted 7 patches 8 months, 1 week ago
There is a newer version of this series
[PATCH 6/7] xen/arm: rcar4: add simple optimization to avoid ATU reprogramming
Posted by Mykyta Poturai 8 months, 1 week ago
From: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

There are high chances that there will be a number of a consecutive
accesses to configuration space of one device. To speed things up,
we can program ATU only during first access.

This is mostly beneficial taking into account the previous patch that
adds 1ms delay after ATU reprogramming.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
 xen/arch/arm/pci/pci-host-rcar4.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/arch/arm/pci/pci-host-rcar4.c b/xen/arch/arm/pci/pci-host-rcar4.c
index 3b97bf138a..3e3e073b09 100644
--- a/xen/arch/arm/pci/pci-host-rcar4.c
+++ b/xen/arch/arm/pci/pci-host-rcar4.c
@@ -367,6 +367,14 @@ static void dw_pcie_prog_outbound_atu(struct pci_host_bridge *pci, int index,
                                       int type, uint64_t cpu_addr,
                                       uint64_t pci_addr, uint64_t size)
 {
+    static uint64_t prev_addr = ~0;
+
+    /* Simple optimization to not-program ATU for every transaction */
+    if (prev_addr == pci_addr)
+        return;
+
+    prev_addr = pci_addr;
+
     __dw_pcie_prog_outbound_atu(pci, 0, index, type,
                                 cpu_addr, pci_addr, size);
 }
-- 
2.34.1