[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Wed, 12 Mar 2025 12:04:44 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5CcxKcv4E5l3ZKvy6K0qVPjENVxR8nE2gTmbnyncZ8k=; b=KdWhQCkhyLMdwyEl/EGH7mEddOotUnHq5Xw9C59/VhwFI6RQnCIYU4pa7Bs/TEidcEUyyZDX/IKEgk2NGyEWkrQjaLdB10blImqAF6Ji4Ay/B9zYAjTCwDyi1E6PqjXrBhwoxCxZ8EoyTio1fbSwBlZP4dpLNp6LVcg6ucA3sqJvhodJeicw60EXUBBRw1A47F4oV9iBbh9aLk5i/09hNTKa8jlSipidQYyDyx+IGO/oExz7twqHs3TUZtPwWMSXtd6xd24XjSPILJqWUC/hxVPyN8IdzpGCrHCuiKABG476GMVtCRue3rm75x0qYD573lvu9CLh/gETRfPRURbSsg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bM4F1wFb3l0uPKTBQcJjVAiGdtwJNLxw6Ek+P/Oxupwov8NtwAwlkrFBkLdZFyOQWqqm4CHe4UnZcV9+K/zbBcb9IpGud5/fPl0ORQezjZ4i4hB/rLCuD8F5kir+fUEyVni5106yHIMSgWTRvwUM6FcMFo6L0Um/XqBT3rQ8tYJtgYWBRRE2ZkuWsqtjObvb2Td2tJgOOvbvLXRZ0919tz71U69P540GJDUvGHCvk/vc+qcANZJLgWwtafSj0IrBXoZmyIbAHLS17pWA+uixaltphnya3sdOMYXQnA/IgYtrfsJAIzY0CnKvS4K0arFTaYSO9atpLylaLV4YTmYl4A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Wed, 12 Mar 2025 10:04:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 11.03.25 12:24, Mykyta Poturai wrote:
From: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>

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@xxxxxxxx>
Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
---
v1->v2:
* rebased
---
  xen/arch/arm/pci/pci-designware.c | 8 ++++++++
  1 file changed, 8 insertions(+)

diff --git a/xen/arch/arm/pci/pci-designware.c 
b/xen/arch/arm/pci/pci-designware.c
index def2c12d63..cec52cf81a 100644
--- a/xen/arch/arm/pci/pci-designware.c
+++ b/xen/arch/arm/pci/pci-designware.c
@@ -272,6 +272,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)
  {

First, using (hiding) static var inside the function deserve big, fat comment 
on why and what.

+    static uint64_t prev_addr = ~0;

Second, from an experience, static vars in functions is source of potential 
problems,
it's kinda land mines in code. For example, lets assume there are two 
pci_host_bridge
instances in Xen and they are accessed concurrently.

Best to get rid of static var here - may be move in pci_host_bridge, like 
cached_pci_addr? not sure

+
+    /* 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);
  }

BR,
-grygorii



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.