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

[PATCH v1 2/3] xen/vpci: add vpci_read_val helper


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Thu, 10 Aug 2023 15:12:58 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=PlSGpBPqcY633oL1I0uwX+30drJWk9gY6gx+J9uhOBw=; b=j0m5y0FLl5ctbfLv1bfq8Wz/6DONkZNTmlQe1QdIoSPvv+0Mg0lfAjayXo6XZc0JVGGwUSXRnw9qKVekI2I0/cuViQgx4YnAOhSAG2/uIxs+kDZvtTIxOUgKF68aR+c/BZ4uJKWx3vN/CYAQ2837ox+36eg4Y3ism95RK7ahJsIeQ3M2vkag8NMlJi93q1YUKfKuNZTrBPb4MA/raadasyEbu/vlYhByOuig58+Q3VS2Pr1mXQnmc9Ws2GZbUt1q2ZsQbr3Qao1NT7ubkfkhaYdoiHUkSryFlLe/STO7pXJjyy/+Td8e4l2nf8G4m17STlgFUczBIy0GBOZX8Rq+Iw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Frt7eqpDRVjpO63Xw4tuM2/DRqg33XW+xaMuVkGL4wIGH0FwxTqK2DpEA8ezB+PABXWn6LxcrO9WGOxUXIOgEVt7Vo5MkdS8lSM+XLtrBKCOWAGIo3iyN5eM0NrV3LmG/TYYceXrK+qCXOXPfggcozy5uWWnB8uM+m8dO5+XiPCyWyfCgNjl3upVBOuk9kKkTn0/wA/VmmnkouMfu4aF2c3H0n8gAsBage2pHJmQRBqMDfxmpeF/WEkufuZ/QDlnO+Azu0s6l23QRa2o+YM8+2B8gxvOyQzjb1HcPDGf1ogY8THYfgl3/3+tWkrF/xlIXzQdDtDDBh1LSYCAQHEcAA==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 10 Aug 2023 19:14:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Introduce a vPCI read helper function that returns a fixed value. This may be
used for RAZ registers, or registers whose value doesn't change. This helper
will be used in a subsequent patch.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
RFC: I'm not a fan of the (uintptr_t) cast, but without it I wasn't sure how to
     pass a value without allocating more memory (either with an xalloc function
     of sorts, or by adding a new element in struct vpci_register and changing
     the interface). Plus, in the current state, to pass a value to
     vpci_add_register(), it may be necessary to cast twice:
     (void *)(uintptr_t)myval. See next patch. Perhaps a new allocation is worth
     it to avoid the casts? Or maybe I'm being overly pedantic and the casts are
     okay?
---
 xen/drivers/vpci/vpci.c | 6 ++++++
 xen/include/xen/vpci.h  | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index acadba1fd6c5..4a96aa50494d 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -133,6 +133,12 @@ static void cf_check vpci_ignored_write(
 {
 }
 
+uint32_t cf_check vpci_read_val(
+    const struct pci_dev *pdev, unsigned int reg, void *data)
+{
+    return (uintptr_t)data;
+}
+
 uint32_t cf_check vpci_hw_read8(
     const struct pci_dev *pdev, unsigned int reg, void *data)
 {
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index ee7a8fcdee83..17fd252746ec 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -45,6 +45,9 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, 
unsigned int size);
 void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
                 uint32_t data);
 
+uint32_t cf_check vpci_read_val(
+    const struct pci_dev *pdev, unsigned int reg, void *data);
+
 /* Passthrough handlers. */
 uint32_t cf_check vpci_hw_read8(
     const struct pci_dev *pdev, unsigned int reg, void *data);
-- 
2.41.0




 


Rackspace

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