From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 184BDC433EF for ; Wed, 25 May 2022 02:13:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240592AbiEYCNc (ORCPT ); Tue, 24 May 2022 22:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbiEYCNa (ORCPT ); Tue, 24 May 2022 22:13:30 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB06164BDD for ; Tue, 24 May 2022 19:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653444808; x=1684980808; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=y00jKpGRgIg6OivHiwn8VODmVJdokGS+y/8+3XdeIVU=; b=PRXdIV6n5m56DbwocsaDv1oG9+cqTMChYNl3c8TzgUaRRGpYtFLbbVsO tyDKH4R+zuz8Y79vjPP3VF+AZfSLMxXMP5TyxNmJYRjgQPhDEkYZznSrD kMA539jO8t0+12t95A+4BQU6kE08zk9qRCrA8749xCpsUw6Se4pyIAGCE j7EMGSe6yFZbCociDwWB6WqZMNZrujMnJeGIWOPT9x6BL4RPHJocIuSk5 t4I7Ru0Y8NPkOu8gp7MyX3LlMN3HJi+2RyzxTlTLrJx7geTgsxTreD76L BHL1qKZKCZ4z1Q6cm3Y58fLN9E8OwuKMWjRxXXPDm/VRV8hPrmDaIyuf7 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10357"; a="360086128" X-IronPort-AV: E=Sophos;i="5.91,250,1647327600"; d="scan'208";a="360086128" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 19:13:28 -0700 X-IronPort-AV: E=Sophos;i="5.91,250,1647327600"; d="scan'208";a="601604562" Received: from jwang96-mobl.ccr.corp.intel.com (HELO [10.255.29.139]) ([10.255.29.139]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 19:13:23 -0700 Message-ID: <3751d422-924f-81e6-de8e-3e33de38a50f@linux.intel.com> Date: Wed, 25 May 2022 10:13:20 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Cc: baolu.lu@linux.intel.com, Eric Auger , "Liu, Yi L" , "Pan, Jacob jun" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , Jean-Philippe Brucker Subject: Re: [PATCH v7 01/10] iommu: Add pasids field in struct iommu_device Content-Language: en-US To: "Tian, Kevin" , Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , "Raj, Ashok" , Will Deacon , Robin Murphy , Jean-Philippe Brucker , "Jiang, Dave" , Vinod Koul References: <20220519072047.2996983-1-baolu.lu@linux.intel.com> <20220519072047.2996983-2-baolu.lu@linux.intel.com> <3c112762-f6e6-0b41-b38f-3bb2995d97cf@linux.intel.com> From: Baolu Lu In-Reply-To: <3c112762-f6e6-0b41-b38f-3bb2995d97cf@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/5/25 10:03, Baolu Lu wrote: >>> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c >>> index 4de960834a1b..1c3cf267934d 100644 >>> --- a/drivers/iommu/intel/dmar.c >>> +++ b/drivers/iommu/intel/dmar.c >>> @@ -1126,6 +1126,10 @@ static int alloc_iommu(struct dmar_drhd_unit >>> *drhd) >>> >>>       raw_spin_lock_init(&iommu->register_lock); >>> >>> +    /* Supports full 20-bit PASID in scalable mode. */ >>> +    if (ecap_pasid(iommu->ecap)) >>> +        iommu->iommu.pasids = 1UL << 20; >>> + >> >> supported pasid bits is reported by ecap_pss(). I don't think we should >> assume 20bits here. > > Yes. I overlooked this. Thanks for reminding. > > Another thing I need to improve is that scalable mode could be disabled. > This field should be 0 in that case. I will change above to: + /* + * A value of N in PSS field of eCap register indicates hardware + * supports PASID field of N+1 bits. + */ + if (pasid_supported(iommu)) + iommu->iommu.max_pasids = 2UL << ecap_pss(iommu->ecap); Best regards, baolu