Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1378207rwn; Thu, 8 Sep 2022 19:09:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR6yrdOmvqOMCed9A0vkCKJxz6VUvvsqCLjCWRG3mxByv7AbiNMLMKM9/CWJltoMfjm3bvvS X-Received: by 2002:a05:6512:139c:b0:48f:da64:d050 with SMTP id p28-20020a056512139c00b0048fda64d050mr3341218lfa.268.1662689370106; Thu, 08 Sep 2022 19:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662689370; cv=none; d=google.com; s=arc-20160816; b=dNg8XY+/s2gkUU5A+sdtnWi9XkIqcWgVtxDyTZk1GvmUsV9BqBP3ajd+DNaR9zuWIm I6sETeQMx6TQLGczeFgx4X9nSuhWtZbpcCE+duZM31L60icppSLvhOXfe+iA2/SiJSog AjbILxRMMRIEK64of9G/ppnI4A/tbGOo/0UNllWTJVyX3ySVfKQX/5Sotk+5NsatC4/G y0YqzUchnon5Th77EfvBYihKMgblGUD5IlU9qZAh/rg92Xz55xuRAIKJJywC/wo+65r/ g+qKHrU+ufvpQg0HuSR1gzvil1tloqVd998mPfzIT59sqZT3weD/ggEg9hoQVDcb12ya aLFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:to:content-language:cc:user-agent:mime-version:date :message-id:dkim-signature; bh=+s7DY5++rWFLPQ51l2gZqvTjMmskcByZZyJA6u9yHvw=; b=OTsSNHQcxJ/DNDd0+RRl9FITS8+MiLHZ5FWMeei5NE28l1rte+d9niv7A3SuD8VOkG RJc5+wajaxIlgDx1af4q1PjFJR5uPOVbX1J5Id/4yA5geP8jyTlUGE2kzghNFQgb6+ZM Gnpa+gn9dm5fdgWr3zj7jRnvo5Of6qZLmIPCmxFLEIYUgrxR6vn1FlG0+iCjwe5kNfl+ ix7Dy1ubB+ozJbq6opudWSEUC7BF1vzf/zg1AwKE+LTeDerzGl3tJ5rQByISVTSISWk7 1Zhl51ZzDdoUiFBV8FQfvFYY5D3ydpe9f9wE9N+bvcGv/JmdHk34Sup3UM7EB+ySCtoW SEBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jHfzaO81; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a2ebe13000000b0026180ef7bd5si228126ljq.524.2022.09.08.19.08.59; Thu, 08 Sep 2022 19:09:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jHfzaO81; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbiIIByT (ORCPT + 99 others); Thu, 8 Sep 2022 21:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbiIIByP (ORCPT ); Thu, 8 Sep 2022 21:54:15 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E0A7A50F9; Thu, 8 Sep 2022 18:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662688455; x=1694224455; h=message-id:date:mime-version:cc:to:references:from: subject:in-reply-to:content-transfer-encoding; bh=V8rWhGS1JBuyEKj5MooRa936Kyq13co5hPOuxZW39vo=; b=jHfzaO81jgHc6/5uJglCGPcyTEIgqS2UZSXShlrEF7xfLvrO6RbFJk+P IQTGVVDBZxbmPtWaLKElAEbkMwyQpVbt0xsi1qLJNHTwfuoB4vrwCjODf xfoWYjubHKmRv4oShe0o5NwBXxGPZnGeoM3cDwI5FjxnEX4YALTPtXfUz PwWP/A4LNItQuwt/PK5pS9aWoMQVArCFoEUdKmZi+6Bb+T6xKiN9XNssx t4DDqG26b23yg+xAGDNUH8XyC+ftp/dFtHDU9hER6Dc+YRFEF+2TTabRS B8zwLQ/iairKPZqWcddazd+9b01TC0uYCYD+pxqN+Tc+ZZVnmcor4napB A==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="277760452" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="277760452" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:54:14 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="676961624" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.214.159]) ([10.254.214.159]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:54:09 -0700 Message-ID: Date: Fri, 9 Sep 2022 09:54:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Cc: baolu.lu@linux.intel.com, Joerg Roedel , Christoph Hellwig , Bjorn Helgaas , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Fenghua Yu , Vinod Koul , Eric Auger , Liu Yi L , Jacob jun Pan , Zhangfei Gao , Zhu Tony , iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Content-Language: en-US To: Jason Gunthorpe , Jean-Philippe Brucker References: <20220906124458.46461-1-baolu.lu@linux.intel.com> <20220906124458.46461-10-baolu.lu@linux.intel.com> <682d8922-200d-8c89-7142-83e7b3754b8d@linux.intel.com> From: Baolu Lu Subject: Re: [PATCH v13 09/13] iommu/sva: Refactoring iommu_sva_bind/unbind_device() In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/9/9 0:41, Jason Gunthorpe wrote: > On Thu, Sep 08, 2022 at 05:25:32PM +0100, Jean-Philippe Brucker wrote: >> On Wed, Sep 07, 2022 at 02:33:11PM -0300, Jason Gunthorpe wrote: >>> On Wed, Sep 07, 2022 at 10:54:54AM +0100, Jean-Philippe Brucker wrote: >>> >>>> Is iommu_domain still going to represent both a device context (whole >>>> PASID table) and individual address spaces, or are you planning to move >>>> away from that? What happens when a driver does: >>>> >>>> d1 = iommu_domain_alloc() >>>> iommu_attach_device(d1) >>>> d2 = iommu_sva_bind_device() >>>> iommu_detach_device(d1) >>>> >>>> Does detach >>>> (a) only disable the non-PASID address space? >>>> (b) disable everything? >>>> (c) fail because the driver didn't unbind first? >>> I think it must be (a), considering how everything is defined and the >>> needs for vIOMMU emulation. >> Yes (a) is probably better. The SMMU driver currently implements (c) to >> ensure that you can't switch device driver without unbinding everything >> first, and we should keep that check somewhere > Yes, the owner stuff is a logical place to put that, when ownership > is all released the PASID table of the group must be empty. Lu? I agree. The ownership is about the whole device (more precisely, group), including the RID and PASIDs. When the ownership is converted, the pasid array must be empty. I will add code in this series to enforce this. Thanks for pointing out this. Best regards, baolu