Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1132554ybz; Fri, 17 Apr 2020 16:49:16 -0700 (PDT) X-Google-Smtp-Source: APiQypJ9+0fT8MfkI4grLFwkAig4FsTVSgEP8WWIKA44f4SOhz1epQymXrexbt71PVAK5ZXHBE5X X-Received: by 2002:a17:907:a89:: with SMTP id by9mr5323326ejc.289.1587167356527; Fri, 17 Apr 2020 16:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587167356; cv=none; d=google.com; s=arc-20160816; b=IA6tardEpDdNDl3bHmCNfgeSRPXGEtWx9reu9AOwG+XitRyz5CvRdeSb5/TVvoM6ku 70VJX+osIEKKMfT/RMP/Jw3rLBScB+uk5fiBCfExmJ7U4RBsGYrGoRezf571VQY2iAwJ S8oUhUJhGWOlQU1XD8yoZQIg64NR6sIo+N6Rau39pfvatACfUjLO3rveXKMyI70AQcGf ewZ96qlbeGRDC8R/S7Lo2PTDv0rnS9eOzuiu6kkjyqw8IOakOXxkWyW9Y83FqZV8s/SY cdnMZaBL6FJKcUaXOscZMShizpT6pBaLwcmGAs/zc/a7W3Uemx6WARcW/C+ZBOSM8S/0 H2Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=dTgFxwn6vi8KgAEYqZ6AE/Z7zzN+b2pvepGenxEfT9o=; b=PtWbFPA6BH6e56vQxzO+VmjJn4+cJYMiI4IUyB/UogLbh2wCzt1kW67OrUd609enxI 3Hd5E6q7T6/vtboR9nFwCfisc/aGlN0dBX/crPyAe4pKweXjkgLKJz9u7aWAcVQv0Iek /rryutu+3LrSwEBZtBmYAQ0k9xRP95qOVwF1S2xP6I0nLG2o1++yHZOpU1TOBZcCirbv TAWG2Q8f9yGPJIAMqrb4KTDhdnXjmvlDYwCkf2drnpZHD+/ykfHVoshwQixl853Sio3B c2DRzZK+PgAS1MQ4hQRRl49ZnVZQPCGvq2y+VHXd809u+DzbLF4AdlnXWEHmCHEsYs8U Zy+Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a72si15605753edf.28.2020.04.17.16.48.48; Fri, 17 Apr 2020 16:49:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727911AbgDQXqV convert rfc822-to-8bit (ORCPT + 99 others); Fri, 17 Apr 2020 19:46:21 -0400 Received: from mga03.intel.com ([134.134.136.65]:45942 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbgDQXqU (ORCPT ); Fri, 17 Apr 2020 19:46:20 -0400 IronPort-SDR: 7YJm9L6kGFEbGq9F7HuvgyF/ynFuUn6ymqLo0qClyDHPyUeB9h+tAN8yH6smYFf5gEnHxgGSZX D+qhV3o34n4A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2020 16:46:19 -0700 IronPort-SDR: ASTM0DenDX4diKwnGTttR6Xv7iDqv3xnQHPdpPTR7mJ4hGFXK2+44Gcq/V1yQWM1yzhcI/Jldu X9SO2dbxBxhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,395,1580803200"; d="scan'208";a="280903732" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga008.jf.intel.com with ESMTP; 17 Apr 2020 16:46:18 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 17 Apr 2020 16:46:18 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 17 Apr 2020 16:46:18 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.225]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.7]) with mapi id 14.03.0439.000; Sat, 18 Apr 2020 07:46:14 +0800 From: "Tian, Kevin" To: Jacob Pan , Auger Eric CC: Yi L , Alex Williamson , "Raj, Ashok" , "David Woodhouse" , LKML , "iommu@lists.linux-foundation.org" , Jean-Philippe Brucker , Jonathan Cameron Subject: RE: [PATCH v11 05/10] iommu/vt-d: Add bind guest PASID support Thread-Topic: [PATCH v11 05/10] iommu/vt-d: Add bind guest PASID support Thread-Index: AQHWCebOp12IiW87IUSByO2zgM/w7qhv6qkAgAJcu4CACNZVgIABkaSw///PdICAAIEBgIABEGEg Date: Fri, 17 Apr 2020 23:46:13 +0000 Message-ID: References: <1585939334-21396-1-git-send-email-jacob.jun.pan@linux.intel.com> <1585939334-21396-6-git-send-email-jacob.jun.pan@linux.intel.com> <20200410124557.4012b99b@jacob-builder> <6d9721a8-2198-5ecd-6c8b-fc43ff2ad7e1@redhat.com> <2025736d-e7f2-d746-e030-e609b2f465e2@redhat.com> <20200417082839.45d6321e@jacob-builder> In-Reply-To: <20200417082839.45d6321e@jacob-builder> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Jacob Pan > Sent: Friday, April 17, 2020 11:29 PM > > On Fri, 17 Apr 2020 09:46:55 +0200 > Auger Eric wrote: > > > Hi Kevin, > > On 4/17/20 4:45 AM, Tian, Kevin wrote: > > >> From: Auger Eric > > >> Sent: Thursday, April 16, 2020 6:43 PM > > >> > > > [...] > > >>>>> + if (svm) { > > >>>>> + /* > > >>>>> + * If we found svm for the PASID, there must > > >>>>> be at > > >>>>> + * least one device bond, otherwise svm should > > >>>>> be freed. > > >>>>> + */ > > >>>>> + if (WARN_ON(list_empty(&svm->devs))) { > > >>>>> + ret = -EINVAL; > > >>>>> + goto out; > > >>>>> + } > > >>>>> + > > >>>>> + for_each_svm_dev(sdev, svm, dev) { > > >>>>> + /* In case of multiple sub-devices of > > >>>>> the same pdev > > >>>>> + * assigned, we should allow multiple > > >>>>> bind calls with > > >>>>> + * the same PASID and pdev. > > >>>>> + */ > > >>>>> + sdev->users++; > > >>>> What if this is not an mdev device. Is it also allowed? > > >>> Yes. IOMMU and VT-d driver is not mdev aware. Here mdev is just an > > >>> example of normal use case. You can bind the same PCI device (PF > > >>> or SRIOV VF) more than once to the same PASID. Just need to > > >>> unbind also. > > >> > > >> I don't get the point of binding a non mdev device several times > > >> with the same PASID. Do you intend to allow that at userspace > > >> level or prevent this from happening in VFIO? > > > > > > I feel it's better to prevent this from happening, otherwise VFIO > > > also needs to track the bind count and do multiple unbinds at > > > mm_exit. But it's not necessary to prevent it in VFIO. We can check > > > here upon whether aux_domain is valid, and if not return -EBUSY. > > Ah OK. So if we can detect the case here it is even better > > > I don't understand why VFIO cannot track, since it is mdev aware. if we > don;t refcount the users, one mdev unbind will result unbind for all > mdev under the same pdev. That may not be the right thing to do. > The open here is not for mdev, which refcount is still required. Eric's point is for non-mdev endpoints. It's meaningless and not intuitive to allow binding a PASID multiple-times to the same device. Thanks Kevin