From patchwork Mon Jan 25 11:06:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 370187 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp3897989jam; Mon, 25 Jan 2021 03:25:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsV8zRkA/uHEiuefA8iSAyKX1H1VQuyxBLNENJSzwzUP88DUi99t86NIA+ilIgbfPVk7pb X-Received: by 2002:a17:907:3343:: with SMTP id yr3mr60958ejb.73.1611573945237; Mon, 25 Jan 2021 03:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611573945; cv=none; d=google.com; s=arc-20160816; b=aBbjkF7YDod50ljlDUHS3GANbWloECt3loWQAdE82sdwE5cClEpxChiHWRWMJQWDOq bWvxCibe96UmK++HFjJQkmEiSmxZCH8ZqPh5qXomMLoZ4Au6cB4eRNhiYnXJv9V/L4eu vRj4fAUuVQx/Sobukoevj26wVEIiqCHIp8dqwIQxH/BE7XUU4yhhHh9g3kZ/lysMzlGg /3dPFpTrLYb4zdeSJTJ78EcpNcLbQC3lkKGo1ItXRiQI08LoATo+MthjDcr/BdqOtJtb GcMY1wRnr443KoUIWiY8xCJtrEsIcQcmcZN3K0tACWKPDwtrU5BEMKCvniClhSYVYloT WC4w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=D32J+akdetMmA5Myd4Zx5B3eWdLb4pZJ7wlpCkerL8M=; b=wFMTMCVjMVOSKNgO0BoMH0HGt9Ib/0cA3I2dT4ul9msdSmWb1pfAhhbnAlxUswUlZn kjbvGeM8lTOYCzQVITLFrePQZSa/UT4DAQrg9M4Aktuasq1jkBoOk0ojhaOPRxSEUC4n 6xojRyk7VuJTEZJxXf1UEJI6TKSv46sxsCBU3axd0JtxVdTnaX6tb9Ku5zIbH07cVnow NVnxzQRsuLaIxW21PlqlIhiitzeAMNxM0RagW3qN+L9Rm0RsfxI3/K2pw1txx3Sj/gbI I52/4dNf/r9JyhxVc6NyRFDErqux3JdKIzZU4+9QUaU0gm8A5f7+G0q7ltkyDYFnNfNc Eq2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sIgFUy1B; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f29si7641532edj.297.2021.01.25.03.25.44; Mon, 25 Jan 2021 03:25:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sIgFUy1B; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-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 S1727663AbhAYLZ0 (ORCPT + 4 others); Mon, 25 Jan 2021 06:25:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727676AbhAYLMl (ORCPT ); Mon, 25 Jan 2021 06:12:41 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D90EC06178B for ; Mon, 25 Jan 2021 03:08:45 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id y187so10445214wmd.3 for ; Mon, 25 Jan 2021 03:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D32J+akdetMmA5Myd4Zx5B3eWdLb4pZJ7wlpCkerL8M=; b=sIgFUy1B4NVZTMdif41pOLYx/+zRTjX1CmBp28JOvA9dBq+ncegVdQKTKx6zFKpMA0 RLrBDORpb4Wopov1wmsqCNwtxU/OTA+4T/HidEMzrcX/l10yuWmh2vn1tHVSCMf1WGwn k/I3+x++pEPyRk48uxdzw2k8HGR8Ad4NRGsrzffLFLL0/IVqTdb8ajx4Lw+x49oM0mb+ iPBIL+SI8d3oTuaFhQanBe3jnURITn3n3J5wb8bR46LkJ/HFRCz+dKaO+UEi+7Murd4i KSPMi9rgFEX2zKXtfEEoY7s4DzLcaxbp9ooMwRJIcrA/HFyS6BmTyiujmteB8sgRLdFG CK3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D32J+akdetMmA5Myd4Zx5B3eWdLb4pZJ7wlpCkerL8M=; b=lQUJyhXbjEPSwU12idbs0KKZsKPxxJ9n4fVN5MvR0MKAAjDWC+mzyLOHkwYvOJL0oj rIitRaJhCKSdK7iuQIEqMxXjn6/7CC+hp3BHhCW0CXNw8zcEfvfxkLrlIVE4oBrd8X0v mWPJVXc3z6Z2oM8EPSB0t/BsEkNkrRsuD57lx1mffIo19xEQm9wUXadSWeN2RgGb2hq3 /cKK0Jje8SWEOruLD+zrnVh3RjE2fFLjSbkaOI0zato0JDPmuWwYhSpmL+Y1yjp0AP27 RxVXoLcf5Kyyx/DG63JmVy6CutCiLXbTOCWBqSiHB6O6PSscRkQGDot7LrnbVuOazVye 6UNQ== X-Gm-Message-State: AOAM532kKn4DUYnyuPpeLA3tA56Y8TldefceuTmd7XB4QbDOi8FFQ5wj I2fXNcRy+5Qwdtm3GgBQj4YMPw== X-Received: by 2002:a05:600c:4ed3:: with SMTP id g19mr579133wmq.95.1611572924335; Mon, 25 Jan 2021 03:08:44 -0800 (PST) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id u6sm16636014wro.75.2021.01.25.03.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 03:08:43 -0800 (PST) From: Jean-Philippe Brucker To: joro@8bytes.org, will@kernel.org Cc: lorenzo.pieralisi@arm.com, robh+dt@kernel.org, guohanjun@huawei.com, sudeep.holla@arm.com, rjw@rjwysocki.net, lenb@kernel.org, robin.murphy@arm.com, Jonathan.Cameron@huawei.com, eric.auger@redhat.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-accelerators@lists.ozlabs.org, baolu.lu@linux.intel.com, jacob.jun.pan@linux.intel.com, kevin.tian@intel.com, vdumpa@nvidia.com, zhangfei.gao@linaro.org, shameerali.kolothum.thodi@huawei.com, vivek.gautam@arm.com, Jean-Philippe Brucker Subject: [PATCH v11 02/10] iommu/arm-smmu-v3: Use device properties for pasid-num-bits Date: Mon, 25 Jan 2021 12:06:43 +0100 Message-Id: <20210125110650.3232195-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210125110650.3232195-1-jean-philippe@linaro.org> References: <20210125110650.3232195-1-jean-philippe@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The pasid-num-bits property shouldn't need a dedicated fwspec field, it's a job for device properties. Add properties for IORT, and access the number of PASID bits using device_property_read_u32(). Suggested-by: Robin Murphy Acked-by: Jonathan Cameron Signed-off-by: Jean-Philippe Brucker --- include/linux/iommu.h | 2 -- drivers/acpi/arm64/iort.c | 13 +++++++------ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 ++- drivers/iommu/of_iommu.c | 5 ----- 4 files changed, 9 insertions(+), 14 deletions(-) -- 2.30.0 diff --git a/include/linux/iommu.h b/include/linux/iommu.h index bdf3f34a4457..b7ea11fc1a93 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -571,7 +571,6 @@ struct iommu_group *fsl_mc_device_group(struct device *dev); * @ops: ops for this device's IOMMU * @iommu_fwnode: firmware handle for this device's IOMMU * @flags: IOMMU_FWSPEC_* flags - * @num_pasid_bits: number of PASID bits supported by this device * @num_ids: number of associated device IDs * @ids: IDs which this device may present to the IOMMU */ @@ -579,7 +578,6 @@ struct iommu_fwspec { const struct iommu_ops *ops; struct fwnode_handle *iommu_fwnode; u32 flags; - u32 num_pasid_bits; unsigned int num_ids; u32 ids[]; }; diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index d4eac6d7e9fb..c9a8bbb74b09 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -968,15 +968,16 @@ static int iort_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data) static void iort_named_component_init(struct device *dev, struct acpi_iort_node *node) { + struct property_entry props[2] = {}; struct acpi_iort_named_component *nc; - struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); - - if (!fwspec) - return; nc = (struct acpi_iort_named_component *)node->node_data; - fwspec->num_pasid_bits = FIELD_GET(ACPI_IORT_NC_PASID_BITS, - nc->node_flags); + props[0] = PROPERTY_ENTRY_U32("pasid-num-bits", + FIELD_GET(ACPI_IORT_NC_PASID_BITS, + nc->node_flags)); + + if (device_add_properties(dev, props)) + dev_warn(dev, "Could not add device properties\n"); } static int iort_nc_iommu_map(struct device *dev, struct acpi_iort_node *node) 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 baebaac34a83..88dd9feb32f4 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2392,7 +2392,8 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev) } } - master->ssid_bits = min(smmu->ssid_bits, fwspec->num_pasid_bits); + device_property_read_u32(dev, "pasid-num-bits", &master->ssid_bits); + master->ssid_bits = min(smmu->ssid_bits, master->ssid_bits); /* * Note that PASID must be enabled before, and disabled after ATS: diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index e505b9130a1c..a9d2df001149 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -210,11 +210,6 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, of_pci_iommu_init, &info); } else { err = of_iommu_configure_device(master_np, dev, id); - - fwspec = dev_iommu_fwspec_get(dev); - if (!err && fwspec) - of_property_read_u32(master_np, "pasid-num-bits", - &fwspec->num_pasid_bits); } /*