All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 1/3]  misc/pvpanic: return 0 for empty body register function
@ 2018-12-17  2:09 Peng Hao
  2018-12-17  2:09 ` [PATCH V2 2/3] misc/pvpanic : add pci interface for pvpanic Peng Hao
  2018-12-17  2:09 ` [PATCH V2 3/3] misc/pvpanic : add pci dependency in Kconfig Peng Hao
  0 siblings, 2 replies; 4+ messages in thread
From: Peng Hao @ 2018-12-17  2:09 UTC (permalink / raw)
  To: gregkh, arnd, andy.shevchenko; +Cc: linux-kernel, Peng Hao

Return 0 for empty body register function normally.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 drivers/misc/pvpanic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
index 3150dc2..f84ed30 100644
--- a/drivers/misc/pvpanic.c
+++ b/drivers/misc/pvpanic.c
@@ -125,7 +125,7 @@ static void pvpanic_unregister_acpi_driver(void)
 #else
 static int pvpanic_register_acpi_driver(void)
 {
-	return -ENODEV;
+	return 0;
 }
 
 static void pvpanic_unregister_acpi_driver(void) {}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH V2 2/3]  misc/pvpanic : add pci interface for pvpanic
  2018-12-17  2:09 [PATCH V2 1/3] misc/pvpanic: return 0 for empty body register function Peng Hao
@ 2018-12-17  2:09 ` Peng Hao
  2018-12-17  9:21   ` kbuild test robot
  2018-12-17  2:09 ` [PATCH V2 3/3] misc/pvpanic : add pci dependency in Kconfig Peng Hao
  1 sibling, 1 reply; 4+ messages in thread
From: Peng Hao @ 2018-12-17  2:09 UTC (permalink / raw)
  To: gregkh, arnd, andy.shevchenko; +Cc: linux-kernel, Peng Hao

Support pvpanic as a pci device in guest kernel.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 drivers/misc/pvpanic.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 80 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
index f84ed30..b8d8dba 100644
--- a/drivers/misc/pvpanic.c
+++ b/drivers/misc/pvpanic.c
@@ -13,11 +13,14 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
 
 static void __iomem *base;
 
+#define PCI_VENDOR_ID_REDHAT             0x1b36
+#define PCI_DEVICE_ID_REDHAT_PVPANIC     0x0101
 #define PVPANIC_PANICKED        (1 << 0)
 
 MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>");
@@ -172,12 +175,86 @@ static int pvpanic_mmio_remove(struct platform_device *pdev)
 	.remove = pvpanic_mmio_remove,
 };
 
+#ifdef CONFIG_PCI
+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 err;
+
+	err = pci_enable_device(pdev);
+	if (err)
+		return err;
+	if (pci_request_region(pdev, 0, "pvpanic-pci"))
+		goto disable;
+
+	base = pci_ioremap_bar(pdev, 0);
+	if (!base)
+		goto release;
+
+	atomic_notifier_chain_register(&panic_notifier_list,
+				       &pvpanic_panic_nb);
+	return 0;
+
+release:
+	pci_release_region(pdev, 0);
+disable:
+	pci_disable_device(pdev);
+
+	return -ENODEV;
+}
+
+static void pvpanic_pci_remove(struct pci_dev *pdev)
+{
+	atomic_notifier_chain_unregister(&panic_notifier_list,
+					 &pvpanic_panic_nb);
+	iounmap(base);
+	pci_release_region(pdev, 0);
+	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,
+};
+
+static int pvpanic_register_pci_drvier(void)
+{
+	return pci_register_driver(&pvpanic_pci_driver);
+}
+
+static void pvpanic_unregister_pci_drvier(void)
+{
+	pci_unregister_driver(&pvpanic_pci_driver);
+}
+#else /* CONFIG_PCI */
+static int pvpanic_register_pci_drvier(void)
+{
+	return 0;
+}
+
+static void pvpanic_unregister_pci_drvier(void) {}
+#endif
+
 static int __init pvpanic_mmio_init(void)
 {
+	int r1, r2;
+
 	if (acpi_disabled)
-		return platform_driver_register(&pvpanic_mmio_driver);
+		r1 = platform_driver_register(&pvpanic_mmio_driver);
+	else
+		r2 = pvpanic_register_acpi_driver();
+	r2 = pvpanic_register_pci_drvier();
+	if (r1 && r2) /* all drivers register failed */
+		return 1;
 	else
-		return pvpanic_register_acpi_driver();
+		return 0;
 }
 
 static void __exit pvpanic_mmio_exit(void)
@@ -186,6 +263,7 @@ static void __exit pvpanic_mmio_exit(void)
 		platform_driver_unregister(&pvpanic_mmio_driver);
 	else
 		pvpanic_unregister_acpi_driver();
+	pvpanic_unregister_pci_drvier();
 }
 
 module_init(pvpanic_mmio_init);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH V2 3/3]  misc/pvpanic : add pci dependency in Kconfig
  2018-12-17  2:09 [PATCH V2 1/3] misc/pvpanic: return 0 for empty body register function Peng Hao
  2018-12-17  2:09 ` [PATCH V2 2/3] misc/pvpanic : add pci interface for pvpanic Peng Hao
@ 2018-12-17  2:09 ` Peng Hao
  1 sibling, 0 replies; 4+ messages in thread
From: Peng Hao @ 2018-12-17  2:09 UTC (permalink / raw)
  To: gregkh, arnd, andy.shevchenko; +Cc: linux-kernel, Peng Hao

Add PCI dependency for pvpanic in Kconfig.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 drivers/misc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index f417b06..5ff8ca4 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -515,7 +515,7 @@ config MISC_RTSX
 
 config PVPANIC
 	tristate "pvpanic device support"
-	depends on HAS_IOMEM && (ACPI || OF)
+	depends on HAS_IOMEM && (ACPI || OF || PCI)
 	help
 	  This driver provides support for the pvpanic device.  pvpanic is
 	  a paravirtualized device provided by QEMU; it lets a virtual machine
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V2 2/3]  misc/pvpanic : add pci interface for pvpanic
  2018-12-17  2:09 ` [PATCH V2 2/3] misc/pvpanic : add pci interface for pvpanic Peng Hao
@ 2018-12-17  9:21   ` kbuild test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2018-12-17  9:21 UTC (permalink / raw)
  To: Peng Hao
  Cc: kbuild-all, gregkh, arnd, andy.shevchenko, linux-kernel, Peng Hao

[-- Attachment #1: Type: text/plain, Size: 1604 bytes --]

Hi Peng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on char-misc/char-misc-testing]
[cannot apply to v4.20-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Peng-Hao/misc-pvpanic-return-0-for-empty-body-register-function/20181217-151203
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=ia64 

All warnings (new ones prefixed by >>):

   drivers//misc/pvpanic.c: In function 'pvpanic_mmio_init':
>> drivers//misc/pvpanic.c:254:6: warning: 'r1' is used uninitialized in this function [-Wuninitialized]
     if (r1 && r2) /* all drivers register failed */
         ^~

vim +/r1 +254 drivers//misc/pvpanic.c

   244	
   245	static int __init pvpanic_mmio_init(void)
   246	{
   247		int r1, r2;
   248	
   249		if (acpi_disabled)
   250			r1 = platform_driver_register(&pvpanic_mmio_driver);
   251		else
   252			r2 = pvpanic_register_acpi_driver();
   253		r2 = pvpanic_register_pci_drvier();
 > 254		if (r1 && r2) /* all drivers register failed */
   255			return 1;
   256		else
   257			return 0;
   258	}
   259	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 52387 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-17  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17  2:09 [PATCH V2 1/3] misc/pvpanic: return 0 for empty body register function Peng Hao
2018-12-17  2:09 ` [PATCH V2 2/3] misc/pvpanic : add pci interface for pvpanic Peng Hao
2018-12-17  9:21   ` kbuild test robot
2018-12-17  2:09 ` [PATCH V2 3/3] misc/pvpanic : add pci dependency in Kconfig Peng Hao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.