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

Re: [PATCH v2 1/7] xen/arm: allow PCI host bridge to have private data


  • To: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Tue, 11 Mar 2025 17:05:41 +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=F0NUy53ZdaNsOaVAHtjmaOVQnvnKBmP4ygnw/1fyCB0=; b=fPmlRPTIjs48uklu1a70CQtR41gAk0XJyRb0qS5fOIWBe8EJodHTdL3ykv5rKr8RYfYu0iRbkR0XOL97g6+GRqt2b0ucfdBWFgR9PyaQfUqVM8+VPNI5ClnMFCLsyDJ/mh7ntsvUo40rupQllbXP7YMz0BzOeLh7CnFg26Q+HehaA9yBP1queMaVCSxJVcheC7vLpOoR4MtzHn36OIwSHReWvfkHigYGWcrHSY+8zQZ3ahDbUp+53nVh6s0Kq7I9JRgZvfSD0MylO5AMhGF+Y0RIqv+aJz7pKHpy6wbnY+urp3RIlMAbyoBobVZsinFI57+Oq+f9lwysg0bsi7AYTQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YiUdQ9j7eC85jweYi978E0DtBOIuCQFbptqGKGSB9K14WFsEwRzI9vlB1plGzugQ9gbB+w/raWgcmJMwbkQdLHVTlK8ITZrQ8eTv2n6C8TfqfakQAXVcO5ovyAu3LD276H+nQDXbM4IP/WghHVejhuX3ayMOM257E96Xi2Y7hzMA9M0aHPcYjfyaehkLPZFPPHVZorC+++nVks3+dbP3gG5h27aZYn4C/zAphNgNyZgLKFrGaNWREcu2BibHNdFJBAxKO+qls7865Sv7tjCZGvovuRfd9m+jNQFapJlWMO3a7ztQyOdpCsuU3pVsMwGfrwPYh8hrw1nQVZZGm0+kUA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 11 Mar 2025 15:05:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 11.03.25 12:24, Mykyta Poturai wrote:
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>

Some of the PCI host bridges require private data. Create a generic
approach for that, so such bridges may request the private data to
be allocated during initialization.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
---
v1->v2:
* no change
---
  xen/arch/arm/include/asm/pci.h      |  4 +++-
  xen/arch/arm/pci/pci-host-common.c  | 18 +++++++++++++++++-
  xen/arch/arm/pci/pci-host-generic.c |  2 +-
  xen/arch/arm/pci/pci-host-zynqmp.c  |  2 +-
  4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/include/asm/pci.h b/xen/arch/arm/include/asm/pci.h
index 7f77226c9b..44344ac8c1 100644
--- a/xen/arch/arm/include/asm/pci.h
+++ b/xen/arch/arm/include/asm/pci.h
@@ -66,6 +66,7 @@ struct pci_host_bridge {
      uint16_t segment;                /* Segment number */
      struct pci_config_window* cfg;   /* Pointer to the bridge config window */
      const struct pci_ops *ops;
+    void *priv;                      /* Private data of the bridge. */
  };
struct pci_ops {
@@ -95,7 +96,8 @@ struct pci_ecam_ops {
  extern const struct pci_ecam_ops pci_generic_ecam_ops;
int pci_host_common_probe(struct dt_device_node *dev,
-                          const struct pci_ecam_ops *ops);
+                          const struct pci_ecam_ops *ops,
+                          size_t priv_sz);
  int pci_generic_config_read(struct pci_host_bridge *bridge, pci_sbdf_t sbdf,
                              uint32_t reg, uint32_t len, uint32_t *value);
  int pci_generic_config_write(struct pci_host_bridge *bridge, pci_sbdf_t sbdf,
diff --git a/xen/arch/arm/pci/pci-host-common.c 
b/xen/arch/arm/pci/pci-host-common.c
index c0faf0f436..be7e6c3510 100644
--- a/xen/arch/arm/pci/pci-host-common.c
+++ b/xen/arch/arm/pci/pci-host-common.c
@@ -209,7 +209,8 @@ static int pci_bus_find_domain_nr(struct dt_device_node 
*dev)
  }
int pci_host_common_probe(struct dt_device_node *dev,
-                          const struct pci_ecam_ops *ops)
+                          const struct pci_ecam_ops *ops,
+                          size_t priv_sz)
  {
      struct pci_host_bridge *bridge;
      struct pci_config_window *cfg;
@@ -241,11 +242,26 @@ int pci_host_common_probe(struct dt_device_node *dev,
          printk(XENLOG_ERR "Inconsistent \"linux,pci-domain\" property in 
DT\n");
          BUG();
      }
+
      bridge->segment = domain;
+
+    if ( priv_sz )
+    {
+        bridge->priv = xzalloc_bytes(priv_sz);
+        if ( !bridge->priv )
+        {
+            err = -ENOMEM;
+            goto err_priv;
+        }
+    }
+

I'd like to propose to move allocation into pci_alloc_host_bridge()
to keep mallocs in one place and do it earlier, before proceeding
with other initialization steps.

Also the pci_alloc_host_bridge() could be made static, seems.

      pci_add_host_bridge(bridge);
return 0; +err_priv:
+    xfree(bridge->priv);
+
  err_exit:
      xfree(bridge);

[...]

-grygorii



 


Rackspace

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