Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1272223ybl; Fri, 23 Aug 2019 16:39:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhcfQsWjUFmQDqAK2CNx2JvaAvcYPMrz/uyRkSXrpYNlzPN0/aWoNZvibp0aMPaXOAVDSB X-Received: by 2002:aa7:8f2e:: with SMTP id y14mr8116293pfr.113.1566603567181; Fri, 23 Aug 2019 16:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566603567; cv=none; d=google.com; s=arc-20160816; b=lehh556lpna2IJ5QoXhg/WHPhRtEOyt+g+VMFiwTNegcVjtJznvmNkmYzqYbPW7VCK jYagGQ2NAPo16cSMveeOhj8zp8AAVPZyvLTdy3FskLRQETKG8G4pBjX6dy+LKY5g8dn/ bO4f0Y1wzv4xAAz9paq0IxWRl/kK6kldyFR7cC3IhDvDFcnkwRLoJtXChTP06nOXBdiB eegop/49MLhWnw/c6jORIYRaF4Q4ejQOLc8QL4qg0Vuu2gJFw9GYIooScUa7nqsSMxEO SaaDkCDCfPIw8bSGqHldcKQ2hMn/67pMlo8DdfXx0SUvHdDYHYNbRy1EPEI9ui3lnGjH mtfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=K6TTa2FUVE/jbvvh+ruzeS1UiVfWQ+D5YxQJOTz1n64=; b=B47JnhdVr/eFc1KyIDCVr1mLDOljdOwuTFcSSgZz27jOKSXbbl7mG81Qp181o7UONX F2hao1N2AF3WhNf7ltjuVAu+N1QhD3BYec0x1thBpr6FfG7jdY3ItaXerouUEPjxa1bq K5GXQAwDLcSWs66Xtj2WvV9wPz9HmlVMz2jLpjeHrzjAWZVTbsP+vqODYuzZlqlSp1Dy Oi+w1kp1K7KgagPPSM1b/s9shQeIp89qE0XWQbbGAg/Rl+QIOnKg1SBn/Xj8CT/rqe7S gZftrJGVSaT+sqOdAdF8KuHz2nBA0pDYFr2QL81nBwaVtkVd7L2ptt1nW+hwimD0TjEl Dvyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si3069111pgq.586.2019.08.23.16.39.12; Fri, 23 Aug 2019 16:39:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392615AbfHWUso (ORCPT + 99 others); Fri, 23 Aug 2019 16:48:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34390 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388903AbfHWUso (ORCPT ); Fri, 23 Aug 2019 16:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16D673C919; Fri, 23 Aug 2019 20:48:44 +0000 (UTC) Received: from x1.home (ovpn-116-99.phx2.redhat.com [10.3.116.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 999DF5D6B2; Fri, 23 Aug 2019 20:48:43 +0000 (UTC) Date: Fri, 23 Aug 2019 14:48:43 -0600 From: Alex Williamson To: Parav Pandit Cc: kvm@vger.kernel.org, kwankhede@nvidia.com, linux-kernel@vger.kernel.org, cohuck@redhat.com, cjia@nvidia.com Subject: Re: [PATCH v2 1/2] vfio-mdev/mtty: Simplify interrupt generation Message-ID: <20190823144843.1d778c6b@x1.home> In-Reply-To: <20190808141255.45236-2-parav@mellanox.com> References: <20190802065905.45239-1-parav@mellanox.com> <20190808141255.45236-1-parav@mellanox.com> <20190808141255.45236-2-parav@mellanox.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 23 Aug 2019 20:48:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 8 Aug 2019 09:12:54 -0500 Parav Pandit wrote: > 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 > --- > samples/vfio-mdev/mtty.c | 39 ++++++++------------------------------- > 1 file changed, 8 insertions(+), 31 deletions(-) Applied this commit to vfio next branch with Christoph's review for v5.4. As Connie has another use case for the mdev_uuid() API in flight, I'm not applying patch 2/. Thanks, Alex > 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))