From patchwork Thu Aug 8 14:12:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 11084235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1883B746 for ; Thu, 8 Aug 2019 14:13:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07911288A2 for ; Thu, 8 Aug 2019 14:13:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F049828ADE; Thu, 8 Aug 2019 14:13:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8944028B24 for ; Thu, 8 Aug 2019 14:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403981AbfHHONa (ORCPT ); Thu, 8 Aug 2019 10:13:30 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:36588 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2403975AbfHHON3 (ORCPT ); Thu, 8 Aug 2019 10:13:29 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from parav@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Aug 2019 17:13:19 +0300 Received: from sw-mtx-036.mtx.labs.mlnx (sw-mtx-036.mtx.labs.mlnx [10.12.150.149]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x78EDFcX025404; Thu, 8 Aug 2019 17:13:17 +0300 From: Parav Pandit To: kvm@vger.kernel.org, kwankhede@nvidia.com, linux-kernel@vger.kernel.org Cc: parav@mellanox.com, alex.williamson@redhat.com, cohuck@redhat.com, cjia@nvidia.com Subject: [PATCH v2 1/2] vfio-mdev/mtty: Simplify interrupt generation Date: Thu, 8 Aug 2019 09:12:54 -0500 Message-Id: <20190808141255.45236-2-parav@mellanox.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190808141255.45236-1-parav@mellanox.com> References: <20190802065905.45239-1-parav@mellanox.com> <20190808141255.45236-1-parav@mellanox.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While generating interrupt, mdev_state is already available for which interrupt is generated. Instead of doing indirect way from state->device->uuid-> to searching state linearly in linked list on every interrupt generation, directly use the available state. Hence, simplify the code to use mdev_state and remove unused helper function with that. Reviewed-by: Cornelia Huck Signed-off-by: Parav Pandit Reviewed-by: Christoph Hellwig --- samples/vfio-mdev/mtty.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c index 92e770a06ea2..ce84a300a4da 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c @@ -152,20 +152,9 @@ static const struct file_operations vd_fops = { /* function prototypes */ -static int mtty_trigger_interrupt(const guid_t *uuid); +static int mtty_trigger_interrupt(struct mdev_state *mdev_state); /* Helper functions */ -static struct mdev_state *find_mdev_state_by_uuid(const guid_t *uuid) -{ - struct mdev_state *mds; - - list_for_each_entry(mds, &mdev_devices_list, next) { - if (guid_equal(mdev_uuid(mds->mdev), uuid)) - return mds; - } - - return NULL; -} static void dump_buffer(u8 *buf, uint32_t count) { @@ -337,8 +326,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, pr_err("Serial port %d: Fifo level trigger\n", index); #endif - mtty_trigger_interrupt( - mdev_uuid(mdev_state->mdev)); + mtty_trigger_interrupt(mdev_state); } } else { #if defined(DEBUG_INTR) @@ -352,8 +340,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, */ if (mdev_state->s[index].uart_reg[UART_IER] & UART_IER_RLSI) - mtty_trigger_interrupt( - mdev_uuid(mdev_state->mdev)); + mtty_trigger_interrupt(mdev_state); } mutex_unlock(&mdev_state->rxtx_lock); break; @@ -372,8 +359,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, pr_err("Serial port %d: IER_THRI write\n", index); #endif - mtty_trigger_interrupt( - mdev_uuid(mdev_state->mdev)); + mtty_trigger_interrupt(mdev_state); } mutex_unlock(&mdev_state->rxtx_lock); @@ -444,7 +430,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, #if defined(DEBUG_INTR) pr_err("Serial port %d: MCR_OUT2 write\n", index); #endif - mtty_trigger_interrupt(mdev_uuid(mdev_state->mdev)); + mtty_trigger_interrupt(mdev_state); } if ((mdev_state->s[index].uart_reg[UART_IER] & UART_IER_MSI) && @@ -452,7 +438,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, #if defined(DEBUG_INTR) pr_err("Serial port %d: MCR RTS/DTR write\n", index); #endif - mtty_trigger_interrupt(mdev_uuid(mdev_state->mdev)); + mtty_trigger_interrupt(mdev_state); } break; @@ -503,8 +489,7 @@ static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state, #endif if (mdev_state->s[index].uart_reg[UART_IER] & UART_IER_THRI) - mtty_trigger_interrupt( - mdev_uuid(mdev_state->mdev)); + mtty_trigger_interrupt(mdev_state); } mutex_unlock(&mdev_state->rxtx_lock); @@ -1028,17 +1013,9 @@ static int mtty_set_irqs(struct mdev_device *mdev, uint32_t flags, return ret; } -static int mtty_trigger_interrupt(const guid_t *uuid) +static int mtty_trigger_interrupt(struct mdev_state *mdev_state) { int ret = -1; - struct mdev_state *mdev_state; - - mdev_state = find_mdev_state_by_uuid(uuid); - - if (!mdev_state) { - pr_info("%s: mdev not found\n", __func__); - return -EINVAL; - } if ((mdev_state->irq_index == VFIO_PCI_MSI_IRQ_INDEX) && (!mdev_state->msi_evtfd)) From patchwork Thu Aug 8 14:12:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 11084233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E71B21399 for ; Thu, 8 Aug 2019 14:13:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D56AE28A0C for ; Thu, 8 Aug 2019 14:13:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA29028B37; Thu, 8 Aug 2019 14:13:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A14B28A0C for ; Thu, 8 Aug 2019 14:13:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403979AbfHHON3 (ORCPT ); Thu, 8 Aug 2019 10:13:29 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:36589 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733253AbfHHON3 (ORCPT ); Thu, 8 Aug 2019 10:13:29 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from parav@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Aug 2019 17:13:21 +0300 Received: from sw-mtx-036.mtx.labs.mlnx (sw-mtx-036.mtx.labs.mlnx [10.12.150.149]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x78EDFcY025404; Thu, 8 Aug 2019 17:13:19 +0300 From: Parav Pandit To: kvm@vger.kernel.org, kwankhede@nvidia.com, linux-kernel@vger.kernel.org Cc: parav@mellanox.com, alex.williamson@redhat.com, cohuck@redhat.com, cjia@nvidia.com Subject: [PATCH v2 2/2] vfio/mdev: Removed unused and redundant API for mdev UUID Date: Thu, 8 Aug 2019 09:12:55 -0500 Message-Id: <20190808141255.45236-3-parav@mellanox.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190808141255.45236-1-parav@mellanox.com> References: <20190802065905.45239-1-parav@mellanox.com> <20190808141255.45236-1-parav@mellanox.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no single production driver who is interested in mdev device uuid. Currently UUID is mainly used to derive a device name. Additionally mdev device name is already available using core kernel API dev_name(). Hence removed unused exported symbol. Reviewed-by: Cornelia Huck Signed-off-by: Parav Pandit Reviewed-by: Christoph Hellwig --- Changelog: v0->v1: - Updated commit log to address comments from Cornelia --- drivers/vfio/mdev/mdev_core.c | 6 ------ include/linux/mdev.h | 1 - 2 files changed, 7 deletions(-) diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index b558d4cfd082..c2b809cbe59f 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -57,12 +57,6 @@ struct mdev_device *mdev_from_dev(struct device *dev) } EXPORT_SYMBOL(mdev_from_dev); -const guid_t *mdev_uuid(struct mdev_device *mdev) -{ - return &mdev->uuid; -} -EXPORT_SYMBOL(mdev_uuid); - /* Should be called holding parent_list_lock */ static struct mdev_parent *__find_parent_device(struct device *dev) { diff --git a/include/linux/mdev.h b/include/linux/mdev.h index 0ce30ca78db0..375a5830c3d8 100644 --- a/include/linux/mdev.h +++ b/include/linux/mdev.h @@ -131,7 +131,6 @@ struct mdev_driver { void *mdev_get_drvdata(struct mdev_device *mdev); void mdev_set_drvdata(struct mdev_device *mdev, void *data); -const guid_t *mdev_uuid(struct mdev_device *mdev); extern struct bus_type mdev_bus_type;