Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2611808imi; Mon, 25 Jul 2022 03:32:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sUc447B0J4ily3x0nT+f9gEwCK2cplt469/HW/0gTmElMISHKuFcEpQP+wJGimD6XDx2hZ X-Received: by 2002:a05:6402:3554:b0:43b:ed52:12 with SMTP id f20-20020a056402355400b0043bed520012mr6214147edd.119.1658745120974; Mon, 25 Jul 2022 03:32:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658745120; cv=none; d=google.com; s=arc-20160816; b=cCG7gBnlv68zMuH8pHVIPcQtZt7wsKiNeHHRhksXchH6/fCE+QMV/mBYv27EyrUPgK 5ksE0HRjHCjVatm0+4WQwsy4dGG4mm0qe+MPVt+rU94sYvhs7b823t/u4tJUMxxsVMaY FxL4CrmhBrgaYsj7FhTYt70jWneign3V0Oop9+nouxtv93zsRHaHxuC1WUKtHJwPEFKy L6NQcbLKJtlUSYWZDDfFF3Rh3PmDhDZPIgoBJMsxlYSoNePziTOwIzoeT2jWmUznh6oh yATx8iHhvke2IBnunFqL4wL6tBNBtXWhQiVn/IQMIf0qYri0hb5Mmd4Ise/GipJcAs5f ayLQ== 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:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=uSsIpjprRtr8zI07FaH6+kM6x9FkQ88vbhyIAbSTApk=; b=eEIwPV+eQ4BT6Vd5rxC6qCil/9kw2150p0Ih01P1pJKtdNDUI0zheCnrnVT9Fgw0bW 5zHnledkZ0lnzrVkuUd2enMUguKM7FdF+8AoMahl/t6hSC/wM8urYyLO/wuI870Z/oMe On+kEb2k7pPpbvxtnuCcAeL1DF+7LAVNktncyOadv2i06wvZhXCtzsxNK5/HcId7idki u7j58+zOryx0r7tu+l07FjgrtFcD21deFEDpHtxvMIWBOFvA9iv5HQgOQHWdXexUxesv WAQfTKGdDhB5PiT5xHsVyO1NPnQSslzCXxJGtXYg1Pd8SMCuM6G16KrCLEdgfgoq5rx2 7P5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FdkodQZe; 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 ss24-20020a170907c01800b0072af8809a85si8505149ejc.332.2022.07.25.03.31.36; Mon, 25 Jul 2022 03:32:00 -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=FdkodQZe; 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 S234111AbiGYKLh (ORCPT + 99 others); Mon, 25 Jul 2022 06:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234690AbiGYKLZ (ORCPT ); Mon, 25 Jul 2022 06:11:25 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BC92FD13 for ; Mon, 25 Jul 2022 03:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658743878; x=1690279878; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=1kqxjz8pEwN4Kot1Jt27wFtLc1vilZcf22t+QeswRi8=; b=FdkodQZeh7U5pdupHIqVQe5t8N9ewFZaMYNst55Wu2RlsTIsW1DS7pfv FQhHrCqt6hqA6CgcSKRvWDuAAlBhiLKczxXhRvsc+Tq4FnaJ3KjLe1KRu BSHvkk2M0Pc3Y1FM6CvB8+aXrPcxVweNlm5gPMdOIpKoOPh2ODs+l2Mqs 6v8ouN5tKy7e4moNMhb4zsOrUNvINtn5JE08hkMzVtinj70eet63soKRT VTio+GODf4f2rgvr+idl6HFf0JnFOSrHHHrAl0GDPDX38Ii/1eGcT+m1i jTavvA/mk892TsrsDBWF9Fb+rscLty0XsZyMkWqUJN0rP/6sVMmUJXkPr w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="351656941" X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="351656941" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 03:11:17 -0700 X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="658125872" Received: from liangk-mobl.ccr.corp.intel.com (HELO [10.255.30.67]) ([10.255.30.67]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 03:11:13 -0700 Message-ID: <441f6537-dde0-885a-3cc2-089b3ed4f4df@linux.intel.com> Date: Mon, 25 Jul 2022 18:11:13 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cc: baolu.lu@linux.intel.com, Joerg Roedel , Christoph Hellwig , "Raj, Ashok" , Will Deacon , Robin Murphy , Jean-Philippe Brucker , "Jiang, Dave" , Vinod Koul , Eric Auger , "Liu, Yi L" , "Pan, Jacob jun" , Zhangfei Gao , "Zhu, Tony" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , Jean-Philippe Brucker Subject: Re: [PATCH v10 04/12] iommu: Add attach/detach_dev_pasid iommu interface Content-Language: en-US To: "Tian, Kevin" , Jason Gunthorpe References: <20220705050710.2887204-1-baolu.lu@linux.intel.com> <20220705050710.2887204-5-baolu.lu@linux.intel.com> <20220723141118.GD79279@nvidia.com> <5d353fe4-b642-992e-ef42-7d7f8b2edf7e@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 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 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/7/25 15:46, Tian, Kevin wrote: >> From: Baolu Lu >> Sent: Sunday, July 24, 2022 5:14 PM >> >> On 2022/7/23 22:11, Jason Gunthorpe wrote: >>>> +void iommu_detach_device_pasid(struct iommu_domain *domain, >> struct device *dev, >>>> + ioasid_t pasid) >>>> +{ >>>> + struct iommu_group *group = iommu_group_get(dev); >>>> + >>>> + mutex_lock(&group->mutex); >>>> + domain->ops->block_dev_pasid(domain, dev, pasid); >>> I still really this OP, it is nonsense to invoke 'block_dev_pasid' on >>> a domain, it should be on the iommu ops and it should not take in a >>> domain parameter. This is why I prefer we write it as >>> >>> domain->ops->set_dev_pasid(group->blocking_domain, dev, pasid); >>> >> >> I originally plan to refactor this after both Intel and ARM SMMUv3 >> drivers have real blocking domain supports. After revisiting this, it >> seems that the only difficulty is how to check whether a domain is a >> blocking domain. I am going to use below checking code: >> >> + /* >> + * Detach the domain if a blocking domain is set. Check the >> + * right domain type once the IOMMU driver supports a real >> + * blocking domain. >> + */ >> + if (!domain || domain->type == IOMMU_DOMAIN_UNMANAGED) { >> >> Does this work for you? >> > > Or you can call __iommu_group_alloc_blocking_domain() in the sva > path and then just check whether the domain is equal to > group->blocking_domain here. Above check is in the IOMMU driver where group->blocking_domain is not viable. I ever thought about have something like struct iommu_domain *iommu_group_blocking_domain(struct iommu_group *group) to return group->blocking_domain. But it looks redundant. Best regards, baolu