Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36973693rwd; Tue, 11 Jul 2023 07:59:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlFCMwCt9EW/0bCbXp7oQvrvTiKuv09/hoxur2SYH+2q7D+wxPM5kQXKWUrAd0If91EJWLly X-Received: by 2002:a05:6358:2495:b0:133:ac7:c847 with SMTP id m21-20020a056358249500b001330ac7c847mr14877938rwc.20.1689087562680; Tue, 11 Jul 2023 07:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689087562; cv=none; d=google.com; s=arc-20160816; b=z8xfBpfmzlCktHd3kpjzVpqW1qRa5ctdQywgvm9orP/zpjdw2fxhZUW0uvTsJfFURz /C4hEqQpVYHX17cnN/FGmyuPb4IjYD9VF15Fs1bJxBAPAUH8aHlnSAVWWI8WyYsII9od 8lEcd2N/+EH7WySv+HAiqd2x9Bbe7oyWRyxDGRMNfmhZezuI1hoBRIHXy2RAny0FK+Gr LXu4BS92rH+WNZAXI0uo7Y4/TG4b03NnppbxVdciwpiTzXebXPE2o0erf644cWwCoWrp i0LhgNCJnam6qxTnna7poNCENPbRRIO2H80A1MjU1YppJvAC/GiGvDvxvBlQoa5u36r8 4lNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=U2VjMIBaQFwFV2yCsiAIPkINHiaXP29T8v8fRYZCrOQ=; fh=QbDK5RzTFA07Ecq39vAyTB5DU2cqtriAikhlpy3mu8Y=; b=sMyboHa0ZCaJQLN+zopUBYP7oLRmd/EBvpiwExz0f3NLnTOOUPt61+Q89Ml0xPbM7/ NgCz3rIz1I21FolUZ6BkFo6gy9b6o049Dntit+pMjR/LrU9G5X0gye9EjSb7z/DmA3Q4 PoiNflqIx+Up/UmW38W+lwd6CDPmGO3nQP4Y+GkuAj6ftlcg0Ke9PiUW+FjbYr5Qy1NX jtNPin3qTMl7U0FNXeU9goGH+pL+jRgnDeqGHrjsw5Fa233rygOeA9NwXrEeR6cwQCEJ Tov/Wv7TqXVf5L8cBiSxiJhkL7vg7Hgh3PQLIMHgkrEuOU8lFkKL2FZZo6Jo20ShNf2Q km8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cUg4trA+; 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 h190-20020a636cc7000000b0055bc2561b72si1534049pgc.739.2023.07.11.07.59.09; Tue, 11 Jul 2023 07:59:22 -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=cUg4trA+; 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 S233631AbjGKO2v (ORCPT + 99 others); Tue, 11 Jul 2023 10:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234052AbjGKO20 (ORCPT ); Tue, 11 Jul 2023 10:28:26 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 334B51BC0; Tue, 11 Jul 2023 07:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689085678; x=1720621678; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hd7KPTyRP0JRvFe990SYWoGyr6006I4GxCYcQVy1VCM=; b=cUg4trA+t3NH/Vpxr1ucFyIePfFQzhzGQ8YdMlE4ZJ51QBXvU2LvrGGC tREYZlZkCts73Gte83Ry6Z0Ip5I/kzMqGwkhvDkZ2JHnzVgMhR4UK3WRu FjCFsCFSgHTUKzsRwmBQLc5dYx+JWRWt7EoXid73lC+9I/TEYom/dUHAM K+o9m0rdjbFhDTkqQyBnHZXu6Jlt1cqLcUGPrdKtOkZanOFOZ6LkKsY9K UXNuxliUy/DRUil0hp9Tr3LnbtF6k8WTBFeZ1lckhusQUYWh5fCbl8loD NdEbxxXymT871Px0Hwp8mtXrkTn8hdWrip2+tFVSd5EZlhDhiRq9gwKWT g==; X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="367212620" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="367212620" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2023 07:27:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="750774534" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="750774534" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.24.100.114]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2023 07:27:31 -0700 Date: Tue, 11 Jul 2023 07:32:28 -0700 From: Jacob Pan To: Baolu Lu Cc: LKML , iommu@lists.linux.dev, Jason Gunthorpe , Joerg Roedel , Robin Murphy , Jean-Philippe Brucker , dmaengine@vger.kernel.org, vkoul@kernel.org, Will Deacon , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , "Yu, Fenghua" , Dave Jiang , Tony Luck , "Zanussi, Tom" , rex.zhang@intel.com, xiaochen.shen@intel.com, narayan.ranganathan@intel.com, jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v8 2/7] iommu: Move global PASID allocation from SVA to core Message-ID: <20230711073228.7c4977f8@jacob-builder> In-Reply-To: <08830c11-5528-0c42-0bc3-89c3796611fe@linux.intel.com> References: <20230602182212.150825-1-jacob.jun.pan@linux.intel.com> <20230602182212.150825-3-jacob.jun.pan@linux.intel.com> <08830c11-5528-0c42-0bc3-89c3796611fe@linux.intel.com> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hi Baolu, On Sat, 10 Jun 2023 20:13:03 +0800, Baolu Lu wrote: > On 6/3/23 2:22 AM, Jacob Pan wrote: > > +ioasid_t iommu_alloc_global_pasid_dev(struct device *dev) > > +{ > > + int ret; > > + ioasid_t max; > > + > > + max = dev->iommu->max_pasids; > > + /* > > + * max_pasids is set up by vendor driver based on number of > > PASID bits > > + * supported but the IDA allocation is inclusive. > > + */ > > + ret = ida_alloc_range(&iommu_global_pasid_ida, > > IOMMU_FIRST_GLOBAL_PASID, max - 1, GFP_KERNEL); > > + if (ret < 0) > > + return IOMMU_PASID_INVALID; > > + > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(iommu_alloc_global_pasid_dev); > > "dev->iommu->max_pasids == 0" indicates no pasid support on the device. > The code should return IOMMU_PASID_INVALID explicitly. Perhaps we can > make this function like this: > > ioasid_t iommu_alloc_global_pasid_dev(struct device *dev) > { > int ret; > > if (!dev->iommu->max_pasids) > return IOMMU_PASID_INVALID; > > /* > * max_pasids is set up by vendor driver based on number of > PASID bits > * supported but the IDA allocation is inclusive. > */ > ret = ida_alloc_range(&iommu_global_pasid_ida, > IOMMU_FIRST_GLOBAL_PASID, > dev->iommu->max_pasids - 1, GFP_KERNEL); > > return ret < 0 ? IOMMU_PASID_INVALID : ret; > } > EXPORT_SYMBOL_GPL(iommu_alloc_global_pasid_dev); > good catch, sorry i missed this. let me send an updated version. > Other change in this series looks good to me. > > I hope I can queue this series including above change as part of my VT-d > update for v6.5 to Joerg if no objection. > > Let's try to re-enable this key feature of Intel idxd driver in v6.5. > > Best regards, > baolu Thanks, Jacob