Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1155927rdb; Wed, 20 Sep 2023 00:47:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGW6LOZvr4o3hLBqAAZGKHjt96dyQoY57l83wcCKLGVhPI8l+ieYna0IbIxAyj7FAcnAbY5 X-Received: by 2002:a67:d08d:0:b0:452:607d:8603 with SMTP id s13-20020a67d08d000000b00452607d8603mr1905160vsi.1.1695196076419; Wed, 20 Sep 2023 00:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695196076; cv=none; d=google.com; s=arc-20160816; b=CZ9/4q72HgKYJXPcSbm6nHEtwdC1QMLRqJEUmAUW0BflSytVisJ2TnnPDVrUUGK7vB BeThnR2sLh7aBt0SMtTXcDDio5vckYpXkLppN2n17Y4iKYmPqmJT2arADYd91OHEZT5w KOF3bq8prFw3VfX9GTUk8S9IzlKx4K2mBS7TEr+fzgqHNqliSXX/thAhzpvRCpxd7vqb MaL8T0SfRfI8OHV7Lhn0fa/pJYrOeTJzsUbpqH3K39P5Zyet/7224sckNR3Y+ZQJZ5hf lxhg6DTNBbsZaHWNNsVtMeqYBwnQvXlqPpnXm3bgOyjY0RgVPpr1WyXoycTPYrFQZq2d IE8w== 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=q4wGDiO4btuykN49Xc9D+R8lm6X03vgNLiDA3PxcbT0=; fh=RyUMBMrENLl9z3agrcvUie7TturAiXShjxmDx0E12f4=; b=KQpEl8aa7Hv373sj291NBuG6VsyPKvB/zv0PxJFZifvYISlONFxFqb1CxluZIPrdlP xkVGA0/iqkXcLE2ArxV2R30H8Na1n2kNTXoEaSKcwfiGoDS8FOYJn19K14XVCs4l8scI H6pA47yytCaxm0o5nlWGTtrqF7yLSgbAQ0bRBANMwzylTQEOAxus/yzt5hYvnJyk86s1 fFcUj+qF7lAfF2WzGtMNbhscLhxu5s2nDYzGFGrVu9aNiJ9uaCjs5Q+a8bhe+5h6v94Y /6tOqIbsqPfMP6E6+4Su5ngo3Kq430Qb28B1EAonqfVLQoaMAdc2yYAHFJwjAGY4T/eK XAtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cIlTPRo5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00578ca217740si1820159pgb.711.2023.09.20.00.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 00:47:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cIlTPRo5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 7FA9D80608C1; Tue, 19 Sep 2023 22:32:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232446AbjITFcD (ORCPT + 99 others); Wed, 20 Sep 2023 01:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230021AbjITFcA (ORCPT ); Wed, 20 Sep 2023 01:32:00 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFC9994; Tue, 19 Sep 2023 22:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695187914; x=1726723914; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=2ZDObok8tPCkBhY6mmZB5GJuaJNpwpqQA9IWqa6JVVc=; b=cIlTPRo5ZMDfKHf1PhlDW/3Dc6mw6TGdS+bLzq4valYKCBvRE9Taqrj+ 2dCnMPKEDgxax3TiNO8LAtBJBt1NKYW51avF4e2vwNSgHR9N5mPLylNDV gaGm6ByQLwDD1VVIInPDYx0r+Bq9muSUPZI67TSTcaYwBiwakEj7nOuF5 ZY/8ELuwjbf+3pO4Q/K3FvMTcrgnr0AvCg5/Xp2mzti7IlbzQruAPel7H SKG1HAA6nB5bFBqQBIQD+TSkbRiQ4g3rt4hffY5tMUKE5ecKsyz6XHdOD NvaP5lTuHcdZC0qhaZoelju2MqSyVCYNJKFrYCzJPbVhy7uxvW1R755cG w==; X-IronPort-AV: E=McAfee;i="6600,9927,10838"; a="365179311" X-IronPort-AV: E=Sophos;i="6.02,161,1688454000"; d="scan'208";a="365179311" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2023 22:31:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10838"; a="861832052" X-IronPort-AV: E=Sophos;i="6.02,161,1688454000"; d="scan'208";a="861832052" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by fmsmga002.fm.intel.com with ESMTP; 19 Sep 2023 22:31:48 -0700 Message-ID: <7aa8fd9e-e43d-db68-bdb6-fe4f891255ca@linux.intel.com> Date: Wed, 20 Sep 2023 13:28:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Cc: baolu.lu@linux.intel.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 6/6] iommu/vt-d: Add domain_alloc_user op Content-Language: en-US To: Yi Liu , joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.com References: <20230919092523.39286-1-yi.l.liu@intel.com> <20230919092523.39286-7-yi.l.liu@intel.com> From: Baolu Lu In-Reply-To: <20230919092523.39286-7-yi.l.liu@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 19 Sep 2023 22:32:09 -0700 (PDT) On 9/19/23 5:25 PM, Yi Liu wrote: > This adds the domain_alloc_user op implementation. It supports allocating > domains to be used as parent under nested translation. Documentation/process/submitting-patches.rst: Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behaviour. So how about, Add the domain_alloc_user callback to support allocating domains used as parent under nested translation. ? > > Signed-off-by: Yi Liu > --- > drivers/iommu/intel/iommu.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index 5db283c17e0d..491bcde1ff96 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -4074,6 +4074,25 @@ 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; > + > + iommu = device_to_iommu(dev, NULL, NULL); > + if (!iommu) > + return ERR_PTR(-ENODEV); > + > + if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ecap_nest(iommu->ecap)) > + return ERR_PTR(-EOPNOTSUPP); > + > + domain = iommu_domain_alloc(dev->bus); No need to bounce between core and driver. Just, intel_iommu_domain_alloc(IOMMU_DOMAIN_UNMANAGED); and fully initialize it before return. > + if (!domain) > + domain = ERR_PTR(-ENOMEM); > + return domain; > +} > + > static void intel_iommu_domain_free(struct iommu_domain *domain) > { > if (domain != &si_domain->domain && domain != &blocking_domain) > @@ -4807,6 +4826,7 @@ const struct iommu_ops intel_iommu_ops = { > .capable = intel_iommu_capable, > .hw_info = intel_iommu_hw_info, > .domain_alloc = intel_iommu_domain_alloc, > + .domain_alloc_user = intel_iommu_domain_alloc_user, > .probe_device = intel_iommu_probe_device, > .probe_finalize = intel_iommu_probe_finalize, > .release_device = intel_iommu_release_device, Best regards, baolu