[PATCH 05/16] PCI: PCIe portdrv: Add interface for getting CXL isolation IRQ

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

 



Add a function to the CXL isolation service driver that allows the CXL
core to get the necessary information for setting up an interrupt
handler.

Signed-off-by: Ben Cheatham <Benjamin.Cheatham@xxxxxxx>
---
 drivers/pci/pcie/cxl_isolation.c | 26 +++++++++++++++++++++++++-
 include/cxl/isolation.h          | 26 ++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 include/cxl/isolation.h

diff --git a/drivers/pci/pcie/cxl_isolation.c b/drivers/pci/pcie/cxl_isolation.c
index 550f16271d1c..5a56a327b599 100644
--- a/drivers/pci/pcie/cxl_isolation.c
+++ b/drivers/pci/pcie/cxl_isolation.c
@@ -13,6 +13,7 @@
  */
 
 #include <linux/pci.h>
+#include <cxl/isolation.h>
 
 #include "../../cxl/cxlpci.h"
 #include "portdrv.h"
@@ -62,14 +63,37 @@ int pcie_cxliso_get_intr_vec(struct pci_dev *dev, int *vec)
 
 	cxl_unmap_component_regs(&map, &regs, BIT(CXL_CM_CAP_CAP_ID_ISOLATION));
 	return 0;
+}
+
+struct cxl_isolation_info *
+pcie_cxl_dport_get_isolation_info(struct pci_dev *dport_dev)
+{
+	struct device *dev;
 
+	dev = pcie_port_find_device(dport_dev, PCIE_PORT_SERVICE_CXLISO);
+	if (!dev)
+		return NULL;
+
+	return get_service_data(to_pcie_device(dev));
 }
 
 static int cxl_isolation_probe(struct pcie_device *dev)
 {
-	if (!pcie_is_cxl(dev->port) || pcie_cxliso_get_intr_vec(dev->port, NULL))
+	struct cxl_isolation_info *info;
+	if (!pcie_is_cxl(dev->port) ||
+	    pcie_cxliso_get_intr_vec(dev->port, NULL))
 		return -ENXIO;
 
+	info = devm_kzalloc(&dev->device, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	*info = (struct cxl_isolation_info) {
+		.dev = &dev->device,
+		.irq = dev->irq,
+	};
+
+	set_service_data(dev, info);
 	pci_info(dev->port, "CXLISO: Signaling with IRQ %d\n", dev->irq);
 	return 0;
 }
diff --git a/include/cxl/isolation.h b/include/cxl/isolation.h
new file mode 100644
index 000000000000..20a3a8942b2c
--- /dev/null
+++ b/include/cxl/isolation.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __CXL_ISOLATION_H__
+#define __CXL_ISOLATION_H__
+
+#include <linux/pci.h>
+
+/**
+ * struct cxl_isolation_info - Information for mapping CXL Isolation interrupts
+ * @dev: PCIe portdrv service device associated with IRQ
+ * @irq: IRQ line for interrupt
+ */
+struct cxl_isolation_info {
+	struct device *dev;
+	int irq;
+};
+
+#ifdef CONFIG_CXL_ISOLATION
+struct cxl_isolation_info *
+pcie_cxl_dport_get_isolation_info(struct pci_dev *dport_dev);
+#else /* !CONFIG_CXL_ISOLATION */
+static inline struct cxl_isolation_info *
+pcie_cxl_dport_get_isolation_info(struct pci_dev *dport_dev)
+{ return NULL; }
+#endif /* !CONFIG_CXL_ISOLATION */
+
+#endif
-- 
2.34.1





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux