Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp279432iob; Tue, 3 May 2022 17:21:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC1DYVowfof9aOdR6vUayujuLGh/Ytd1bh8e5LQ8FNdfbbw9M1qymxICz7xkiJF256mHFy X-Received: by 2002:a05:6402:e99:b0:41d:11f2:85e0 with SMTP id h25-20020a0564020e9900b0041d11f285e0mr20208245eda.339.1651623688947; Tue, 03 May 2022 17:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651623688; cv=none; d=google.com; s=arc-20160816; b=YwysAT7rB6Co1CYquMGSMoy2p7Ubl1NpeD8GokIERMKZ1YDxQwdfCmkQ8kGx7b9Hno PHSwZiGlaluvYs430PkaAtgzVDlY/Q80uzttSaEyoCsC/94QhKV/jtDdbTlAK5AtiLN4 V4mkMYDZV/k6v9AtI6ZP/loqY/kzrnX8pd58uZ/aocly8zjqH0TYU6/hOWoRkQBtDikA l3Xg1Kn42PEUMDf3nL1lZI6ouKmIYfA9FpQS3OO8UHBHX5XXoKUei7yORx+PQ+kFasfO a/+GVt/9v34+g/NgwNyHB6loa6M9LL4k7K03WLtxBUDaZfXVGDE7YYX/S4gkXjv5hkXV 7puA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Uyl9FgqCpk0Nf843k4+zgAZBrShtUTws+zDSvi2LfUM=; b=D49Ei+kJ75wlaVRL+j4ViYt2srBX8ou29aJghi/s5luHD6L0CYxawOJtmptFeRfbAv t9E9iG2JYnYpBua2R7ZJdi1siuMBhaUjD/c/06/NT1W1R91W4FifNIWNvG7V6BQQZLpm OH/WEE0/JDrMFwci4H03jx2Hu2UuAPfUUcbY/OT/Ta57ZM95RHeHww6KoVd2qst0pB5N 0nir1pWHna7WxFkW0DYQbiUgDojibqLxHkxnTz6nPV6OycYMvUfIBYn08Labq+61G85S +qlqu2LUxwK83TJYvVy30xKxwZzSZMJtxcX9MVleq3GMqvN5nl7Q9JX+lCAU6hkkTl4F iyow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HASzNM8N; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a170906724c00b006f38d7cfbbbsi15072591ejk.515.2022.05.03.17.21.05; Tue, 03 May 2022 17:21:28 -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=@linaro.org header.s=google header.b=HASzNM8N; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240885AbiECSG1 (ORCPT + 99 others); Tue, 3 May 2022 14:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239160AbiECSGX (ORCPT ); Tue, 3 May 2022 14:06:23 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B47233EA8E for ; Tue, 3 May 2022 11:02:50 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id j9so14374718qkg.1 for ; Tue, 03 May 2022 11:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Uyl9FgqCpk0Nf843k4+zgAZBrShtUTws+zDSvi2LfUM=; b=HASzNM8N5KvGdhci2AiFzKOaJQwN9mxfIDe/lkZJ5ShoUtwlUdYMfOFqvjDXyIJbF4 yaCwBO/1X43osNrP+A0r7dVcuxLftUPcVym8xAbVVku9NRSgvrtT3UelMCZeHJLzuNfL /5clZPtUWO33c4TklN3NmqsrqPCjOhgAcTCkIEOzaMYJ+wD9Tt0duo4/8BLzMAiOuNdH Th8ElVEgO5wkiBNqADw6YU6YJxaC9PMmi42uZc7tbY4rLb7pZRcZVhFjQU2SahZBEiCr HiDdRYiv2HnjeJQfP+uXqwRIbMnNmiSSP232+3Utj39UgC6S/OvJYFIF+2Ox/UbleRkj /E0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Uyl9FgqCpk0Nf843k4+zgAZBrShtUTws+zDSvi2LfUM=; b=RASqUQEDlP9lNqPJ9DRYXcL96hyOfLFQ3zdZAalNxL8+RwmVxM62jauJU2nSAFhm0A wgpSpuw4BMLnklKtzGHbC5bRjTUlFKpBExegr8L+uCZLzcvd+0i3uHxATKIud/jnySLt k9wZHdUBdXBHuei5spNskSYMmQL/evNdZpovzHnGhv1u0swSBDk8H3sowUVXDCEkmdqL wv6ybQzfVkB5oLqYWVoRqB55f98pHjxpZmBUMdcMckOwU0dP54bkk2xvyOCNFEmmU5DF rlQroyQOUmPzTL+k+VtLmE7XJMySr9fo1HryHjc6iobBoHkRUUNMIg5jGf2RKupPo67v Op0Q== X-Gm-Message-State: AOAM5309Qx1SJ15esAW5k2IVXf5tp7IzkSOgBnBzww2VrcTbt8KwSkMz dJqX64aQ1Z5WwBRqxsfSc5l3gA== X-Received: by 2002:a05:620a:414a:b0:69f:d123:6011 with SMTP id k10-20020a05620a414a00b0069fd1236011mr9378899qko.89.1651600969861; Tue, 03 May 2022 11:02:49 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id b24-20020ac86bd8000000b002f39b99f67esm6180531qtt.24.2022.05.03.11.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 11:02:49 -0700 (PDT) Date: Tue, 3 May 2022 19:02:22 +0100 From: Jean-Philippe Brucker To: Lu Baolu Cc: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Vinod Koul , Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 02/12] iommu: Add pasid_bits field in struct dev_iommu Message-ID: References: <20220502014842.991097-1-baolu.lu@linux.intel.com> <20220502014842.991097-3-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220502014842.991097-3-baolu.lu@linux.intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Mon, May 02, 2022 at 09:48:32AM +0800, Lu Baolu wrote: > Use this field to save the pasid/ssid bits that a device is able to > support with its IOMMU hardware. It is a generic attribute of a device > and lifting it into the per-device dev_iommu struct makes it possible > to allocate a PASID for device without calls into the IOMMU drivers. > Any iommu driver which suports PASID related features should set this > field before features are enabled on the devices. > > For initialization of this field in the VT-d driver, the > info->pasid_supported is only set for PCI devices. So the status is > that non-PCI SVA hasn't been supported yet. Setting this field only for > PCI devices has no functional change. > > Signed-off-by: Lu Baolu Reviewed-by: Jean-Philippe Brucker > --- > include/linux/iommu.h | 1 + > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 ++ > drivers/iommu/intel/iommu.c | 5 ++++- > 3 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 5e1afe169549..b8ffaf2cb1d0 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -373,6 +373,7 @@ struct dev_iommu { > struct iommu_fwspec *fwspec; > struct iommu_device *iommu_dev; > void *priv; > + unsigned int pasid_bits; > }; > > int iommu_device_register(struct iommu_device *iommu, > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 627a3ed5ee8f..afc63fce6107 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -2681,6 +2681,8 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev) > smmu->features & ARM_SMMU_FEAT_STALL_FORCE) > master->stall_enabled = true; > > + dev->iommu->pasid_bits = master->ssid_bits; > + > return &smmu->iommu; > > err_free_master: > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index cf43e8f9091b..170eb777d57b 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -4611,8 +4611,11 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev) > if (pasid_supported(iommu)) { > int features = pci_pasid_features(pdev); > > - if (features >= 0) > + if (features >= 0) { > info->pasid_supported = features | 1; > + dev->iommu->pasid_bits = > + fls(pci_max_pasids(pdev)) - 1; > + } > } > > if (info->ats_supported && ecap_prs(iommu->ecap) && > -- > 2.25.1 >