From patchwork Fri Sep 18 06:24:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 7213291 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41A49BEEC1 for ; Fri, 18 Sep 2015 06:25:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6595B2022D for ; Fri, 18 Sep 2015 06:25:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64ED5206F2 for ; Fri, 18 Sep 2015 06:25:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752527AbbIRGZl (ORCPT ); Fri, 18 Sep 2015 02:25:41 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:54706 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752324AbbIRGZf (ORCPT ); Fri, 18 Sep 2015 02:25:35 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 18 Sep 2015 16:25:32 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 18 Sep 2015 16:25:29 +1000 X-Helo: d23dlp01.au.ibm.com X-MailFrom: gwshan@linux.vnet.ibm.com X-RcptTo: kvm@vger.kernel.org Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 08C552CE8057; Fri, 18 Sep 2015 16:25:28 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t8I6PKI355640192; Fri, 18 Sep 2015 16:25:29 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t8I6OsE0003828; Fri, 18 Sep 2015 16:24:55 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t8I6Osea003244; Fri, 18 Sep 2015 16:24:54 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 8EE00A03BC; Fri, 18 Sep 2015 16:24:30 +1000 (AEST) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 83990E451B; Fri, 18 Sep 2015 16:24:30 +1000 (AEST) Received: by gwshan (Postfix, from userid 1000) id 61632941D64; Fri, 18 Sep 2015 16:24:30 +1000 (AEST) From: Gavin Shan 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 Subject: [PATCH 1/2] drivers/vfio: Support EEH API revision Date: Fri, 18 Sep 2015 16:24:28 +1000 Message-Id: <1442557469-22185-2-git-send-email-gwshan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1442557469-22185-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1442557469-22185-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15091806-0025-0000-0000-0000022A8D8C Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;