[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1613121426-15585-3-git-send-email-mihai.carabas@oracle.com>
Date: Fri, 12 Feb 2021 11:17:05 +0200
From: Mihai Carabas <mihai.carabas@...cle.com>
To: linux-kernel@...r.kernel.org
Cc: gregkh@...uxfoundation.org, arnd@...db.de, rdunlap@...radead.org,
bobo.shaobowang@...wei.com,
Mihai Carabas <mihai.carabas@...cle.com>
Subject: [PATCH v2 2/3] misc/pvpanic: add PCI driver
Add support for pvpanic PCI device added in qemu [1]. At probe time, obtain the
address where to read/write pvpanic events and pass it to the generic handling
code. Will follow the same logic as pvpanic MMIO device driver. At remove time,
unmap base address and disable PCI device.
[1] https://github.com/qemu/qemu/commit/9df52f58e76e904fb141b10318362d718f470db2
Signed-off-by: Mihai Carabas <mihai.carabas@...cle.com>
---
drivers/misc/pvpanic/Kconfig | 8 +++++++
drivers/misc/pvpanic/Makefile | 2 ++
drivers/misc/pvpanic/pci.c | 49 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 59 insertions(+)
create mode 100644 drivers/misc/pvpanic/pci.c
diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
index 0dce6ef..ce8b93e 100644
--- a/drivers/misc/pvpanic/Kconfig
+++ b/drivers/misc/pvpanic/Kconfig
@@ -10,3 +10,11 @@ config PVPANIC_MMIO
This driver provides support for the pvpanic device. pvpanic is
a paravirtualized device provided by QEMU; it lets a virtual machine
(guest) communicate panic events to the host.
+
+config PVPANIC_PCI
+ tristate "pvpanic PCI device support"
+ depends on PCI && PVPANIC
+ help
+ This driver provides support for the pvpanic device. pvpanic is
+ a paravirtualized device provided by QEMU; it lets a virtual machine
+ (guest) communicate panic events to the host.
diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile
index 9ea3355..1763450 100644
--- a/drivers/misc/pvpanic/Makefile
+++ b/drivers/misc/pvpanic/Makefile
@@ -1,2 +1,4 @@
obj-$(CONFIG_PVPANIC_MMIO) += pvpanic-mmio.o
pvpanic-mmio-objs := pvpanic-common.o mmio.o
+obj-$(CONFIG_PVPANIC_PCI) += pvpanic-pci.o
+pvpanic-pci-objs := pvpanic-common.o pci.o
diff --git a/drivers/misc/pvpanic/pci.c b/drivers/misc/pvpanic/pci.c
new file mode 100644
index 00000000..b672727
--- /dev/null
+++ b/drivers/misc/pvpanic/pci.c
@@ -0,0 +1,49 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/types.h>
+#include "pvpanic.h"
+
+#define PCI_VENDOR_ID_REDHAT 0x1b36
+#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011
+
+static void __iomem *base;
+static const struct pci_device_id pvpanic_pci_id_tbl[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC),},
+ {}
+};
+
+static int pvpanic_pci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int ret;
+ struct resource res;
+
+ ret = pci_enable_device(pdev);
+ if (ret < 0)
+ return ret;
+
+ base = pci_iomap(pdev, 0, 0);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
+ pvpanic_probe(base);
+
+ return 0;
+}
+
+static void pvpanic_pci_remove(struct pci_dev *pdev)
+{
+ pvpanic_remove();
+ iounmap(base);
+ pci_disable_device(pdev);
+}
+
+static struct pci_driver pvpanic_pci_driver = {
+ .name = "pvpanic-pci",
+ .id_table = pvpanic_pci_id_tbl,
+ .probe = pvpanic_pci_probe,
+ .remove = pvpanic_pci_remove,
+};
+
+module_pci_driver(pvpanic_pci_driver);
--
1.8.3.1
Powered by blists - more mailing lists