linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
	david@gibson.dropbear.id.au, alex.williamson@redhat.com,
	Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: [PATCH 1/2] drivers/vfio: Support EEH API revision
Date: Fri, 18 Sep 2015 16:24:28 +1000	[thread overview]
Message-ID: <1442557469-22185-2-git-send-email-gwshan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1442557469-22185-1-git-send-email-gwshan@linux.vnet.ibm.com>

This extends the return value from container's IOCTL command
(VFIO_CHECK_EXTENSION + VFIO_EEH) to EEH API revision. Also,
extra check is applied to return -ENOTTY if EEH functionality
is disabled in vfio_spapr_iommu_eeh_ioctl().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 drivers/vfio/vfio_iommu_spapr_tce.c | 5 +++++
 drivers/vfio/vfio_spapr_eeh.c       | 9 ++++++++-
 include/linux/vfio.h                | 6 ++++++
 include/uapi/linux/vfio.h           | 3 +++
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
index 0582b72..812b43b 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -954,6 +954,11 @@ static long tce_iommu_ioctl(void *iommu_data,
 
 	case VFIO_EEH_PE_OP: {
 		struct tce_iommu_group *tcegrp;
+		int eeh_enabled;
+
+		eeh_enabled = vfio_spapr_pci_eeh_enabled();
+		if (eeh_enabled == VFIO_EEH_DISABLED)
+			return -ENOTTY;
 
 		ret = 0;
 		list_for_each_entry(tcegrp, &container->group_list, next) {
diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c
index 38edeb4..d208d77 100644
--- a/drivers/vfio/vfio_spapr_eeh.c
+++ b/drivers/vfio/vfio_spapr_eeh.c
@@ -18,6 +18,12 @@
 #define DRIVER_AUTHOR	"Gavin Shan, IBM Corporation"
 #define DRIVER_DESC	"VFIO IOMMU SPAPR EEH"
 
+int vfio_spapr_pci_eeh_enabled(void)
+{
+	return VFIO_EEH_ENABLED_V1;
+}
+EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_enabled);
+
 /* We might build address mapping here for "fast" path later */
 void vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
 {
@@ -42,7 +48,8 @@ long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
 	switch (cmd) {
 	case VFIO_CHECK_EXTENSION:
 		if (arg == VFIO_EEH)
-			ret = eeh_enabled() ? 1 : 0;
+			ret = eeh_enabled() ? vfio_spapr_pci_eeh_enabled() :
+					      VFIO_EEH_DISABLED;
 		else
 			ret = 0;
 		break;
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index ddb4409..ff036ca 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -91,12 +91,18 @@ extern long vfio_external_check_extension(struct vfio_group *group,
 
 struct pci_dev;
 #ifdef CONFIG_EEH
+extern int vfio_spapr_pci_eeh_enabled(void);
 extern void vfio_spapr_pci_eeh_open(struct pci_dev *pdev);
 extern void vfio_spapr_pci_eeh_release(struct pci_dev *pdev);
 extern long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
 				       unsigned int cmd,
 				       unsigned long arg);
 #else
+static inline int vfio_spapr_pci_eeh_enabled(void)
+{
+	return VFIO_EEH_DISABLED;
+}
+
 static inline void vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
 {
 }
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 9fd7b5d..74f5b8b 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -495,6 +495,9 @@ struct vfio_iommu_spapr_tce_info {
  * - configure PE;
  * - inject EEH error.
  */
+#define VFIO_EEH_DISABLED	0
+#define VFIO_EEH_ENABLED_V1	1
+
 struct vfio_eeh_pe_err {
 	__u32 type;
 	__u32 func;
-- 
2.1.0

  reply	other threads:[~2015-09-18  6:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18  6:24 [PATCH 0/2] VFIO: Accept IOMMU group (PE) ID Gavin Shan
2015-09-18  6:24 ` Gavin Shan [this message]
2015-09-18  6:24 ` [PATCH 2/2] drivers/vfio: Support IOMMU group for EEH operations Gavin Shan
2015-09-18 15:47 ` [PATCH 0/2] VFIO: Accept IOMMU group (PE) ID Alex Williamson
2015-09-19  6:22   ` David Gibson
2015-09-21  1:42     ` David Gibson
2015-09-21  5:21       ` Gavin Shan
2015-09-21 12:11       ` Gavin Shan
2015-09-21 16:41         ` Alex Williamson

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=1442557469-22185-2-git-send-email-gwshan@linux.vnet.ibm.com \
    --to=gwshan@linux.vnet.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).