From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: [PATCH v4 5/5] iommu: arm-smmu: Get reference to memory controller Date: Thu, 13 Feb 2020 17:39:59 +0100 Message-ID: <20200213163959.819733-6-thierry.reding@gmail.com> References: <20200213163959.819733-1-thierry.reding@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20200213163959.819733-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Sender: "iommu" To: Arnd Bergmann , Will Deacon , Robin Murphy , Rob Herring Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: linux-tegra@vger.kernel.org From: Thierry Reding Use the memory controller framework to obtain a reference to the memory controller to which the SMMU will make memory requests. This allows the two drivers to properly order their probes so that the memory controller can be programmed first. An example where this is required is Tegra186 where the stream IDs need to be associated with memory clients before memory requests are emitted with the correct stream ID. Signed-off-by: Thierry Reding --- drivers/iommu/arm-smmu.c | 11 +++++++++++ drivers/iommu/arm-smmu.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 16c4b87af42b..862ea55018e8 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -2109,6 +2109,17 @@ static int arm_smmu_device_probe(struct platform_device *pdev) } smmu->dev = dev; + smmu->mc = devm_memory_controller_get_optional(dev, NULL); + if (IS_ERR(smmu->mc)) { + err = PTR_ERR(smmu->mc); + + if (err != -EPROBE_DEFER) + dev_err(dev, "failed to get memory controller: %d\n", + err); + + return err; + } + if (dev->of_node) err = arm_smmu_device_dt_probe(pdev, smmu); else diff --git a/drivers/iommu/arm-smmu.h b/drivers/iommu/arm-smmu.h index 8d1cd54d82a6..d38bcd3ce447 100644 --- a/drivers/iommu/arm-smmu.h +++ b/drivers/iommu/arm-smmu.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -253,6 +254,7 @@ enum arm_smmu_implementation { struct arm_smmu_device { struct device *dev; + struct memory_controller *mc; void __iomem *base; unsigned int numpage; -- 2.24.1