From: Greg KH <gregkh@linuxfoundation.org>
To: Mihai Carabas <mihai.carabas@oracle.com>
Cc: linux-kernel@vger.kernel.org, arnd@arndb.de,
bobo.shaobowang@huawei.com, rdunlap@infradead.org
Subject: Re: [PATCH v5 3/3] misc/pvpanic: add PCI driver
Date: Tue, 16 Mar 2021 17:48:37 +0100 [thread overview]
Message-ID: <YFDhZbRYE5szZ4l/@kroah.com> (raw)
In-Reply-To: <1615897229-4055-4-git-send-email-mihai.carabas@oracle.com>
On Tue, Mar 16, 2021 at 02:20:29PM +0200, Mihai Carabas wrote:
> Add support for pvpanic PCI device added in qemu [1]. At probe time, obtain the
> address where to read/write pvpanic events and pass it to the generic handling
> code. Will follow the same logic as pvpanic MMIO device driver. At remove time,
> unmap base address and disable PCI device.
>
> [1] https://github.com/qemu/qemu/commit/9df52f58e76e904fb141b10318362d718f470db2
>
> Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
> ---
> drivers/misc/pvpanic/Kconfig | 6 +++
> drivers/misc/pvpanic/Makefile | 1 +
> drivers/misc/pvpanic/pvpanic-pci.c | 102 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 109 insertions(+)
> create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c
>
> diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
> index 454f1ee..9a081ed 100644
> --- a/drivers/misc/pvpanic/Kconfig
> +++ b/drivers/misc/pvpanic/Kconfig
> @@ -17,3 +17,9 @@ config PVPANIC_MMIO
> depends on HAS_IOMEM && (ACPI || OF) && PVPANIC
> help
> This driver provides support for the MMIO pvpanic device.
> +
> +config PVPANIC_PCI
> + tristate "pvpanic PCI device support"
> + depends on PCI && PVPANIC
> + help
> + This driver provides support for the PCI pvpanic device.
Please provide a bit more information here.
> diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile
> index e12a2dc..9471df7 100644
> --- a/drivers/misc/pvpanic/Makefile
> +++ b/drivers/misc/pvpanic/Makefile
> @@ -5,3 +5,4 @@
> # Copyright (C) 2021 Oracle.
> #
> obj-$(CONFIG_PVPANIC_MMIO) += pvpanic.o pvpanic-mmio.o
> +obj-$(CONFIG_PVPANIC_PCI) += pvpanic.o pvpanic-pci.o
> diff --git a/drivers/misc/pvpanic/pvpanic-pci.c b/drivers/misc/pvpanic/pvpanic-pci.c
> new file mode 100644
> index 00000000..27526d3
> --- /dev/null
> +++ b/drivers/misc/pvpanic/pvpanic-pci.c
> @@ -0,0 +1,102 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Pvpanic PCI Device Support
> + *
> + * Copyright (C) 2021 Oracle.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/pci.h>
> +#include <linux/types.h>
> +#include "pvpanic.h"
> +
> +#define PCI_VENDOR_ID_REDHAT 0x1b36
> +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011
> +
> +static void __iomem *base;
> +static const struct pci_device_id pvpanic_pci_id_tbl[] = {
> + { PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC),},
Why the ")}"?
Shouldn't it just be "}"?
> + {}
> +};
> +static unsigned int capability = PVPANIC_PANICKED | PVPANIC_CRASH_LOADED;
> +static unsigned int events;
> +
> +static ssize_t capability_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + return sysfs_emit(buf, "%x\n", capability);
A global capability for all devices? No, this needs to be a per-device
attttribute as you are showing it to userspace as such.
> +}
> +static DEVICE_ATTR_RO(capability);
> +
> +static ssize_t events_show(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> + return sysfs_emit(buf, "%x\n", events);
Same here, this is not global for the whole module.
> +}
> +
> +static ssize_t events_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + unsigned int tmp;
> + int err;
> +
> + err = kstrtouint(buf, 16, &tmp);
> + if (err)
> + return err;
> +
> + if ((tmp & capability) != tmp)
> + return -EINVAL;
> +
> + events = tmp;
> +
> + pvpanic_set_events(base, events);
> +
> + return count;
> +
> +}
> +static DEVICE_ATTR_RW(events);
> +
> +static struct attribute *pvpanic_pci_dev_attrs[] = {
> + &dev_attr_capability.attr,
> + &dev_attr_events.attr,
> + NULL
> +};
> +ATTRIBUTE_GROUPS(pvpanici_pci_dev);
You did not document these new sysfs files in Documentation/ABI/ so it's
hard to judge what they do. Please do so next version.
thanks,
greg k-h
next prev parent reply other threads:[~2021-03-16 16:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 12:20 [PATCH v5] add support for pci in the pvpanic driver Mihai Carabas
2021-03-16 12:20 ` [PATCH v5 1/3] misc/pvpanic: split-up generic and platform dependent code Mihai Carabas
2021-03-16 16:44 ` Greg KH
2021-03-16 12:20 ` [PATCH v5 2/3] misc/pvpanic: probe multiple instances Mihai Carabas
2021-03-16 16:46 ` Greg KH
2021-03-16 12:20 ` [PATCH v5 3/3] misc/pvpanic: add PCI driver Mihai Carabas
2021-03-16 16:48 ` Greg KH [this message]
2021-03-16 17:08 ` Mihai Carabas
2021-03-16 17:29 ` Greg KH
2021-03-16 18:02 ` Mihai Carabas
2021-03-16 18:16 ` Greg KH
2021-03-17 0:02 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YFDhZbRYE5szZ4l/@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=bobo.shaobowang@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mihai.carabas@oracle.com \
--cc=rdunlap@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome