From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: linuxppc-dev@lists.ozlabs.org
Cc: "Jose Ricardo Ziviani" <joserz@linux.ibm.com>,
"Alexey Kardashevskiy" <aik@ozlabs.ru>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
kvm-ppc@vger.kernel.org,
"Piotr Jaroszynski" <pjaroszynski@nvidia.com>,
"Leonardo Augusto Guimarães Garcia" <lagarcia@br.ibm.com>,
"David Gibson" <david@gibson.dropbear.id.au>
Subject: [PATCH kernel RFC 1/2] vfio_pci: Allow device specific error handlers
Date: Fri, 15 Mar 2019 19:18:34 +1100 [thread overview]
Message-ID: <20190315081835.14083-2-aik@ozlabs.ru> (raw)
In-Reply-To: <20190315081835.14083-1-aik@ozlabs.ru>
PCI device drivers can define own pci_error_handlers which are called
on errors or before/after reset. The VFIO PCI driver defines one as well.
This adds a vfio_pci_error_handlers struct for VFIO PCI which is a wrapper
on top of vfio_err_handlers. At the moment it defines reset_done() -
this hook is called right after the device reset and it can be used to do
some device tweaking before the userspace gets a chance to use the device.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
drivers/vfio/pci/vfio_pci_private.h | 5 +++++
drivers/vfio/pci/vfio_pci.c | 17 +++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h
index 1812cf22fc4f..aff96fa28726 100644
--- a/drivers/vfio/pci/vfio_pci_private.h
+++ b/drivers/vfio/pci/vfio_pci_private.h
@@ -87,8 +87,13 @@ struct vfio_pci_reflck {
struct mutex lock;
};
+struct vfio_pci_error_handlers {
+ void (*reset_done)(struct vfio_pci_device *vdev);
+};
+
struct vfio_pci_device {
struct pci_dev *pdev;
+ struct vfio_pci_error_handlers *error_handlers;
void __iomem *barmap[PCI_STD_RESOURCE_END + 1];
bool bar_mmap_supported[PCI_STD_RESOURCE_END + 1];
u8 *pci_config_map;
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 5bd97fa632d3..6ebc441d91c3 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1434,8 +1434,25 @@ static pci_ers_result_t vfio_pci_aer_err_detected(struct pci_dev *pdev,
return PCI_ERS_RESULT_CAN_RECOVER;
}
+static void vfio_pci_reset_done(struct pci_dev *dev)
+{
+ struct vfio_pci_device *vdev;
+ struct vfio_device *device;
+
+ device = vfio_device_get_from_dev(&dev->dev);
+ if (device == NULL)
+ return;
+
+ vdev = vfio_device_data(device);
+ if (vdev && vdev->error_handlers && vdev->error_handlers->reset_done)
+ vdev->error_handlers->reset_done(vdev);
+
+ vfio_device_put(device);
+}
+
static const struct pci_error_handlers vfio_err_handlers = {
.error_detected = vfio_pci_aer_err_detected,
+ .reset_done = vfio_pci_reset_done,
};
static struct pci_driver vfio_pci_driver = {
--
2.17.1
next prev parent reply other threads:[~2019-03-15 8:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-15 8:18 [PATCH kernel RFC 0/2] vfio, powerpc/powernv: Isolate GV100GL Alexey Kardashevskiy
2019-03-15 8:18 ` Alexey Kardashevskiy [this message]
2019-03-15 8:18 ` [PATCH kernel RFC 2/2] vfio-pci-nvlink2: Implement interconnect isolation Alexey Kardashevskiy
2019-03-19 16:36 ` Alex Williamson
2019-03-20 1:57 ` Alexey Kardashevskiy
2019-03-20 4:38 ` David Gibson
2019-03-20 19:09 ` Alex Williamson
2019-03-20 23:56 ` David Gibson
2019-03-21 18:19 ` Alex Williamson
2019-03-22 3:08 ` David Gibson
2019-03-22 23:10 ` Alex Williamson
2019-04-05 0:34 ` David Gibson
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=20190315081835.14083-2-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=joserz@linux.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=lagarcia@br.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=pjaroszynski@nvidia.com \
/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;
as well as URLs for NNTP newsgroup(s).