add support for pci in the pvpanic driver
PATCH v4 1/1 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].
v2:
- mmio -> MMIO, pci -> PCI suggested by Randy Dunlap.
- group pvpanic-common.c and mmio.c in the same module. The intention was to have only one module and the common code splitted up to be re-used by the pvpanic-pci module in the next patch.
- add a new patch where add the licenses for the new files (when I moved the code to mmio.c I preserved the original licenses there)
- properly clean-up PCI device when driver removed.
v3:
- drop patch 3 with licenses and add them when creating files
- create a new patch (2/3) which allowes multiple pvpanic instances
v4:
- fix Makefile in patch 1/3 and 3/3 for pvpanic.o as suggested by Arnd
How to test:
Run a VM with latest qemu which has the pvpanic-pci device:
qemu-system-aarch64 -device pvpanic-pci
Generate a panic in the guest:
echo 1 > /proc/sys/kernel/sysrq
echo c > /proc/sysrq-trigger
Observe in the QMP console the panic events received by the device:
{"timestamp": {"seconds": 1613122186, "microseconds": 141729}, "event":
"GUEST_PANICKED", "data": {"action": "pause"}}
{"timestamp": {"seconds": 1613122186, "microseconds": 141833}, "event":
"GUEST_PANICKED", "data": {"action": "poweroff"}}
{"timestamp": {"seconds": 1613122186, "microseconds": 141896}, "event":
"SHUTDOWN", "data": {"guest": true, "reason": "guest-panic"}}
[1] https://github.com/qemu/qemu/commit/9df52f58e76e904fb141b10318362d718f470db2
Mihai Carabas (3):
misc/pvpanic: split-up generic and platform dependent code misc/pvpanic: probe multiple instances misc/pvpanic: add PCI driver
drivers/misc/Kconfig | 9 +-
drivers/misc/Makefile | 2 +-
drivers/misc/pvpanic/Kconfig | 25 +++++
drivers/misc/pvpanic/Makefile | 8 ++
drivers/misc/{pvpanic.c => pvpanic/pvpanic-mmio.c} | 43 ++------
drivers/misc/pvpanic/pvpanic-pci.c | 54 ++++++++++
drivers/misc/pvpanic/pvpanic.c | 120 +++++++++++++++++++++
drivers/misc/pvpanic/pvpanic.h | 16 +++
8 files changed, 232 insertions(+), 45 deletions(-)
create mode 100644 drivers/misc/pvpanic/Kconfig
create mode 100644 drivers/misc/pvpanic/Makefile
rename drivers/misc/{pvpanic.c => pvpanic/pvpanic-mmio.c} (67%)
create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c
create mode 100644 drivers/misc/pvpanic/pvpanic.c
create mode 100644 drivers/misc/pvpanic/pvpanic.hSignature · 1 line
1.8.3.1
PATCH v4 1/3 misc/pvpanic: split-up generic and platform dependent code
Split-up generic and platform dependent code in order to be able to re-use generic event handling code in pvpanic PCI device driver in the next patches.
The code from pvpanic.c was split in two new files:
- pvpanic.c: generic code that handles pvpanic events
- pvpanic-mmio.c: platform/bus dependent code
---
drivers/misc/Kconfig | 9 +---
drivers/misc/Makefile | 2 +-
drivers/misc/pvpanic/Kconfig | 19 +++++++
drivers/misc/pvpanic/Makefile | 7 +++
drivers/misc/{pvpanic.c => pvpanic/pvpanic-mmio.c} | 42 +++------------
drivers/misc/pvpanic/pvpanic.c | 62 ++++++++++++++++++++++
drivers/misc/pvpanic/pvpanic.h | 17 ++++++
7 files changed, 114 insertions(+), 44 deletions(-)
create mode 100644 drivers/misc/pvpanic/Kconfig
create mode 100644 drivers/misc/pvpanic/Makefile
rename drivers/misc/{pvpanic.c => pvpanic/pvpanic-mmio.c} (67%)
create mode 100644 drivers/misc/pvpanic/pvpanic.c
create mode 100644 drivers/misc/pvpanic/pvpanic.hdrivers/misc/Kconfig +1 -8
@@ -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
drivers/misc/Makefile +1 -1
@@ -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
drivers/misc/pvpanic/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Pvpanic Kconfig +# +# Copyright (C) 2021 Oracle. +# + +config PVPANIC + bool "pvpanic device support" + help + This option allows to select a specific pvpanic device driver. + pvpanic is a paravirtualized device provided by QEMU; it lets + a virtual machine (guest) communicate panic events to the host. + +config PVPANIC_MMIO + tristate "pvpanic MMIO device support" + depends on HAS_IOMEM && (ACPI || OF) && PVPANIC + help + This driver provides support for the MMIO pvpanic device.
drivers/misc/pvpanic/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Pvpanic Makefile +# +# Copyright (C) 2021 Oracle. +# +obj-$(CONFIG_PVPANIC_MMIO) += pvpanic.o pvpanic-mmio.o
drivers/misc/pvpanic/pvpanic-mmio.c renamed from drivers/misc/pvpanic.c +7 -35
77 lines not on this page · raw message
drivers/misc/pvpanic/pvpanic.c new file +62 -0
62 lines not on this page · raw message
drivers/misc/pvpanic/pvpanic.h new file +17 -0
@@ -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_ */
Signature · 1 line
1.8.3.1
kernel test robot
build botRe: [PATCH v4 1/3] misc/pvpanic: split-up generic and platform dependent code
Thank you for the patch! Perhaps something to improve:
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-rc7] [cannot apply to char-misc/char-misc-testing next-20210212] [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/20210214-044449 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ab38c17aac10bf55ab3efde4c4db3893d8691d2 config: arm-randconfig-r035-20210214 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project c9439ca36342fb6013187d0a69aef92736951476)
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
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/2014e17b0bb6fb0bbea9dfa9d4d04ad6352d77bf
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/20210214-044449 git checkout 2014e17b0bb6fb0bbea9dfa9d4d04ad6352d77bf
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from drivers/misc/pvpanic/pvpanic-mmio.c:19:
>> drivers/misc/pvpanic/pvpanic.h:12:9: warning: 'pr_fmt' macro redefined [-Wmacro-redefined]
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^
include/linux/printk.h:301:9: note: previous definition is here
#define pr_fmt(fmt) fmt
^1 warning generated.
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/kbuild-all(a)lists.01.org
PATCH v4 2/3 misc/pvpanic: probe multiple instances
In reply to Mihai CarabasCreate the mecahism that allows multiple pvpanic instances to call pvpanic_probe and receive panic events. A global list will retain all the mapped addresses where to write panic events.
--- drivers/misc/pvpanic/pvpanic-mmio.c | 9 ++--- drivers/misc/pvpanic/pvpanic.c | 76 ++++++++++++++++++++++++++++++++----- drivers/misc/pvpanic/pvpanic.h | 5 +-- 3 files changed, 73 insertions(+), 17 deletions(-)
drivers/misc/pvpanic/pvpanic-mmio.c +4 -5
@@ -22,11 +22,12 @@MODULE_DESCRIPTION ("pvpanic device driver" );MODULE_LICENSE ("GPL" ); +static void __iomem *base; +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)
@@ -47,15 +48,13 @@ static int pvpanic_mmio_probe(struct platform_device *pdev)return -EINVAL ; } -pvpanic_probe (base); - -return 0 ; +return pvpanic_probe (base); }static int pvpanic_mmio_remove (struct platform_device *pdev) { -pvpanic_remove (); +pvpanic_remove (base);return 0 ; }
drivers/misc/pvpanic/pvpanic.c +67 -9
101 lines not on this page · raw message
drivers/misc/pvpanic/pvpanic.h +2 -3
@@ -8,10 +8,9 @@#ifndef PVPANIC_H_ #define PVPANIC_H_ -#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt -void pvpanic_probe (void __iomem *base); -void pvpanic_remove (void ); +int pvpanic_probe (void __iomem *base); +void pvpanic_remove (void __iomem *base);#endif /* PVPANIC_H_ */
Signature · 1 line
1.8.3.1
PATCH v4 3/3 misc/pvpanic: add PCI driver
In reply to Mihai CarabasAdd 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
--- drivers/misc/pvpanic/Kconfig | 6 +++++ drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-pci.c | 54 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c
drivers/misc/pvpanic/Kconfig +6 -0
@@ -17,3 +17,9 @@ config PVPANIC_MMIO depends on HAS_IOMEM && (ACPI || OF) && PVPANIC help This driver provides support for the MMIO pvpanic device. + +config PVPANIC_PCI + tristate "pvpanic PCI device support" + depends on PCI && PVPANIC + help + This driver provides support for the PCI pvpanic device.
drivers/misc/pvpanic/Makefile +1 -0
@@ -5,3 +5,4 @@ # Copyright (C) 2021 Oracle. # obj-$(CONFIG_PVPANIC_MMIO) += pvpanic.o pvpanic-mmio.o +obj-$(CONFIG_PVPANIC_PCI) += pvpanic.o pvpanic-pci.o
drivers/misc/pvpanic/pvpanic-pci.c new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Hello,
Any feedback on this last series?
Thank you,
Mihai
Quoted 65 lines
This patchset adds support for PCI in the pvpanic driver. The device already got in qemu [1].
v2:
- mmio -> MMIO, pci -> PCI suggested by Randy Dunlap.
- grouppvpanic-common.candmmio.cin the same module. The intention was to have only one module and the common code splitted up to be re-used by the pvpanic-pci module in the next patch.
- add a new patch where add the licenses for the new files (when I moved the code tommio.cI preserved the original licenses there)
- properly clean-up PCI device when driver removed.v3:
- drop patch 3 with licenses and add them when creating files
- create a new patch (2/3) which allowes multiple pvpanic instancesv4:
- fixMakefilein patch 1/3 and 3/3 for pvpanic.o as suggested by ArndHow to test:
Run a VM with latest qemu which has the pvpanic-pci device:
qemu-system-aarch64 -device pvpanic-pciGenerate a panic in the guest:
echo 1 >/proc/sys/kernel/sysrq
echo c >/proc/sysrq-triggerObserve in the QMP console the panic events received by the device:
{"timestamp": {"seconds": 1613122186, "microseconds": 141729}, "event":
"GUEST_PANICKED", "data": {"action": "pause"}}{"timestamp": {"seconds": 1613122186, "microseconds": 141833}, "event":
"GUEST_PANICKED", "data": {"action": "poweroff"}}{"timestamp": {"seconds": 1613122186, "microseconds": 141896}, "event":
"SHUTDOWN", "data": {"guest": true, "reason": "guest-panic"}}[1] https://github.com/qemu/qemu/commit/9df52f58e76e904fb141b10318362d718f470db2
Mihai Carabas (3):
misc/pvpanic: split-up generic and platform dependent code misc/pvpanic: probe multiple instances misc/pvpanic: add PCI driverdrivers/misc/Kconfig | 9 +- drivers/misc/Makefile | 2 +- drivers/misc/pvpanic/Kconfig | 25 +++++ drivers/misc/pvpanic/Makefile | 8 ++ drivers/misc/{pvpanic.c => pvpanic/pvpanic-mmio.c} | 43 ++------ drivers/misc/pvpanic/pvpanic-pci.c | 54 ++++++++++ drivers/misc/pvpanic/pvpanic.c | 120 +++++++++++++++++++++ drivers/misc/pvpanic/pvpanic.h | 16 +++ 8 files changed, 232 insertions(+), 45 deletions(-)create mode 100644
drivers/misc/pvpanic/Kconfigcreate mode 100644drivers/misc/pvpanic/Makefilerenamedrivers/misc/{pvpanic.c=>pvpanic/pvpanic-mmio.c} (67%) create mode 100644drivers/misc/pvpanic/pvpanic-pci.ccreate mode 100644drivers/misc/pvpanic/pvpanic.ccreate mode 100644drivers/misc/pvpanic/pvpanic.h
Greg KH
maintainerQuoted 3 lines · Mihai Carabas
Hello,
Any feedback on this last series?
Other than the "this breaks the build according to the kernel test robot"?
I think that needs to be fixed before we can do anything here...
thnaks,
greg k-h
Greg KH
maintainerQuoted 9 lines · Greg KH
Quoted 3 lines · Mihai Carabas
Hello,
Any feedback on this last series?
Other than the "this breaks the build according to the kernel test robot"?
I think that needs to be fixed before we can do anything here...
Ok, it didn't break the build, it added a warning, which is still not allowed, as you know.
thanks,
greg k-h