2021-02-03 15:36:12

by Mihai Carabas

[permalink] [raw]
Subject: [PATCH] add support for pci in the pvpanic driver

This patchset adds support for pci in the pvpanic driver. The device already
got in qemu [1].

[1] https://github.com/qemu/qemu/commit/9df52f58e76e904fb141b10318362d718f470db2

Mihai Carabas (2):
misc/pvpanic: split-up generic and platform dependent code
misc/pvpanic: add pci driver

drivers/misc/Kconfig | 9 +--
drivers/misc/Makefile | 2 +-
drivers/misc/pvpanic.c | 111 ------------------------------------
drivers/misc/pvpanic/Kconfig | 28 +++++++++
drivers/misc/pvpanic/Makefile | 9 +++
drivers/misc/pvpanic/pvpanic-mmio.c | 83 +++++++++++++++++++++++++++
drivers/misc/pvpanic/pvpanic-pci.c | 54 ++++++++++++++++++
drivers/misc/pvpanic/pvpanic.c | 59 +++++++++++++++++++
drivers/misc/pvpanic/pvpanic.h | 17 ++++++
9 files changed, 252 insertions(+), 120 deletions(-)
delete mode 100644 drivers/misc/pvpanic.c
create mode 100644 drivers/misc/pvpanic/Kconfig
create mode 100644 drivers/misc/pvpanic/Makefile
create mode 100644 drivers/misc/pvpanic/pvpanic-mmio.c
create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c
create mode 100644 drivers/misc/pvpanic/pvpanic.c
create mode 100644 drivers/misc/pvpanic/pvpanic.h

--
1.8.3.1


2021-02-03 15:36:34

by Mihai Carabas

[permalink] [raw]
Subject: [PATCH 2/2] misc/pvpanic: add pci driver

Add pvpanic pci device driver support.

Signed-off-by: Mihai Carabas <[email protected]>
---
drivers/misc/pvpanic/Kconfig | 16 ++++++++++-
drivers/misc/pvpanic/Makefile | 7 +++++
drivers/misc/pvpanic/pvpanic-pci.c | 54 ++++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 1 deletion(-)
create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c

diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
index 12bb017..4a96e8d 100644
--- a/drivers/misc/pvpanic/Kconfig
+++ b/drivers/misc/pvpanic/Kconfig
@@ -1,6 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# pvpanic device
+#
+
config PVPANIC
bool "pvpanic device support"
- depends on PVPANIC_MMIO
+ depends on (PVPANIC_MMIO || PVPANIC_PCI)
help
This option enable generic code for pvpanic device driver logic.

@@ -12,3 +17,12 @@ 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
+ select 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 d08379b..fe57d1f 100644
--- a/drivers/misc/pvpanic/Makefile
+++ b/drivers/misc/pvpanic/Makefile
@@ -1,2 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for pvpanic device.
+#
+
+
obj-$(CONFIG_PVPANIC) += pvpanic.o
obj-$(CONFIG_PVPANIC_MMIO) += pvpanic-mmio.o
+obj-$(CONFIG_PVPANIC_PCI) += pvpanic-pci.o
diff --git a/drivers/misc/pvpanic/pvpanic-pci.c b/drivers/misc/pvpanic/pvpanic-pci.c
new file mode 100644
index 00000000..1d25d11
--- /dev/null
+++ b/drivers/misc/pvpanic/pvpanic-pci.c
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * pvpanic pci driver.
+ *
+ * Copyright (C) 2021 Oracle.
+ */
+
+#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 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;
+ void __iomem *base;
+
+ ret = pcim_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();
+}
+
+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

2021-02-03 15:37:57

by Mihai Carabas

[permalink] [raw]
Subject: [PATCH 1/2] misc/pvpanic: split-up generic and platform dependent code

Split-up generic and platform dependent code in order to introduce pvpanic pci
device driver later.

Signed-off-by: Mihai Carabas <[email protected]>
---
drivers/misc/Kconfig | 9 +--
drivers/misc/Makefile | 2 +-
drivers/misc/pvpanic.c | 111 ------------------------------------
drivers/misc/pvpanic/Kconfig | 14 +++++
drivers/misc/pvpanic/Makefile | 2 +
drivers/misc/pvpanic/pvpanic-mmio.c | 83 +++++++++++++++++++++++++++
drivers/misc/pvpanic/pvpanic.c | 59 +++++++++++++++++++
drivers/misc/pvpanic/pvpanic.h | 17 ++++++
8 files changed, 177 insertions(+), 120 deletions(-)
delete mode 100644 drivers/misc/pvpanic.c
create mode 100644 drivers/misc/pvpanic/Kconfig
create mode 100644 drivers/misc/pvpanic/Makefile
create mode 100644 drivers/misc/pvpanic/pvpanic-mmio.c
create mode 100644 drivers/misc/pvpanic/pvpanic.c
create mode 100644 drivers/misc/pvpanic/pvpanic.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index fafa8b0..0273ecb 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -448,14 +448,6 @@ config MISC_RTSX
tristate
default MISC_RTSX_PCI || MISC_RTSX_USB

-config PVPANIC
- tristate "pvpanic device support"
- depends on HAS_IOMEM && (ACPI || OF)
- 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.
-
config HISI_HIKEY_USB
tristate "USB GPIO Hub on HiSilicon Hikey 960/970 Platform"
depends on (OF && GPIOLIB) || COMPILE_TEST
@@ -481,4 +473,5 @@ source "drivers/misc/ocxl/Kconfig"
source "drivers/misc/cardreader/Kconfig"
source "drivers/misc/habanalabs/Kconfig"
source "drivers/misc/uacce/Kconfig"
+source "drivers/misc/pvpanic/Kconfig"
endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index d23231e..9f411b8 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -52,7 +52,7 @@ obj-$(CONFIG_CXL_BASE) += cxl/
obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o
obj-$(CONFIG_OCXL) += ocxl/
obj-y += cardreader/
-obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_PVPANIC) += pvpanic/
obj-$(CONFIG_HABANA_AI) += habanalabs/
obj-$(CONFIG_UACCE) += uacce/
obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o
diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
deleted file mode 100644
index 41cab29..00000000
--- a/drivers/misc/pvpanic.c
+++ /dev/null
@@ -1,111 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Pvpanic Device Support
- *
- * Copyright (C) 2013 Fujitsu.
- * Copyright (C) 2018 ZTE.
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/io.h>
-#include <linux/kernel.h>
-#include <linux/kexec.h>
-#include <linux/mod_devicetable.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/types.h>
-
-#include <uapi/misc/pvpanic.h>
-
-static void __iomem *base;
-
-MODULE_AUTHOR("Hu Tao <[email protected]>");
-MODULE_DESCRIPTION("pvpanic device driver");
-MODULE_LICENSE("GPL");
-
-static void
-pvpanic_send_event(unsigned int event)
-{
- iowrite8(event, base);
-}
-
-static int
-pvpanic_panic_notify(struct notifier_block *nb, unsigned long code,
- void *unused)
-{
- unsigned int event = PVPANIC_PANICKED;
-
- if (kexec_crash_loaded())
- event = PVPANIC_CRASH_LOADED;
-
- pvpanic_send_event(event);
-
- return NOTIFY_DONE;
-}
-
-static struct notifier_block pvpanic_panic_nb = {
- .notifier_call = pvpanic_panic_notify,
- .priority = 1, /* let this called before broken drm_fb_helper */
-};
-
-static int pvpanic_mmio_probe(struct platform_device *pdev)
-{
- struct device *dev = &pdev->dev;
- struct resource *res;
-
- res = platform_get_mem_or_io(pdev, 0);
- if (!res)
- return -EINVAL;
-
- switch (resource_type(res)) {
- case IORESOURCE_IO:
- base = devm_ioport_map(dev, res->start, resource_size(res));
- if (!base)
- return -ENOMEM;
- break;
- case IORESOURCE_MEM:
- base = devm_ioremap_resource(dev, res);
- if (IS_ERR(base))
- return PTR_ERR(base);
- break;
- default:
- return -EINVAL;
- }
-
- atomic_notifier_chain_register(&panic_notifier_list,
- &pvpanic_panic_nb);
-
- return 0;
-}
-
-static int pvpanic_mmio_remove(struct platform_device *pdev)
-{
-
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &pvpanic_panic_nb);
-
- return 0;
-}
-
-static const struct of_device_id pvpanic_mmio_match[] = {
- { .compatible = "qemu,pvpanic-mmio", },
- {}
-};
-
-static const struct acpi_device_id pvpanic_device_ids[] = {
- { "QEMU0001", 0 },
- { "", 0 }
-};
-MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids);
-
-static struct platform_driver pvpanic_mmio_driver = {
- .driver = {
- .name = "pvpanic-mmio",
- .of_match_table = pvpanic_mmio_match,
- .acpi_match_table = pvpanic_device_ids,
- },
- .probe = pvpanic_mmio_probe,
- .remove = pvpanic_mmio_remove,
-};
-module_platform_driver(pvpanic_mmio_driver);
diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
new file mode 100644
index 00000000..12bb017
--- /dev/null
+++ b/drivers/misc/pvpanic/Kconfig
@@ -0,0 +1,14 @@
+config PVPANIC
+ bool "pvpanic device support"
+ depends on PVPANIC_MMIO
+ help
+ This option enable generic code for pvpanic device driver logic.
+
+config PVPANIC_MMIO
+ tristate "pvpanic mmio device support"
+ depends on HAS_IOMEM && (ACPI || OF)
+ select 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
new file mode 100644
index 00000000..d08379b
--- /dev/null
+++ b/drivers/misc/pvpanic/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_PVPANIC_MMIO) += pvpanic-mmio.o
diff --git a/drivers/misc/pvpanic/pvpanic-mmio.c b/drivers/misc/pvpanic/pvpanic-mmio.c
new file mode 100644
index 00000000..f361747
--- /dev/null
+++ b/drivers/misc/pvpanic/pvpanic-mmio.c
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Pvpanic Device Support
+ *
+ * Copyright (C) 2013 Fujitsu.
+ * Copyright (C) 2018 ZTE.
+ * Copyright (C) 2021 Oracle.
+*/
+
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/kexec.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
+#include <uapi/misc/pvpanic.h>
+#include "pvpanic.h"
+
+MODULE_AUTHOR("Hu Tao <[email protected]>");
+MODULE_DESCRIPTION("pvpanic device driver");
+MODULE_LICENSE("GPL");
+
+static int pvpanic_mmio_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ void __iomem *base;
+
+ res = platform_get_mem_or_io(pdev, 0);
+ if (!res)
+ return -EINVAL;
+
+ switch (resource_type(res)) {
+ case IORESOURCE_IO:
+ base = devm_ioport_map(dev, res->start, resource_size(res));
+ if (!base)
+ return -ENOMEM;
+ break;
+ case IORESOURCE_MEM:
+ base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ pvpanic_probe(base);
+
+ return 0;
+}
+
+static int pvpanic_mmio_remove(struct platform_device *pdev)
+{
+
+ pvpanic_remove();
+
+ return 0;
+}
+
+static const struct of_device_id pvpanic_mmio_match[] = {
+ { .compatible = "qemu,pvpanic-mmio", },
+ {}
+};
+
+static const struct acpi_device_id pvpanic_device_ids[] = {
+ { "QEMU0001", 0 },
+ { "", 0 }
+};
+MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids);
+
+static struct platform_driver pvpanic_mmio_driver = {
+ .driver = {
+ .name = "pvpanic-mmio",
+ .of_match_table = pvpanic_mmio_match,
+ .acpi_match_table = pvpanic_device_ids,
+ },
+ .probe = pvpanic_mmio_probe,
+ .remove = pvpanic_mmio_remove,
+};
+module_platform_driver(pvpanic_mmio_driver);
diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c
new file mode 100644
index 00000000..b4e5bbc
--- /dev/null
+++ b/drivers/misc/pvpanic/pvpanic.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Pvpanic Device Support
+ *
+ * Copyright (C) 2013 Fujitsu.
+ * Copyright (C) 2018 ZTE.
+ * Copyright (C) 2021 Oracle.
+ */
+
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/kexec.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
+#include <uapi/misc/pvpanic.h>
+
+static void __iomem *base;
+
+static void
+pvpanic_send_event(unsigned int event)
+{
+ iowrite8(event, base);
+}
+
+static int
+pvpanic_panic_notify(struct notifier_block *nb, unsigned long code,
+ void *unused)
+{
+ unsigned int event = PVPANIC_PANICKED;
+
+ if (kexec_crash_loaded())
+ event = PVPANIC_CRASH_LOADED;
+
+ pvpanic_send_event(event);
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block pvpanic_panic_nb = {
+ .notifier_call = pvpanic_panic_notify,
+ .priority = 1, /* let this called before broken drm_fb_helper */
+};
+
+void pvpanic_probe(void __iomem *pbase)
+{
+ base = pbase;
+ atomic_notifier_chain_register(&panic_notifier_list,
+ &pvpanic_panic_nb);
+}
+
+void pvpanic_remove(void)
+{
+
+ atomic_notifier_chain_unregister(&panic_notifier_list,
+ &pvpanic_panic_nb);
+}
diff --git a/drivers/misc/pvpanic/pvpanic.h b/drivers/misc/pvpanic/pvpanic.h
new file mode 100644
index 00000000..a3aca5a
--- /dev/null
+++ b/drivers/misc/pvpanic/pvpanic.h
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Pvpanic Device Support
+ *
+ * Copyright (C) 2021 Oracle.
+ */
+
+#ifndef PVPANIC_H_
+#define PVPANIC_H_
+
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+void pvpanic_probe(void __iomem *base);
+void pvpanic_remove(void);
+
+#endif /* PVPANIC_H_ */
--
1.8.3.1

2021-02-03 15:45:20

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 2/2] misc/pvpanic: add pci driver

On Wed, Feb 03, 2021 at 04:43:59PM +0200, Mihai Carabas wrote:
> Add pvpanic pci device driver support.

What does that mean? Please provide more changelog text here.

>
> Signed-off-by: Mihai Carabas <[email protected]>
> ---
> drivers/misc/pvpanic/Kconfig | 16 ++++++++++-
> drivers/misc/pvpanic/Makefile | 7 +++++
> drivers/misc/pvpanic/pvpanic-pci.c | 54 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 76 insertions(+), 1 deletion(-)
> create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c
>
> diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
> index 12bb017..4a96e8d 100644
> --- a/drivers/misc/pvpanic/Kconfig
> +++ b/drivers/misc/pvpanic/Kconfig
> @@ -1,6 +1,11 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# pvpanic device
> +#

While nice, why add this now?

> +
> config PVPANIC
> bool "pvpanic device support"
> - depends on PVPANIC_MMIO
> + depends on (PVPANIC_MMIO || PVPANIC_PCI)
> help
> This option enable generic code for pvpanic device driver logic.
>
> @@ -12,3 +17,12 @@ 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
> + select 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 d08379b..fe57d1f 100644
> --- a/drivers/misc/pvpanic/Makefile
> +++ b/drivers/misc/pvpanic/Makefile
> @@ -1,2 +1,9 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Makefile for pvpanic device.
> +#

Again, nice, but nothing to do with this change. Please only do "one
thing" per patch.

thanks,

greg k-h

2021-02-03 15:48:32

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 2/2] misc/pvpanic: add pci driver

On Wed, Feb 03, 2021 at 04:43:59PM +0200, Mihai Carabas wrote:
> Add pvpanic pci device driver support.
>
> Signed-off-by: Mihai Carabas <[email protected]>
> ---
> drivers/misc/pvpanic/Kconfig | 16 ++++++++++-
> drivers/misc/pvpanic/Makefile | 7 +++++
> drivers/misc/pvpanic/pvpanic-pci.c | 54 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 76 insertions(+), 1 deletion(-)
> create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c
>
> diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
> index 12bb017..4a96e8d 100644
> --- a/drivers/misc/pvpanic/Kconfig
> +++ b/drivers/misc/pvpanic/Kconfig
> @@ -1,6 +1,11 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# pvpanic device
> +#
> +
> config PVPANIC
> bool "pvpanic device support"
> - depends on PVPANIC_MMIO
> + depends on (PVPANIC_MMIO || PVPANIC_PCI)
> help
> This option enable generic code for pvpanic device driver logic.
>
> @@ -12,3 +17,12 @@ 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
> + select 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 d08379b..fe57d1f 100644
> --- a/drivers/misc/pvpanic/Makefile
> +++ b/drivers/misc/pvpanic/Makefile
> @@ -1,2 +1,9 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Makefile for pvpanic device.
> +#
> +
> +
> obj-$(CONFIG_PVPANIC) += pvpanic.o
> obj-$(CONFIG_PVPANIC_MMIO) += pvpanic-mmio.o
> +obj-$(CONFIG_PVPANIC_PCI) += pvpanic-pci.o
> diff --git a/drivers/misc/pvpanic/pvpanic-pci.c b/drivers/misc/pvpanic/pvpanic-pci.c
> new file mode 100644
> index 00000000..1d25d11
> --- /dev/null
> +++ b/drivers/misc/pvpanic/pvpanic-pci.c
> @@ -0,0 +1,54 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * pvpanic pci driver.
> + *
> + * Copyright (C) 2021 Oracle.
> + */
> +
> +#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 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;
> + void __iomem *base;
> +
> + ret = pcim_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();

So no real device here? That feels really wrong, you can't have a
single global instance anymore :(

thanks,

greg k-h

2021-02-03 15:52:24

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 1/2] misc/pvpanic: split-up generic and platform dependent code

On Wed, Feb 03, 2021 at 04:43:58PM +0200, Mihai Carabas wrote:
> Split-up generic and platform dependent code in order to introduce pvpanic pci
> device driver later.

What is "later"?

And did you just create a new driver/module in this change? Why?
And how did you test? This new module looks to probably taint the
kernel, correct?

How about doing this at the very least, 2 patches, one to move to the
new directory, and the second to split into two modules. And of course,
please TEST THIS!

thanks,

greg k-h

2021-02-03 17:15:50

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 1/2] misc/pvpanic: split-up generic and platform dependent code

On 2/3/21 6:43 AM, Mihai Carabas wrote:
> diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
> new file mode 100644
> index 00000000..12bb017
> --- /dev/null
> +++ b/drivers/misc/pvpanic/Kconfig
> @@ -0,0 +1,14 @@
> +config PVPANIC
> + bool "pvpanic device support"
> + depends on PVPANIC_MMIO
> + help
> + This option enable generic code for pvpanic device driver logic.
> +
> +config PVPANIC_MMIO
> + tristate "pvpanic mmio device support"

MMIO


Also capitalize PCI in the other patch in the similar location.

> + depends on HAS_IOMEM && (ACPI || OF)
> + select 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.


thanks.
--
~Randy

2021-02-03 20:02:24

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/2] misc/pvpanic: split-up generic and platform dependent code

Hi Mihai,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on soc/for-next linus/master v5.11-rc6 next-20210125]
[cannot apply to char-misc/char-misc-testing]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Mihai-Carabas/misc-pvpanic-split-up-generic-and-platform-dependent-code/20210203-234431
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ab38c17aac10bf55ab3efde4c4db3893d8691d2
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/a1b3e466013502c380f409d8a4635c796f8fc1ef
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Mihai-Carabas/misc-pvpanic-split-up-generic-and-platform-dependent-code/20210203-234431
git checkout a1b3e466013502c380f409d8a4635c796f8fc1ef
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from drivers/misc/pvpanic/pvpanic-mmio.c:19:
>> drivers/misc/pvpanic/pvpanic.h:12: warning: "pr_fmt" redefined
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
In file included from include/linux/kernel.h:16,
from include/asm-generic/bug.h:20,
from arch/m68k/include/asm/bug.h:32,
from include/linux/bug.h:5,
from include/linux/io.h:11,
from drivers/misc/pvpanic/pvpanic-mmio.c:10:
include/linux/printk.h:301: note: this is the location of the previous definition
301 | #define pr_fmt(fmt) fmt
|
--
>> drivers/misc/pvpanic/pvpanic.c:47:6: warning: no previous prototype for 'pvpanic_probe' [-Wmissing-prototypes]
47 | void pvpanic_probe(void __iomem *pbase)
| ^~~~~~~~~~~~~
>> drivers/misc/pvpanic/pvpanic.c:54:6: warning: no previous prototype for 'pvpanic_remove' [-Wmissing-prototypes]
54 | void pvpanic_remove(void)
| ^~~~~~~~~~~~~~


vim +/pr_fmt +12 drivers/misc/pvpanic/pvpanic.h

10
11
> 12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.84 kB)
.config.gz (58.22 kB)
Download all attachments

2021-02-03 23:22:04

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/2] misc/pvpanic: split-up generic and platform dependent code

Hi Mihai,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linux/master]
[also build test ERROR on soc/for-next linus/master v5.11-rc6]
[cannot apply to char-misc/char-misc-testing]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Mihai-Carabas/misc-pvpanic-split-up-generic-and-platform-dependent-code/20210203-234431
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ab38c17aac10bf55ab3efde4c4db3893d8691d2
config: s390-allmodconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/a1b3e466013502c380f409d8a4635c796f8fc1ef
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Mihai-Carabas/misc-pvpanic-split-up-generic-and-platform-dependent-code/20210203-234431
git checkout a1b3e466013502c380f409d8a4635c796f8fc1ef
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=s390

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "pvpanic_probe" [drivers/misc/pvpanic/pvpanic-mmio.ko] undefined!
>> ERROR: modpost: "pvpanic_remove" [drivers/misc/pvpanic/pvpanic-mmio.ko] undefined!

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (1.85 kB)
.config.gz (50.57 kB)
Download all attachments