linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]  arm64/pvpanic-mmio : add pvpanic mmio device
@ 2018-10-17 10:08 Peng Hao
  2018-10-17 11:38 ` Mark Rutland
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Hao @ 2018-10-17 10:08 UTC (permalink / raw)
  To: catalin.marinas, will.deacon; +Cc: linux-kernel, Peng Hao

Add a platform device driver, pvpanic-mmio that is similar
to x86's pvpanic device.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 drivers/platform/Kconfig            |   3 +
 drivers/platform/Makefile           |   1 +
 drivers/platform/arm/Kconfig        |   6 ++
 drivers/platform/arm/Makefile       |   6 ++
 drivers/platform/arm/pvpanic-mmio.c | 123 ++++++++++++++++++++++++++++++++++++
 5 files changed, 139 insertions(+)
 create mode 100644 drivers/platform/arm/Kconfig
 create mode 100644 drivers/platform/arm/Makefile
 create mode 100644 drivers/platform/arm/pvpanic-mmio.c

diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig
index d4c2e42..8b64b78 100644
--- a/drivers/platform/Kconfig
+++ b/drivers/platform/Kconfig
@@ -1,3 +1,6 @@
+if ARM64
+source "drivers/platform/arm/Kconfig"
+endif
 if X86
 source "drivers/platform/x86/Kconfig"
 endif
diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile
index 4b2ce58..232231c 100644
--- a/drivers/platform/Makefile
+++ b/drivers/platform/Makefile
@@ -3,6 +3,7 @@
 # Makefile for linux/drivers/platform
 #
 
+obj-$(CONFIG_ARM64)               += arm/
 obj-$(CONFIG_X86)		+= x86/
 obj-$(CONFIG_MELLANOX_PLATFORM)	+= mellanox/
 obj-$(CONFIG_MIPS)		+= mips/
diff --git a/drivers/platform/arm/Kconfig b/drivers/platform/arm/Kconfig
new file mode 100644
index 0000000..89fd694
--- /dev/null
+++ b/drivers/platform/arm/Kconfig
@@ -0,0 +1,6 @@
+config PVPANIC_MMIO
+        tristate "pvpanic mmio device support"
+        help
+          This driver provides support for the pvpanic mmio device. pvpanic mmio
+          is a paravirtualized device provided by QEMU; it lets a virtual machine
+          (guest) communicate panic events to the host.
diff --git a/drivers/platform/arm/Makefile b/drivers/platform/arm/Makefile
new file mode 100644
index 0000000..a68af01
--- /dev/null
+++ b/drivers/platform/arm/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for linux/drivers/platform/arm
+# arm Platform-Specific Drivers
+#
+obj-$(CONFIG_PVPANIC_MMIO) = pvpanic-mmio.o
diff --git a/drivers/platform/arm/pvpanic-mmio.c b/drivers/platform/arm/pvpanic-mmio.c
new file mode 100644
index 0000000..6a06d24
--- /dev/null
+++ b/drivers/platform/arm/pvpanic-mmio.c
@@ -0,0 +1,123 @@
+/*
+ * pvpanic mmio device driver
+ *
+ * Copyright (C) 2018 ZTE Ltd.
+ * Author: Peng Hao <peng.hao2@zte.com.cn>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <asm/virt.h>
+#include <linux/platform_device.h>
+
+#define PVPANIC_MMIO_CRASHED	(1 << 0)
+
+struct pvpanic_mmio_device {
+	void __iomem *base;
+};
+
+static struct pvpanic_mmio_device pvpanic_mmio_dev;
+
+static void
+pvpanic_mmio_trigger_event(unsigned int event)
+{
+	writeb(event, pvpanic_mmio_dev.base);
+}
+
+static int
+pvpanic_mmio_crash_notify(struct notifier_block *nb, unsigned long code,
+			void *unused)
+{
+	pvpanic_mmio_trigger_event(PVPANIC_MMIO_CRASHED);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block pvpanic_mmio_crash_nb = {
+	.notifier_call = pvpanic_mmio_crash_notify,
+	.priority = 1,
+};
+
+static int pvpanic_mmio_probe(struct platform_device *pdev)
+{
+	struct resource *mem;
+
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!mem)
+		return -EINVAL;
+
+	if (!devm_request_mem_region(&pdev->dev, mem->start,
+				resource_size(mem), pdev->name))
+		return -EBUSY;
+
+	pvpanic_mmio_dev.base = devm_ioremap(&pdev->dev, mem->start,
+										resource_size(mem));
+	if (pvpanic_mmio_dev.base == NULL)
+		return -EFAULT;
+
+	platform_set_drvdata(pdev, &pvpanic_mmio_dev);
+
+	atomic_notifier_chain_register(&panic_notifier_list,
+								  &pvpanic_mmio_crash_nb);
+
+	return 0;
+}
+
+
+static int pvpanic_mmio_remove(struct platform_device *pdev)
+{
+
+	atomic_notifier_chain_unregister(&panic_notifier_list,
+					&pvpanic_mmio_crash_nb);
+	devm_kfree(&pdev->dev, &pvpanic_mmio_dev);
+	return 0;
+}
+
+static const struct of_device_id pvpanic_mmio_match[] = {
+	{ .compatible = "pvpanic,mmio", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, pvpanic_mmio_match);
+
+static struct platform_driver pvpanic_mmio_driver = {
+	.probe =        pvpanic_mmio_probe,
+	.remove =       pvpanic_mmio_remove,
+	.driver = {
+		.name =	"pvpanic-mmio",
+		.of_match_table = pvpanic_mmio_match,
+	},
+};
+
+static int __init pvpanic_mmio_init(void)
+{
+	return platform_driver_register(&pvpanic_mmio_driver);
+}
+
+static void __exit pvpanic_mmio_exit(void)
+{
+	platform_driver_unregister(&pvpanic_mmio_driver);
+}
+
+module_init(pvpanic_mmio_init);
+module_exit(pvpanic_mmio_exit);
+
+MODULE_AUTHOR("Peng Hao<peng.hao2@zte.com.cn>");
+MODULE_DESCRIPTION("pvpanic mmio device driver");
+MODULE_LICENSE("GPL");
-- 
1.8.3.1


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

* Re: [PATCH]  arm64/pvpanic-mmio : add pvpanic mmio device
  2018-10-17 10:08 [PATCH] arm64/pvpanic-mmio : add pvpanic mmio device Peng Hao
@ 2018-10-17 11:38 ` Mark Rutland
       [not found]   ` <201810180956117739833@zte.com.cn>
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Rutland @ 2018-10-17 11:38 UTC (permalink / raw)
  To: Peng Hao; +Cc: catalin.marinas, will.deacon, linux-kernel, devicetree, nd

Hi,

[adding devicetree]

On Wed, Oct 17, 2018 at 06:08:23PM +0800, Peng Hao wrote:
> Add a platform device driver, pvpanic-mmio that is similar
> to x86's pvpanic device.

It would be worth noting in the commit message that this is a
QEMU-specific device.

Is this already in upstream QEMU?

> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> ---
>  drivers/platform/Kconfig            |   3 +
>  drivers/platform/Makefile           |   1 +
>  drivers/platform/arm/Kconfig        |   6 ++
>  drivers/platform/arm/Makefile       |   6 ++
>  drivers/platform/arm/pvpanic-mmio.c | 123 ++++++++++++++++++++++++++++++++++++
>  5 files changed, 139 insertions(+)
>  create mode 100644 drivers/platform/arm/Kconfig
>  create mode 100644 drivers/platform/arm/Makefile
>  create mode 100644 drivers/platform/arm/pvpanic-mmio.c

If this is an MMIO device, why does this need to be specific to arm?

Surely *any* architecture could use this?

> 
> diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig
> index d4c2e42..8b64b78 100644
> --- a/drivers/platform/Kconfig
> +++ b/drivers/platform/Kconfig
> @@ -1,3 +1,6 @@
> +if ARM64
> +source "drivers/platform/arm/Kconfig"
> +endif
>  if X86
>  source "drivers/platform/x86/Kconfig"
>  endif
> diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile
> index 4b2ce58..232231c 100644
> --- a/drivers/platform/Makefile
> +++ b/drivers/platform/Makefile
> @@ -3,6 +3,7 @@
>  # Makefile for linux/drivers/platform
>  #
>  
> +obj-$(CONFIG_ARM64)               += arm/
>  obj-$(CONFIG_X86)		+= x86/
>  obj-$(CONFIG_MELLANOX_PLATFORM)	+= mellanox/
>  obj-$(CONFIG_MIPS)		+= mips/
> diff --git a/drivers/platform/arm/Kconfig b/drivers/platform/arm/Kconfig
> new file mode 100644
> index 0000000..89fd694
> --- /dev/null
> +++ b/drivers/platform/arm/Kconfig
> @@ -0,0 +1,6 @@
> +config PVPANIC_MMIO
> +        tristate "pvpanic mmio device support"
> +        help
> +          This driver provides support for the pvpanic mmio device. pvpanic mmio
> +          is a paravirtualized device provided by QEMU; it lets a virtual machine
> +          (guest) communicate panic events to the host.
> diff --git a/drivers/platform/arm/Makefile b/drivers/platform/arm/Makefile
> new file mode 100644
> index 0000000..a68af01
> --- /dev/null
> +++ b/drivers/platform/arm/Makefile
> @@ -0,0 +1,6 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Makefile for linux/drivers/platform/arm
> +# arm Platform-Specific Drivers
> +#
> +obj-$(CONFIG_PVPANIC_MMIO) = pvpanic-mmio.o
> diff --git a/drivers/platform/arm/pvpanic-mmio.c b/drivers/platform/arm/pvpanic-mmio.c
> new file mode 100644
> index 0000000..6a06d24
> --- /dev/null
> +++ b/drivers/platform/arm/pvpanic-mmio.c
> @@ -0,0 +1,123 @@
> +/*
> + * pvpanic mmio device driver
> + *
> + * Copyright (C) 2018 ZTE Ltd.
> + * Author: Peng Hao <peng.hao2@zte.com.cn>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/types.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <asm/virt.h>
> +#include <linux/platform_device.h>
> +
> +#define PVPANIC_MMIO_CRASHED	(1 << 0)

This looks like it's identical to PVPANIC_PANICKED in the existing ACPI
IO pvpanic driver.

I suspect on the QEMU side, there's one device, and the distinction is
only in how this is described.

Can't one driver support both?

> +
> +struct pvpanic_mmio_device {
> +	void __iomem *base;
> +};
> +
> +static struct pvpanic_mmio_device pvpanic_mmio_dev;
> +
> +static void
> +pvpanic_mmio_trigger_event(unsigned int event)
> +{
> +	writeb(event, pvpanic_mmio_dev.base);
> +}
> +
> +static int
> +pvpanic_mmio_crash_notify(struct notifier_block *nb, unsigned long code,
> +			void *unused)
> +{
> +	pvpanic_mmio_trigger_event(PVPANIC_MMIO_CRASHED);
> +	return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block pvpanic_mmio_crash_nb = {
> +	.notifier_call = pvpanic_mmio_crash_notify,
> +	.priority = 1,
> +};
> +
> +static int pvpanic_mmio_probe(struct platform_device *pdev)
> +{
> +	struct resource *mem;
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!mem)
> +		return -EINVAL;
> +
> +	if (!devm_request_mem_region(&pdev->dev, mem->start,
> +				resource_size(mem), pdev->name))
> +		return -EBUSY;
> +
> +	pvpanic_mmio_dev.base = devm_ioremap(&pdev->dev, mem->start,
> +										resource_size(mem));
> +	if (pvpanic_mmio_dev.base == NULL)
> +		return -EFAULT;
> +
> +	platform_set_drvdata(pdev, &pvpanic_mmio_dev);
> +
> +	atomic_notifier_chain_register(&panic_notifier_list,
> +								  &pvpanic_mmio_crash_nb);
> +
> +	return 0;
> +}
> +
> +
> +static int pvpanic_mmio_remove(struct platform_device *pdev)
> +{
> +
> +	atomic_notifier_chain_unregister(&panic_notifier_list,
> +					&pvpanic_mmio_crash_nb);
> +	devm_kfree(&pdev->dev, &pvpanic_mmio_dev);
> +	return 0;
> +}
> +
> +static const struct of_device_id pvpanic_mmio_match[] = {
> +	{ .compatible = "pvpanic,mmio", },
> +	{},
> +};

This should be "qemu,pvpanic-mmio"; "pvpanic" is not the vendor.

This should also have a binding document somewhere.

Thanks,
Mark.

> +MODULE_DEVICE_TABLE(of, pvpanic_mmio_match);
> +
> +static struct platform_driver pvpanic_mmio_driver = {
> +	.probe =        pvpanic_mmio_probe,
> +	.remove =       pvpanic_mmio_remove,
> +	.driver = {
> +		.name =	"pvpanic-mmio",
> +		.of_match_table = pvpanic_mmio_match,
> +	},
> +};
> +
> +static int __init pvpanic_mmio_init(void)
> +{
> +	return platform_driver_register(&pvpanic_mmio_driver);
> +}
> +
> +static void __exit pvpanic_mmio_exit(void)
> +{
> +	platform_driver_unregister(&pvpanic_mmio_driver);
> +}
> +
> +module_init(pvpanic_mmio_init);
> +module_exit(pvpanic_mmio_exit);
> +
> +MODULE_AUTHOR("Peng Hao<peng.hao2@zte.com.cn>");
> +MODULE_DESCRIPTION("pvpanic mmio device driver");
> +MODULE_LICENSE("GPL");
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH]  arm64/pvpanic-mmio : add pvpanic mmio device
       [not found]   ` <201810180956117739833@zte.com.cn>
@ 2018-10-18 14:43     ` Mark Rutland
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Rutland @ 2018-10-18 14:43 UTC (permalink / raw)
  To: peng.hao2; +Cc: catalin.marinas, will.deacon, linux-kernel, devicetree, nd

On Thu, Oct 18, 2018 at 09:56:11AM +0800, peng.hao2@zte.com.cn wrote:
> >Hi,
> >
> >[adding devicetree]
> >
> >On Wed, Oct 17, 2018 at 06:08:23PM +0800, Peng Hao wrote:

[...]

> >> +#define PVPANIC_MMIO_CRASHED    (1 << 0)
> >
> >This looks like it's identical to PVPANIC_PANICKED in the existing ACPI
> >IO pvpanic driver.
> >
> >I suspect on the QEMU side, there's one device, and the distinction is
> >only in how this is described.
> >
> in qemu:
> Firstly pvpanic(x86) use ioport, but arm don't support ioport.
> secondly pvpanic device is emulated as a isa bus device, but arm don't support
> isa bus.

I am aware of arm platforms with an ISA bus (well, LPC, at least).

> thirdly the realization of pvpanic device is depends on ACPI in linux
> kernel driver and in qemu the port info is passed through ACPI , but
> It is not necessary to configure ACPI for arm guest.

There are many people using ACPI with arm64 under QEMU, so while it's
not *necessary* to use ACPI, it is a common use case that we cannot rule
out.

> in linux : I don't want to depends on ACPI .

I'm not saying that you must depend on ACPI for your specific use-case.

> ARM virt machine  in qemu uses FDT, and I can easily 
> use FDT to get mmio information from QEMU. 
> >Can't one driver support both?
> Just like  virtio-mmio driver, It is mainly used for non x86 architecture.

So? I can build virtio-mmio for x86, too.

My concern is that other than the initial probing, the vast majority of
this is *identical* to the existing pvpanic driver (ignoring cosmetic
differences like the naming of variables).

I'm worried that there could be additions to the pvpanic device in
future (e.g. passing a pointer to some crash context), which would then
have to be duplicated across two drivers.

IMO we should:

a) Move the existing pvpanic driver to a neutral location (e.g.
   drivers/virt/qemu_pvpanic.c).

b) Teach the existing pvpanic driver to handle MMIO, even for ACPI.

c) Teach the existing pvpanic driver to handle DT, even if that DT
   binding only caters for MMIO.

Thanks,
Mark.

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

* [PATCH]  arm64/pvpanic-mmio : add pvpanic mmio device
@ 2018-10-17  8:32 Peng Hao
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Hao @ 2018-10-17  8:32 UTC (permalink / raw)
  To: catalin.marinas, will.deacon; +Cc: linux-kernel, 彭浩10096742

From: 彭浩10096742 <peng.hao2@zte.com.cn>

Add a platform device driver, pvpanic-mmio that is similar
to x86's pvpanic device.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 drivers/platform/Kconfig            |   3 +
 drivers/platform/Makefile           |   1 +
 drivers/platform/arm/Kconfig        |   6 ++
 drivers/platform/arm/Makefile       |   6 ++
 drivers/platform/arm/pvpanic-mmio.c | 123 ++++++++++++++++++++++++++++++++++++
 5 files changed, 139 insertions(+)
 create mode 100644 drivers/platform/arm/Kconfig
 create mode 100644 drivers/platform/arm/Makefile
 create mode 100644 drivers/platform/arm/pvpanic-mmio.c

diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig
index d4c2e42..8b64b78 100644
--- a/drivers/platform/Kconfig
+++ b/drivers/platform/Kconfig
@@ -1,3 +1,6 @@
+if ARM64
+source "drivers/platform/arm/Kconfig"
+endif
 if X86
 source "drivers/platform/x86/Kconfig"
 endif
diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile
index 4b2ce58..232231c 100644
--- a/drivers/platform/Makefile
+++ b/drivers/platform/Makefile
@@ -3,6 +3,7 @@
 # Makefile for linux/drivers/platform
 #
 
+obj-$(CONFIG_ARM64)               += arm/
 obj-$(CONFIG_X86)		+= x86/
 obj-$(CONFIG_MELLANOX_PLATFORM)	+= mellanox/
 obj-$(CONFIG_MIPS)		+= mips/
diff --git a/drivers/platform/arm/Kconfig b/drivers/platform/arm/Kconfig
new file mode 100644
index 0000000..89fd694
--- /dev/null
+++ b/drivers/platform/arm/Kconfig
@@ -0,0 +1,6 @@
+config PVPANIC_MMIO
+        tristate "pvpanic mmio device support"
+        help
+          This driver provides support for the pvpanic mmio device. pvpanic mmio
+          is a paravirtualized device provided by QEMU; it lets a virtual machine
+          (guest) communicate panic events to the host.
diff --git a/drivers/platform/arm/Makefile b/drivers/platform/arm/Makefile
new file mode 100644
index 0000000..a68af01
--- /dev/null
+++ b/drivers/platform/arm/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for linux/drivers/platform/arm
+# arm Platform-Specific Drivers
+#
+obj-$(CONFIG_PVPANIC_MMIO) = pvpanic-mmio.o
diff --git a/drivers/platform/arm/pvpanic-mmio.c b/drivers/platform/arm/pvpanic-mmio.c
new file mode 100644
index 0000000..6a06d24
--- /dev/null
+++ b/drivers/platform/arm/pvpanic-mmio.c
@@ -0,0 +1,123 @@
+/*
+ * pvpanic mmio device driver
+ *
+ * Copyright (C) 2018 ZTE Ltd.
+ * Author: Peng Hao <peng.hao2@zte.com.cn>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <asm/virt.h>
+#include <linux/platform_device.h>
+
+#define PVPANIC_MMIO_CRASHED	(1 << 0)
+
+struct pvpanic_mmio_device {
+	void __iomem *base;
+};
+
+static struct pvpanic_mmio_device pvpanic_mmio_dev;
+
+static void
+pvpanic_mmio_trigger_event(unsigned int event)
+{
+	writeb(event, pvpanic_mmio_dev.base);
+}
+
+static int
+pvpanic_mmio_crash_notify(struct notifier_block *nb, unsigned long code,
+			void *unused)
+{
+	pvpanic_mmio_trigger_event(PVPANIC_MMIO_CRASHED);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block pvpanic_mmio_crash_nb = {
+	.notifier_call = pvpanic_mmio_crash_notify,
+	.priority = 1,
+};
+
+static int pvpanic_mmio_probe(struct platform_device *pdev)
+{
+	struct resource *mem;
+
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!mem)
+		return -EINVAL;
+
+	if (!devm_request_mem_region(&pdev->dev, mem->start,
+				resource_size(mem), pdev->name))
+		return -EBUSY;
+
+	pvpanic_mmio_dev.base = devm_ioremap(&pdev->dev, mem->start,
+										resource_size(mem));
+	if (pvpanic_mmio_dev.base == NULL)
+		return -EFAULT;
+
+	platform_set_drvdata(pdev, &pvpanic_mmio_dev);
+
+	atomic_notifier_chain_register(&panic_notifier_list,
+								  &pvpanic_mmio_crash_nb);
+
+	return 0;
+}
+
+
+static int pvpanic_mmio_remove(struct platform_device *pdev)
+{
+
+	atomic_notifier_chain_unregister(&panic_notifier_list,
+					&pvpanic_mmio_crash_nb);
+	devm_kfree(&pdev->dev, &pvpanic_mmio_dev);
+	return 0;
+}
+
+static const struct of_device_id pvpanic_mmio_match[] = {
+	{ .compatible = "pvpanic,mmio", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, pvpanic_mmio_match);
+
+static struct platform_driver pvpanic_mmio_driver = {
+	.probe =        pvpanic_mmio_probe,
+	.remove =       pvpanic_mmio_remove,
+	.driver = {
+		.name =	"pvpanic-mmio",
+		.of_match_table = pvpanic_mmio_match,
+	},
+};
+
+static int __init pvpanic_mmio_init(void)
+{
+	return platform_driver_register(&pvpanic_mmio_driver);
+}
+
+static void __exit pvpanic_mmio_exit(void)
+{
+	platform_driver_unregister(&pvpanic_mmio_driver);
+}
+
+module_init(pvpanic_mmio_init);
+module_exit(pvpanic_mmio_exit);
+
+MODULE_AUTHOR("Peng Hao<peng.hao2@zte.com.cn>");
+MODULE_DESCRIPTION("pvpanic mmio device driver");
+MODULE_LICENSE("GPL");
-- 
1.8.3.1


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

end of thread, other threads:[~2018-10-18 14:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-17 10:08 [PATCH] arm64/pvpanic-mmio : add pvpanic mmio device Peng Hao
2018-10-17 11:38 ` Mark Rutland
     [not found]   ` <201810180956117739833@zte.com.cn>
2018-10-18 14:43     ` Mark Rutland
  -- strict thread matches above, loose matches on Subject: below --
2018-10-17  8:32 Peng Hao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).