From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6E147A00E6 for ; Tue, 9 Jul 2019 15:40:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F37D61B951; Tue, 9 Jul 2019 15:40:24 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id D19004C8D for ; Tue, 9 Jul 2019 15:40:23 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x69DUBLC013113; Tue, 9 Jul 2019 06:40:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=yTLsIB0aixNFvcixvn5eWAPTS8XpqhM1pyDjUPAanMQ=; b=TQFJ+BdGup4PrtMxww152/Q7wBttLnrxYDiK5Z9mXss5m81fLjDjdL8qMzkqT/5K/23i dpSdFS82AybSFZ+05WJy4/mgp2IFwDgHpu03u5c8YoNPz6yn4OyYxbNYaH7JfxeX2o/B T76tKbQvqWDKxVtHFUK/T2JXI5adMTYcqwgOP7oCJu/JffAE5XxG7PRD9JCExfmVEXdR I6yEty1jcK5u2dZUrcw1Pdy7iDYLqYD3rm7tWOqTCJqMWDEWSdIeY184r9ZECOgkyZR+ 3qT7S1OcqJiZ9nU7xLty/6QdpG618wJOqcJLZCRAOvrpLwLifcuC8wcodNU0YrZkZP9S 8w== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2tmn10heu5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 09 Jul 2019 06:40:22 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 9 Jul 2019 06:40:21 -0700 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (104.47.41.50) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 9 Jul 2019 06:40:20 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yTLsIB0aixNFvcixvn5eWAPTS8XpqhM1pyDjUPAanMQ=; b=bWV57e6+f45iWXzlglXhEgEBkmuVtXFh7aQS/43SciclN7VAHgJZYRdrYwvtlWIa/kprtGux61wRQ1cflRqOwc3+NuukW3jNG3+30x6LzwvQXmzSa8oaz8VUzhaveBxvkendIYgja/Y8U2xgfKcvZ1Xc2mKBxVb2r8pvlvUmzoo= Received: from BYAPR18MB2696.namprd18.prod.outlook.com (20.178.207.225) by BYAPR18MB2392.namprd18.prod.outlook.com (20.179.91.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.17; Tue, 9 Jul 2019 13:40:16 +0000 Received: from BYAPR18MB2696.namprd18.prod.outlook.com ([fe80::d09e:8c06:c6c4:ccd3]) by BYAPR18MB2696.namprd18.prod.outlook.com ([fe80::d09e:8c06:c6c4:ccd3%3]) with mapi id 15.20.2052.020; Tue, 9 Jul 2019 13:40:16 +0000 From: Shahed Shaikh To: David Marchand , "dev@dpdk.org" CC: "anatoly.burakov@intel.com" , "alex.williamson@redhat.com" , "maxime.coquelin@redhat.com" , "thomas@monjalon.net" , "stephen@networkplumber.org" Thread-Topic: [EXT] [dpdk-dev] [RFC PATCH] vfio: move eventfd/interrupt pairing at setup time Thread-Index: AQHVMNSBBsD/gzNJvESdVgDvqbCGrqbCSeFQ Date: Tue, 9 Jul 2019 13:40:15 +0000 Message-ID: References: <1562071706-11009-1-git-send-email-david.marchand@redhat.com> In-Reply-To: <1562071706-11009-1-git-send-email-david.marchand@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [123.201.116.242] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8af19964-d0fa-4d43-0f6c-08d70472f9d1 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:BYAPR18MB2392; x-ms-traffictypediagnostic: BYAPR18MB2392: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0093C80C01 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(366004)(346002)(376002)(136003)(39860400002)(199004)(189003)(13464003)(6506007)(71200400001)(99286004)(2501003)(71190400001)(30864003)(7696005)(14454004)(68736007)(66066001)(76176011)(486006)(7736002)(6246003)(4326008)(6116002)(2906002)(305945005)(11346002)(110136005)(14444005)(446003)(25786009)(74316002)(54906003)(256004)(476003)(229853002)(52536014)(55016002)(316002)(478600001)(53936002)(9686003)(26005)(102836004)(81166006)(53546011)(86362001)(6306002)(966005)(66446008)(76116006)(186003)(81156014)(73956011)(6436002)(33656002)(66946007)(66556008)(64756008)(66476007)(5660300002)(8936002)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR18MB2392; H:BYAPR18MB2696.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2lhRGqYbaLi3+fwwbWq8etuCLGpe0IhcGmy9zRWP2KA3K6uBGhvg1jMIVDVHBYoibM56gvJ4ZOvMe2xWyDhM7KAbbFmuebXq2llc3UflLH0NmwXNQj/bCbYM/Gkx7k4DcTrH4x3MAXVjbwHSS8ilpPnEcI4fdoBLJk1+hU6kvbjso0R2OT54p1g/KoRHtv4UFtkdXtUjEo9l8tN6VTwC3K/sAAknHG1/Y2KstGz6pU9lasMA06lzHK+PmTYxytq5QE4TGKxvVkE6piw358KLMKiyG4LqPDKGo0M9Xmx/1hDrvtY0Q3uwEqYpowiVqBE3EfY4J3KW4qyQqphkBKV9xGu2JOlW+v6tPSLRv8rNGp4OizML5+bopLl6HzZ8d/nlxU6ak9n+2OvSWkRvGE2sj5izEl/hehZY93dDmy+D/TQ= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 8af19964-d0fa-4d43-0f6c-08d70472f9d1 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2019 13:40:15.8476 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: shshaikh@marvell.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2392 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-09_05:, , signatures=0 Subject: Re: [dpdk-dev] [EXT] [RFC PATCH] vfio: move eventfd/interrupt pairing at setup time X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: dev On Behalf Of David Marchand > Sent: Tuesday, July 2, 2019 6:18 PM > To: dev@dpdk.org > Cc: anatoly.burakov@intel.com; alex.williamson@redhat.com; > maxime.coquelin@redhat.com; thomas@monjalon.net; > stephen@networkplumber.org > Subject: [EXT] [dpdk-dev] [RFC PATCH] vfio: move eventfd/interrupt pairin= g at > setup time >=20 >=20 > ---------------------------------------------------------------------- > Populating the eventfd in rte_intr_enable in each request to vfio trigger= s a > reconfiguration of the interrupt handler on the kernel side. > The problem is that rte_intr_enable is often used to re-enable masked int= errupts > from drivers interrupt handlers. >=20 > This reconfiguration leaves a window during which a device could send an > interrupt and then the kernel logs this unsolicited interrupt: > [158764.159833] do_IRQ: 9.34 No irq handler for vector >=20 > VFIO api makes it possible to set the fd at setup time. > Make use of this and then we only need to ask for masking/unmasking legac= y > interrupts and we have nothing to do for MSI/MSIX. >=20 > "rxtx" interrupts are left untouched but are most likely subject to the s= ame issue. >=20 > Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=3D1654824 > Signed-off-by: David Marchand Thanks David for this patch. I have tested this patch with FastLinq adapters on which original issue is = reported. Tested this with MSI-x and legacy interrupt mode. Tested-by: Shahed Shaikh > --- > Sending as a RFC patch since it is not trivial and can eat your babies. > Could people that know well this parts have a look at this? > Thanks! >=20 > --- > drivers/bus/pci/linux/pci_vfio.c | 78 ++++++------ > lib/librte_eal/linux/eal/eal_interrupts.c | 197 +++++++-----------------= ------ > 2 files changed, 86 insertions(+), 189 deletions(-) >=20 > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci= _vfio.c > index ebf6ccd..e4c32c4 100644 > --- a/drivers/bus/pci/linux/pci_vfio.c > +++ b/drivers/bus/pci/linux/pci_vfio.c > @@ -186,8 +186,11 @@ > static int > pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd) = { > - int i, ret, intr_idx; > + char irq_set_buf[sizeof(struct vfio_irq_set) + sizeof(int)]; > + struct vfio_irq_set *irq_set; > enum rte_intr_mode intr_mode; > + int i, ret, intr_idx; > + int fd; >=20 > /* default to invalid index */ > intr_idx =3D VFIO_PCI_NUM_IRQS; > @@ -219,7 +222,6 @@ > /* start from MSI-X interrupt type */ > for (i =3D VFIO_PCI_MSIX_IRQ_INDEX; i >=3D 0; i--) { > struct vfio_irq_info irq =3D { .argsz =3D sizeof(irq) }; > - int fd =3D -1; >=20 > /* skip interrupt modes we don't want */ > if (intr_mode !=3D RTE_INTR_MODE_NONE && @@ -235,51 > +237,51 @@ > return -1; > } >=20 > + /* found a usable interrupt mode */ > + if ((irq.flags & VFIO_IRQ_INFO_EVENTFD) !=3D 0) > + break; > + > /* if this vector cannot be used with eventfd, fail if we explicitly > * specified interrupt type, otherwise continue */ > - if ((irq.flags & VFIO_IRQ_INFO_EVENTFD) =3D=3D 0) { > - if (intr_mode !=3D RTE_INTR_MODE_NONE) { > - RTE_LOG(ERR, EAL, > - " interrupt vector does not > support eventfd!\n"); > - return -1; > - } else > - continue; > - } > - > - /* set up an eventfd for interrupts */ > - fd =3D eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); > - if (fd < 0) { > - RTE_LOG(ERR, EAL, " cannot set up eventfd, " > - "error %i (%s)\n", errno, > strerror(errno)); > + if (intr_mode !=3D RTE_INTR_MODE_NONE) { > + RTE_LOG(ERR, EAL, " interrupt vector does not support > eventfd!\n"); > return -1; > } > + } >=20 > - dev->intr_handle.fd =3D fd; > - dev->intr_handle.vfio_dev_fd =3D vfio_dev_fd; > + if (i < 0) > + return -1; >=20 > - switch (i) { > - case VFIO_PCI_MSIX_IRQ_INDEX: > - intr_mode =3D RTE_INTR_MODE_MSIX; > - dev->intr_handle.type =3D > RTE_INTR_HANDLE_VFIO_MSIX; > - break; > - case VFIO_PCI_MSI_IRQ_INDEX: > - intr_mode =3D RTE_INTR_MODE_MSI; > - dev->intr_handle.type =3D RTE_INTR_HANDLE_VFIO_MSI; > - break; > - case VFIO_PCI_INTX_IRQ_INDEX: > - intr_mode =3D RTE_INTR_MODE_LEGACY; > - dev->intr_handle.type =3D > RTE_INTR_HANDLE_VFIO_LEGACY; > - break; > - default: > - RTE_LOG(ERR, EAL, " unknown interrupt type!\n"); > - return -1; > - } > + fd =3D eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); > + if (fd < 0) { > + RTE_LOG(ERR, EAL, " cannot set up eventfd, error %i (%s)\n", > + errno, strerror(errno)); > + return -1; > + } >=20 > - return 0; > + irq_set =3D (struct vfio_irq_set *)irq_set_buf; > + irq_set->argsz =3D sizeof(irq_set_buf); > + irq_set->flags =3D > VFIO_IRQ_SET_DATA_EVENTFD|VFIO_IRQ_SET_ACTION_TRIGGER; > + irq_set->index =3D i; > + irq_set->start =3D 0; > + irq_set->count =3D 1; > + memcpy(&irq_set->data, &fd, sizeof(int)); > + if (ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set) < 0) { > + RTE_LOG(ERR, EAL, " error configuring interrupt\n"); > + close(fd); > + return -1; > } >=20 > - /* if we're here, we haven't found a suitable interrupt vector */ > - return -1; > + dev->intr_handle.fd =3D fd; > + dev->intr_handle.vfio_dev_fd =3D vfio_dev_fd; > + if (i =3D=3D VFIO_PCI_MSIX_IRQ_INDEX) > + dev->intr_handle.type =3D RTE_INTR_HANDLE_VFIO_MSIX; > + else if (i =3D=3D VFIO_PCI_MSI_IRQ_INDEX) > + dev->intr_handle.type =3D RTE_INTR_HANDLE_VFIO_MSI; > + else if (i =3D=3D VFIO_PCI_INTX_IRQ_INDEX) > + dev->intr_handle.type =3D RTE_INTR_HANDLE_VFIO_LEGACY; > + > + return 0; > } >=20 > #ifdef HAVE_VFIO_DEV_REQ_INTERFACE > diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c > b/lib/librte_eal/linux/eal/eal_interrupts.c > index 79ad5e8..27976b3 100644 > --- a/lib/librte_eal/linux/eal/eal_interrupts.c > +++ b/lib/librte_eal/linux/eal/eal_interrupts.c > @@ -109,42 +109,19 @@ struct rte_intr_source { >=20 > /* enable legacy (INTx) interrupts */ > static int > -vfio_enable_intx(const struct rte_intr_handle *intr_handle) { > - struct vfio_irq_set *irq_set; > - char irq_set_buf[IRQ_SET_BUF_LEN]; > - int len, ret; > - int *fd_ptr; > - > - len =3D sizeof(irq_set_buf); > - > - /* enable INTx */ > - irq_set =3D (struct vfio_irq_set *) irq_set_buf; > - irq_set->argsz =3D len; > - irq_set->count =3D 1; > - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | > VFIO_IRQ_SET_ACTION_TRIGGER; > - irq_set->index =3D VFIO_PCI_INTX_IRQ_INDEX; > - irq_set->start =3D 0; > - fd_ptr =3D (int *) &irq_set->data; > - *fd_ptr =3D intr_handle->fd; > - > - ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); > - > - if (ret) { > - RTE_LOG(ERR, EAL, "Error enabling INTx interrupts for fd > %d\n", > - intr_handle->fd); > - return -1; > - } > +vfio_enable_intx(const struct rte_intr_handle *intr_handle) { > + struct vfio_irq_set irq_set; > + int ret; >=20 > - /* unmask INTx after enabling */ > - memset(irq_set, 0, len); > - len =3D sizeof(struct vfio_irq_set); > - irq_set->argsz =3D len; > - irq_set->count =3D 1; > - irq_set->flags =3D VFIO_IRQ_SET_DATA_NONE | > VFIO_IRQ_SET_ACTION_UNMASK; > - irq_set->index =3D VFIO_PCI_INTX_IRQ_INDEX; > - irq_set->start =3D 0; > + /* unmask INTx */ > + irq_set.argsz =3D sizeof(irq_set); > + irq_set.flags =3D VFIO_IRQ_SET_DATA_NONE | > VFIO_IRQ_SET_ACTION_UNMASK; > + irq_set.index =3D VFIO_PCI_INTX_IRQ_INDEX; > + irq_set.start =3D 0; > + irq_set.count =3D 1; >=20 > - ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); > + ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, &irq_set)= ; >=20 > if (ret) { > RTE_LOG(ERR, EAL, "Error unmasking INTx interrupts for fd > %d\n", @@ -156,128 +133,51 @@ struct rte_intr_source { >=20 > /* disable legacy (INTx) interrupts */ > static int > -vfio_disable_intx(const struct rte_intr_handle *intr_handle) { > - struct vfio_irq_set *irq_set; > - char irq_set_buf[IRQ_SET_BUF_LEN]; > - int len, ret; > - > - len =3D sizeof(struct vfio_irq_set); > +vfio_disable_intx(const struct rte_intr_handle *intr_handle) { > + struct vfio_irq_set irq_set; > + int ret; >=20 > - /* mask interrupts before disabling */ > - irq_set =3D (struct vfio_irq_set *) irq_set_buf; > - irq_set->argsz =3D len; > - irq_set->count =3D 1; > - irq_set->flags =3D VFIO_IRQ_SET_DATA_NONE | > VFIO_IRQ_SET_ACTION_MASK; > - irq_set->index =3D VFIO_PCI_INTX_IRQ_INDEX; > - irq_set->start =3D 0; > + /* mask interrupts */ > + irq_set.argsz =3D sizeof(irq_set); > + irq_set.flags =3D VFIO_IRQ_SET_DATA_NONE | > VFIO_IRQ_SET_ACTION_MASK; > + irq_set.index =3D VFIO_PCI_INTX_IRQ_INDEX; > + irq_set.start =3D 0; > + irq_set.count =3D 1; >=20 > - ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); > + ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, &irq_set)= ; >=20 > if (ret) { > RTE_LOG(ERR, EAL, "Error masking INTx interrupts for fd %d\n", > intr_handle->fd); > return -1; > } > - > - /* disable INTx*/ > - memset(irq_set, 0, len); > - irq_set->argsz =3D len; > - irq_set->count =3D 0; > - irq_set->flags =3D VFIO_IRQ_SET_DATA_NONE | > VFIO_IRQ_SET_ACTION_TRIGGER; > - irq_set->index =3D VFIO_PCI_INTX_IRQ_INDEX; > - irq_set->start =3D 0; > - > - ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); > - > - if (ret) { > - RTE_LOG(ERR, EAL, > - "Error disabling INTx interrupts for fd %d\n", > intr_handle->fd); > - return -1; > - } > - return 0; > -} > - > -/* enable MSI interrupts */ > -static int > -vfio_enable_msi(const struct rte_intr_handle *intr_handle) { > - int len, ret; > - char irq_set_buf[IRQ_SET_BUF_LEN]; > - struct vfio_irq_set *irq_set; > - int *fd_ptr; > - > - len =3D sizeof(irq_set_buf); > - > - irq_set =3D (struct vfio_irq_set *) irq_set_buf; > - irq_set->argsz =3D len; > - irq_set->count =3D 1; > - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | > VFIO_IRQ_SET_ACTION_TRIGGER; > - irq_set->index =3D VFIO_PCI_MSI_IRQ_INDEX; > - irq_set->start =3D 0; > - fd_ptr =3D (int *) &irq_set->data; > - *fd_ptr =3D intr_handle->fd; > - > - ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); > - > - if (ret) { > - RTE_LOG(ERR, EAL, "Error enabling MSI interrupts for fd %d\n", > - intr_handle->fd); > - return -1; > - } > return 0; > } >=20 > -/* disable MSI interrupts */ > -static int > -vfio_disable_msi(const struct rte_intr_handle *intr_handle) { > - struct vfio_irq_set *irq_set; > - char irq_set_buf[IRQ_SET_BUF_LEN]; > - int len, ret; > - > - len =3D sizeof(struct vfio_irq_set); > - > - irq_set =3D (struct vfio_irq_set *) irq_set_buf; > - irq_set->argsz =3D len; > - irq_set->count =3D 0; > - irq_set->flags =3D VFIO_IRQ_SET_DATA_NONE | > VFIO_IRQ_SET_ACTION_TRIGGER; > - irq_set->index =3D VFIO_PCI_MSI_IRQ_INDEX; > - irq_set->start =3D 0; > - > - ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); > - > - if (ret) > - RTE_LOG(ERR, EAL, > - "Error disabling MSI interrupts for fd %d\n", > intr_handle->fd); > - > - return ret; > -} > - > /* enable MSI-X interrupts */ > static int > -vfio_enable_msix(const struct rte_intr_handle *intr_handle) { > - int len, ret; > +vfio_enable_msix(const struct rte_intr_handle *intr_handle) { > char irq_set_buf[MSIX_IRQ_SET_BUF_LEN]; > struct vfio_irq_set *irq_set; > - int *fd_ptr; > + int len, ret; > + > + if (intr_handle->nb_efd =3D=3D 0) > + return 0; >=20 > len =3D sizeof(irq_set_buf); >=20 > irq_set =3D (struct vfio_irq_set *) irq_set_buf; > irq_set->argsz =3D len; > - /* 0 < irq_set->count < RTE_MAX_RXTX_INTR_VEC_ID + 1 */ > - irq_set->count =3D intr_handle->max_intr ? > - (intr_handle->max_intr > RTE_MAX_RXTX_INTR_VEC_ID + 1 ? > - RTE_MAX_RXTX_INTR_VEC_ID + 1 : intr_handle->max_intr) : 1; > irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | > VFIO_IRQ_SET_ACTION_TRIGGER; > irq_set->index =3D VFIO_PCI_MSIX_IRQ_INDEX; > - irq_set->start =3D 0; > - fd_ptr =3D (int *) &irq_set->data; > - /* INTR vector offset 0 reserve for non-efds mapping */ > - fd_ptr[RTE_INTR_VEC_ZERO_OFFSET] =3D intr_handle->fd; > - memcpy(&fd_ptr[RTE_INTR_VEC_RXTX_OFFSET], intr_handle->efds, > - sizeof(*intr_handle->efds) * intr_handle->nb_efd); > + irq_set->start =3D RTE_INTR_VEC_RXTX_OFFSET; > + irq_set->count =3D intr_handle->nb_efd; > + memcpy(&irq_set->data, intr_handle->efds, > + sizeof(*intr_handle->efds) * intr_handle->nb_efd); >=20 > ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); > - > if (ret) { > RTE_LOG(ERR, EAL, "Error enabling MSI-X interrupts for fd > %d\n", > intr_handle->fd); > @@ -289,22 +189,21 @@ struct rte_intr_source { >=20 > /* disable MSI-X interrupts */ > static int > -vfio_disable_msix(const struct rte_intr_handle *intr_handle) { > - struct vfio_irq_set *irq_set; > - char irq_set_buf[MSIX_IRQ_SET_BUF_LEN]; > - int len, ret; > - > - len =3D sizeof(struct vfio_irq_set); > +vfio_disable_msix(const struct rte_intr_handle *intr_handle) { > + struct vfio_irq_set irq_set; > + int ret; >=20 > - irq_set =3D (struct vfio_irq_set *) irq_set_buf; > - irq_set->argsz =3D len; > - irq_set->count =3D 0; > - irq_set->flags =3D VFIO_IRQ_SET_DATA_NONE | > VFIO_IRQ_SET_ACTION_TRIGGER; > - irq_set->index =3D VFIO_PCI_MSIX_IRQ_INDEX; > - irq_set->start =3D 0; > + if (intr_handle->nb_efd =3D=3D 0) > + return 0; >=20 > - ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); > + irq_set.argsz =3D sizeof(irq_set); > + irq_set.flags =3D VFIO_IRQ_SET_DATA_NONE | > VFIO_IRQ_SET_ACTION_TRIGGER; > + irq_set.index =3D VFIO_PCI_MSIX_IRQ_INDEX; > + irq_set.start =3D RTE_INTR_VEC_RXTX_OFFSET; > + irq_set.count =3D intr_handle->nb_efd; >=20 > + ret =3D ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, &irq_set)= ; > if (ret) > RTE_LOG(ERR, EAL, > "Error disabling MSI-X interrupts for fd %d\n", > intr_handle->fd); @@ -665,9 +564,7 @@ struct rte_intr_source { > return -1; > break; > case RTE_INTR_HANDLE_VFIO_MSI: > - if (vfio_enable_msi(intr_handle)) > - return -1; > - break; > + return 0; > case RTE_INTR_HANDLE_VFIO_LEGACY: > if (vfio_enable_intx(intr_handle)) > return -1; > @@ -721,9 +618,7 @@ struct rte_intr_source { > return -1; > break; > case RTE_INTR_HANDLE_VFIO_MSI: > - if (vfio_disable_msi(intr_handle)) > - return -1; > - break; > + return 0; > case RTE_INTR_HANDLE_VFIO_LEGACY: > if (vfio_disable_intx(intr_handle)) > return -1; > -- > 1.8.3.1