Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp397634rwr; Tue, 2 May 2023 23:35:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ARMc9Y6kLlwqZ+moMTAfPxAbxoIfmJlsIpW9VI/1aGH0WvOurSiLJN+TyTgORcW6m++qE X-Received: by 2002:a17:902:dad0:b0:1a9:7622:e2f2 with SMTP id q16-20020a170902dad000b001a97622e2f2mr961588plx.66.1683095718270; Tue, 02 May 2023 23:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683095718; cv=none; d=google.com; s=arc-20160816; b=XcpV0GAuwfktnImfuTVkuvBPKhQkYXfLjXz/wf4jNZXgyauy4ovveJN4RGUGu11OST tYs6UNcuMFk77JBdQ6Qhx0JAF2+BB5mGh5shsdvUcEVMucmzbmzrZPtshD4G6CXhJ8Ou r9SyBmCQaq+rtSG10kf9I0wlEMchFsGYEtS75Y5RXTwjuNhJv8JbT5zg1u3ocOpS+4p6 OsZs0op1oRPcZC+6HJzw23ptHzubARgGMCf62HgsQ5qvV/XGPT1kvoJtOfDNGTPk3qvd zMys5BV/prcnjDIqki/CFo7o8Wdefg4edkGjEbCj2VcvBrDEeq5dLLSf6/TxSw3h3Uha 1AGQ== 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=edM6x8+xkJeYzS54e0bzC1sWRGJAaMMpyzn9ZC3MJS0=; b=PvMwxsGVWYOpvHFRskn4Q+KoIRv+9Y/3h/MWZ4LFC5BNZEiXebw8UlrlM244aoDwpx LMaiRGxbkbY2G2JlaDsvXS+UCnRNMZhZ+3LlDxZexaRppmSlQ4SocN2Gn06HD/CQf5T9 ElUGIsIMD0hTAqTsozpY1WUKuAaL6GSqbiATu4ktDprcdqKlQ3uJ5pizsM5rggjQX40V hpm7B4kDlbCt/3GFSgzX3KOoJaTDrAP6OlfzPn/M6kB0mBuVKmnCev6p54dUIovIJU7C 8DuiOSZ/jm85WRBCdijVR994RldWVoqQrnFKntelSnMWt7XMayQsuFN5q8LaT+DA2l5d vipg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GttYtMBd; 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 b18-20020a170902d51200b001a9265e6fdasi34448411plg.268.2023.05.02.23.35.03; Tue, 02 May 2023 23:35:18 -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=GttYtMBd; 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 S229553AbjECGcn (ORCPT + 99 others); Wed, 3 May 2023 02:32:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjECGcl (ORCPT ); Wed, 3 May 2023 02:32:41 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C77D1BC1; Tue, 2 May 2023 23:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683095560; x=1714631560; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=e5swZYwhebmaWxsOicAhkmAZGeGkAWyKrW2zu6S4FRg=; b=GttYtMBdILImotpP7wlw4asna1U3dfSnUCtB3WJfeTCU+g9MN6mjgSv9 VIbKNtwL+j3JwNtb3H3suYot9RtNdP4m3agLYX+lc1O2dPRO0fwgCtCjI 5LB7RY/mn0EpgOmpB0Ol0XR88bJfK+zPwiWCEACHUgNnELeJYfYqf1J6u ZmSeqe71Oq7c5LGlJhiJOuCxj9bgM9YkrvGLTa6Nql+yCHsUw93bmk5uP /L/EQk27LqDzWh1POzrzBYJoZBzSyeAPrJqHYejONRRTYaNYJvKGPW917 cNaJE/4e4IQUw2Fqvm9k2Biqkw45atyKUj728551Z2WUu2vhw4/aUyscb w==; X-IronPort-AV: E=McAfee;i="6600,9927,10698"; a="347397789" X-IronPort-AV: E=Sophos;i="5.99,246,1677571200"; d="scan'208";a="347397789" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2023 23:32:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10698"; a="646805690" X-IronPort-AV: E=Sophos;i="5.99,246,1677571200"; d="scan'208";a="646805690" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by orsmga003.jf.intel.com with ESMTP; 02 May 2023 23:32:35 -0700 Message-ID: Date: Wed, 3 May 2023 14:32:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Cc: baolu.lu@linux.intel.com, Will Deacon , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , "Yu, Fenghua" , Dave Jiang , Tony Luck , "Zanussi, Tom" , narayan.ranganathan@intel.com Subject: Re: [PATCH v5 3/7] iommu: Move global PASID allocation from SVA to core Content-Language: en-US To: Jacob Pan , LKML , iommu@lists.linux.dev, Robin Murphy , Jason Gunthorpe , Joerg Roedel , dmaengine@vger.kernel.org, vkoul@kernel.org References: <20230427174937.471668-1-jacob.jun.pan@linux.intel.com> <20230427174937.471668-4-jacob.jun.pan@linux.intel.com> From: Baolu Lu In-Reply-To: <20230427174937.471668-4-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.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,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 On 4/28/23 1:49 AM, Jacob Pan wrote: > +ioasid_t iommu_alloc_global_pasid_dev(struct device *dev) > +{ > + int ret; > + ioasid_t max; > + > + max = dev_iommu_get_max_pasids(dev); Perhaps you can use dev->iommu->max_pasids. It's static, so no need to recalculate it. > + ret = ida_alloc_range(&iommu_global_pasid_ida, IOMMU_DEF_RID_PASID + 1, max, GFP_KERNEL); > + if (ret < 0) > + return IOMMU_PASID_INVALID; > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(iommu_alloc_global_pasid_dev); Best regards, baolu