[PATCH] arm64/module-plts: Consider the special case where plt_max_entries is 0
If plt_max_entries is 0, a warning is triggered. WARNING: CPU: 200 PID: 3000 at arch/arm64/kernel/module-plts.c:97 module_emit_plt_entry+0xa4/0x150 Signed-off-by: Peng Hao --- arch/arm64/kernel/module-plts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/module-plts.c index 65b08a74aec6..1868c9ac13f2 100644 --- a/arch/arm64/kernel/module-plts.c +++ b/arch/arm64/kernel/module-plts.c @@ -79,7 +79,8 @@ u64 module_emit_plt_entry(struct module *mod, Elf64_Shdr *sechdrs, int i = pltsec->plt_num_entries; int j = i - 1; u64 val = sym->st_value + rela->r_addend; - + if (pltsec->plt_max_entries == 0) + return 0; if (is_forbidden_offset_for_adrp([i].adrp)) i++; -- 2.18.4
[PATCH] kvm/arm64: Correct incorrect function parameter specification
update_vmid() just has one parameter "vmid".The other parameter "kvm" is no longer used. Signed-off-by: Peng Hao --- arch/arm64/kvm/arm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 90cb90561446..5bf9bf54b22c 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -466,7 +466,6 @@ static bool need_new_vmid_gen(struct kvm_vmid *vmid) /** * update_vmid - Update the vmid with a valid VMID for the current generation - * @kvm: The guest that struct vmid belongs to * @vmid: The stage-2 VMID information struct */ static void update_vmid(struct kvm_vmid *vmid) -- 2.18.4
[PATCH] kvm/arm64: Correct incorrect function parameter specification
update_vmid() just has one parameter "vmid".The other parameter "kvm" is no longer used. Signed-off-by: Peng Hao --- arch/arm64/kvm/arm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 90cb90561446..5bf9bf54b22c 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -466,7 +466,6 @@ static bool need_new_vmid_gen(struct kvm_vmid *vmid) /** * update_vmid - Update the vmid with a valid VMID for the current generation - * @kvm: The guest that struct vmid belongs to * @vmid: The stage-2 VMID information struct */ static void update_vmid(struct kvm_vmid *vmid) -- 2.18.4 OPPO 本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。 This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!
[PATCH v4] arm/mach-at91/pm : fix possible object reference leak
of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device. When returning error we should call put_device. Reviewed-by: Mukesh Ojha Signed-off-by: Peng Hao --- arch/arm/mach-at91/pm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 51e808a..38511a5 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -591,13 +591,13 @@ static int __init at91_pm_backup_init(void) np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); if (!np) - goto securam_fail; + goto securam_fail_no_ref_dev; pdev = of_find_device_by_node(np); of_node_put(np); if (!pdev) { pr_warn("%s: failed to find securam device!\n", __func__); - goto securam_fail; + goto securam_fail_no_ref_dev; } sram_pool = gen_pool_get(>dev, NULL); @@ -620,6 +620,8 @@ static int __init at91_pm_backup_init(void) return 0; securam_fail: + put_device(>dev); +securam_fail_no_ref_dev: iounmap(pm_data.sfrbu); pm_data.sfrbu = NULL; return ret; -- 1.8.3.1
[PATCH v3] arm/mach-at91/pm : fix possible object reference leak
of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device. When returning error we should call put_device. Signed-off-by: Peng Hao --- arch/arm/mach-at91/pm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 51e808a..38511a5 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -591,13 +591,13 @@ static int __init at91_pm_backup_init(void) np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); if (!np) - goto securam_fail; + goto securam_fail_no_get; pdev = of_find_device_by_node(np); of_node_put(np); if (!pdev) { pr_warn("%s: failed to find securam device!\n", __func__); - goto securam_fail; + goto securam_fail_no_get; } sram_pool = gen_pool_get(>dev, NULL); @@ -620,6 +620,8 @@ static int __init at91_pm_backup_init(void) return 0; securam_fail: + put_device(>dev); +securam_fail_no_get: iounmap(pm_data.sfrbu); pm_data.sfrbu = NULL; return ret; -- 1.8.3.1
[PATCH V2] arm/mach-at91/pm : fix possible object reference leak
of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device. When returning error we should call put_device. Signed-off-by: Peng Hao --- arch/arm/mach-at91/pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 51e808a..b60fcc9 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -591,7 +591,7 @@ static int __init at91_pm_backup_init(void) np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); if (!np) - goto securam_fail; + goto securam_fail_1; pdev = of_find_device_by_node(np); of_node_put(np); @@ -620,6 +620,8 @@ static int __init at91_pm_backup_init(void) return 0; securam_fail: + put_device(>dev); +securam_fail_1: iounmap(pm_data.sfrbu); pm_data.sfrbu = NULL; return ret; -- 1.8.3.1
[PATCH] kvm: fix a function description error
The parameter's name of function description is different from definition. Signed-off-by: Peng Hao --- virt/kvm/kvm_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 5858452..4e11918 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1134,7 +1134,7 @@ int kvm_get_dirty_log(struct kvm *kvm, * and reenable dirty page tracking for the corresponding pages. * @kvm: pointer to kvm instance * @log: slot id and address to which we copy the log - * @is_dirty: flag set if any page is dirty + * @flush: flag set if any page is dirty (need to flush tlb) * * We need to keep it in mind that VCPU threads can write to the bitmap * concurrently. So, to avoid losing track of dirty pages we keep the @@ -1221,6 +1221,7 @@ int kvm_get_dirty_log_protect(struct kvm *kvm, * and reenable dirty page tracking for the corresponding pages. * @kvm: pointer to kvm instance * @log: slot id and address from which to fetch the bitmap of dirty pages + * @flush: flag set if any page is dirty (need to flush tlb) */ int kvm_clear_dirty_log_protect(struct kvm *kvm, struct kvm_clear_dirty_log *log, bool *flush) -- 1.8.3.1
[tip:x86/urgent] x86/resctrl: Remove unused variable
Commit-ID: 7f2daa96759b0700ad28579133aa91bc663632a7 Gitweb: https://git.kernel.org/tip/7f2daa96759b0700ad28579133aa91bc663632a7 Author: Peng Hao AuthorDate: Sun, 10 Mar 2019 01:29:44 +0800 Committer: Thomas Gleixner CommitDate: Sun, 24 Mar 2019 22:09:27 +0100 x86/resctrl: Remove unused variable Variable "struct rdt_resource *r" is set but not used. So remove it. Signed-off-by: Peng Hao Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/1552152584-26087-1-git-send-email-peng.h...@zte.com.cn --- arch/x86/kernel/cpu/resctrl/monitor.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index f33f11f69078..1573a0a6b525 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -501,11 +501,8 @@ out_unlock: void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms) { unsigned long delay = msecs_to_jiffies(delay_ms); - struct rdt_resource *r; int cpu; - r = _resources_all[RDT_RESOURCE_L3]; - cpu = cpumask_any(>cpu_mask); dom->cqm_work_cpu = cpu;
[tip:x86/urgent] x86/resctrl: Remove unused variable
Commit-ID: cec67c6ea58c6cca9234b7b551f3d66296bc1e69 Gitweb: https://git.kernel.org/tip/cec67c6ea58c6cca9234b7b551f3d66296bc1e69 Author: Peng Hao AuthorDate: Sun, 10 Mar 2019 01:29:44 +0800 Committer: Thomas Gleixner CommitDate: Sun, 24 Mar 2019 22:07:46 +0100 x86/resctrl: Remove unused variable Variable "struct rdt_resource *r" is set but not used. So remove it. Signed-off-by: Peng Hao Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/1552152584-26087-1-git-send-email-peng.h...@zte.com.cn --- arch/x86/kernel/cpu/resctrl/monitor.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index f33f11f69078..1573a0a6b525 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -501,11 +501,8 @@ out_unlock: void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms) { unsigned long delay = msecs_to_jiffies(delay_ms); - struct rdt_resource *r; int cpu; - r = _resources_all[RDT_RESOURCE_L3]; - cpu = cpumask_any(>cpu_mask); dom->cqm_work_cpu = cpu;
[PATCH] x86/resctrl: remove unused variable
Variable "struct rdt_resource *r" is set but not used. So remove it. Signed-off-by: Peng Hao --- arch/x86/kernel/cpu/resctrl/monitor.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index f33f11f..1573a0a 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -501,11 +501,8 @@ void cqm_handle_limbo(struct work_struct *work) void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms) { unsigned long delay = msecs_to_jiffies(delay_ms); - struct rdt_resource *r; int cpu; - r = _resources_all[RDT_RESOURCE_L3]; - cpu = cpumask_any(>cpu_mask); dom->cqm_work_cpu = cpu; -- 1.8.3.1
[PATCH V6 1/4] misc/pvpanic : preparing for pvpanic driver framework
Preparing for pvpanic driver framework. Create a pvpanic driver directory and move current driver file to new directory. Reviewed-by: Andy Shevchenko Signed-off-by: Peng Hao --- drivers/misc/Kconfig | 9 + drivers/misc/Makefile| 2 +- drivers/misc/pvpanic/Kconfig | 7 +++ drivers/misc/pvpanic/Makefile| 5 + drivers/misc/{ => pvpanic}/pvpanic.c | 0 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 drivers/misc/pvpanic/Kconfig create mode 100644 drivers/misc/pvpanic/Makefile rename drivers/misc/{ => pvpanic}/pvpanic.c (100%) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index f417b06..aa3a805 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -513,14 +513,7 @@ 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. - +source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e39ccbb..cfe20b3 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -58,4 +58,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)+= aspeed-lpc-snoop.o 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/ diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig new file mode 100644 index 000..3e612c6 --- /dev/null +++ b/drivers/misc/pvpanic/Kconfig @@ -0,0 +1,7 @@ +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. diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile new file mode 100644 index 000..6394224 --- /dev/null +++ b/drivers/misc/pvpanic/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (c) 2018 ZTE Ltd. + +obj-$(CONFIG_PVPANIC)+= pvpanic.o diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c similarity index 100% rename from drivers/misc/pvpanic.c rename to drivers/misc/pvpanic/pvpanic.c -- 1.8.3.1
[PATCH V6 2/4] misc/pvpanic: Add pvpanic driver framework
Add pvpanic driver framework and split the original pvpanic acpi/of driver as the two separate files and modify code to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig| 19 drivers/misc/pvpanic/Makefile | 2 + drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++ drivers/misc/pvpanic/pvpanic-of.c | 53 +++ drivers/misc/pvpanic/pvpanic.c | 181 drivers/misc/pvpanic/pvpanic.h | 15 +++ 6 files changed, 225 insertions(+), 122 deletions(-) create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c create mode 100644 drivers/misc/pvpanic/pvpanic-of.c create mode 100644 drivers/misc/pvpanic/pvpanic.h diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 3e612c6..0c0c0b2 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -5,3 +5,22 @@ config PVPANIC 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. + +if PVPANIC + +config PVPANIC_ACPI + tristate "pvpanic acpi driver" + depends on ACPI + default PVPANIC + help + This driver is one specific driver for pvpanic driver framework. + It provides an acpi device as pvpanic device. + +config PVPANIC_OF + tristate "pvpanic mmio driver" + depends on OF + help + This driver is one specific driver for pvpanic driver framework. + It provides a mmio device as pvpanic device. + +endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 6394224..8819509 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -3,3 +3,5 @@ # Copyright (c) 2018 ZTE Ltd. obj-$(CONFIG_PVPANIC)+= pvpanic.o +obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o +obj-$(CONFIG_PVPANIC_OF) += pvpanic-of.o diff --git a/drivers/misc/pvpanic/pvpanic-acpi.c b/drivers/misc/pvpanic/pvpanic-acpi.c new file mode 100644 index 000..8d10924 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-acpi.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_add(struct acpi_device *device); +static int pvpanic_remove(struct acpi_device *device); + +static const struct acpi_device_id pvpanic_device_ids[] = { + { "QEMU0001", 0 }, + { "", 0 } +}; +MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); + +static struct acpi_driver pvpanic_driver = { + .name = "pvpanic", + .class ="QEMU", + .ids = pvpanic_device_ids, + .ops = { + .add = pvpanic_add, + .remove = pvpanic_remove, + }, + .owner =THIS_MODULE, +}; + +static acpi_status +pvpanic_walk_resources(struct acpi_resource *res, void *context) +{ + struct resource r; + int ret = 0; + struct device *dev = context; + + memset(, 0, sizeof(r)); + if (acpi_dev_resource_io(res, ) || acpi_dev_resource_memory(res, )) + ret = pvpanic_add_device(dev, ); + + if (!ret) + return AE_OK; + + return AE_ERROR; +} +static int pvpanic_add(struct acpi_device *device) +{ + int ret; + acpi_status status; + + ret = acpi_bus_get_status(device); + if (ret < 0) + return ret; + + if (!device->status.enabled || !device->status.functional) + return -ENODEV; + + status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, +pvpanic_walk_resources, >dev); + + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} + +static int pvpanic_remove(struct acpi_device *device) +{ + pvpanic_remove_device(); + return 0; +} + +module_acpi_driver(pvpanic_driver); diff --git a/drivers/misc/pvpanic/pvpanic-of.c b/drivers/misc/pvpanic/pvpanic-of.c new file mode 100644 index 000..73ca5f3 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-of.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * pvpanic of driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_mmio_probe(struct platform_device *pdev) +{ + struct resource *res; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; + + ret = pvpanic_add_device(>dev, res); + if (ret) + ret
[PATCH V6 0/4] add pvpanic driver framework
QEMU community requires additional PCI devices to simulate PVPANIC devices so that some architectures can not occupy precious less than 4G of memory space. Previously, I added PCI driver directly to the original version of the driver, which made the whole driver file look a bit cluttered. So Andy Shevchenko suggests: "I would recommend to split it in a way how it's done for ChipIdea USB driver, for example. (drivers/usb/chipidea if I'm not mistaken)". v5 ---> v6 : add mutex lock in pvpanic_remove_device. v4 ---> v5 : Merge some patches to one for avoiding bisectability issues. Make sure that just one pvpanic device is working. v3 ---> v4 : add help text info in Konfig. adjust structure definition position. v2 ---> v3 : add change infomation. v1 ---> v2 : add patch to descript the whole patch series. modify text infomation. modify "SPDX-License-Identifier: GPL-2.0-or-later" to "SPDX-License-Identifier: GPL-2.0+" Peng Hao (4): misc/pvpanic: preparing for pvpanic driver framework misc/pvpanic: Add pvpanic driver framework misc/pvpanic: Avoid initializing multiple pvpanic devices misc/pvpanic: add new pvpanic pci driver drivers/misc/Kconfig| 9 +- drivers/misc/Makefile | 2 +- drivers/misc/pvpanic.c | 192 drivers/misc/pvpanic/Kconfig| 34 +++ drivers/misc/pvpanic/Makefile | 8 ++ drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++ drivers/misc/pvpanic/pvpanic-of.c | 53 ++ drivers/misc/pvpanic/pvpanic-pci.c | 56 +++ drivers/misc/pvpanic/pvpanic.c | 140 ++ drivers/misc/pvpanic/pvpanic.h | 15 +++ 10 files changed, 385 insertions(+), 201 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-acpi.c create mode 100644 drivers/misc/pvpanic/pvpanic-of.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
[PATCH V6 4/4] misc/pvpanic: add new pvpanic pci driver
Add new pvpanic pci driver to pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 10 ++- drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-pci.c | 56 ++ 3 files changed, 66 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 0c0c0b2..866cb37 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -1,6 +1,6 @@ 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 @@ -23,4 +23,12 @@ config PVPANIC_OF This driver is one specific driver for pvpanic driver framework. It provides a mmio device as pvpanic device. +config PVPANIC_PCI + tristate "pvpanic pci driver" + depends on PCI + default PVPANIC + help + This driver is one specific driver for pvpanic driver framework. + It provides a pci device as pvpanic device. + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 8819509..eb3e0ee 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_PVPANIC)+= pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o obj-$(CONFIG_PVPANIC_OF) += pvpanic-of.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 000..1261710 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-pci.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include "pvpanic.h" + +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 + +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 = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + memset(, 0, sizeof(res)); + res.start = pci_resource_start(pdev, 0); + res.end = pci_resource_end(pdev, 0); + res.flags = IORESOURCE_MEM; + ret = pvpanic_add_device(>dev, ); + if (ret) + return ret; + + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + pvpanic_remove_device(); +} + +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
[PATCH V6 3/4] misc/pvpanic: Avoid initializing multiple pvpanic devices
Avoid initializing multiple pvpanic devices when configure multiple pvpanic device driver type. Make sure that only one pvpanic device is working. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index ccadec0..3c9d957 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -15,10 +15,13 @@ #include static struct { + struct mutex lock; struct platform_device *pdev; void __iomem *base; bool is_ioport; -} pvpanic_data; +} pvpanic_data = { + .lock = __MUTEX_INITIALIZER(pvpanic_data.lock), +}; #define PVPANIC_PANICKED(1 << 0) @@ -50,9 +53,17 @@ int pvpanic_add_device(struct device *dev, struct resource *res) struct platform_device *pdev; int ret; + mutex_lock(_data.lock); + if (pvpanic_data.pdev) { + mutex_unlock(_data.lock); + return -EEXIST; + } + pdev = platform_device_alloc("pvpanic", -1); - if (!pdev) + if (!pdev) { + mutex_unlock(_data.lock); return -ENOMEM; + } pdev->dev.parent = dev; @@ -64,9 +75,11 @@ int pvpanic_add_device(struct device *dev, struct resource *res) if (ret) goto err; pvpanic_data.pdev = pdev; + mutex_unlock(_data.lock); return 0; err: + mutex_unlock(_data.lock); platform_device_put(pdev); return ret; } @@ -74,8 +87,10 @@ int pvpanic_add_device(struct device *dev, struct resource *res) void pvpanic_remove_device(void) { + mutex_lock(_data.lock); platform_device_unregister(pvpanic_data.pdev); pvpanic_data.pdev = NULL; + mutex_unlock(_data.lock); } EXPORT_SYMBOL_GPL(pvpanic_remove_device); -- 1.8.3.1
[PATCH V5 3/4] misc/pvpanic: Avoid initializing multiple pvpanic devices
Avoid initializing multiple pvpanic devices when configure multiple pvpanic device driver type. Make sure that only one pvpanic device is working. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index ccadec0..fbb5038 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -15,10 +15,13 @@ #include static struct { + struct mutex lock; struct platform_device *pdev; void __iomem *base; bool is_ioport; -} pvpanic_data; +} pvpanic_data = { + .lock = __MUTEX_INITIALIZER(pvpanic_data.lock), +}; #define PVPANIC_PANICKED(1 << 0) @@ -50,6 +53,12 @@ int pvpanic_add_device(struct device *dev, struct resource *res) struct platform_device *pdev; int ret; + mutex_lock(_data.lock); + if (pvpanic_data.pdev) { + mutex_unlock(_data.lock); + return -EEXIST; + } + pdev = platform_device_alloc("pvpanic", -1); if (!pdev) return -ENOMEM; @@ -64,9 +73,11 @@ int pvpanic_add_device(struct device *dev, struct resource *res) if (ret) goto err; pvpanic_data.pdev = pdev; + mutex_unlock(_data.lock); return 0; err: + mutex_unlock(_data.lock); platform_device_put(pdev); return ret; } -- 1.8.3.1
[PATCH V5 2/4] misc/pvpanic: Add pvpanic driver framework
Add pvpanic driver framework and split the original pvpanic acpi/of driver as the two separate files and modify code to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig| 19 drivers/misc/pvpanic/Makefile | 2 + drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++ drivers/misc/pvpanic/pvpanic-of.c | 53 +++ drivers/misc/pvpanic/pvpanic.c | 181 drivers/misc/pvpanic/pvpanic.h | 15 +++ 6 files changed, 225 insertions(+), 122 deletions(-) create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c create mode 100644 drivers/misc/pvpanic/pvpanic-of.c create mode 100644 drivers/misc/pvpanic/pvpanic.h diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 3e612c6..0c0c0b2 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -5,3 +5,22 @@ config PVPANIC 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. + +if PVPANIC + +config PVPANIC_ACPI + tristate "pvpanic acpi driver" + depends on ACPI + default PVPANIC + help + This driver is one specific driver for pvpanic driver framework. + It provides an acpi device as pvpanic device. + +config PVPANIC_OF + tristate "pvpanic mmio driver" + depends on OF + help + This driver is one specific driver for pvpanic driver framework. + It provides a mmio device as pvpanic device. + +endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 6394224..8819509 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -3,3 +3,5 @@ # Copyright (c) 2018 ZTE Ltd. obj-$(CONFIG_PVPANIC)+= pvpanic.o +obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o +obj-$(CONFIG_PVPANIC_OF) += pvpanic-of.o diff --git a/drivers/misc/pvpanic/pvpanic-acpi.c b/drivers/misc/pvpanic/pvpanic-acpi.c new file mode 100644 index 000..8d10924 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-acpi.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_add(struct acpi_device *device); +static int pvpanic_remove(struct acpi_device *device); + +static const struct acpi_device_id pvpanic_device_ids[] = { + { "QEMU0001", 0 }, + { "", 0 } +}; +MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); + +static struct acpi_driver pvpanic_driver = { + .name = "pvpanic", + .class ="QEMU", + .ids = pvpanic_device_ids, + .ops = { + .add = pvpanic_add, + .remove = pvpanic_remove, + }, + .owner =THIS_MODULE, +}; + +static acpi_status +pvpanic_walk_resources(struct acpi_resource *res, void *context) +{ + struct resource r; + int ret = 0; + struct device *dev = context; + + memset(, 0, sizeof(r)); + if (acpi_dev_resource_io(res, ) || acpi_dev_resource_memory(res, )) + ret = pvpanic_add_device(dev, ); + + if (!ret) + return AE_OK; + + return AE_ERROR; +} +static int pvpanic_add(struct acpi_device *device) +{ + int ret; + acpi_status status; + + ret = acpi_bus_get_status(device); + if (ret < 0) + return ret; + + if (!device->status.enabled || !device->status.functional) + return -ENODEV; + + status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, +pvpanic_walk_resources, >dev); + + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} + +static int pvpanic_remove(struct acpi_device *device) +{ + pvpanic_remove_device(); + return 0; +} + +module_acpi_driver(pvpanic_driver); diff --git a/drivers/misc/pvpanic/pvpanic-of.c b/drivers/misc/pvpanic/pvpanic-of.c new file mode 100644 index 000..73ca5f3 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-of.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * pvpanic of driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_mmio_probe(struct platform_device *pdev) +{ + struct resource *res; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; + + ret = pvpanic_add_device(>dev, res); + if (ret) + ret
[PATCH V5 1/4] misc/pvpanic : preparing for pvpanic driver framework
Preparing for pvpanic driver framework. Create a pvpanic driver directory and move current driver file to new directory. Signed-off-by: Peng Hao --- drivers/misc/Kconfig | 9 + drivers/misc/Makefile| 2 +- drivers/misc/pvpanic/Kconfig | 7 +++ drivers/misc/pvpanic/Makefile| 5 + drivers/misc/{ => pvpanic}/pvpanic.c | 0 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 drivers/misc/pvpanic/Kconfig create mode 100644 drivers/misc/pvpanic/Makefile rename drivers/misc/{ => pvpanic}/pvpanic.c (100%) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index f417b06..aa3a805 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -513,14 +513,7 @@ 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. - +source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e39ccbb..cfe20b3 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -58,4 +58,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)+= aspeed-lpc-snoop.o 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/ diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig new file mode 100644 index 000..3e612c6 --- /dev/null +++ b/drivers/misc/pvpanic/Kconfig @@ -0,0 +1,7 @@ +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. diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile new file mode 100644 index 000..6394224 --- /dev/null +++ b/drivers/misc/pvpanic/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (c) 2018 ZTE Ltd. + +obj-$(CONFIG_PVPANIC)+= pvpanic.o diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c similarity index 100% rename from drivers/misc/pvpanic.c rename to drivers/misc/pvpanic/pvpanic.c -- 1.8.3.1
[PATCH V5 4/4] misc/pvpanic: add new pvpanic pci driver
Add new pvpanic pci driver to pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 10 ++- drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-pci.c | 56 ++ 3 files changed, 66 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 0c0c0b2..866cb37 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -1,6 +1,6 @@ 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 @@ -23,4 +23,12 @@ config PVPANIC_OF This driver is one specific driver for pvpanic driver framework. It provides a mmio device as pvpanic device. +config PVPANIC_PCI + tristate "pvpanic pci driver" + depends on PCI + default PVPANIC + help + This driver is one specific driver for pvpanic driver framework. + It provides a pci device as pvpanic device. + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 8819509..eb3e0ee 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_PVPANIC)+= pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o obj-$(CONFIG_PVPANIC_OF) += pvpanic-of.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 000..1261710 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-pci.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include "pvpanic.h" + +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 + +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 = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + memset(, 0, sizeof(res)); + res.start = pci_resource_start(pdev, 0); + res.end = pci_resource_end(pdev, 0); + res.flags = IORESOURCE_MEM; + ret = pvpanic_add_device(>dev, ); + if (ret) + return ret; + + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + pvpanic_remove_device(); +} + +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
[PATCH V5 0/4] add pvpanic driver framework
QEMU community requires additional PCI devices to simulate PVPANIC devices so that some architectures can not occupy precious less than 4G of memory space. Previously, I added PCI driver directly to the original version of the driver, which made the whole driver file look a bit cluttered. So Andy Shevchenko suggests: "I would recommend to split it in a way how it's done for ChipIdea USB driver, for example. (drivers/usb/chipidea if I'm not mistaken)". v4 ---> v5 : Merge some patches to one for avoiding bisectability issues. Make sure that just one pvpanic device is working. v3 ---> v4 : add help text info in Konfig. adjust structure definition position. v2 ---> v3 : add change infomation. v1 ---> v2 : add patch to descript the whole patch series. modify text infomation. modify "SPDX-License-Identifier: GPL-2.0-or-later" to "SPDX-License-Identifier: GPL-2.0+" Peng Hao (4): misc/pvpanic: preparing for pvpanic driver framework misc/pvpanic: Add pvpanic driver framework misc/pvpanic: Avoid initializing multiple pvpanic devices misc/pvpanic: add new pvpanic pci driver drivers/misc/Kconfig| 9 +- drivers/misc/Makefile | 2 +- drivers/misc/pvpanic.c | 192 drivers/misc/pvpanic/Kconfig| 34 +++ drivers/misc/pvpanic/Makefile | 8 ++ drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++ drivers/misc/pvpanic/pvpanic-of.c | 53 ++ drivers/misc/pvpanic/pvpanic-pci.c | 56 +++ drivers/misc/pvpanic/pvpanic.c | 140 ++ drivers/misc/pvpanic/pvpanic.h | 15 +++ 10 files changed, 385 insertions(+), 201 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-acpi.c create mode 100644 drivers/misc/pvpanic/pvpanic-of.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
[PATCH] arm/mach-socfpga/pm: fix possible object reference leak
of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device. When returning error we should call put_device. Signed-off-by: Peng Hao --- arch/arm/mach-socfpga/pm.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c index d486678..b782294 100644 --- a/arch/arm/mach-socfpga/pm.c +++ b/arch/arm/mach-socfpga/pm.c @@ -60,14 +60,14 @@ static int socfpga_setup_ocram_self_refresh(void) if (!ocram_pool) { pr_warn("%s: ocram pool unavailable!\n", __func__); ret = -ENODEV; - goto put_node; + goto put_device; } ocram_base = gen_pool_alloc(ocram_pool, socfpga_sdram_self_refresh_sz); if (!ocram_base) { pr_warn("%s: unable to alloc ocram!\n", __func__); ret = -ENOMEM; - goto put_node; + goto put_device; } ocram_pbase = gen_pool_virt_to_phys(ocram_pool, ocram_base); @@ -78,7 +78,7 @@ static int socfpga_setup_ocram_self_refresh(void) if (!suspend_ocram_base) { pr_warn("%s: __arm_ioremap_exec failed!\n", __func__); ret = -ENOMEM; - goto put_node; + goto put_device; } /* Copy the code that puts DDR in self refresh to ocram */ @@ -92,6 +92,8 @@ static int socfpga_setup_ocram_self_refresh(void) if (!socfpga_sdram_self_refresh_in_ocram) ret = -EFAULT; +put_device: + put_device(>dev); put_node: of_node_put(np); -- 1.8.3.1
[PATCH] arm/mach-omap2/display: fix possible object reference leak
of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device.When returning error we should call put_device. Signed-off-by: Peng Hao --- arch/arm/mach-omap2/display.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c index f86b72d..c6aa9ed 100644 --- a/arch/arm/mach-omap2/display.c +++ b/arch/arm/mach-omap2/display.c @@ -258,6 +258,7 @@ static int __init omapdss_init_of(void) r = of_platform_populate(node, NULL, NULL, >dev); if (r) { pr_err("Unable to populate DSS submodule devices\n"); + put_device(>dev); return r; } -- 1.8.3.1
[PATCH] arm/mach-at91/pm : fix possible object reference leak
of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device. When returning error we should call put_device. Signed-off-by: Peng Hao --- arch/arm/mach-at91/pm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 51e808a..70fadb7 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -621,6 +621,7 @@ static int __init at91_pm_backup_init(void) securam_fail: iounmap(pm_data.sfrbu); + put_device(>dev); pm_data.sfrbu = NULL; return ret; } -- 1.8.3.1
[PATCH] thermal/qcom/tsens-common : fix possible object reference leak
of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device. We also should make sure to drop the reference to the device taken by of_find_device_by_node() when returning error. Signed-off-by: Peng Hao --- drivers/thermal/qcom/tsens-common.c | 33 +++-- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 78652ca..f80c73f 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -144,13 +144,17 @@ int __init init_common(struct tsens_device *tmdev) tmdev->tm_offset = 0; res = platform_get_resource(op, IORESOURCE_MEM, 1); srot_base = devm_ioremap_resource(>dev, res); - if (IS_ERR(srot_base)) - return PTR_ERR(srot_base); + if (IS_ERR(srot_base)) { + ret = PTR_ERR(srot_base); + goto err_put_device; + } tmdev->srot_map = devm_regmap_init_mmio(tmdev->dev, srot_base, _srot_config); - if (IS_ERR(tmdev->srot_map)) - return PTR_ERR(tmdev->srot_map); + if (IS_ERR(tmdev->srot_map)) { + ret = PTR_ERR(tmdev->srot_map); + goto err_put_device; + } } else { /* old DTs where SROT and TM were in a contiguous 2K block */ @@ -159,22 +163,31 @@ int __init init_common(struct tsens_device *tmdev) res = platform_get_resource(op, IORESOURCE_MEM, 0); tm_base = devm_ioremap_resource(>dev, res); - if (IS_ERR(tm_base)) - return PTR_ERR(tm_base); + if (IS_ERR(tm_base)) { + ret = PTR_ERR(tm_base); + goto err_put_device; + } tmdev->tm_map = devm_regmap_init_mmio(tmdev->dev, tm_base, _config); - if (IS_ERR(tmdev->tm_map)) - return PTR_ERR(tmdev->tm_map); + if (IS_ERR(tmdev->tm_map)) { + ret = PTR_ERR(tmdev->tm_map); + goto err_put_device; + } if (tmdev->srot_map) { ret = regmap_read(tmdev->srot_map, ctrl_offset, ); if (ret) - return ret; + goto err_put_device; if (!(code & TSENS_EN)) { dev_err(tmdev->dev, "tsens device is not enabled\n"); - return -ENODEV; + ret = -ENODEV; + goto err_put_device; } } return 0; + +err_put_device: + put_device(>dev); + return ret; } -- 1.8.3.1
[PATCH V4 2/6] misc/pvpanic: Add pvpanic driver framework
Add pvpanic driver framework. Follow-up patches will split the original pvpanic acpi/of driver as the two separate files and modify code to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 158 +++-- 1 file changed, 27 insertions(+), 131 deletions(-) diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index 595ac06..f44a884 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -8,11 +8,9 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include +#include #include #include -#include -#include #include #include @@ -43,59 +41,25 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; -#ifdef CONFIG_ACPI -static int pvpanic_add(struct acpi_device *device); -static int pvpanic_remove(struct acpi_device *device); - -static const struct acpi_device_id pvpanic_device_ids[] = { - { "QEMU0001", 0 }, - { "", 0 } -}; -MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); - -static struct acpi_driver pvpanic_driver = { - .name = "pvpanic", - .class ="QEMU", - .ids = pvpanic_device_ids, - .ops = { - .add = pvpanic_add, - .remove = pvpanic_remove, - }, - .owner =THIS_MODULE, -}; - -static acpi_status -pvpanic_walk_resources(struct acpi_resource *res, void *context) +static int pvpanic_platform_probe(struct platform_device *pdev) { - struct resource r; - - if (acpi_dev_resource_io(res, )) { - base = ioport_map(r.start, resource_size()); - return AE_OK; - } else if (acpi_dev_resource_memory(res, )) { - base = ioremap(r.start, resource_size()); - return AE_OK; - } - - return AE_ERROR; -} - -static int pvpanic_add(struct acpi_device *device) -{ - int ret; - - ret = acpi_bus_get_status(device); - if (ret < 0) - return ret; - - if (!device->status.enabled || !device->status.functional) - return -ENODEV; - - acpi_walk_resources(device->handle, METHOD_NAME__CRS, - pvpanic_walk_resources, NULL); - - if (!base) - return -ENODEV; + struct device *dev = >dev; + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res) { + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return -ENODEV; + } else { + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -ENODEV; + + base = ioport_map(res->start, resource_size(res)); + if (!base) + return -ENODEV; + } atomic_notifier_chain_register(_notifier_list, _panic_nb); @@ -103,90 +67,22 @@ static int pvpanic_add(struct acpi_device *device) return 0; } -static int pvpanic_remove(struct acpi_device *device) +static int pvpanic_platform_remove(struct platform_device *pdev) { - atomic_notifier_chain_unregister(_notifier_list, _panic_nb); - iounmap(base); - - return 0; -} - -static int pvpanic_register_acpi_driver(void) -{ - return acpi_bus_register_driver(_driver); -} - -static void pvpanic_unregister_acpi_driver(void) -{ - acpi_bus_unregister_driver(_driver); -} -#else -static int pvpanic_register_acpi_driver(void) -{ - return -ENODEV; -} -static void pvpanic_unregister_acpi_driver(void) {} -#endif - -static int pvpanic_mmio_probe(struct platform_device *pdev) -{ - struct resource *mem; - - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem) - return -EINVAL; - - base = devm_ioremap_resource(>dev, mem); - if (IS_ERR(base)) - return PTR_ERR(base); - - atomic_notifier_chain_register(_notifier_list, - _panic_nb); - - return 0; -} - -static int pvpanic_mmio_remove(struct platform_device *pdev) -{ - - atomic_notifier_chain_unregister(_notifier_list, -_panic_nb); + iounmap(base); return 0; } -static const struct of_device_id pvpanic_mmio_match[] = { - { .compatible = "qemu,pvpanic-mmio", }, - {} -}; - -static struct platform_driver pvpanic_mmio_driver = { +static struct platform_driver pvpanic_driver = { + .probe = pvpanic_platform_probe, + .remove = pvpanic_platform_remove, .driver = { - .name = "pvpanic-mmio", - .of_match_table = pvpanic_mmio_m
[PATCH V4 6/6] misc/pvpanic: add new pvpanic pci driver
Add new pvpanic pci driver to pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 10 ++- drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-pci.c | 56 ++ 3 files changed, 66 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 14074af..f24c488 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -1,6 +1,6 @@ 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 @@ -23,5 +23,13 @@ config PVPANIC_OF This driver is one specific driver for pvpanic driver framework. It provides a mmio device as pvpanic device. +config PVPANIC_PCI + tristate "pvpanic pci driver" + depends on PCI + default PVPANIC + help + This driver is one specific driver for pvpanic driver framework. + It provides a pci device as pvpanic device. + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 63ef0db..7c71f85 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o obj-$(CONFIG_PVPANIC_OF) += pvpanic-of.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 000..1261710 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-pci.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include "pvpanic.h" + +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 + +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 = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + memset(, 0, sizeof(res)); + res.start = pci_resource_start(pdev, 0); + res.end = pci_resource_end(pdev, 0); + res.flags = IORESOURCE_MEM; + ret = pvpanic_add_device(>dev, ); + if (ret) + return ret; + + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + pvpanic_remove_device(); +} + +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
[PATCH V4 0/6] add pvpanic driver framework
QEMU community requires additional PCI devices to simulate PVPANIC devices so that some architectures can not occupy precious less than 4G of memory space. Previously, I added PCI driver directly to the original version of the driver, which made the whole driver file look a bit cluttered. So Andy Shevchenko suggests: "I would recommend to split it in a way how it's done for ChipIdea USB driver, for example. (drivers/usb/chipidea if I'm not mistaken)". v3 ---> v4 : add help text info in Konfig from patch_0004 to patch_0006 adjust structure definition position in patch_0002 and patch_0003 v2 ---> v3 : add change infomation. v1 ---> v2 : add patch to descript the whole patch series. modify text infomation from patch_0002 to patch_0006. modify "SPDX-License-Identifier: GPL-2.0-or-later" to "SPDX-License-Identifier: GPL-2.0+" Peng Hao (6): misc/pvpanic: preparing for pvpanic driver framework misc/pvpanic: Add pvpanic driver framework misc/pvpanic: add API for pvpanic driver framework misc/pvpanic: add pvpanic acpi driver misc/pvpanic: add pvpanic mmio driver misc/pvpanic: add new pvpanic pci driver drivers/misc/Kconfig| 9 +- drivers/misc/Makefile | 2 +- drivers/misc/pvpanic.c | 192 drivers/misc/pvpanic/Kconfig| 34 ++ drivers/misc/pvpanic/Makefile | 8 ++ drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++ drivers/misc/pvpanic/pvpanic-of.c | 53 ++ drivers/misc/pvpanic/pvpanic-pci.c | 56 +++ drivers/misc/pvpanic/pvpanic.c | 131 drivers/misc/pvpanic/pvpanic.h | 14 +++ 10 files changed, 366 insertions(+), 201 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-acpi.c create mode 100644 drivers/misc/pvpanic/pvpanic-of.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
[PATCH V4 3/6] misc/pvpanic: add API for pvpanic driver framework
Add pvpanic_add/remove_device API. Follow-up patches will use them to add/remove specific drivers into framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 47 ++ drivers/misc/pvpanic/pvpanic.h | 15 ++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 drivers/misc/pvpanic/pvpanic.h diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index f44a884..6225dfb 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -14,7 +14,11 @@ #include #include -static void __iomem *base; +static struct { + struct platform_device *pdev; + void __iomem *base; + bool is_ioport; +} pvpanic_data; #define PVPANIC_PANICKED(1 << 0) @@ -25,7 +29,7 @@ static void pvpanic_send_event(unsigned int event) { - iowrite8(event, base); + iowrite8(event, pvpanic_data.base); } static int @@ -41,10 +45,43 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; +int pvpanic_add_device(struct device *dev, struct resource *res) +{ + struct platform_device *pdev; + int ret; + + pdev = platform_device_alloc("pvpanic", -1); + if (!pdev) + return -ENOMEM; + + pdev->dev.parent = dev; + + ret = platform_device_add_resources(pdev, res, 1); + if (ret) + goto err; + + ret = platform_device_add(pdev); + if (ret) + goto err; + pvpanic_data.pdev = pdev; + + return 0; +err: + platform_device_put(pdev); + return -1; +} + +void pvpanic_remove_device(void) +{ + platform_device_unregister(pvpanic_data.pdev); + pvpanic_data.pdev = NULL; +} + static int pvpanic_platform_probe (struct platform_device *pdev) { struct device *dev = >dev; struct resource *res; + void __iomem *base; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res) { @@ -59,8 +96,10 @@ static int pvpanic_platform_probe (struct platform_device *pdev) base = ioport_map(res->start, resource_size(res)); if (!base) return -ENODEV; + pvpanic_data.is_ioport = true; } + pvpanic_data.base = base; atomic_notifier_chain_register(_notifier_list, _panic_nb); @@ -71,8 +110,8 @@ static int pvpanic_platform_remove(struct platform_device *pdev) { atomic_notifier_chain_unregister(_notifier_list, _panic_nb); - - iounmap(base); + if (pvpanic_data.is_ioport) + iounmap(pvpanic_data.base); return 0; } diff --git a/drivers/misc/pvpanic/pvpanic.h b/drivers/misc/pvpanic/pvpanic.h new file mode 100644 index 000..7fb6bb2 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic.h @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* pvpanic driver framework header file + * + * Copyright (C) 2019 ZTE Ltd. + * + * Author: Peng Hao + */ + +#ifndef __DRIVERS_MISC_PVPANIC_H +#define __DRIVERS_MISC_PVPANIC_H + +extern int pvpanic_add_device(struct device *dev, struct resource *res); +extern void pvpanic_remove_device(void); + +#endif -- 1.8.3.1
[PATCH V4 1/6] misc/pvpanic: preparing for pvpanic driver framework
Preparing for pvpanic driver framework. Create a pvpanic driver directory and move current driver file to new directory. Signed-off-by: Peng Hao --- drivers/misc/Kconfig | 9 + drivers/misc/Makefile| 2 +- drivers/misc/pvpanic/Kconfig | 7 +++ drivers/misc/pvpanic/Makefile| 5 + drivers/misc/{ => pvpanic}/pvpanic.c | 0 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 drivers/misc/pvpanic/Kconfig create mode 100644 drivers/misc/pvpanic/Makefile rename drivers/misc/{ => pvpanic}/pvpanic.c (100%) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index f417b06..aa3a805 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -513,14 +513,7 @@ 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. - +source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e39ccbb..cfe20b3 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -58,4 +58,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)+= aspeed-lpc-snoop.o 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/ diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig new file mode 100644 index 000..3e612c6 --- /dev/null +++ b/drivers/misc/pvpanic/Kconfig @@ -0,0 +1,7 @@ +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. diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile new file mode 100644 index 000..6394224 --- /dev/null +++ b/drivers/misc/pvpanic/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2018 ZTE Ltd. + +obj-$(CONFIG_PVPANIC) += pvpanic.o diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c similarity index 100% rename from drivers/misc/pvpanic.c rename to drivers/misc/pvpanic/pvpanic.c -- 1.8.3.1
[PATCH V4 5/6] misc/pvpanic: add pvpanic mmio driver
Make pvpanic mmio driver as separate file and modify code in order to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 7 ++ drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-of.c | 53 +++ 3 files changed, 61 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-of.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 1dcfe20..14074af 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -16,5 +16,12 @@ config PVPANIC_ACPI This driver is one specific driver for pvpanic driver framework. It provides an acpi device as pvpanic device. +config PVPANIC_OF + tristate "pvpanic mmio driver" + depends on OF + help + This driver is one specific driver for pvpanic driver framework. + It provides a mmio device as pvpanic device. + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index c5b73ca..63ef0db 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o +obj-$(CONFIG_PVPANIC_OF) += pvpanic-of.o diff --git a/drivers/misc/pvpanic/pvpanic-of.c b/drivers/misc/pvpanic/pvpanic-of.c new file mode 100644 index 000..73ca5f3 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-of.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * pvpanic of driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_mmio_probe(struct platform_device *pdev) +{ + struct resource *res; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; + + ret = pvpanic_add_device(>dev, res); + if (ret) + return -ENODEV; + + return 0; +} + +static int pvpanic_mmio_remove(struct platform_device *pdev) +{ + pvpanic_remove_device(); + return 0; +} + +static const struct of_device_id pvpanic_mmio_match[] = { + { .compatible = "qemu,pvpanic-mmio", }, + {} +}; + +static struct platform_driver pvpanic_mmio_driver = { + .driver = { + .name = "pvpanic-mmio", + .of_match_table = pvpanic_mmio_match, + }, + .probe = pvpanic_mmio_probe, + .remove = pvpanic_mmio_remove, +}; + +module_platform_driver(pvpanic_mmio_driver); -- 1.8.3.1
[PATCH V4 4/6] misc/pvpanic: add pvpanic acpi driver
Make pvpanic acpi driver as separate file and modify code in order to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig| 13 +++ drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-acpi.c | 77 + 3 files changed, 91 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 3e612c6..1dcfe20 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -5,3 +5,16 @@ config PVPANIC 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. + +if PVPANIC + +config PVPANIC_ACPI + tristate "pvpanic acpi driver" + depends on ACPI + default PVPANIC + help + This driver is one specific driver for pvpanic driver framework. + It provides an acpi device as pvpanic device. + +endif + diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 6394224..c5b73ca 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -3,3 +3,4 @@ # Copyright (c) 2018 ZTE Ltd. obj-$(CONFIG_PVPANIC) += pvpanic.o +obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o diff --git a/drivers/misc/pvpanic/pvpanic-acpi.c b/drivers/misc/pvpanic/pvpanic-acpi.c new file mode 100644 index 000..8d10924 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-acpi.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_add(struct acpi_device *device); +static int pvpanic_remove(struct acpi_device *device); + +static const struct acpi_device_id pvpanic_device_ids[] = { + { "QEMU0001", 0 }, + { "", 0 } +}; +MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); + +static struct acpi_driver pvpanic_driver = { + .name = "pvpanic", + .class ="QEMU", + .ids = pvpanic_device_ids, + .ops = { + .add = pvpanic_add, + .remove = pvpanic_remove, + }, + .owner =THIS_MODULE, +}; + +static acpi_status +pvpanic_walk_resources(struct acpi_resource *res, void *context) +{ + struct resource r; + int ret = 0; + struct device *dev = context; + + memset(, 0, sizeof(r)); + if (acpi_dev_resource_io(res, ) || acpi_dev_resource_memory(res, )) + ret = pvpanic_add_device(dev, ); + + if (!ret) + return AE_OK; + + return AE_ERROR; +} +static int pvpanic_add(struct acpi_device *device) +{ + int ret; + acpi_status status; + + ret = acpi_bus_get_status(device); + if (ret < 0) + return ret; + + if (!device->status.enabled || !device->status.functional) + return -ENODEV; + + status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, +pvpanic_walk_resources, >dev); + + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} + +static int pvpanic_remove(struct acpi_device *device) +{ + pvpanic_remove_device(); + return 0; +} + +module_acpi_driver(pvpanic_driver); -- 1.8.3.1
[PATCH V3 2/6] misc/pvpanic: Add pvpanic driver framework
Add pvpanic driver framework. Follow-up patches will split the original pvpanic acpi/of driver as the two seperate files and modify code to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 171 ++--- 1 file changed, 39 insertions(+), 132 deletions(-) diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index 595ac06..6380540 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -8,15 +8,20 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include +#include #include #include -#include -#include #include #include -static void __iomem *base; +static struct { + struct platform_device *pdev; + void __iomem *base; + bool is_ioport; +} pvpanic_data = { + .pdev = NULL, + .is_ioport = false, +}; #define PVPANIC_PANICKED(1 << 0) @@ -27,7 +32,7 @@ static void pvpanic_send_event(unsigned int event) { - iowrite8(event, base); + iowrite8(event, pvpanic_data.base); } static int @@ -43,150 +48,52 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; -#ifdef CONFIG_ACPI -static int pvpanic_add(struct acpi_device *device); -static int pvpanic_remove(struct acpi_device *device); - -static const struct acpi_device_id pvpanic_device_ids[] = { - { "QEMU0001", 0 }, - { "", 0 } -}; -MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); - -static struct acpi_driver pvpanic_driver = { - .name = "pvpanic", - .class ="QEMU", - .ids = pvpanic_device_ids, - .ops = { - .add = pvpanic_add, - .remove = pvpanic_remove, - }, - .owner =THIS_MODULE, -}; - -static acpi_status -pvpanic_walk_resources(struct acpi_resource *res, void *context) +static int pvpanic_platform_probe(struct platform_device *pdev) { - struct resource r; - - if (acpi_dev_resource_io(res, )) { - base = ioport_map(r.start, resource_size()); - return AE_OK; - } else if (acpi_dev_resource_memory(res, )) { - base = ioremap(r.start, resource_size()); - return AE_OK; + struct device *dev = >dev; + struct resource *res; + void __iomem *base; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res) { + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return -ENODEV; + } else { + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -ENODEV; + + base = ioport_map(res->start, resource_size(res)); + if (!base) + return -ENODEV; + pvpanic_data.is_ioport = true; } - return AE_ERROR; -} - -static int pvpanic_add(struct acpi_device *device) -{ - int ret; - - ret = acpi_bus_get_status(device); - if (ret < 0) - return ret; - - if (!device->status.enabled || !device->status.functional) - return -ENODEV; - - acpi_walk_resources(device->handle, METHOD_NAME__CRS, - pvpanic_walk_resources, NULL); - - if (!base) - return -ENODEV; - + pvpanic_data.base = base; atomic_notifier_chain_register(_notifier_list, _panic_nb); return 0; } -static int pvpanic_remove(struct acpi_device *device) +static int pvpanic_platform_remove(struct platform_device *pdev) { - atomic_notifier_chain_unregister(_notifier_list, _panic_nb); - iounmap(base); - - return 0; -} - -static int pvpanic_register_acpi_driver(void) -{ - return acpi_bus_register_driver(_driver); -} - -static void pvpanic_unregister_acpi_driver(void) -{ - acpi_bus_unregister_driver(_driver); -} -#else -static int pvpanic_register_acpi_driver(void) -{ - return -ENODEV; -} -static void pvpanic_unregister_acpi_driver(void) {} -#endif - -static int pvpanic_mmio_probe(struct platform_device *pdev) -{ - struct resource *mem; - - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem) - return -EINVAL; - - base = devm_ioremap_resource(>dev, mem); - if (IS_ERR(base)) - return PTR_ERR(base); - - atomic_notifier_chain_register(_notifier_list, - _panic_nb); - - return 0; -} - -static int pvpanic_mmio_remove(struct platform_device *pdev) -{ - - atomic_notifier_chain_unregister(_notifier_list, -_panic_nb); + if (pvpanic_data.is_ioport) +
[PATCH V3 1/6] misc/pvpanic: preparing for pvpanic driver framework
Preparing for pvpanic driver framework. Create a pvpanic driver directory and move current driver file to new directory. Signed-off-by: Peng Hao --- drivers/misc/Kconfig | 9 + drivers/misc/Makefile| 2 +- drivers/misc/pvpanic/Kconfig | 7 +++ drivers/misc/pvpanic/Makefile| 5 + drivers/misc/{ => pvpanic}/pvpanic.c | 0 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 drivers/misc/pvpanic/Kconfig create mode 100644 drivers/misc/pvpanic/Makefile rename drivers/misc/{ => pvpanic}/pvpanic.c (100%) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index f417b06..aa3a805 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -513,14 +513,7 @@ 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. - +source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e39ccbb..cfe20b3 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -58,4 +58,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)+= aspeed-lpc-snoop.o 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/ diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig new file mode 100644 index 000..3e612c6 --- /dev/null +++ b/drivers/misc/pvpanic/Kconfig @@ -0,0 +1,7 @@ +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. diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile new file mode 100644 index 000..6394224 --- /dev/null +++ b/drivers/misc/pvpanic/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2018 ZTE Ltd. + +obj-$(CONFIG_PVPANIC)+= pvpanic.o diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c similarity index 100% rename from drivers/misc/pvpanic.c rename to drivers/misc/pvpanic/pvpanic.c -- 1.8.3.1
[PATCH V3 3/6] misc/pvpanic: add API for pvpanic driver framework
Add pvpanic_add/remove_device API. Follow-up patches will use them to add/remove specific drivers into framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 32 drivers/misc/pvpanic/pvpanic.h | 14 ++ 2 files changed, 46 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic.h diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index 227ab4e..f842ee4 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -48,6 +48,38 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; +int pvpanic_add_device(struct device *dev, struct resource *res) +{ + struct platform_device *pdev; + int ret; + + pdev = platform_device_alloc("pvpanic", -1); + if (!pdev) + return -ENOMEM; + + pdev->dev.parent = dev; + + ret = platform_device_add_resources(pdev, res, 1); + if (ret) + goto err; + + ret = platform_device_add(pdev); + if (ret) + goto err; + pvpanic_data.pdev = pdev; + + return 0; +err: + platform_device_put(pdev); + return -1; +} + +void pvpanic_remove_device(void) +{ + platform_device_unregister(pvpanic_data.pdev); + pvpanic_data.pdev = NULL; +} + static int pvpanic_platform_probe(struct platform_device *pdev) { struct device *dev = >dev; diff --git a/drivers/misc/pvpanic/pvpanic.h b/drivers/misc/pvpanic/pvpanic.h new file mode 100644 index 000..a72ca59 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* pvpanic driver framework header file + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#ifndef __DRIVERS_MISC_PVPANIC_H +#define __DRIVERS_MISC_PVPANIC_H + +extern int pvpanic_add_device(struct device *dev, struct resource *res); +extern void pvpanic_remove_device(void); + +#endif -- 1.8.3.1
[PATCH V3 5/6] misc/pvpanic: add pvpanic mmio driver
Make pvpanic mmio driver as seperate file and modify code in order to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 4 +++ drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-of.c | 53 +++ 3 files changed, 58 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-of.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index d274130..47f8709 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -13,4 +13,8 @@ config PVPANIC_ACPI depends on ACPI default PVPANIC +config PVPANIC_OF + tristate "pvpanic mmio driver" + depends on OF + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index c5b73ca..63ef0db 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_PVPANIC)+= pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o +obj-$(CONFIG_PVPANIC_OF)+= pvpanic-of.o diff --git a/drivers/misc/pvpanic/pvpanic-of.c b/drivers/misc/pvpanic/pvpanic-of.c new file mode 100644 index 000..73ca5f3 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-of.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic of driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_mmio_probe(struct platform_device *pdev) +{ + struct resource *res; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; + + ret = pvpanic_add_device(>dev, res); + if (ret) + return -ENODEV; + + return 0; +} + +static int pvpanic_mmio_remove(struct platform_device *pdev) +{ + pvpanic_remove_device(); + return 0; +} + +static const struct of_device_id pvpanic_mmio_match[] = { + { .compatible = "qemu,pvpanic-mmio", }, + {} +}; + +static struct platform_driver pvpanic_mmio_driver = { + .driver = { + .name = "pvpanic-mmio", + .of_match_table = pvpanic_mmio_match, + }, + .probe = pvpanic_mmio_probe, + .remove = pvpanic_mmio_remove, +}; + +module_platform_driver(pvpanic_mmio_driver); -- 1.8.3.1
[PATCH V3 4/6] misc/pvpanic: add pvpanic acpi driver
Make pvpanic acpi driver as seperate file and modify code in order to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig| 9 + drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-acpi.c | 77 + 3 files changed, 87 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 3e612c6..d274130 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -5,3 +5,12 @@ config PVPANIC 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. + +if PVPANIC + +config PVPANIC_ACPI + tristate "pvpanic acpi driver" + depends on ACPI + default PVPANIC + +endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 6394224..c5b73ca 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -3,3 +3,4 @@ # Copyright (c) 2018 ZTE Ltd. obj-$(CONFIG_PVPANIC)+= pvpanic.o +obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o diff --git a/drivers/misc/pvpanic/pvpanic-acpi.c b/drivers/misc/pvpanic/pvpanic-acpi.c new file mode 100644 index 000..a6153fa --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-acpi.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_add(struct acpi_device *device); +static int pvpanic_remove(struct acpi_device *device); + +static const struct acpi_device_id pvpanic_device_ids[] = { + { "QEMU0001", 0 }, + { "", 0 } +}; +MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); + +static struct acpi_driver pvpanic_driver = { + .name = "pvpanic", + .class ="QEMU", + .ids = pvpanic_device_ids, + .ops = { + .add = pvpanic_add, + .remove = pvpanic_remove, + }, + .owner =THIS_MODULE, +}; + +static acpi_status +pvpanic_walk_resources(struct acpi_resource *res, void *context) +{ + struct resource r; + int ret = 0; + struct device *dev = context; + + memset(, 0, sizeof(r)); + if (acpi_dev_resource_io(res, ) || acpi_dev_resource_memory(res, )) + ret = pvpanic_add_device(dev, ); + + if (!ret) + return AE_OK; + + return AE_ERROR; +} +static int pvpanic_add(struct acpi_device *device) +{ + int ret; + acpi_status status; + + ret = acpi_bus_get_status(device); + if (ret < 0) + return ret; + + if (!device->status.enabled || !device->status.functional) + return -ENODEV; + + status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, +pvpanic_walk_resources, >dev); + + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} + +static int pvpanic_remove(struct acpi_device *device) +{ + pvpanic_remove_device(); + return 0; +} + +module_acpi_driver(pvpanic_driver); -- 1.8.3.1
[PATCH V3 6/6] misc/pvpanic: add new pvpanic pci driver
Add new pvpanic pci driver to pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 5 drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-pci.c | 56 ++ 3 files changed, 62 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 47f8709..46b6e05 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -17,4 +17,9 @@ config PVPANIC_OF tristate "pvpanic mmio driver" depends on OF +config PVPANIC_PCI + tristate "pvpanic pci driver" + depends on PCI + default PVPANIC + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 63ef0db..7c71f85 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_PVPANIC)+= pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o obj-$(CONFIG_PVPANIC_OF)+= pvpanic-of.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 000..b4f453b --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-pci.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include "pvpanic.h" + +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 + +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 = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + memset(, 0, sizeof(res)); + res.start = pci_resource_start(pdev, 0); + res.end = pci_resource_end(pdev, 0); + res.flags = IORESOURCE_MEM; + ret = pvpanic_add_device(>dev, ); + if (ret) + return ret; + + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + pvpanic_remove_device(); +} + +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
[PATCH V3 0/6] add pvpanic driver framework
QEMU community requires additional PCI devices to simulate PVPANIC devices so that some architectures can not occupy precious less than 4G of memory space. Previously, I added PCI driver directly to the original version of the driver, which made the whole driver file look a bit cluttered. So Andy Shevchenko suggests: "I would recommend to split it in a way how it's done for ChipIdea USB driver, for example. (drivers/usb/chipidea if I'm not mistaken)". v2 ---> v3 : add change infomation. v1 ---> v2 : add patch to descript the whole patch series. modify text infomation from patch_0002 to patch_0006. modify "SPDX-License-Identifier: GPL-2.0-or-later" to "SPDX-License-Identifier: GPL-2.0+" Peng Hao (6): misc/pvpanic: preparing for pvpanic driver framework misc/pvpanic: Add pvpanic driver framework misc/pvpanic: add API for pvpanic driver framework misc/pvpanic: add pvpanic acpi driver misc/pvpanic: add pvpanic mmio driver misc/pvpanic: add pvpanic pci driver drivers/misc/Kconfig| 9 +- drivers/misc/Makefile | 2 +- drivers/misc/pvpanic.c | 192 drivers/misc/pvpanic/Kconfig| 25 + drivers/misc/pvpanic/Makefile | 8 ++ drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++ drivers/misc/pvpanic/pvpanic-of.c | 53 ++ drivers/misc/pvpanic/pvpanic-pci.c | 56 +++ drivers/misc/pvpanic/pvpanic.c | 131 drivers/misc/pvpanic/pvpanic.h | 14 +++ 10 files changed, 366 insertions(+), 201 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-acpi.c create mode 100644 drivers/misc/pvpanic/pvpanic-of.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
[PATCH V2 4/6] misc/pvpanic: add pvpanic acpi driver
Make pvpanic acpi driver as seperate file and modify code in order to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig| 9 + drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-acpi.c | 77 + 3 files changed, 87 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 3e612c6..d274130 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -5,3 +5,12 @@ config PVPANIC 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. + +if PVPANIC + +config PVPANIC_ACPI + tristate "pvpanic acpi driver" + depends on ACPI + default PVPANIC + +endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 6394224..c5b73ca 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -3,3 +3,4 @@ # Copyright (c) 2018 ZTE Ltd. obj-$(CONFIG_PVPANIC)+= pvpanic.o +obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o diff --git a/drivers/misc/pvpanic/pvpanic-acpi.c b/drivers/misc/pvpanic/pvpanic-acpi.c new file mode 100644 index 000..a6153fa --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-acpi.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_add(struct acpi_device *device); +static int pvpanic_remove(struct acpi_device *device); + +static const struct acpi_device_id pvpanic_device_ids[] = { + { "QEMU0001", 0 }, + { "", 0 } +}; +MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); + +static struct acpi_driver pvpanic_driver = { + .name = "pvpanic", + .class ="QEMU", + .ids = pvpanic_device_ids, + .ops = { + .add = pvpanic_add, + .remove = pvpanic_remove, + }, + .owner =THIS_MODULE, +}; + +static acpi_status +pvpanic_walk_resources(struct acpi_resource *res, void *context) +{ + struct resource r; + int ret = 0; + struct device *dev = context; + + memset(, 0, sizeof(r)); + if (acpi_dev_resource_io(res, ) || acpi_dev_resource_memory(res, )) + ret = pvpanic_add_device(dev, ); + + if (!ret) + return AE_OK; + + return AE_ERROR; +} +static int pvpanic_add(struct acpi_device *device) +{ + int ret; + acpi_status status; + + ret = acpi_bus_get_status(device); + if (ret < 0) + return ret; + + if (!device->status.enabled || !device->status.functional) + return -ENODEV; + + status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, +pvpanic_walk_resources, >dev); + + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} + +static int pvpanic_remove(struct acpi_device *device) +{ + pvpanic_remove_device(); + return 0; +} + +module_acpi_driver(pvpanic_driver); -- 1.8.3.1
[PATCH V2 1/6] misc/pvpanic: preparing for pvpanic driver framework
Preparing for pvpanic driver framework. Create a pvpanic driver directory and move current driver file to new directory. Signed-off-by: Peng Hao --- drivers/misc/Kconfig | 9 + drivers/misc/Makefile| 2 +- drivers/misc/pvpanic/Kconfig | 7 +++ drivers/misc/pvpanic/Makefile| 5 + drivers/misc/{ => pvpanic}/pvpanic.c | 0 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 drivers/misc/pvpanic/Kconfig create mode 100644 drivers/misc/pvpanic/Makefile rename drivers/misc/{ => pvpanic}/pvpanic.c (100%) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index f417b06..aa3a805 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -513,14 +513,7 @@ 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. - +source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e39ccbb..cfe20b3 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -58,4 +58,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)+= aspeed-lpc-snoop.o 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/ diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig new file mode 100644 index 000..3e612c6 --- /dev/null +++ b/drivers/misc/pvpanic/Kconfig @@ -0,0 +1,7 @@ +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. diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile new file mode 100644 index 000..6394224 --- /dev/null +++ b/drivers/misc/pvpanic/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2018 ZTE Ltd. + +obj-$(CONFIG_PVPANIC)+= pvpanic.o diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c similarity index 100% rename from drivers/misc/pvpanic.c rename to drivers/misc/pvpanic/pvpanic.c -- 1.8.3.1
[PATCH V2 5/6] misc/pvpanic: add pvpanic mmio driver
Make pvpanic mmioi driver as seperate file and modify code in order to adapt the framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 4 +++ drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-of.c | 53 +++ 3 files changed, 58 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-of.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index d274130..47f8709 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -13,4 +13,8 @@ config PVPANIC_ACPI depends on ACPI default PVPANIC +config PVPANIC_OF + tristate "pvpanic mmio driver" + depends on OF + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index c5b73ca..63ef0db 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_PVPANIC)+= pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o +obj-$(CONFIG_PVPANIC_OF)+= pvpanic-of.o diff --git a/drivers/misc/pvpanic/pvpanic-of.c b/drivers/misc/pvpanic/pvpanic-of.c new file mode 100644 index 000..73ca5f3 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-of.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic of driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_mmio_probe(struct platform_device *pdev) +{ + struct resource *res; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; + + ret = pvpanic_add_device(>dev, res); + if (ret) + return -ENODEV; + + return 0; +} + +static int pvpanic_mmio_remove(struct platform_device *pdev) +{ + pvpanic_remove_device(); + return 0; +} + +static const struct of_device_id pvpanic_mmio_match[] = { + { .compatible = "qemu,pvpanic-mmio", }, + {} +}; + +static struct platform_driver pvpanic_mmio_driver = { + .driver = { + .name = "pvpanic-mmio", + .of_match_table = pvpanic_mmio_match, + }, + .probe = pvpanic_mmio_probe, + .remove = pvpanic_mmio_remove, +}; + +module_platform_driver(pvpanic_mmio_driver); -- 1.8.3.1
[PATCH V2 0/6] add pvpanic driver framework
QEMU community requires additional PCI devices to simulate PVPANIC devices so that some architectures can not occupy precious less than 4G of memory space. Previously, I added PCI driver directly to the original version of the driver, which made the whole driver file look a bit cluttered. So Andy Shevchenko suggests: "I would recommend to split it in a way how it's done for ChipIdea USB driver, for example. (drivers/usb/chipidea if I'm not mistaken)". Peng Hao (6): misc/pvpanic: preparing for pvpanic driver framework misc/pvpanic: Add pvpanic driver framework misc/pvpanic: add API for pvpanic driver framework misc/pvpanic: add pvpanic acpi driver misc/pvpanic: add pvpanic mmio driver misc/pvpanic: add pvpanic pci driver drivers/misc/Kconfig| 9 +- drivers/misc/Makefile | 2 +- drivers/misc/pvpanic.c | 192 drivers/misc/pvpanic/Kconfig| 25 + drivers/misc/pvpanic/Makefile | 8 ++ drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++ drivers/misc/pvpanic/pvpanic-of.c | 53 ++ drivers/misc/pvpanic/pvpanic-pci.c | 56 +++ drivers/misc/pvpanic/pvpanic.c | 131 drivers/misc/pvpanic/pvpanic.h | 14 +++ 10 files changed, 366 insertions(+), 201 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-acpi.c create mode 100644 drivers/misc/pvpanic/pvpanic-of.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
[PATCH V2 6/6] misc/pvpanic: add new pvpanic pci driver
Add new pvpanic pci driver to pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 5 drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-pci.c | 56 ++ 3 files changed, 62 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 47f8709..46b6e05 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -17,4 +17,9 @@ config PVPANIC_OF tristate "pvpanic mmio driver" depends on OF +config PVPANIC_PCI + tristate "pvpanic pci driver" + depends on PCI + default PVPANIC + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 63ef0db..7c71f85 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_PVPANIC)+= pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o obj-$(CONFIG_PVPANIC_OF)+= pvpanic-of.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 000..b4f453b --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-pci.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include "pvpanic.h" + +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 + +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 = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + memset(, 0, sizeof(res)); + res.start = pci_resource_start(pdev, 0); + res.end = pci_resource_end(pdev, 0); + res.flags = IORESOURCE_MEM; + ret = pvpanic_add_device(>dev, ); + if (ret) + return ret; + + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + pvpanic_remove_device(); +} + +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
[PATCH V2 2/6] misc/pvpanic: Add pvpanic driver framework
Add pvpanic driver framework. Split the original pvpanic acpi/of driver as the two seperate files and modify code for adaptation framework in follow-up patches. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 171 ++--- 1 file changed, 39 insertions(+), 132 deletions(-) diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index 595ac06..6380540 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -8,15 +8,20 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include +#include #include #include -#include -#include #include #include -static void __iomem *base; +static struct { + struct platform_device *pdev; + void __iomem *base; + bool is_ioport; +} pvpanic_data = { + .pdev = NULL, + .is_ioport = false, +}; #define PVPANIC_PANICKED(1 << 0) @@ -27,7 +32,7 @@ static void pvpanic_send_event(unsigned int event) { - iowrite8(event, base); + iowrite8(event, pvpanic_data.base); } static int @@ -43,150 +48,52 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; -#ifdef CONFIG_ACPI -static int pvpanic_add(struct acpi_device *device); -static int pvpanic_remove(struct acpi_device *device); - -static const struct acpi_device_id pvpanic_device_ids[] = { - { "QEMU0001", 0 }, - { "", 0 } -}; -MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); - -static struct acpi_driver pvpanic_driver = { - .name = "pvpanic", - .class ="QEMU", - .ids = pvpanic_device_ids, - .ops = { - .add = pvpanic_add, - .remove = pvpanic_remove, - }, - .owner =THIS_MODULE, -}; - -static acpi_status -pvpanic_walk_resources(struct acpi_resource *res, void *context) +static int pvpanic_platform_probe(struct platform_device *pdev) { - struct resource r; - - if (acpi_dev_resource_io(res, )) { - base = ioport_map(r.start, resource_size()); - return AE_OK; - } else if (acpi_dev_resource_memory(res, )) { - base = ioremap(r.start, resource_size()); - return AE_OK; + struct device *dev = >dev; + struct resource *res; + void __iomem *base; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res) { + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return -ENODEV; + } else { + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -ENODEV; + + base = ioport_map(res->start, resource_size(res)); + if (!base) + return -ENODEV; + pvpanic_data.is_ioport = true; } - return AE_ERROR; -} - -static int pvpanic_add(struct acpi_device *device) -{ - int ret; - - ret = acpi_bus_get_status(device); - if (ret < 0) - return ret; - - if (!device->status.enabled || !device->status.functional) - return -ENODEV; - - acpi_walk_resources(device->handle, METHOD_NAME__CRS, - pvpanic_walk_resources, NULL); - - if (!base) - return -ENODEV; - + pvpanic_data.base = base; atomic_notifier_chain_register(_notifier_list, _panic_nb); return 0; } -static int pvpanic_remove(struct acpi_device *device) +static int pvpanic_platform_remove(struct platform_device *pdev) { - atomic_notifier_chain_unregister(_notifier_list, _panic_nb); - iounmap(base); - - return 0; -} - -static int pvpanic_register_acpi_driver(void) -{ - return acpi_bus_register_driver(_driver); -} - -static void pvpanic_unregister_acpi_driver(void) -{ - acpi_bus_unregister_driver(_driver); -} -#else -static int pvpanic_register_acpi_driver(void) -{ - return -ENODEV; -} -static void pvpanic_unregister_acpi_driver(void) {} -#endif - -static int pvpanic_mmio_probe(struct platform_device *pdev) -{ - struct resource *mem; - - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem) - return -EINVAL; - - base = devm_ioremap_resource(>dev, mem); - if (IS_ERR(base)) - return PTR_ERR(base); - - atomic_notifier_chain_register(_notifier_list, - _panic_nb); - - return 0; -} - -static int pvpanic_mmio_remove(struct platform_device *pdev) -{ - - atomic_notifier_chain_unregister(_notifier_list, -_panic_nb); + if (pvpanic_data.is_ioport) +
[PATCH V2 3/6] misc/pvpanic: add API for pvpanic driver framework
Add pvpanic_add/remove_device API. Follow-up patches will use them to add/remove specific drivers into framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 32 drivers/misc/pvpanic/pvpanic.h | 14 ++ 2 files changed, 46 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic.h diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index 227ab4e..f842ee4 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -48,6 +48,38 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; +int pvpanic_add_device(struct device *dev, struct resource *res) +{ + struct platform_device *pdev; + int ret; + + pdev = platform_device_alloc("pvpanic", -1); + if (!pdev) + return -ENOMEM; + + pdev->dev.parent = dev; + + ret = platform_device_add_resources(pdev, res, 1); + if (ret) + goto err; + + ret = platform_device_add(pdev); + if (ret) + goto err; + pvpanic_data.pdev = pdev; + + return 0; +err: + platform_device_put(pdev); + return -1; +} + +void pvpanic_remove_device(void) +{ + platform_device_unregister(pvpanic_data.pdev); + pvpanic_data.pdev = NULL; +} + static int pvpanic_platform_probe(struct platform_device *pdev) { struct device *dev = >dev; diff --git a/drivers/misc/pvpanic/pvpanic.h b/drivers/misc/pvpanic/pvpanic.h new file mode 100644 index 000..a72ca59 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* pvpanic driver framework header file + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#ifndef __DRIVERS_MISC_PVPANIC_H +#define __DRIVERS_MISC_PVPANIC_H + +extern int pvpanic_add_device(struct device *dev, struct resource *res); +extern void pvpanic_remove_device(void); + +#endif -- 1.8.3.1
[PATCH 6/6] misc/pvpanic : add pvpanic pci driver
Add pvpanic pci driver to pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 5 drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-pci.c | 56 ++ 3 files changed, 62 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 47f8709..46b6e05 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -17,4 +17,9 @@ config PVPANIC_OF tristate "pvpanic mmio driver" depends on OF +config PVPANIC_PCI + tristate "pvpanic pci driver" + depends on PCI + default PVPANIC + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 63ef0db..7c71f85 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_PVPANIC)+= pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o obj-$(CONFIG_PVPANIC_OF)+= pvpanic-of.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 000..b4f453b --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-pci.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include "pvpanic.h" + +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 + +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 = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + memset(, 0, sizeof(res)); + res.start = pci_resource_start(pdev, 0); + res.end = pci_resource_end(pdev, 0); + res.flags = IORESOURCE_MEM; + ret = pvpanic_add_device(>dev, ); + if (ret) + return ret; + + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + pvpanic_remove_device(); +} + +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
[PATCH 3/6] misc/pvpanic: add API for pvpanic driver framework
Add pvpanic_add/remove_device API. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 32 drivers/misc/pvpanic/pvpanic.h | 14 ++ 2 files changed, 46 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic.h diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index 227ab4e..f842ee4 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -48,6 +48,38 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; +int pvpanic_add_device(struct device *dev, struct resource *res) +{ + struct platform_device *pdev; + int ret; + + pdev = platform_device_alloc("pvpanic", -1); + if (!pdev) + return -ENOMEM; + + pdev->dev.parent = dev; + + ret = platform_device_add_resources(pdev, res, 1); + if (ret) + goto err; + + ret = platform_device_add(pdev); + if (ret) + goto err; + pvpanic_data.pdev = pdev; + + return 0; +err: + platform_device_put(pdev); + return -1; +} + +void pvpanic_remove_device(void) +{ + platform_device_unregister(pvpanic_data.pdev); + pvpanic_data.pdev = NULL; +} + static int pvpanic_platform_probe(struct platform_device *pdev) { struct device *dev = >dev; diff --git a/drivers/misc/pvpanic/pvpanic.h b/drivers/misc/pvpanic/pvpanic.h new file mode 100644 index 000..a72ca59 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* pvpanic driver framework header file + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#ifndef __DRIVERS_MISC_PVPANIC_H +#define __DRIVERS_MISC_PVPANIC_H + +extern int pvpanic_add_device(struct device *dev, struct resource *res); +extern void pvpanic_remove_device(void); + +#endif -- 1.8.3.1
[PATCH 1/6] misc/pvpanic : preparing for pvpanic driver framework
Preparing for pvpanic driver framework. Create a pvpanic driver directory and move current driver file to new directory. Signed-off-by: Peng Hao --- drivers/misc/Kconfig | 9 + drivers/misc/Makefile| 2 +- drivers/misc/pvpanic/Kconfig | 7 +++ drivers/misc/pvpanic/Makefile| 5 + drivers/misc/{ => pvpanic}/pvpanic.c | 0 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 drivers/misc/pvpanic/Kconfig create mode 100644 drivers/misc/pvpanic/Makefile rename drivers/misc/{ => pvpanic}/pvpanic.c (100%) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index f417b06..aa3a805 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -513,14 +513,7 @@ 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. - +source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e39ccbb..cfe20b3 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -58,4 +58,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)+= aspeed-lpc-snoop.o 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/ diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig new file mode 100644 index 000..3e612c6 --- /dev/null +++ b/drivers/misc/pvpanic/Kconfig @@ -0,0 +1,7 @@ +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. diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile new file mode 100644 index 000..6394224 --- /dev/null +++ b/drivers/misc/pvpanic/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2018 ZTE Ltd. + +obj-$(CONFIG_PVPANIC)+= pvpanic.o diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c similarity index 100% rename from drivers/misc/pvpanic.c rename to drivers/misc/pvpanic/pvpanic.c -- 1.8.3.1
[PATCH 4/6] misc/pvpanic : add pvpanic acpi driver
Add pvpanic acpi driver in pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig| 9 + drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-acpi.c | 77 + 3 files changed, 87 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index 3e612c6..d274130 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -5,3 +5,12 @@ config PVPANIC 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. + +if PVPANIC + +config PVPANIC_ACPI + tristate "pvpanic acpi driver" + depends on ACPI + default PVPANIC + +endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index 6394224..c5b73ca 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -3,3 +3,4 @@ # Copyright (c) 2018 ZTE Ltd. obj-$(CONFIG_PVPANIC)+= pvpanic.o +obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o diff --git a/drivers/misc/pvpanic/pvpanic-acpi.c b/drivers/misc/pvpanic/pvpanic-acpi.c new file mode 100644 index 000..a6153fa --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-acpi.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * pvpanic acpi driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_add(struct acpi_device *device); +static int pvpanic_remove(struct acpi_device *device); + +static const struct acpi_device_id pvpanic_device_ids[] = { + { "QEMU0001", 0 }, + { "", 0 } +}; +MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); + +static struct acpi_driver pvpanic_driver = { + .name = "pvpanic", + .class ="QEMU", + .ids = pvpanic_device_ids, + .ops = { + .add = pvpanic_add, + .remove = pvpanic_remove, + }, + .owner =THIS_MODULE, +}; + +static acpi_status +pvpanic_walk_resources(struct acpi_resource *res, void *context) +{ + struct resource r; + int ret = 0; + struct device *dev = context; + + memset(, 0, sizeof(r)); + if (acpi_dev_resource_io(res, ) || acpi_dev_resource_memory(res, )) + ret = pvpanic_add_device(dev, ); + + if (!ret) + return AE_OK; + + return AE_ERROR; +} +static int pvpanic_add(struct acpi_device *device) +{ + int ret; + acpi_status status; + + ret = acpi_bus_get_status(device); + if (ret < 0) + return ret; + + if (!device->status.enabled || !device->status.functional) + return -ENODEV; + + status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, +pvpanic_walk_resources, >dev); + + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} + +static int pvpanic_remove(struct acpi_device *device) +{ + pvpanic_remove_device(); + return 0; +} + +module_acpi_driver(pvpanic_driver); -- 1.8.3.1
[PATCH 5/6] misc/pvpanic: add pvpanic mmio driver
Add pvpanic mmio driver to pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/Kconfig | 4 +++ drivers/misc/pvpanic/Makefile | 1 + drivers/misc/pvpanic/pvpanic-of.c | 53 +++ 3 files changed, 58 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic-of.c diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig index d274130..47f8709 100644 --- a/drivers/misc/pvpanic/Kconfig +++ b/drivers/misc/pvpanic/Kconfig @@ -13,4 +13,8 @@ config PVPANIC_ACPI depends on ACPI default PVPANIC +config PVPANIC_OF + tristate "pvpanic mmio driver" + depends on OF + endif diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile index c5b73ca..63ef0db 100644 --- a/drivers/misc/pvpanic/Makefile +++ b/drivers/misc/pvpanic/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_PVPANIC)+= pvpanic.o obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o +obj-$(CONFIG_PVPANIC_OF)+= pvpanic-of.o diff --git a/drivers/misc/pvpanic/pvpanic-of.c b/drivers/misc/pvpanic/pvpanic-of.c new file mode 100644 index 000..73ca5f3 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic-of.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * pvpanic of driver. + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#include +#include +#include +#include +#include +#include +#include "pvpanic.h" + +static int pvpanic_mmio_probe(struct platform_device *pdev) +{ + struct resource *res; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; + + ret = pvpanic_add_device(>dev, res); + if (ret) + return -ENODEV; + + return 0; +} + +static int pvpanic_mmio_remove(struct platform_device *pdev) +{ + pvpanic_remove_device(); + return 0; +} + +static const struct of_device_id pvpanic_mmio_match[] = { + { .compatible = "qemu,pvpanic-mmio", }, + {} +}; + +static struct platform_driver pvpanic_mmio_driver = { + .driver = { + .name = "pvpanic-mmio", + .of_match_table = pvpanic_mmio_match, + }, + .probe = pvpanic_mmio_probe, + .remove = pvpanic_mmio_remove, +}; + +module_platform_driver(pvpanic_mmio_driver); -- 1.8.3.1
[PATCH 2/6] misc/pvpanic: Add pvpanic driver framework
Add pvpanic driver framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 171 ++--- 1 file changed, 39 insertions(+), 132 deletions(-) diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index 595ac06..6380540 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -8,15 +8,20 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include +#include #include #include -#include -#include #include #include -static void __iomem *base; +static struct { + struct platform_device *pdev; + void __iomem *base; + bool is_ioport; +} pvpanic_data = { + .pdev = NULL, + .is_ioport = false, +}; #define PVPANIC_PANICKED(1 << 0) @@ -27,7 +32,7 @@ static void pvpanic_send_event(unsigned int event) { - iowrite8(event, base); + iowrite8(event, pvpanic_data.base); } static int @@ -43,150 +48,52 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; -#ifdef CONFIG_ACPI -static int pvpanic_add(struct acpi_device *device); -static int pvpanic_remove(struct acpi_device *device); - -static const struct acpi_device_id pvpanic_device_ids[] = { - { "QEMU0001", 0 }, - { "", 0 } -}; -MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); - -static struct acpi_driver pvpanic_driver = { - .name = "pvpanic", - .class ="QEMU", - .ids = pvpanic_device_ids, - .ops = { - .add = pvpanic_add, - .remove = pvpanic_remove, - }, - .owner =THIS_MODULE, -}; - -static acpi_status -pvpanic_walk_resources(struct acpi_resource *res, void *context) +static int pvpanic_platform_probe(struct platform_device *pdev) { - struct resource r; - - if (acpi_dev_resource_io(res, )) { - base = ioport_map(r.start, resource_size()); - return AE_OK; - } else if (acpi_dev_resource_memory(res, )) { - base = ioremap(r.start, resource_size()); - return AE_OK; + struct device *dev = >dev; + struct resource *res; + void __iomem *base; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res) { + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return -ENODEV; + } else { + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -ENODEV; + + base = ioport_map(res->start, resource_size(res)); + if (!base) + return -ENODEV; + pvpanic_data.is_ioport = true; } - return AE_ERROR; -} - -static int pvpanic_add(struct acpi_device *device) -{ - int ret; - - ret = acpi_bus_get_status(device); - if (ret < 0) - return ret; - - if (!device->status.enabled || !device->status.functional) - return -ENODEV; - - acpi_walk_resources(device->handle, METHOD_NAME__CRS, - pvpanic_walk_resources, NULL); - - if (!base) - return -ENODEV; - + pvpanic_data.base = base; atomic_notifier_chain_register(_notifier_list, _panic_nb); return 0; } -static int pvpanic_remove(struct acpi_device *device) +static int pvpanic_platform_remove(struct platform_device *pdev) { - atomic_notifier_chain_unregister(_notifier_list, _panic_nb); - iounmap(base); - - return 0; -} - -static int pvpanic_register_acpi_driver(void) -{ - return acpi_bus_register_driver(_driver); -} - -static void pvpanic_unregister_acpi_driver(void) -{ - acpi_bus_unregister_driver(_driver); -} -#else -static int pvpanic_register_acpi_driver(void) -{ - return -ENODEV; -} -static void pvpanic_unregister_acpi_driver(void) {} -#endif - -static int pvpanic_mmio_probe(struct platform_device *pdev) -{ - struct resource *mem; - - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem) - return -EINVAL; - - base = devm_ioremap_resource(>dev, mem); - if (IS_ERR(base)) - return PTR_ERR(base); - - atomic_notifier_chain_register(_notifier_list, - _panic_nb); - - return 0; -} - -static int pvpanic_mmio_remove(struct platform_device *pdev) -{ - - atomic_notifier_chain_unregister(_notifier_list, -_panic_nb); + if (pvpanic_data.is_ioport) + iounmap(pvpanic_data.base); return 0; } -static const struct of_device_id pvpanic_mmio_match[] = { -
[tip:x86/urgent] x86/mm/mem_encrypt: Fix erroneous sizeof()
Commit-ID: bf7d28c53453ea904584960de55e33e03b9d93b1 Gitweb: https://git.kernel.org/tip/bf7d28c53453ea904584960de55e33e03b9d93b1 Author: Peng Hao AuthorDate: Sat, 29 Dec 2018 14:34:12 +0800 Committer: Thomas Gleixner CommitDate: Tue, 15 Jan 2019 11:41:58 +0100 x86/mm/mem_encrypt: Fix erroneous sizeof() Using sizeof(pointer) for determining the size of a memset() only works when the size of the pointer and the size of type to which it points are the same. For pte_t this is only true for 64bit and 32bit-NONPAE. On 32bit PAE systems this is wrong as the pointer size is 4 byte but the PTE entry is 8 bytes. It's actually not a real world issue as this code depends on 64bit, but it's wrong nevertheless. Use sizeof(*p) for correctness sake. Fixes: aad983913d77 ("x86/mm/encrypt: Simplify sme_populate_pgd() and sme_populate_pgd_large()") Signed-off-by: Peng Hao Signed-off-by: Thomas Gleixner Cc: Kirill A. Shutemov Cc: Tom Lendacky Cc: dave.han...@linux.intel.com Cc: pet...@infradead.org Cc: l...@kernel.org Link: https://lkml.kernel.org/r/1546065252-97996-1-git-send-email-peng.h...@zte.com.cn --- arch/x86/mm/mem_encrypt_identity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index a19ef1a416ff..4aa9b1480866 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -158,8 +158,8 @@ static void __init sme_populate_pgd(struct sme_populate_pgd_data *ppd) pmd = pmd_offset(pud, ppd->vaddr); if (pmd_none(*pmd)) { pte = ppd->pgtable_area; - memset(pte, 0, sizeof(pte) * PTRS_PER_PTE); - ppd->pgtable_area += sizeof(pte) * PTRS_PER_PTE; + memset(pte, 0, sizeof(*pte) * PTRS_PER_PTE); + ppd->pgtable_area += sizeof(*pte) * PTRS_PER_PTE; set_pmd(pmd, __pmd(PMD_FLAGS | __pa(pte))); }
[PATCH] rcu: Remove rcu_*_state declaration
Because of just only one set of rcu_state, the declaration of rcu_sched_state/rcu_bh_state/rcu_preempt_state is unnecessary. Signed-off-by: Peng Hao --- kernel/rcu/tree.h | 7 --- 1 file changed, 7 deletions(-) diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 703e19f..9ea704c 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -401,13 +401,6 @@ struct rcu_state { /* * RCU implementation internal declarations: */ -extern struct rcu_state rcu_sched_state; - -extern struct rcu_state rcu_bh_state; - -#ifdef CONFIG_PREEMPT_RCU -extern struct rcu_state rcu_preempt_state; -#endif /* #ifdef CONFIG_PREEMPT_RCU */ int rcu_dynticks_snap(struct rcu_data *rdp); -- 1.8.3.1
[PATCH] x86/kvm: convert to DEFINE_DEBUGFS_ATTRIBUTE
From: Peng Hao The preferred strategy to define debugfs attributes is to use the DEFINE_DEBUGFS_ATTRIBUTE() macro and to use debugfs_create_file_unsafe(). Signed-off-by: Peng Hao --- arch/x86/kvm/debugfs.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/debugfs.c b/arch/x86/kvm/debugfs.c index c19c7ed..cc1187f 100644 --- a/arch/x86/kvm/debugfs.c +++ b/arch/x86/kvm/debugfs.c @@ -22,7 +22,8 @@ static int vcpu_get_tsc_offset(void *data, u64 *val) return 0; } -DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_offset_fops, vcpu_get_tsc_offset, NULL, "%lld\n"); +DEFINE_DEBUGFS_ATTRIBUTE(vcpu_tsc_offset_fops, +vcpu_get_tsc_offset, NULL, "%lld\n"); static int vcpu_get_tsc_scaling_ratio(void *data, u64 *val) { @@ -31,7 +32,8 @@ static int vcpu_get_tsc_scaling_ratio(void *data, u64 *val) return 0; } -DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_fops, vcpu_get_tsc_scaling_ratio, NULL, "%llu\n"); +DEFINE_DEBUGFS_ATTRIBUTE(vcpu_tsc_scaling_fops, +vcpu_get_tsc_scaling_ratio, NULL, "%llu\n"); static int vcpu_get_tsc_scaling_frac_bits(void *data, u64 *val) { @@ -39,25 +41,26 @@ static int vcpu_get_tsc_scaling_frac_bits(void *data, u64 *val) return 0; } -DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_frac_fops, vcpu_get_tsc_scaling_frac_bits, NULL, "%llu\n"); +DEFINE_DEBUGFS_ATTRIBUTE(vcpu_tsc_scaling_frac_fops, +vcpu_get_tsc_scaling_frac_bits, NULL, "%llu\n"); int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu) { struct dentry *ret; - ret = debugfs_create_file("tsc-offset", 0444, + ret = debugfs_create_file_unsafe("tsc-offset", 0444, vcpu->debugfs_dentry, vcpu, _tsc_offset_fops); if (!ret) return -ENOMEM; if (kvm_has_tsc_control) { - ret = debugfs_create_file("tsc-scaling-ratio", 0444, + ret = debugfs_create_file_unsafe("tsc-scaling-ratio", 0444, vcpu->debugfs_dentry, vcpu, _tsc_scaling_fops); if (!ret) return -ENOMEM; - ret = debugfs_create_file("tsc-scaling-ratio-frac-bits", 0444, + ret = debugfs_create_file_unsafe("tsc-scaling-ratio-frac-bits", 0444, vcpu->debugfs_dentry, vcpu, _tsc_scaling_frac_fops); if (!ret) -- 1.8.3.1
[PATCH] security/selinux/hooks: remove unneeded semicolon
Remove unneeded semicolon. Signed-off-by: Peng Hao --- security/selinux/hooks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index a67459e..73c679e 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1263,7 +1263,7 @@ static void selinux_write_opts(struct seq_file *m, default: BUG(); return; - }; + } /* we need a comma before each option */ seq_putc(m, ','); seq_puts(m, prefix); -- 1.8.3.1
[PATCH] security/apparmor/domain: use PTR_ERR_OR_ZERO
The variable 'new' may be NULL, so use PTR_ERR_OR_ZERO instead of PTR_ERR. Signed-off-by: Peng Hao --- security/apparmor/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c index 08c88de..7663589 100644 --- a/security/apparmor/domain.c +++ b/security/apparmor/domain.c @@ -1444,7 +1444,7 @@ int aa_change_profile(const char *fqname, int flags) new = aa_label_merge(label, target, GFP_KERNEL); if (IS_ERR_OR_NULL(new)) { info = "failed to build target label"; - error = PTR_ERR(new); + error = PTR_ERR_OR_ZERO(new); new = NULL; perms.allow = 0; goto audit; -- 1.8.3.1
[RESEND PATCH v5] soc/fsl/qe: fix err handling of ucc_of_parse_tdm
From: Wen Yang Currently there are some issues with the ucc_of_parse_tdm function: 1, a possible null pointer dereference in ucc_of_parse_tdm, detected by the semantic patch deref_null.cocci, with the following warning: drivers/soc/fsl/qe/qe_tdm.c:177:21-24: ERROR: pdev is NULL but dereferenced. 2, dev gets modified, so in any case that devm_iounmap() will fail even when the new pdev is valid, because the iomap was done with a different pdev. 3, there is no driver bind with the "fsl,t1040-qe-si" or "fsl,t1040-qe-siram" device. So allocating resources using devm_*() with these devices won't provide a cleanup path for these resources when the caller fails. This patch fixes them. Suggested-by: Li Yang Suggested-by: Christophe LEROY Signed-off-by: Wen Yang Reviewed-by: Peng Hao CC: Julia Lawall CC: Zhao Qiang CC: David S. Miller CC: net...@vger.kernel.org CC: linuxppc-...@lists.ozlabs.org CC: linux-kernel@vger.kernel.org --- v5->v4: - "of_find_device_by_node()" takes a reference to the underlying device structure, we should release it. v4->v3: - This assignment to 'res' doesn't do what you think it does. The caller never sees the value you compute. v3->v2: - there is no driver bind with the "fsl,t1040-qe-si" or "fsl,t1040-qe-siram" device. So allocating resources using devm_*() with these devices won't provide a cleanup path for these resources when the caller fails. v2->v1: - dev gets modified, so in any case that devm_iounmap() will fail even when the new pdev is valid, because the iomap was done with a different pdev. drivers/net/wan/fsl_ucc_hdlc.c | 62 +- drivers/soc/fsl/qe/qe_tdm.c| 55 - 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 839fa77..f30a040 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -1057,6 +1057,54 @@ static const struct net_device_ops uhdlc_ops = { .ndo_tx_timeout = uhdlc_tx_timeout, }; +static int hdlc_map_iomem(char *name, int init_flag, void __iomem **ptr) +{ + struct device_node *np; + struct platform_device *pdev; + struct resource *res; + static int siram_init_flag; + int ret = 0; + + np = of_find_compatible_node(NULL, NULL, name); + if (!np) + return -EINVAL; + + pdev = of_find_device_by_node(np); + if (!pdev) { + pr_err("%pOFn: failed to lookup pdev\n", np); + of_node_put(np); + return -EINVAL; + } + + of_node_put(np); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + ret = -EINVAL; + goto error_put_device; + } + *ptr = ioremap(res->start, resource_size(res)); + if (!*ptr) { + ret = -ENOMEM; + goto error_put_device; + } + + /* We've remapped the addresses, and we don't need the device any +* more, so we should release it. +*/ + put_device(>dev); + + if (init_flag && siram_init_flag == 0) { + memset_io(*ptr, 0, resource_size(res)); + siram_init_flag = 1; + } + return 0; + +error_put_device: + put_device(>dev); + + return ret; +} + static int ucc_hdlc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1151,6 +1199,15 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ret = ucc_of_parse_tdm(np, utdm, ut_info); if (ret) goto free_utdm; + + ret = hdlc_map_iomem("fsl,t1040-qe-si", 0, +(void __iomem **)>si_regs); + if (ret) + goto free_utdm; + ret = hdlc_map_iomem("fsl,t1040-qe-siram", 1, +(void __iomem **)>siram); + if (ret) + goto unmap_si_regs; } if (of_property_read_u16(np, "fsl,hmask", _priv->hmask)) @@ -1159,7 +1216,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ret = uhdlc_init(uhdlc_priv); if (ret) { dev_err(>dev, "Failed to init uhdlc\n"); - goto free_utdm; + goto undo_uhdlc_init; } dev = alloc_hdlcdev(uhdlc_priv); @@ -1188,6 +1245,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev) free_dev: free_netdev(dev); undo_uhdlc_init: + iounmap(utdm->siram); +unmap_si_regs: + iounmap(utdm->si_regs); free_utdm: if (uhdlc_priv->tsa) kfree(utdm); diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c index f78c346..
[PATCH v5] soc/fsl/qe: fix err handling of ucc_of_parse_tdm
From: Wen Yang Currently there are some issues with the ucc_of_parse_tdm function: 1, a possible null pointer dereference in ucc_of_parse_tdm, detected by the semantic patch deref_null.cocci, with the following warning: drivers/soc/fsl/qe/qe_tdm.c:177:21-24: ERROR: pdev is NULL but dereferenced. 2, dev gets modified, so in any case that devm_iounmap() will fail even when the new pdev is valid, because the iomap was done with a different pdev. 3, there is no driver bind with the "fsl,t1040-qe-si" or "fsl,t1040-qe-siram" device. So allocating resources using devm_*() with these devices won't provide a cleanup path for these resources when the caller fails. This patch fixes them. Suggested-by: Li Yang Suggested-by: Christophe LEROY Signed-off-by: Wen Yang Reviewed-by: Peng Hao CC: Julia Lawall CC: Zhao Qiang CC: David S. Miller CC: net...@vger.kernel.org CC: linuxppc-...@lists.ozlabs.org CC: linux-kernel@vger.kernel.org --- drivers/net/wan/fsl_ucc_hdlc.c | 62 +- drivers/soc/fsl/qe/qe_tdm.c| 55 - 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 839fa77..f30a040 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -1057,6 +1057,54 @@ static const struct net_device_ops uhdlc_ops = { .ndo_tx_timeout = uhdlc_tx_timeout, }; +static int hdlc_map_iomem(char *name, int init_flag, void __iomem **ptr) +{ + struct device_node *np; + struct platform_device *pdev; + struct resource *res; + static int siram_init_flag; + int ret = 0; + + np = of_find_compatible_node(NULL, NULL, name); + if (!np) + return -EINVAL; + + pdev = of_find_device_by_node(np); + if (!pdev) { + pr_err("%pOFn: failed to lookup pdev\n", np); + of_node_put(np); + return -EINVAL; + } + + of_node_put(np); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + ret = -EINVAL; + goto error_put_device; + } + *ptr = ioremap(res->start, resource_size(res)); + if (!*ptr) { + ret = -ENOMEM; + goto error_put_device; + } + + /* We've remapped the addresses, and we don't need the device any +* more, so we should release it. +*/ + put_device(>dev); + + if (init_flag && siram_init_flag == 0) { + memset_io(*ptr, 0, resource_size(res)); + siram_init_flag = 1; + } + return 0; + +error_put_device: + put_device(>dev); + + return ret; +} + static int ucc_hdlc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1151,6 +1199,15 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ret = ucc_of_parse_tdm(np, utdm, ut_info); if (ret) goto free_utdm; + + ret = hdlc_map_iomem("fsl,t1040-qe-si", 0, +(void __iomem **)>si_regs); + if (ret) + goto free_utdm; + ret = hdlc_map_iomem("fsl,t1040-qe-siram", 1, +(void __iomem **)>siram); + if (ret) + goto unmap_si_regs; } if (of_property_read_u16(np, "fsl,hmask", _priv->hmask)) @@ -1159,7 +1216,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ret = uhdlc_init(uhdlc_priv); if (ret) { dev_err(>dev, "Failed to init uhdlc\n"); - goto free_utdm; + goto undo_uhdlc_init; } dev = alloc_hdlcdev(uhdlc_priv); @@ -1188,6 +1245,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev) free_dev: free_netdev(dev); undo_uhdlc_init: + iounmap(utdm->siram); +unmap_si_regs: + iounmap(utdm->si_regs); free_utdm: if (uhdlc_priv->tsa) kfree(utdm); diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c index f78c346..76480df 100644 --- a/drivers/soc/fsl/qe/qe_tdm.c +++ b/drivers/soc/fsl/qe/qe_tdm.c @@ -44,10 +44,6 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, const char *sprop; int ret = 0; u32 val; - struct resource *res; - struct device_node *np2; - static int siram_init_flag; - struct platform_device *pdev; sprop = of_get_property(np, "fsl,rx-sync-clock", NULL); if (sprop) { @@ -124,57 +120,6 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, utdm->siram_entry_id = val; set_si_param(utdm, ut_info); - - np2 = of_find_compatible_node(N
[PATCH] misc/mic/vop/vop_main : remove unneeded semicolon
From: Peng Hao Remove unnecessary semicolon in two functions. Signed-off-by: Peng Hao --- drivers/misc/mic/vop/vop_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mic/vop/vop_main.c b/drivers/misc/mic/vop/vop_main.c index 3633202..70d4b4d 100644 --- a/drivers/misc/mic/vop/vop_main.c +++ b/drivers/misc/mic/vop/vop_main.c @@ -213,7 +213,7 @@ static void vop_reset_inform_host(struct virtio_device *dev) if (ioread8(>host_ack)) break; msleep(100); - }; + } dev_dbg(_vop_dev(vdev), "%s: retry: %d\n", __func__, retry); @@ -408,7 +408,7 @@ static int vop_find_vqs(struct virtio_device *dev, unsigned nvqs, if (!ioread8(>used_address_updated)) break; msleep(100); - }; + } dev_dbg(_vop_dev(vdev), "%s: retry: %d\n", __func__, retry); if (!retry) { -- 1.8.3.1
[PATCH] misc/sgi-gru/grufault: fix a style error
From: Peng Hao Fix a style error. Remove redundant space. Signed-off-by: Peng Hao --- drivers/misc/sgi-gru/grufault.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c index 93be82f..2ec5808 100644 --- a/drivers/misc/sgi-gru/grufault.c +++ b/drivers/misc/sgi-gru/grufault.c @@ -616,8 +616,8 @@ irqreturn_t gru_intr_mblade(int irq, void *dev_id) for_each_possible_blade(blade) { if (uv_blade_nr_possible_cpus(blade)) continue; -gru_intr(0, blade); -gru_intr(1, blade); + gru_intr(0, blade); + gru_intr(1, blade); } return IRQ_HANDLED; } -- 1.8.3.1
[PATCH v4] soc/fsl/qe: fix err handling of ucc_of_parse_tdm
From: Wen Yang Currently there are some issues with the ucc_of_parse_tdm function: 1, a possible null pointer dereference in ucc_of_parse_tdm, detected by the semantic patch deref_null.cocci, with the following warning: drivers/soc/fsl/qe/qe_tdm.c:177:21-24: ERROR: pdev is NULL but dereferenced. 2, dev gets modified, so in any case that devm_iounmap() will fail even when the new pdev is valid, because the iomap was done with a different pdev. 3, there is no driver bind with the "fsl,t1040-qe-si" or "fsl,t1040-qe-siram" device. So allocating resources using devm_*() with these devices won't provide a cleanup path for these resources when the caller fails. This patch fixes them. Suggested-by: Li Yang Suggested-by: Christophe LEROY Signed-off-by: Wen Yang Reviewed-by: Peng Hao CC: Julia Lawall CC: Zhao Qiang CC: David S. Miller CC: net...@vger.kernel.org CC: linuxppc-...@lists.ozlabs.org CC: linux-kernel@vger.kernel.org --- drivers/net/wan/fsl_ucc_hdlc.c | 52 ++- drivers/soc/fsl/qe/qe_tdm.c| 55 -- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 839fa77..07a496c 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -1057,6 +1057,26 @@ static const struct net_device_ops uhdlc_ops = { .ndo_tx_timeout = uhdlc_tx_timeout, }; +static struct resource *ucc_get_resource_by_nodename(char *name) +{ + struct device_node *np; + struct platform_device *pdev; + + np = of_find_compatible_node(NULL, NULL, name); + if (!np) + return ERR_PTR(-EINVAL); + + pdev = of_find_device_by_node(np); + if (!pdev) { + pr_err("%pOFn: failed to lookup pdev\n", np); + of_node_put(np); + return ERR_PTR(-EINVAL); + } + + of_node_put(np); + return platform_get_resource(pdev, IORESOURCE_MEM, 0); +} + static int ucc_hdlc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1070,6 +1090,8 @@ static int ucc_hdlc_probe(struct platform_device *pdev) const char *sprop; int ret; u32 val; + struct resource *r_mem; + static int siram_init_flag; ret = of_property_read_u32_index(np, "cell-index", 0, ); if (ret) { @@ -1151,6 +1173,31 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ret = ucc_of_parse_tdm(np, utdm, ut_info); if (ret) goto free_utdm; + + r_mem = ucc_get_resource_by_nodename("fsl,t1040-qe-si"); + if (IS_ERR_OR_NULL(r_mem)) { + ret = -EINVAL; + goto free_utdm; + } + utdm->si_regs = ioremap(r_mem->start, resource_size(r_mem)); + if (!utdm->si_regs) { + ret = -ENOMEM; + goto free_utdm; + } + r_mem = ucc_get_resource_by_nodename("fsl,t1040-qe-siram"); + if (IS_ERR_OR_NULL(r_mem)) { + ret = -EINVAL; + goto unmap_si_regs; + } + utdm->siram = ioremap(r_mem->start, resource_size(r_mem)); + if (!utdm->siram) { + ret = -ENOMEM; + goto unmap_si_regs; + } + if (siram_init_flag == 0) { + memset_io(utdm->siram, 0, resource_size(r_mem)); + siram_init_flag = 1; + } } if (of_property_read_u16(np, "fsl,hmask", _priv->hmask)) @@ -1159,7 +1206,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ret = uhdlc_init(uhdlc_priv); if (ret) { dev_err(>dev, "Failed to init uhdlc\n"); - goto free_utdm; + goto undo_uhdlc_init; } dev = alloc_hdlcdev(uhdlc_priv); @@ -1188,6 +1235,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev) free_dev: free_netdev(dev); undo_uhdlc_init: + iounmap(utdm->siram); +unmap_si_regs: + iounmap(utdm->si_regs); free_utdm: if (uhdlc_priv->tsa) kfree(utdm); diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c index f78c346..76480df 100644 --- a/drivers/soc/fsl/qe/qe_tdm.c +++ b/drivers/soc/fsl/qe/qe_tdm.c @@ -44,10 +44,6 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, const char *sprop; int ret = 0; u32 val; - struct resource *res; - struct device_node *np2; - static int siram_init_flag; - struct platform_device *pdev; sprop = of_get_property(np, "fsl,rx-sync-clock",
[PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof
Fix error usage to sizeof. It should not use sizeof to pointer. Signed-off-by: Peng Hao --- arch/x86/mm/mem_encrypt_identity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index a19ef1a..4aa9b14 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -158,8 +158,8 @@ static void __init sme_populate_pgd(struct sme_populate_pgd_data *ppd) pmd = pmd_offset(pud, ppd->vaddr); if (pmd_none(*pmd)) { pte = ppd->pgtable_area; - memset(pte, 0, sizeof(pte) * PTRS_PER_PTE); - ppd->pgtable_area += sizeof(pte) * PTRS_PER_PTE; + memset(pte, 0, sizeof(*pte) * PTRS_PER_PTE); + ppd->pgtable_area += sizeof(*pte) * PTRS_PER_PTE; set_pmd(pmd, __pmd(PMD_FLAGS | __pa(pte))); } -- 1.8.3.1
[PATCH 2/2] arm/plat-pxa/ssp : unneeded to free devm_ allocated data
devm_ allocated data will be automatically freed. The free of devm_ allocated data is invalid. Signed-off-by: Peng Hao --- arch/arm/plat-pxa/ssp.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c index ed36dca..f519199 100644 --- a/arch/arm/plat-pxa/ssp.c +++ b/arch/arm/plat-pxa/ssp.c @@ -190,8 +190,6 @@ static int pxa_ssp_remove(struct platform_device *pdev) if (ssp == NULL) return -ENODEV; - iounmap(ssp->mmio_base); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); release_mem_region(res->start, resource_size(res)); @@ -201,7 +199,6 @@ static int pxa_ssp_remove(struct platform_device *pdev) list_del(>node); mutex_unlock(_lock); - kfree(ssp); return 0; } -- 1.8.3.1
[PATCH 1/2] arm/common/dmabounce : NULL check before dma_pool_destroy
NULL check before dma_pool_destroy is unnecessary because there is a NULL check in dma_pool_destroy. Signed-off-by: Peng Hao --- arch/arm/common/dmabounce.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 9a92de6..dcdd80c 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -569,10 +569,8 @@ void dmabounce_unregister_dev(struct device *dev) BUG(); } - if (device_info->small.pool) - dma_pool_destroy(device_info->small.pool); - if (device_info->large.pool) - dma_pool_destroy(device_info->large.pool); + dma_pool_destroy(device_info->small.pool); + dma_pool_destroy(device_info->large.pool); #ifdef STATS if (device_info->attr_res == 0) -- 1.8.3.1
[PATCH] arm/mach-lpc32xx/pm : use kmemdup instead of duplicating
kmemdup has implemented the function that kmalloc() + memcpy(). Prefer to kmemdup rather than code opened implementation. Signed-off-by: Peng Hao --- arch/arm/mach-lpc32xx/pm.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c index 6247157..1a2535c 100644 --- a/arch/arm/mach-lpc32xx/pm.c +++ b/arch/arm/mach-lpc32xx/pm.c @@ -85,8 +85,11 @@ static int lpc32xx_pm_enter(suspend_state_t state) int (*lpc32xx_suspend_ptr) (void); void *iram_swap_area; - /* Allocate some space for temporary IRAM storage */ - iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL); + /* Allocate some space for temporary IRAM storage. Then +* backup a small area of IRAM used for the suspend code. +*/ + iram_swap_area = kmemdup((void *) TEMP_IRAM_AREA, +lpc32xx_sys_suspend_sz, GFP_KERNEL); if (!iram_swap_area) { printk(KERN_ERR "PM Suspend: cannot allocate memory to save portion " @@ -94,10 +97,6 @@ static int lpc32xx_pm_enter(suspend_state_t state) return -ENOMEM; } - /* Backup a small area of IRAM used for the suspend code */ - memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA, - lpc32xx_sys_suspend_sz); - /* * Copy code to suspend system into IRAM. The suspend code * needs to run from IRAM as DRAM may no longer be available -- 1.8.3.1
[PATCH] arm/mm/pmsa-v8 : remove unneeded semicolon
Remove unneeded semicolon. Signed-off-by: Peng Hao --- arch/arm/mm/pmsa-v8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/pmsa-v8.c b/arch/arm/mm/pmsa-v8.c index 617a83d..0d7d5fb 100644 --- a/arch/arm/mm/pmsa-v8.c +++ b/arch/arm/mm/pmsa-v8.c @@ -165,7 +165,7 @@ static int __init pmsav8_setup_ram(unsigned int number, phys_addr_t start,phys_a return -EINVAL; bar = start; - lar = (end - 1) & ~(PMSAv8_MINALIGN - 1);; + lar = (end - 1) & ~(PMSAv8_MINALIGN - 1); bar |= PMSAv8_AP_PL1RW_PL0RW | PMSAv8_RGN_SHARED; lar |= PMSAv8_LAR_IDX(PMSAv8_RGN_NORMAL) | PMSAv8_LAR_EN; @@ -181,7 +181,7 @@ static int __init pmsav8_setup_io(unsigned int number, phys_addr_t start,phys_ad return -EINVAL; bar = start; - lar = (end - 1) & ~(PMSAv8_MINALIGN - 1);; + lar = (end - 1) & ~(PMSAv8_MINALIGN - 1); bar |= PMSAv8_AP_PL1RW_PL0RW | PMSAv8_RGN_SHARED | PMSAv8_BAR_XN; lar |= PMSAv8_LAR_IDX(PMSAv8_RGN_DEVICE_nGnRnE) | PMSAv8_LAR_EN; -- 1.8.3.1
[PATCH] arm/mach-iop13xx: remove duplicated argument in define
Remove duplicated PCI_STATUS_REC_TARGET_ABORT. Signed-off-by: Peng Hao --- arch/arm/mach-iop13xx/pci.h | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/mach-iop13xx/pci.h b/arch/arm/mach-iop13xx/pci.h index 736168d..c6a0678 100644 --- a/arch/arm/mach-iop13xx/pci.h +++ b/arch/arm/mach-iop13xx/pci.h @@ -23,7 +23,6 @@ #define IOP_PCI_STATUS_ERROR (PCI_STATUS_PARITY | \ PCI_STATUS_SIG_TARGET_ABORT | \ PCI_STATUS_REC_TARGET_ABORT | \ - PCI_STATUS_REC_TARGET_ABORT | \ PCI_STATUS_REC_MASTER_ABORT | \ PCI_STATUS_SIG_SYSTEM_ERROR | \ PCI_STATUS_DETECTED_PARITY) -- 1.8.3.1
[PATCH] kvm/eventfd : unnecessory conversion to bool
Conversion to bool is not needed in ioeventfd_in_range. Signed-off-by: Peng Hao --- virt/kvm/eventfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index b20b751..d4cdc9c 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -723,7 +723,7 @@ struct _ioeventfd { return false; } - return _val == p->datamatch ? true : false; + return _val == p->datamatch; } /* MMIO/PIO writes trigger an event if the addr/val match */ -- 1.8.3.1
[PATCH] kvm:arm/arm64: vgic: remove unnecessary semicolon
Remove unnecessary semicolon in vgic_put_irq. Signed-off-by: Peng Hao --- virt/kvm/arm/vgic/vgic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 7cfdfbc..f9ff5c7 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -142,7 +142,7 @@ void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) if (!kref_put(>refcount, vgic_irq_release)) { spin_unlock_irqrestore(>lpi_list_lock, flags); return; - }; + } list_del(>lpi_list); dist->lpi_list_count--; -- 1.8.3.1
[PATCH] kvm: arm/arm64 : vgic: remove unneeded semicolon
Remove unneeded semicolon in kvm_vgic_hyp_init. Signed-off-by: Peng Hao --- virt/kvm/arm/vgic/vgic-init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index c0c0b88..3496155 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -510,7 +510,7 @@ int kvm_vgic_hyp_init(void) break; default: ret = -ENODEV; - }; + } if (ret) return ret; -- 1.8.3.1
[PATCH] net/wan/fsl_ucc_hdlc: Avoid double free in ucc_hdlc_probe()
From: Wen Yang This patch fixes potential double frees if register_hdlc_device() fails. Signed-off-by: Wen Yang Reviewed-by: Peng Hao CC: Zhao Qiang CC: "David S. Miller" CC: net...@vger.kernel.org CC: linuxppc-...@lists.ozlabs.org CC: linux-kernel@vger.kernel.org --- drivers/net/wan/fsl_ucc_hdlc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 7a42336..839fa77 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -1180,7 +1180,6 @@ static int ucc_hdlc_probe(struct platform_device *pdev) if (register_hdlc_device(dev)) { ret = -ENOBUFS; pr_err("ucc_hdlc: unable to register hdlc device\n"); - free_netdev(dev); goto free_dev; } -- 2.9.5
[PATCH v3] soc/fsl/qe: fix err handling of ucc_of_parse_tdm
From: Wen Yang Currently there are some issues with the ucc_of_parse_tdm function: 1, a possible null pointer dereference in ucc_of_parse_tdm, detected by the semantic patch deref_null.cocci, with the following warning: drivers/soc/fsl/qe/qe_tdm.c:177:21-24: ERROR: pdev is NULL but dereferenced. 2, dev gets modified, so in any case that devm_iounmap() will fail even when the new pdev is valid, because the iomap was done with a different pdev. 3, there is no driver bind with the "fsl,t1040-qe-si" or "fsl,t1040-qe-siram" device. So allocating resources using devm_*() with these devices won't provide a cleanup path for these resources when the caller fails. This patch fixes them. Suggested-by: Li Yang Suggested-by: Christophe LEROY Signed-off-by: Wen Yang Reviewed-by: Peng Hao CC: Julia Lawall CC: Zhao Qiang CC: net...@vger.kernel.org CC: linuxppc-...@lists.ozlabs.org CC: linux-kernel@vger.kernel.org --- drivers/net/wan/fsl_ucc_hdlc.c | 48 +++- drivers/soc/fsl/qe/qe_tdm.c| 55 -- 2 files changed, 47 insertions(+), 56 deletions(-) diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 839fa77..8ce4921f 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -1057,6 +1057,27 @@ static const struct net_device_ops uhdlc_ops = { .ndo_tx_timeout = uhdlc_tx_timeout, }; +static int ucc_get_resource_by_nodename(char *name, struct resource *res) +{ + struct device_node *np; + struct platform_device *pdev; + + np = of_find_compatible_node(NULL, NULL, name); + if (!np) + return -EINVAL; + + pdev = of_find_device_by_node(np); + if (!pdev) { + pr_err("%pOFn: failed to lookup pdev\n", np); + of_node_put(np); + return -EINVAL; + } + + of_node_put(np); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + return 0; +} + static int ucc_hdlc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1070,6 +1091,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev) const char *sprop; int ret; u32 val; + static int siram_init_flag; ret = of_property_read_u32_index(np, "cell-index", 0, ); if (ret) { @@ -1151,6 +1173,27 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ret = ucc_of_parse_tdm(np, utdm, ut_info); if (ret) goto free_utdm; + + ret = ucc_get_resource_by_nodename("fsl,t1040-qe-si", ); + if (ret) + goto free_utdm; + utdm->si_regs = ioremap(res.start, resource_size()); + if (!utdm->si_regs) { + ret = -ENOMEM; + goto free_utdm; + } + ret = ucc_get_resource_by_nodename("fsl,t1040-qe-siram", ); + if (ret) + goto unmap_si_regs; + utdm->siram = ioremap(res.start, resource_size()); + if (!utdm->siram) { + ret = -ENOMEM; + goto unmap_si_regs; + } + if (siram_init_flag == 0) { + memset_io(utdm->siram, 0, resource_size()); + siram_init_flag = 1; + } } if (of_property_read_u16(np, "fsl,hmask", _priv->hmask)) @@ -1159,7 +1202,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ret = uhdlc_init(uhdlc_priv); if (ret) { dev_err(>dev, "Failed to init uhdlc\n"); - goto free_utdm; + goto undo_uhdlc_init; } dev = alloc_hdlcdev(uhdlc_priv); @@ -1188,6 +1231,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev) free_dev: free_netdev(dev); undo_uhdlc_init: + iounmap(utdm->siram); +unmap_si_regs: + iounmap(utdm->si_regs); free_utdm: if (uhdlc_priv->tsa) kfree(utdm); diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c index f78c346..76480df 100644 --- a/drivers/soc/fsl/qe/qe_tdm.c +++ b/drivers/soc/fsl/qe/qe_tdm.c @@ -44,10 +44,6 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, const char *sprop; int ret = 0; u32 val; - struct resource *res; - struct device_node *np2; - static int siram_init_flag; - struct platform_device *pdev; sprop = of_get_property(np, "fsl,rx-sync-clock", NULL); if (sprop) { @@ -124,57 +120,6 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, utdm->siram_entry_id = val; set_si_param(utdm, ut_info); - - np2 = of_find_compatible_
[PATCH] kvm/arm : remove unnecessary local variable
Remove unnecessary local variable in vgic_set_common_attr Signed-off-by: Peng Hao --- virt/kvm/arm/vgic/vgic-kvm-device.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-kvm-device.c b/virt/kvm/arm/vgic/vgic-kvm-device.c index 114dce9..53e5df7 100644 --- a/virt/kvm/arm/vgic/vgic-kvm-device.c +++ b/virt/kvm/arm/vgic/vgic-kvm-device.c @@ -163,7 +163,7 @@ int kvm_vgic_addr(struct kvm *kvm, unsigned long type, u64 *addr, bool write) static int vgic_set_common_attr(struct kvm_device *dev, struct kvm_device_attr *attr) { - int r; + int r = 0; switch (attr->group) { case KVM_DEV_ARM_VGIC_GRP_ADDR: { @@ -180,7 +180,6 @@ static int vgic_set_common_attr(struct kvm_device *dev, case KVM_DEV_ARM_VGIC_GRP_NR_IRQS: { u32 __user *uaddr = (u32 __user *)(long)attr->addr; u32 val; - int ret = 0; if (get_user(val, uaddr)) return -EFAULT; @@ -199,14 +198,14 @@ static int vgic_set_common_attr(struct kvm_device *dev, mutex_lock(>kvm->lock); if (vgic_ready(dev->kvm) || dev->kvm->arch.vgic.nr_spis) - ret = -EBUSY; + r = -EBUSY; else dev->kvm->arch.vgic.nr_spis = val - VGIC_NR_PRIVATE_IRQS; mutex_unlock(>kvm->lock); - return ret; + return r; } case KVM_DEV_ARM_VGIC_GRP_CTRL: { switch (attr->attr) { -- 1.8.3.1
[RESEND PATCH] kvm/x86: propagate fetch fault into guest
When handling ept misconfig exit, it will call emulate instruction with insn_len = 0. The decode instruction function may return a fetch fault and should propagate to guest. The problem will result to emulation fail. KVM internal error. Suberror: 1 emulation failure EAX=f81a0024 EBX=f6a07000 ECX=f6a0737c EDX=f8be0118 ESI=f6a0737c EDI=0021 EBP=f6929f98 ESP=f6929f98 EIP=f8bdd141 EFL=00010086 [--S--P-] CPL=0 II=0 A20=1 SMM=0 HLT=0 ES =007b 00c0f300 DPL=3 DS [-WA] CS =0060 00c09b00 DPL=0 CS32 [-RA] SS =0068 00c09300 DPL=0 DS [-WA] DS =007b 00c0f300 DPL=3 DS [-WA] FS =00d8 2c044000 00809300 DPL=0 DS16 [-WA] GS =0033 081a44c8 01000fff 00d0f300 DPL=3 DS [-WA] LDT= TR =0080 f6ea0c80 206b 8b00 DPL=0 TSS32-busy GDT= f6e99000 00ff IDT= fffbb000 07ff CR0=80050033 CR2=b757d000 CR3=35d31000 CR4=001406d0 Signed-off-by: Peng Hao --- arch/x86/kvm/emulate.c | 5 - arch/x86/kvm/x86.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 78e430f..dd132cf 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -5114,8 +5114,11 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) memcpy(ctxt->fetch.data, insn, insn_len); else { rc = __do_insn_fetch_bytes(ctxt, 1); - if (rc != X86EMUL_CONTINUE) + if (rc != X86EMUL_CONTINUE) { + if (rc == X86EMUL_PROPAGATE_FAULT) + ctxt->have_exception = true; return rc; + } } switch (mode) { diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f049ecf..137d384 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6333,8 +6333,10 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, if (reexecute_instruction(vcpu, cr2, write_fault_to_spt, emulation_type)) return EMULATE_DONE; - if (ctxt->have_exception && inject_emulated_exception(vcpu)) + if (ctxt->have_exception) { + inject_emulated_exception(vcpu); return EMULATE_DONE; + } if (emulation_type & EMULTYPE_SKIP) return EMULATE_FAIL; return handle_emulation_failure(vcpu, emulation_type); -- 1.8.3.1
[PATCH] kvm/arm64 : reduce the size of kvm_vcpu
According to adjust the position of variables in kvm_vcpu_arch, the size of kvm_vcpu can reduce 16 bytes. before: cat /proc/slabinfo | grep kvm kvm_vcpu 252252 9120 28 ... after: cat /proc/slabinfo | grep kvm kvm_vcpu 28 28 9104 28 ... Signed-off-by: Peng Hao --- arch/arm64/include/asm/kvm_host.h | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 52fbc82..e805b7e 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -287,16 +287,17 @@ struct kvm_vcpu_arch { /* Cache some mmu pages needed inside spinlock regions */ struct kvm_mmu_memory_cache mmu_page_cache; + /* Virtual SError ESR to restore when HCR_EL2.VSE is set */ + u64 vsesr_el2; + + DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES); + /* Target CPU and feature flags */ int target; - DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES); /* Detect first run of a vcpu */ bool has_run_once; - /* Virtual SError ESR to restore when HCR_EL2.VSE is set */ - u64 vsesr_el2; - /* True when deferrable sysregs are loaded on the physical CPU, * see kvm_vcpu_load_sysregs and kvm_vcpu_put_sysregs. */ bool sysregs_loaded_on_cpu; -- 1.8.3.1
[PATCH RESEND V5 1/3] misc/pvpanic: return 0 for empty body register function
Return 0 for empty body register function normally. Signed-off-by: Peng Hao --- v4 --> v5 : resolve kbuild issue: handle all typo "drvier/driver" in funtion name. v3 --> v4 : use pcim* function instead of pci* function. handle typo "drvier/driver" in funtion name. v2 --> v3 : resolve kbuild issue : a uninitialized variable in some path. v2 --> v1 : resolve kbuild issue : arch=sh don't support pci, adjust CONFIG_PCI macro. v1 : QEMU community requires additional PCI devices to simulate PVPANIC devices so that some architectures can not occupy precious less than 4G of memory space. 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
[PATCH RESEND V5 2/3] misc/pvpanic : add pci interface for pvpanic
Support pvpanic as a pci device in guest kernel. Suggested-by: Andy Shevchenko [Use pcim_* API. - Andy] Signed-off-by: Peng Hao --- drivers/misc/pvpanic.c | 72 -- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c index f84ed30..c30bf62 100644 --- a/drivers/misc/pvpanic.c +++ b/drivers/misc/pvpanic.c @@ -13,9 +13,12 @@ #include #include #include +#include #include #include +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 static void __iomem *base; #define PVPANIC_PANICKED(1 << 0) @@ -172,12 +175,76 @@ 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 ret; + + ret = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + ret = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); + if (ret) + return ret; + + base = pcim_iomap_table(pdev)[0]; + + atomic_notifier_chain_register(_notifier_list, + _panic_nb); + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + atomic_notifier_chain_unregister(_notifier_list, +_panic_nb); +} + +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_driver(void) +{ + return pci_register_driver(_pci_driver); +} + +static void pvpanic_unregister_pci_driver(void) +{ + pci_unregister_driver(_pci_driver); +} +#else +static int pvpanic_register_pci_driver(void) +{ + return 0; +} + +static void pvpanic_unregister_pci_driver(void) {} +#endif + static int __init pvpanic_mmio_init(void) { + int r1, r2; + if (acpi_disabled) - return platform_driver_register(_mmio_driver); + r1 = platform_driver_register(_mmio_driver); + else + r1 = pvpanic_register_acpi_driver(); + r2 = pvpanic_register_pci_driver(); + 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 +253,7 @@ static void __exit pvpanic_mmio_exit(void) platform_driver_unregister(_mmio_driver); else pvpanic_unregister_acpi_driver(); + pvpanic_unregister_pci_driver(); } module_init(pvpanic_mmio_init); -- 1.8.3.1
[PATCH RESEND V5 3/3] misc/pvpanic : add pci dependency in Kconfig
Add PCI dependency for pvpanic in Kconfig. Signed-off-by: Peng Hao --- 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
[PATCH V5 3/3] misc/pvpanic : add pci dependency in Kconfig
Add PCI dependency for pvpanic in Kconfig. Signed-off-by: Peng Hao --- 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
[PATCH V5 1/3] misc/pvpanic: return 0 for empty body register function
Return 0 for empty body register function normally. Signed-off-by: Peng Hao --- v4 --> v5 : handle all typo "drvier/driver" in funtion name. v3 --> v4 : use pcim* function instead of pci* function. handle typo "drvier/driver" in funtion name. v2 --> v3 : handle a uninitialized variable in some path. v2 --> v1 : arch=sh don't support pci, adjust CONFIG_PCI macro. v1 : QEMU community requires additional PCI devices to simulate PVPANIC devices so that some architectures can not occupy precious less than 4G of memory space. 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
[PATCH V5 2/3] misc/pvpanic : add pci interface for pvpanic
Support pvpanic as a pci device in guest kernel. Signed-off-by: Peng Hao --- drivers/misc/pvpanic.c | 72 -- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c index f84ed30..c30bf62 100644 --- a/drivers/misc/pvpanic.c +++ b/drivers/misc/pvpanic.c @@ -13,9 +13,12 @@ #include #include #include +#include #include #include +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 static void __iomem *base; #define PVPANIC_PANICKED(1 << 0) @@ -172,12 +175,76 @@ 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 ret; + + ret = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + ret = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); + if (ret) + return ret; + + base = pcim_iomap_table(pdev)[0]; + + atomic_notifier_chain_register(_notifier_list, + _panic_nb); + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + atomic_notifier_chain_unregister(_notifier_list, +_panic_nb); +} + +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_driver(void) +{ + return pci_register_driver(_pci_driver); +} + +static void pvpanic_unregister_pci_driver(void) +{ + pci_unregister_driver(_pci_driver); +} +#else +static int pvpanic_register_pci_driver(void) +{ + return 0; +} + +static void pvpanic_unregister_pci_driver(void) {} +#endif + static int __init pvpanic_mmio_init(void) { + int r1, r2; + if (acpi_disabled) - return platform_driver_register(_mmio_driver); + r1 = platform_driver_register(_mmio_driver); + else + r1 = pvpanic_register_acpi_driver(); + r2 = pvpanic_register_pci_driver(); + 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 +253,7 @@ static void __exit pvpanic_mmio_exit(void) platform_driver_unregister(_mmio_driver); else pvpanic_unregister_acpi_driver(); + pvpanic_unregister_pci_driver(); } module_init(pvpanic_mmio_init); -- 1.8.3.1
[PATCH V4 3/3] misc/pvpanic : add pci dependency in Kconfig
Add PCI dependency for pvpanic in Kconfig. Signed-off-by: Peng Hao --- 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
[PATCH V4 2/3] misc/pvpanic : add pci interface for pvpanic
Support pvpanic as a pci device in guest kernel. Signed-off-by: Peng Hao --- drivers/misc/pvpanic.c | 72 -- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c index f84ed30..c30bf62 100644 --- a/drivers/misc/pvpanic.c +++ b/drivers/misc/pvpanic.c @@ -13,9 +13,12 @@ #include #include #include +#include #include #include +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 static void __iomem *base; #define PVPANIC_PANICKED(1 << 0) @@ -172,12 +175,76 @@ 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 ret; + + ret = pcim_enable_device(pdev); + if (ret < 0) + return ret; + + ret = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); + if (ret) + return ret; + + base = pcim_iomap_table(pdev)[0]; + + atomic_notifier_chain_register(_notifier_list, + _panic_nb); + return 0; +} + +static void pvpanic_pci_remove(struct pci_dev *pdev) +{ + atomic_notifier_chain_unregister(_notifier_list, +_panic_nb); +} + +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_driver(void) +{ + return pci_register_driver(_pci_driver); +} + +static void pvpanic_unregister_pci_driver(void) +{ + pci_unregister_driver(_pci_driver); +} +#else +static int pvpanic_register_pci_driver(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(_mmio_driver); + r1 = platform_driver_register(_mmio_driver); + else + r1 = pvpanic_register_acpi_driver(); + r2 = pvpanic_register_pci_driver(); + 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 +253,7 @@ static void __exit pvpanic_mmio_exit(void) platform_driver_unregister(_mmio_driver); else pvpanic_unregister_acpi_driver(); + pvpanic_unregister_pci_driver(); } module_init(pvpanic_mmio_init); -- 1.8.3.1
[PATCH V4 1/3] misc/pvpanic: return 0 for empty body register function
Return 0 for empty body register function normally. Signed-off-by: Peng Hao --- QEMU community requires additional PCI devices to simulate PVPANIC devices so that some architectures can not occupy precious less than 4G of memory space. 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
[PATCH V3 2/3] misc/pvpanic : add pci interface for pvpanic
Support pvpanic as a pci device in guest kernel. Signed-off-by: Peng Hao --- 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 #include #include +#include #include #include 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 "); @@ -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(_notifier_list, + _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(_notifier_list, +_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(_pci_driver); +} + +static void pvpanic_unregister_pci_drvier(void) +{ + pci_unregister_driver(_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(_mmio_driver); + r1 = platform_driver_register(_mmio_driver); + else + r1 = 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(_mmio_driver); else pvpanic_unregister_acpi_driver(); + pvpanic_unregister_pci_drvier(); } module_init(pvpanic_mmio_init); -- 1.8.3.1
[PATCH V3 1/3] misc/pvpanic: return 0 for empty body register function
Return 0 for empty body register function normally. Signed-off-by: Peng Hao --- 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
[PATCH V3 3/3] misc/pvpanic : add pci dependency in Kconfig
Add PCI dependency for pvpanic in Kconfig. Signed-off-by: Peng Hao --- 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
[PATCH V2 2/3] misc/pvpanic : add pci interface for pvpanic
Support pvpanic as a pci device in guest kernel. Signed-off-by: Peng Hao --- 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 #include #include +#include #include #include 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 "); @@ -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(_notifier_list, + _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(_notifier_list, +_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(_pci_driver); +} + +static void pvpanic_unregister_pci_drvier(void) +{ + pci_unregister_driver(_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(_mmio_driver); + r1 = platform_driver_register(_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(_mmio_driver); else pvpanic_unregister_acpi_driver(); + pvpanic_unregister_pci_drvier(); } module_init(pvpanic_mmio_init); -- 1.8.3.1
[PATCH V2 1/3] misc/pvpanic: return 0 for empty body register function
Return 0 for empty body register function normally. Signed-off-by: Peng Hao --- 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
[PATCH V2 3/3] misc/pvpanic : add pci dependency in Kconfig
Add PCI dependency for pvpanic in Kconfig. Signed-off-by: Peng Hao --- 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
[PATCH 1/3] misc/pvpanic: return 0 for empty body register function
Return 0 for empty body register function normally. Signed-off-by: Peng Hao --- 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
[PATCH 2/3] misc/pvpanic : add pci interface for pvpanic
Support pvpanic as a pci device in guest kernel. Signed-off-by: Peng Hao --- drivers/misc/pvpanic.c | 67 -- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c index f84ed30..1fae67e 100644 --- a/drivers/misc/pvpanic.c +++ b/drivers/misc/pvpanic.c @@ -13,11 +13,14 @@ #include #include #include +#include #include #include 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 "); @@ -172,12 +175,71 @@ 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(_notifier_list, + _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(_notifier_list, +_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, +}; + +#endif /* CONFIG_PCI */ + static int __init pvpanic_mmio_init(void) { + int r1, r2; + if (acpi_disabled) - return platform_driver_register(_mmio_driver); + r1 = platform_driver_register(_mmio_driver); + else + r1 = pvpanic_register_acpi_driver(); + r2 = pci_register_driver(_pci_driver); + + 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 +248,7 @@ static void __exit pvpanic_mmio_exit(void) platform_driver_unregister(_mmio_driver); else pvpanic_unregister_acpi_driver(); + pci_unregister_driver(_pci_driver); } module_init(pvpanic_mmio_init); -- 1.8.3.1
[PATCH 3/3] misc/pvpanic : add pci dependency in Kconfig
Add PCI dependency for pvpanic in Kconfig. Signed-off-by: Peng Hao --- 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
[RESEND PATCH] kvm: svm: remove unused struct definition
structure svm_init_data is never used. So remove it. Signed-off-by: Peng Hao --- arch/x86/kvm/svm.c | 5 - 1 file changed, 5 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 61ccfb1..5c7dc8b 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -675,11 +675,6 @@ struct svm_cpu_data { static DEFINE_PER_CPU(struct svm_cpu_data *, svm_data); -struct svm_init_data { - int cpu; - int r; -}; - static const u32 msrpm_ranges[] = {0, 0xc000, 0xc001}; #define NUM_MSR_MAPS ARRAY_SIZE(msrpm_ranges) -- 1.8.3.1
[PATCH V3] kvm:x86 :remove unnecessary recalculate_apic_map
In the previous code, the variable apic_sw_disabled influences recalculate_apic_map. But in "KVM: x86: simplify kvm_apic_map" (commit:3b5a5ffa928a3f875b0d5dd284eeb7c322e1688a), the access to apic_sw_disabled in recalculate_apic_map has been deleted. Signed-off-by: Peng Hao --- arch/x86/kvm/lapic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index fbb0e6d..a11fbf9 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -246,10 +246,9 @@ static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val) if (enabled != apic->sw_enabled) { apic->sw_enabled = enabled; - if (enabled) { + if (enabled) static_key_slow_dec_deferred(_sw_disabled); - recalculate_apic_map(apic->vcpu->kvm); - } else + else static_key_slow_inc(_sw_disabled.key); } } -- 1.8.3.1
[PATCH V3] kvm:x86 :remove unnecessary recalculate_apic_map
In the previous code, the variable apic_sw_disabled influences recalculate_apic_map. But in "KVM: x86: simplify kvm_apic_map" (commit:3b5a5ffa928a3f875b0d5dd284eeb7c322e1688a), the access to apic_sw_disabled in recalculate_apic_map has been deleted. Signed-off-by: Peng Hao --- arch/x86/kvm/lapic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index fbb0e6d..a11fbf9 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -246,10 +246,9 @@ static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val) if (enabled != apic->sw_enabled) { apic->sw_enabled = enabled; - if (enabled) { + if (enabled) static_key_slow_dec_deferred(_sw_disabled); - recalculate_apic_map(apic->vcpu->kvm); - } else + else static_key_slow_inc(_sw_disabled.key); } } -- 1.8.3.1
[PATCH] tick/broadcast: beautify code for removing redundancy statement
Remove redundant "ret = 0" statment which was previously initialized to 0. Signed-off-by: Peng Hao --- kernel/time/tick-broadcast.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index aa2094d..311ee7c 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c @@ -209,7 +209,6 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu) * caller initialize the device. */ tick_broadcast_clear_oneshot(cpu); - ret = 0; break; case TICKDEV_MODE_PERIODIC: -- 1.8.3.1
[PATCH] tick/broadcast: beautify code for removing redundancy statement
Remove redundant "ret = 0" statment which was previously initialized to 0. Signed-off-by: Peng Hao --- kernel/time/tick-broadcast.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index aa2094d..311ee7c 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c @@ -209,7 +209,6 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu) * caller initialize the device. */ tick_broadcast_clear_oneshot(cpu); - ret = 0; break; case TICKDEV_MODE_PERIODIC: -- 1.8.3.1
[PATCH] misc/pvpanic: resolve compile errors for arch=um
Resolve compile error for arch=um pvpanic.c:(.text+0xb6): undefined reference to `devm_ioremap_resource' Signed-off-by: Peng Hao --- drivers/misc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 642626a..f417b06 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -515,7 +515,7 @@ config MISC_RTSX config PVPANIC tristate "pvpanic device support" - depends on ACPI || OF + 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 -- 1.8.3.1
[PATCH] misc/pvpanic: resolve compile errors for arch=um
Resolve compile error for arch=um pvpanic.c:(.text+0xb6): undefined reference to `devm_ioremap_resource' Signed-off-by: Peng Hao --- drivers/misc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 642626a..f417b06 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -515,7 +515,7 @@ config MISC_RTSX config PVPANIC tristate "pvpanic device support" - depends on ACPI || OF + 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 -- 1.8.3.1