Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp288033rwl; Tue, 11 Apr 2023 18:38:38 -0700 (PDT) X-Google-Smtp-Source: AKy350a5uZjduXLosLql6g63OqvbJZHhsQVC1+2Bq9OAkbHZLiucdI1ViJoWW6CJqxUXk+C5hWN4 X-Received: by 2002:a17:902:bc47:b0:19a:a815:2858 with SMTP id t7-20020a170902bc4700b0019aa8152858mr422362plz.51.1681263517708; Tue, 11 Apr 2023 18:38:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681263517; cv=none; d=google.com; s=arc-20160816; b=SIgwd759hXUKrDc09Cslag82Za9WHIImC7dchuAzCGNnOt5pmIcnZywYDMXbpk4mSp HNAUYeuU7n03wlISYmE4KXX5asiGyTFLtDIruzFdsBcRU/ttocx2kDJvQrd9fn49KzZS TOkeSLSI2winysaSVfexHPw1N/vVk2jZ+N8+k8obdCBqpAvGWFNgXL5yshNUaquG3n14 RZovcC2i2Uq7iyVwTZb9jtJ5bVNXJhNzgYyDcYn5ha3wh4yWiHDtFiS8N8yuEyNODjE1 mqwZ6KM2Y2RUYbvHW5WR0lssByeB+hRUEEYMSHV5blujDejLEZm9qGxj5L1PzNRCQXYh 1mxQ== 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=cf0QqwKBatNyfEz22Rfsg2Z4dg3EuU5fuEfvaQHuPBE=; b=GS3eYuWm7w0cxmQaeiQUiXkLq3xYs/D0sQ74k0OPei0A4tkKkKrWFMvwJHvdD9w2Nj BL7sM5rHh4pGA7TCpGnhX1rI992HgRR1kf/SGeyUuKm7Geq+QOLaLmCFauNRoUdDc1v3 pvZQNfas1NFN7IzA4+sBndipJsimyyBrLxz784jZYA+4ArBYj5nbERmTKszLKnlJgvdY NeN7FbaGB/sFW4Jo4nm7p0LKvLF84vTjvml/AjDOecg5N0druD4sm9unZEzwapiqqffu 10G3rBfgPjq1zIMSdvQzAec3+yY/c8cdREfA+7DJGFVAoSDMYrxpRkuw1hmsqJHDmush qTUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CH19JVrA; 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 o12-20020a635d4c000000b00512fab8c401si14111241pgm.427.2023.04.11.18.38.15; Tue, 11 Apr 2023 18:38:37 -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=CH19JVrA; 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 S229522AbjDLBhu (ORCPT + 99 others); Tue, 11 Apr 2023 21:37:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjDLBht (ORCPT ); Tue, 11 Apr 2023 21:37:49 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24FBB127; Tue, 11 Apr 2023 18:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681263469; x=1712799469; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=Ata9j+ZswHLaGP/PHNwL4yocWtHRfpgEJsv6Q2EQZTk=; b=CH19JVrAzctTdPFY6rjbffgTL+NzoBwmsvR/bY7fSQaMsObMZrEZB1Ew ZoF40QNV6Z16K/uMGIG6rRnFCtTNiRCpcCPfwkIAveRQ0HXv8V9mN3Fv4 nF3p1HnOn7UUO5/KRrn0LdNJzwzt+HL/GRANRQlgBI1yegxkn735K95S3 Aog/X87TKofWvtaT0u4EhNA2C627aNRQDBLqqhksEwSg/wJVvsNdmzEw9 xDmfkIW0W4MKtpTHejfqWlwNHfOu1bCuNMMiHVEyELKxcEhAxX/uGiEhv d09lD631Y6zEl3ZPK8KZ12zMDB4SJ2S496/vTq/72wmXZX+qX7eu5OKsM A==; X-IronPort-AV: E=McAfee;i="6600,9927,10677"; a="343781731" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="343781731" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2023 18:37:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10677"; a="812799318" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="812799318" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by orsmga004.jf.intel.com with ESMTP; 11 Apr 2023 18:37:43 -0700 Message-ID: <5882ee52-9657-250d-0474-13edffa7b6b9@linux.intel.com> Date: Wed, 12 Apr 2023 09:37:48 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Cc: baolu.lu@linux.intel.com, Will Deacon , David Woodhouse , "Raj, Ashok" , "Liu, Yi L" , "Yu, Fenghua" , "Jiang, Dave" , "Luck, Tony" , "Zanussi, Tom" Subject: Re: [PATCH v4 3/7] iommu: Support allocation of global PASIDs outside SVA Content-Language: en-US To: "Tian, Kevin" , Jacob Pan , LKML , "iommu@lists.linux.dev" , Robin Murphy , Jason Gunthorpe , Joerg Roedel , "dmaengine@vger.kernel.org" , "vkoul@kernel.org" References: <20230407180554.2784285-1-jacob.jun.pan@linux.intel.com> <20230407180554.2784285-4-jacob.jun.pan@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=-6.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,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 On 4/11/23 4:02 PM, Tian, Kevin wrote: >> From: Jacob Pan >> Sent: Saturday, April 8, 2023 2:06 AM >> @@ -28,8 +26,8 @@ static int iommu_sva_alloc_pasid(struct mm_struct >> *mm, ioasid_t min, ioasid_t ma >> goto out; >> } >> >> - ret = ida_alloc_range(&iommu_global_pasid_ida, min, max, >> GFP_KERNEL); >> - if (ret < min) >> + ret = iommu_alloc_global_pasid(min, max); > > I wonder whether this can take a device pointer so dev->iommu->max_pasids > is enforced inside the alloc function. Agreed. Instead of using the open code, it looks better to have a helper like dev_iommu_max_pasids(). > > and do we even need the min/max parameters? With special pasids reserved > then what driver needs is just to get a free pasid from the global space within > dev->iommu->max_pasids constraint... > > iommu_sva_alloc_pasid() can be reworked to avoid min/max by taking a > device pointer too. Best regards, baolu