Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4510450pxk; Wed, 30 Sep 2020 05:03:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI5VYB1QMNQIg5SNuDd3TWHLODokfnjNYpy2Keiq3l+ttMHJ/OFLItBCegr1/cmoOBa2eI X-Received: by 2002:aa7:d783:: with SMTP id s3mr2374796edq.214.1601467430304; Wed, 30 Sep 2020 05:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601467430; cv=none; d=google.com; s=arc-20160816; b=A+xbgKckPcYwceMKrYKBx/zEi1u0/l6VeueAdYAoy5XrvALMsS7fU6+BW00grTthjN 4gQd9QLGfTrXmT98s5iyFwYGqcxVSm7m8lJWoCE+0jouHx+/EfG77QTb2CSlAlBRg4JQ EdlkxYghUVTxts5Wq2mrRLIm9XGKg0g+Uhk9ejWyRKa7yCMzECuU7qAVU8g0MIb+Fmrq C6NTve49+Afp4JGw479bxtAf82uGpOFSHfyKehDOyXy4KRn2mIboDfp36UuNGYd9xYY6 ZX77HuBUW6u41YrjhGTG+Qzhf+Rh4EzsWhxh4o6pFxuMU41CiaVFhA3GivpWfqJA1A3T Wbag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=HTWvti/vuxtKoYKzUD6BxgnjRBPp9SCs9dRrrQvaN+c=; b=nKBqU2bopeR0wi0qlmFnO6dhEL71QU5m3+90SPEWlhJ/GeggjVKZKezcyKPRpm1EbM OtvFe8aGcOSyErCWhmWL+/jwg7K6Ka6oGihDMknzkX2iIhHyOrsQ6ry0+IUVxhJhspZS xOaYOAhk5qAib/5yZyYTzpmj90tsKxWtOqAAJd5QmIQE6hmhFrWS4QaZPDjnapTaXiiX eOzkQr40JYu9xQokmtKu8yzPWtC1tLj9b1dubXBJm5G4ZVT8D9XrlTrA73ARFtmheGxu c6ZOswspujpar0vjPbvLAfuEwSgWoeYJIxtU72yNKmSSl/vQTgfJ1sf/+/JUj2vYEac/ vJrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=FVu00aG3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h23si1127882ejx.721.2020.09.30.05.03.26; Wed, 30 Sep 2020 05:03:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=FVu00aG3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729586AbgI3MCV (ORCPT + 99 others); Wed, 30 Sep 2020 08:02:21 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:11095 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728235AbgI3MCU (ORCPT ); Wed, 30 Sep 2020 08:02:20 -0400 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Wed, 30 Sep 2020 05:01:29 -0700 Received: from mtl-vdi-166.wap.labs.mlnx (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 30 Sep 2020 12:02:06 +0000 Date: Wed, 30 Sep 2020 15:02:02 +0300 From: Eli Cohen To: Jason Wang CC: , , , , , , , , , , , , , , , Subject: Re: [RFC PATCH 06/24] vhost-vdpa: switch to use vhost-vdpa specific IOTLB Message-ID: <20200930120202.GA229518@mtl-vdi-166.wap.labs.mlnx> References: <20200924032125.18619-1-jasowang@redhat.com> <20200924032125.18619-7-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200924032125.18619-7-jasowang@redhat.com> User-Agent: Mutt/1.9.5 (bf161cf53efb) (2018-04-13) X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1601467289; bh=HTWvti/vuxtKoYKzUD6BxgnjRBPp9SCs9dRrrQvaN+c=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To:User-Agent: X-Originating-IP:X-ClientProxiedBy; b=FVu00aG3ONgcRFrBmD7zJd8ni1KmaI0rxs/mH8LJzd74Y4kLlSvizri95M/muuVm7 XSs2w3M5mZG/Vm9aBREZPBmOGHF4X8T+9DfbKBg/rxQWP3I0d9dTF2ym3W2YIAYDeD ZDabCWv5vzTEjbNbsG8JbZ+PEjM1AeuCEilCKCYpRXW1mZDoSIonUclkyDSrK10oLa cgWFnl2UcRrtKiaaewi3k9sz89p3M6q22jmOJ4FU0HWqOcmGc0JKtGV/y4Qi8wjqk8 tQZqXeIdZTHsxiw+wqKCdNnpQb9IL1ztePuGxy8aq+mSfMIja2rP8c2Ue8wKVieYFh xiRgekRLah/Xg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2020 at 11:21:07AM +0800, Jason Wang wrote: > To ease the implementation of per group ASID support for vDPA > device. This patch switches to use a vhost-vdpa specific IOTLB to > avoid the unnecessary refactoring of the vhost core. > > Signed-off-by: Jason Wang > --- > drivers/vhost/vdpa.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 74bef1c15a70..ec3c94f706c1 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -40,6 +40,7 @@ struct vhost_vdpa { > struct vhost_virtqueue *vqs; > struct completion completion; > struct vdpa_device *vdpa; > + struct vhost_iotlb *iotlb; > struct device dev; > struct cdev cdev; > atomic_t opened; > @@ -514,12 +515,11 @@ static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, > > static void vhost_vdpa_iotlb_free(struct vhost_vdpa *v) > { > - struct vhost_dev *dev = &v->vdev; > - struct vhost_iotlb *iotlb = dev->iotlb; > + struct vhost_iotlb *iotlb = v->iotlb; > > vhost_vdpa_iotlb_unmap(v, iotlb, 0ULL, 0ULL - 1); > - kfree(dev->iotlb); > - dev->iotlb = NULL; > + kfree(v->iotlb); > + v->iotlb = NULL; > } > > static int perm_to_iommu_flags(u32 perm) > @@ -681,7 +681,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, > struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev); > struct vdpa_device *vdpa = v->vdpa; > const struct vdpa_config_ops *ops = vdpa->config; > - struct vhost_iotlb *iotlb = dev->iotlb; > + struct vhost_iotlb *iotlb = v->iotlb; > int r = 0; > > r = vhost_dev_check_owner(dev); > @@ -812,12 +812,14 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) > > r = vhost_vdpa_alloc_domain(v); > if (r) > - goto err_init_iotlb; > + goto err_alloc_domain; You're still using this: dev->iotlb = vhost_iotlb_alloc(0, 0); Shouldn't you use v->iotlb = host_iotlb_alloc(0, 0); to set the vdpa device iotlb field? > > filep->private_data = v; > > return 0; > > +err_alloc_domain: > + vhost_vdpa_iotlb_free(v); > err_init_iotlb: > vhost_vdpa_cleanup(v); > err: > -- > 2.20.1 >