Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp553211rdg; Tue, 10 Oct 2023 20:22:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsME7VXmd5tfJ4ovpKdThfnZhbJiHWYo9ydBfFO/J+ygRuANY2w0OKvih4diiGqT/QmRz4 X-Received: by 2002:a17:902:ed06:b0:1c9:ba89:5cb6 with SMTP id b6-20020a170902ed0600b001c9ba895cb6mr2746499pld.63.1696994560227; Tue, 10 Oct 2023 20:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696994560; cv=none; d=google.com; s=arc-20160816; b=HXEsNLAoTPAlkM8fWyi+ocABwYDdk+FIKg0F/mmkXALlBhIwpou2OWFrWrar2n0neO 8WhqkjjIWeLI7w4eJOKkiyOmpVBeSWvUgVRNlJdhKvOfk4RmGRa/SyHEGiNN/lKjla/J aA8dUPYyDlqtB8cqAZD2MQm80cW0YF2VF4Jlqz+Bhfm5+Ykv3btt2crEpZRGTiUm0DLd nO/rBDAwxNHFalPAWbG5innQMXwBRVqSPsaRVbP4IRrjujTY30OhimRbVrpov9X3m4wo sgTgQW2+2RvU4bQguC1XWGsF3sNoKYHD5lfGRmBHxVC1xWRAE8cdmQ5mzZr5PPkExIUx FStw== 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=adoB4WOsyaZmTJP/j1fWEElRP/otlg3KORVSN4UFFC8=; fh=fhSGjGWshScF+lLC4Uqwb9VoGEV2GgJ3LlB3Wll3Bag=; b=XDH/mgIUjS9fVClO/fm0pcquPfXTA1ZwgU3O1zdnuumKZFctqI3IMgb1NjGuFXQygq VP8fvtGXi2ouEVHQxq32gnZFk70WDCvosbcQm9LIbG+kUO4HL0+2EIhuK6l2wmkTNiZV x/xBh6za67FIItuXkqEmHUsxNbA+u9TfevYBc52zmT2ztQh2bWGXaTXtVMS/oNN9zuS/ so3HoI7e/cVXdtYjn1ZKcPbfEZoMl9X28iUEE0FFG4q7/AH0Vr9bss0NBunzVHkYIXRa RVBDeKXJpKXanQfrpwM6OvpEBY48+Epp6/r6ClcgO3fNvuIswKTdV9p2gqwWkODOcWK5 P8hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FxB1iKyU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d14-20020a170903230e00b001bc079974dbsi14517825plh.355.2023.10.10.20.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 20:22:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FxB1iKyU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E75FB80F696A; Tue, 10 Oct 2023 20:22:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345000AbjJKDWZ (ORCPT + 99 others); Tue, 10 Oct 2023 23:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344915AbjJKDWX (ORCPT ); Tue, 10 Oct 2023 23:22:23 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7D5D91; Tue, 10 Oct 2023 20:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696994541; x=1728530541; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=mfGQA09nt+pjnB7NA+LILPA/SIcWHOBZ2pc/nhd6wsU=; b=FxB1iKyUWuDSxDosftBfKNMxNfGxAlA8qBZLKFWmP5c4cyx63syUC8Fh RRiT0ABrcRREH+HkOa/ik8v7k/PabXdu4SBEdG7srNGsJmntgwyBz69ON phsTfr7xsEq1fdrTB5xELm7cfnR3VLauhSTVFvXZnQkfb02rNBnTpypLf PuVbzFm3esfVsMrkMRt97aJjbytIfFVL5dobXXm3mKTamsQWfUJ6V3U4p LHn4RMtolp/aI7L4D2sZk+x3zMBgRK6iqJY9ytCTeN/Fe2KrWCp1QHELL kNBpjDbKHxvKKHhcBKw49Iz9mIlbi8dtXvVmS2Ncz1v7A5irhJcJfpaEe g==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="364852543" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="364852543" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 20:22:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="877501933" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="877501933" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by orsmga004.jf.intel.com with ESMTP; 10 Oct 2023 20:22:15 -0700 Message-ID: <558c3038-11b4-4afe-b441-fe62b646a192@linux.intel.com> Date: Wed, 11 Oct 2023 11:18:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, joro@8bytes.org, alex.williamson@redhat.com, kevin.tian@intel.com, robin.murphy@arm.com, cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com, yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com, shameerali.kolothum.thodi@huawei.com, lulu@redhat.com, suravee.suthikulpanit@amd.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, zhenzhong.duan@intel.com, joao.m.martins@oracle.com Subject: Re: [PATCH v2 6/6] iommu/vt-d: Add domain_alloc_user op Content-Language: en-US To: Jason Gunthorpe , Yi Liu References: <20230928071528.26258-1-yi.l.liu@intel.com> <20230928071528.26258-7-yi.l.liu@intel.com> <20231010164355.GA74795@nvidia.com> From: Baolu Lu In-Reply-To: <20231010164355.GA74795@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 20:22:38 -0700 (PDT) X-Spam-Level: ** On 10/11/23 12:43 AM, Jason Gunthorpe wrote: > On Thu, Sep 28, 2023 at 12:15:28AM -0700, Yi Liu wrote: >> This adds the domain_alloc_user op implementation. It supports allocating >> domains to be used as parent under nested translation. >> >> Signed-off-by: Yi Liu >> --- >> drivers/iommu/intel/iommu.c | 28 ++++++++++++++++++++++++++++ >> 1 file changed, 28 insertions(+) >> >> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c >> index 5db283c17e0d..017aed5813d8 100644 >> --- a/drivers/iommu/intel/iommu.c >> +++ b/drivers/iommu/intel/iommu.c >> @@ -4074,6 +4074,33 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) >> return NULL; >> } >> >> +static struct iommu_domain * >> +intel_iommu_domain_alloc_user(struct device *dev, u32 flags) >> +{ >> + struct iommu_domain *domain; >> + struct intel_iommu *iommu; >> + >> + if (flags & (~IOMMU_HWPT_ALLOC_NEST_PARENT)) >> + return ERR_PTR(-EOPNOTSUPP); >> + >> + iommu = device_to_iommu(dev, NULL, NULL); >> + if (!iommu) >> + return ERR_PTR(-ENODEV); > Why isn't this just > > struct device_domain_info *info = dev_iommu_priv_get(dev) > struct intel_iommu *iommu = info->iommu > > ??? > > Same question for almost all other calls to this function! The one in > probe is reasonable, but I don't think it should be ever called again. > > I'm going to leave this, but please make a series cleaning all the > device_to_iommu() stuff next cycle.. Sure. I also have a plan to do this. device_to_iommu() is only needed in the probe path. For runtime callbacks, we can just retrieve it from the device's iommu private data. Best regards, baolu