[PATCH] cxl: Add cxl_read_adapter_vpd() to the kernel API

Frederic Barrat fbarrat at linux.vnet.ibm.com
Wed Jan 20 04:14:54 AEDT 2016


Introduce a new API to read the VPD of the adapter. In bare-metal, a
kernel driver can find out the adapter pci_dev behind the AFU device
and call pci_read_vpd() directly, but it won't work in a (powerVM)
guest.
Current implementation is a stub to allow existing drivers (cxlflash)
to start using it.

Signed-off-by: Frederic Barrat <fbarrat at linux.vnet.ibm.com>
---
 drivers/misc/cxl/api.c | 8 ++++++++
 include/misc/cxl.h     | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index ea3eeb7..c73aa3a 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -363,3 +363,11 @@ void cxl_perst_reloads_same_image(struct cxl_afu *afu,
 	afu->adapter->perst_same_image = perst_reloads_same_image;
 }
 EXPORT_SYMBOL_GPL(cxl_perst_reloads_same_image);
+
+ssize_t cxl_read_adapter_vpd(struct pci_dev *afu_dev, void *buf, size_t count)
+{
+	struct device *parent = cxl_get_phys_dev(afu_dev);
+
+	return pci_read_vpd(to_pci_dev(parent), 0, count, buf);
+}
+EXPORT_SYMBOL_GPL(cxl_read_adapter_vpd);
diff --git a/include/misc/cxl.h b/include/misc/cxl.h
index f2ffe5b..3f9e84f 100644
--- a/include/misc/cxl.h
+++ b/include/misc/cxl.h
@@ -210,4 +210,9 @@ ssize_t cxl_fd_read(struct file *file, char __user *buf, size_t count,
 void cxl_perst_reloads_same_image(struct cxl_afu *afu,
 				  bool perst_reloads_same_image);
 
+/*
+ * Read the VPD of the adapter where the AFU pci dev resides
+ */
+ssize_t cxl_read_adapter_vpd(struct pci_dev *afu_dev, void *buf, size_t count);
+
 #endif /* _MISC_CXL_H */
-- 
1.9.1



More information about the Linuxppc-dev mailing list