From patchwork Thu Jun 3 16:46:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66C82C47096 for ; Thu, 3 Jun 2021 16:48:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 35978613B1 for ; Thu, 3 Jun 2021 16:48:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35978613B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ThqnJQZpfMtg+3z4gc4FHvCnuEvXoJFbtU4kPRGLSbU=; b=z2XZA/TaCkHtZ5 1A3WcF6C+tEf5yy7Y1kor8nOQwuq41G+qsUWEnoWcPbDjtrtx/fQ7RwbvjQUYivY+nmla6azXLvFH AoyawxG3vUICzMocY7dEtR/XA3ATJmRKwjXQBxiviDmn+ozxJz9D2S0DP45sd46Uag2+sRt558ja7 HbFAh9OINeOWRkVKlgzYzcimyE3vGs3ZeU/6lBfcn1FD3rn2ASc2eyQUVqwytjPegildRrmLA2Nuj ZGl52XrI457tbubGFMxt49PNrNvYXS7FlIrz8HTyXWaBsyAKvzDaXbNOWWztqt54sF6G6iQEX4JxC Hwp+jwqf++myp3RBuaGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqTN-009az2-4u; Thu, 03 Jun 2021 16:45:33 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqSt-009apl-O4 for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:45:07 +0000 Received: by mail-ej1-x62a.google.com with SMTP id ce15so10225448ejb.4 for ; Thu, 03 Jun 2021 09:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xzw2TUXY9p93oZxbwZKb0YQTzrG6r+scUnZo7x9ZCuU=; b=BLkLvFdApNPPc1q9dm6SyDGGREAVsuQgmtHybL+4Ju9BI2Ouw4EuFvuzh5TFfljaou rSdJmPTj7DJQs6BwlK35x8RuCodKVxouDgYyVI9FYSHyorPWgQAgDQ5F7HW4EzrXLvu+ Ly6zoAVjCiGWNEMseWyo5jTpij6fj2skQMnRL69EqYkc/X/JLUeJkRkI7el1HsVFoMjd cs4MLhUVZrLxR1+BVMQvpMxPU8EZ4DP0ilgpqyQbZohdATLha6u0uQAOzKhnu4JSSKXv 1mX+ILdrIkOayYuTPRONvrYaX/zjOaMqqkTo38mjcT3xFuhqtN5YshKcq0viUUS8CG4D bOrg== 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=Xzw2TUXY9p93oZxbwZKb0YQTzrG6r+scUnZo7x9ZCuU=; b=gQst68DVd6BhyDGuZt6zZoxSEe/KH2PYdWF7uwB+8uXD2a+vzD5zetlYGqmdKuwgXr DqnbvQZ3pXKrFC5Sdaygf/sbg1xh+o7FbIPP8n5nWaRXebJbjNpbjpQZ8P/grDcxTXWT BVVRk43/1g895F30xwuDCs+PVzPj0mHhnJYiS3IhurZzYaRsVEpVXP7sAEx2Gnyg1woC yQO722vQrIxHWrHxX5v7mWgrYnfGQS8oxYHFCRZAStAzh0GYfLdrlplbG8kVuYxL95ai 1er/5jVaDSOWTmw3lHena8/jqjZVeq7MGA2SjEPRO3JwG1MzkJwfDjb6x6WuXhox/7KE zn/Q== X-Gm-Message-State: AOAM531/rB4nmYfHdyL+79RDZRbU4Rm9JlYlLwNHbXc9Osnbaic2bw7f ie4DzMFGkIzgvq8sBhOYYUk= X-Google-Smtp-Source: ABdhPJxskXVbfgGBiwrxr5agPcu7F5QArOGLc64A8ytnD19xBd4ogTRNhjMOLdBL+Va4ArqBKjwpGw== X-Received: by 2002:a17:906:5407:: with SMTP id q7mr302416ejo.158.1622738701180; Thu, 03 Jun 2021 09:45:01 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id c19sm2079710edv.36.2021.06.03.09.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:00 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 1/9] memory: tegra: Implement SID override programming Date: Thu, 3 Jun 2021 18:46:24 +0200 Message-Id: <20210603164632.1000458-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094503_821379_39980861 X-CRM114-Status: GOOD ( 24.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding Instead of programming all SID overrides during early boot, perform the operation on-demand after the SMMU translations have been set up for a device. This reuses data from device tree to match memory clients for a device and programs the SID specified in device tree, which corresponds to the SID used for the SMMU context banks for the device. Signed-off-by: Thierry Reding --- drivers/memory/tegra/mc.c | 9 +++++ drivers/memory/tegra/tegra186.c | 72 +++++++++++++++++++++++++++++++++ include/soc/tegra/mc.h | 3 ++ 3 files changed, 84 insertions(+) diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c index 11b83de9361c..3c5aae7abf35 100644 --- a/drivers/memory/tegra/mc.c +++ b/drivers/memory/tegra/mc.c @@ -97,6 +97,15 @@ struct tegra_mc *devm_tegra_memory_controller_get(struct device *dev) } EXPORT_SYMBOL_GPL(devm_tegra_memory_controller_get); +int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev) +{ + if (mc->soc->ops && mc->soc->ops->probe_device) + return mc->soc->ops->probe_device(mc, dev); + + return 0; +} +EXPORT_SYMBOL_GPL(tegra_mc_probe_device); + static int tegra_mc_block_dma_common(struct tegra_mc *mc, const struct tegra_mc_reset *rst) { diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c index 1f87915ccd62..e65eac5764d4 100644 --- a/drivers/memory/tegra/tegra186.c +++ b/drivers/memory/tegra/tegra186.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -15,6 +16,10 @@ #include #endif +#define MC_SID_STREAMID_OVERRIDE_MASK GENMASK(7, 0) +#define MC_SID_STREAMID_SECURITY_WRITE_ACCESS_DISABLED BIT(16) +#define MC_SID_STREAMID_SECURITY_OVERRIDE BIT(8) + static void tegra186_mc_program_sid(struct tegra_mc *mc) { unsigned int i; @@ -66,10 +71,77 @@ static int tegra186_mc_resume(struct tegra_mc *mc) return 0; } +static void tegra186_mc_client_sid_override(struct tegra_mc *mc, + const struct tegra_mc_client *client, + unsigned int sid) +{ + u32 value, old; + + value = readl(mc->regs + client->regs.sid.security); + if ((value & MC_SID_STREAMID_SECURITY_OVERRIDE) == 0) { + /* + * If the secure firmware has locked this down the override + * for this memory client, there's nothing we can do here. + */ + if (value & MC_SID_STREAMID_SECURITY_WRITE_ACCESS_DISABLED) + return; + + /* + * Otherwise, try to set the override itself. Typically the + * secure firmware will never have set this configuration. + * Instead, it will either have disabled write access to + * this field, or it will already have set an explicit + * override itself. + */ + WARN_ON((value & MC_SID_STREAMID_SECURITY_OVERRIDE) == 0); + + value |= MC_SID_STREAMID_SECURITY_OVERRIDE; + writel(value, mc->regs + client->regs.sid.security); + } + + value = readl(mc->regs + client->regs.sid.override); + old = value & MC_SID_STREAMID_OVERRIDE_MASK; + + if (old != sid) { + dev_dbg(mc->dev, "overriding SID %x for %s with %x\n", old, + client->name, sid); + writel(sid, mc->regs + client->regs.sid.override); + } +} + +static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev) +{ +#if IS_ENABLED(CONFIG_IOMMU_API) + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); + struct of_phandle_args args; + unsigned int i, index = 0; + + while (!of_parse_phandle_with_args(dev->of_node, "interconnects", "#interconnect-cells", + index, &args)) { + if (args.np == mc->dev->of_node && args.args_count != 0) { + for (i = 0; i < mc->soc->num_clients; i++) { + const struct tegra_mc_client *client = &mc->soc->clients[i]; + + if (client->id == args.args[0]) { + u32 sid = fwspec->ids[0] & MC_SID_STREAMID_OVERRIDE_MASK; + + tegra186_mc_client_sid_override(mc, client, sid); + } + } + } + + index++; + } +#endif + + return 0; +} + const struct tegra_mc_ops tegra186_mc_ops = { .probe = tegra186_mc_probe, .remove = tegra186_mc_remove, .resume = tegra186_mc_resume, + .probe_device = tegra186_mc_probe_device, }; #if defined(CONFIG_ARCH_TEGRA_186_SOC) diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h index 1bd5aed81868..e19c2504a14b 100644 --- a/include/soc/tegra/mc.h +++ b/include/soc/tegra/mc.h @@ -180,6 +180,7 @@ struct tegra_mc_ops { int (*suspend)(struct tegra_mc *mc); int (*resume)(struct tegra_mc *mc); irqreturn_t (*handle_irq)(int irq, void *data); + int (*probe_device)(struct tegra_mc *mc, struct device *dev); }; struct tegra_mc_soc { @@ -244,4 +245,6 @@ devm_tegra_memory_controller_get(struct device *dev) } #endif +int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev); + #endif /* __SOC_TEGRA_MC_H__ */ From patchwork Thu Jun 3 16:46:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 184D2C47082 for ; Thu, 3 Jun 2021 16:51:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D88E1613B1 for ; Thu, 3 Jun 2021 16:51:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D88E1613B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=86pMec13J4/zGjYV2br4vPNYCgaGQbPxzC4YxzC14nk=; b=ILSfi3aTPDO7Aa v+V204pBLPP7vvdUms+dLkokkLwXyXXdu1YyY00mjhZiM55h9aH7mJoxPSUJ3HWKWqTxb/6TDLdLQ L2l4Y8GstlAHdZebW4ex/0pikVmX5GvgwyNVEjo9JFlnuCm92XMzDfGlknlgo1Y0hximFtHWIkf1R bkZ1BDmR71e+J0uZnjbzpl42FeZlLxf+6CPv06lQwyJ4LbM7jFTsQAEt2LqkEvK2k3ztZVGPnL2TM +Pd1IU++a7zjMINn2F3/yGM3fop2wOxFEq8js4fiWqpqDk52dhUpIt9Yjx+RKInUlp+48KFxD5+7l 2jLEuUiOqIGTxD1zC6CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqVa-009bz8-OA; Thu, 03 Jun 2021 16:47:51 +0000 Received: from mail-ed1-f42.google.com ([209.85.208.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqTt-009bCb-7r for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:46:06 +0000 Received: by mail-ed1-f42.google.com with SMTP id b11so7917880edy.4 for ; Thu, 03 Jun 2021 09:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1qAlE0u1BDdmT3kxaqiAfVPWOKqwZQKr5SI3k0RTYWA=; b=CAhaaFczzsR+qo5Hqs0zvKaqIcB44uJx5EPBVT/eOlIiBQO8Kxrfy9kyLfEQx2VOs7 3galmUc2FmgWxY4s+wTVSbEWuWpE7chcjjWgW7G3usHcX9445FW8a+FI4SxKccny40G9 q/fTNdBmQFuwoYx+jvtIZ0PiOX9ccEFghofCJ1A553lvVsVk4E/pCiBpbCdtAfC7/WoJ PScqrLCNOHamT8W0H4MR6uoyvJZWtOb0emaiPPYkvaFflu3e5ny9JLMn5eTYgKLpGg/z oxtFgJ2a8IIGrnBOadoSNgfXvSCGi40elWZeTES0IHeWvNw4kZLIqFPAvo+O7Dm5wUqx 02fg== 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=1qAlE0u1BDdmT3kxaqiAfVPWOKqwZQKr5SI3k0RTYWA=; b=P2bw8v5ZC6bzCKfgc/8IxFJIrjQq9A9on/pb9DOcuZlgimmv1p2Z0Ka8mhCZWnX1uL tuJK4+h82Z0tUSFjDhE5SOj0RmiJnFncF/TJJ2T1+TQIiw0IgkA0azwUnulk5LZ+KlwR eAWW3kCmYQyPcpP/mJu7ki2P6w2vWXhM74+YueOYyajXJgEPgHJM4/QEKgBYZPpoA/VL KuuJt8xRitxUFLjZ8nhi8Hmreevr5U4D6UXyD6/36hsBNjm6cwIo2+zUn3PhJ/svf+xN DdhNi7jxVqarRNHzc/E+vTRWY8D4Vgu8hcQ5xZ/6ffvQr29mhSHkCSOm4ywOfryG0IXF LHiA== X-Gm-Message-State: AOAM533pN719wzW3ArZ0uDqvV0BkeLB3HHGOJau6yUY2Za7/jVsKVa3+ e/Lb2Kxmj1J8dltjD2lHwmE= X-Google-Smtp-Source: ABdhPJxWxKKXdiAhQmYMpJQg1u2BfcQfDwX6ekk/hR6cNHnyigeCY0LGOj7xl3o81sGLEp2hfKPUoQ== X-Received: by 2002:a05:6402:4390:: with SMTP id o16mr390957edc.79.1622738703488; Thu, 03 Jun 2021 09:45:03 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id zb19sm1720622ejb.120.2021.06.03.09.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:02 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 2/9] dt-bindings: arm-smmu: Add Tegra186 compatible string Date: Thu, 3 Jun 2021 18:46:25 +0200 Message-Id: <20210603164632.1000458-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094605_331136_D26837DA X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding The ARM SMMU instantiations found on Tegra186 and later need inter- operation with the memory controller in order to correctly program stream ID overrides. Furthermore, on Tegra194 multiple instances of the SMMU can gang up to achieve higher throughput. In order to do this, they have to be programmed identically so that the memory controller can interleave memory accesses between them. Add the Tegra186 compatible string to make sure the interoperation with the memory controller can be enabled on that SoC generation. Signed-off-by: Thierry Reding --- Documentation/devicetree/bindings/iommu/arm,smmu.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.yaml b/Documentation/devicetree/bindings/iommu/arm,smmu.yaml index 9d27aa5111d4..1181b590db71 100644 --- a/Documentation/devicetree/bindings/iommu/arm,smmu.yaml +++ b/Documentation/devicetree/bindings/iommu/arm,smmu.yaml @@ -54,8 +54,14 @@ properties: - const: arm,mmu-500 - description: NVIDIA SoCs that program two ARM MMU-500s identically items: + - description: NVIDIA SoCs that require memory controller interaction + and may program multiple ARM MMU-500s identically with the memory + controller interleaving translations between multiple instances + for improved performance. + items: - enum: - - nvidia,tegra194-smmu + - const: nvidia,tegra194-smmu + - const: nvidia,tegra186-smmu - const: nvidia,smmu-500 - items: - const: arm,mmu-500 @@ -165,10 +171,11 @@ allOf: contains: enum: - nvidia,tegra194-smmu + - nvidia,tegra186-smmu then: properties: reg: - minItems: 2 + minItems: 1 maxItems: 2 else: properties: From patchwork Thu Jun 3 16:46:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A783C47097 for ; Thu, 3 Jun 2021 16:51:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6455D613F1 for ; Thu, 3 Jun 2021 16:51:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6455D613F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QhvfkGDHLGG8ZXLXNTmRJWGZz1HkrX7IGjItGTRfgrI=; b=klzP9iRxaLJamY m0CUTW2JFBc1trBkAyNBqfYW9pIssSAnNE88SxgBpGcSTpAnse7CuM5h+Dde978DN3Du9MwxB5rLY 9MF54uo4u1TMbOO09FMGmE0FmyvuFzv9dUM67QBPKhxPDhYJSm2+9/98taOVJVNnLdiJTB2RO3F5w CawqsCtlM1Z4+OFAbqeyi9r5MjlBBPXss4hipZdP3vwlr8IklG1uR6JC9dUMOwU53XtWemoiIb1rc VXrtnGu58dE5EcBKRQMesNx+AAelhaMh2ieWnHJ/+andaqaHZ49JFWJsVnLDqG8tWqfocZsZ1fBqw gZJyQBf3IWunM3Tn6E9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqWA-009cGu-Gn; Thu, 03 Jun 2021 16:48:27 +0000 Received: from mail-ed1-f44.google.com ([209.85.208.44]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqTv-009bE0-Fc for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:46:08 +0000 Received: by mail-ed1-f44.google.com with SMTP id b11so7918057edy.4 for ; Thu, 03 Jun 2021 09:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VlNxvqMh2IT7k8GWqSLT7kJqPAFU4Cya45iZg+g4Vc4=; b=Zu/ezZh0v9MeUs3qS/pHQ9pRZvTfL/Cqwv4R0B6/VuXkpBg1uWUXtbDZlI3hXXKBGX OwVzW52158BlV3RzQpM8MFlBoDtFQsNlTv0orvpZoI8kGGuVBlj6+P6Uv+vRCoA3Tzox 7QW7pTrBQ6Mfsq0SKQ+dJ+yuTvKMhcIVFrnlUxrHjIbMQ8fFZU7qyB5yxUfJz7qIZfzd 3bwdKSNUycLAafoaEnEnRyT2SyvG8CJdJSBM5IaS2gCrtFxJbymhtrbXWkuk2Di3/9Sp NrS+kmNwVw/gfVNS2uf2k49gsYQtyuh7Qyj18zOPtmjaSGtf1iNaJzZjIARoFqvgVdnI SgRw== 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=VlNxvqMh2IT7k8GWqSLT7kJqPAFU4Cya45iZg+g4Vc4=; b=YyY6xD49sdoCSFLoBD0kXdiK7gjzOQcc4VmlNHN2R1notKGB7Era5vsGLsEJbjGYVs gq2jbvzav9BNzpD9HgMjl5Xn658hO5qiic2CjoMzvdRxIvsfArHjJIwKUrrMnwfQ/F7/ +8eEE9ojhv7ePXgEwuw3U683gcjAtymL6WK2SVQPTFj75xZBpr/HemlgrLGymienVExz KaR9FgKNRNugB9kzMKA9z9f4jYnEubr7DOsAk0qlxnKSXrQ8LIeUx3WrjoeJPAAi0Uqv 8isfIFk3DijMr+sIm88Ioh7jKu13+d2WEOcQfcuaUFLZaP0TD1nYufYgVng7VqkbV6EM 1s2Q== X-Gm-Message-State: AOAM5305vyBkuYo2EDwB0FRNty62U3SyAla+N+2uEwAIlAK1ISugSckj cNqB+7ynof9quCBA5Oo8CEk= X-Google-Smtp-Source: ABdhPJxXrXwWK4QFgB5nUksaiKnWR+sh8XjHBPlh2ZAs/Xu5vH2IbScqCAAZFdw1SPRaf2s7vskTHQ== X-Received: by 2002:a05:6402:b17:: with SMTP id bm23mr411771edb.236.1622738705681; Thu, 03 Jun 2021 09:45:05 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id cz14sm1972696edb.84.2021.06.03.09.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:04 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 3/9] iommu/arm-smmu: Implement ->probe_finalize() Date: Thu, 3 Jun 2021 18:46:26 +0200 Message-Id: <20210603164632.1000458-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094607_567261_6A73183E X-CRM114-Status: GOOD ( 14.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding Implement a ->probe_finalize() callback that can be used by vendor implementations to perform extra programming necessary after devices have been attached to the SMMU. Signed-off-by: Thierry Reding --- Changes in v2: - remove unnecessarily paranoid check drivers/iommu/arm/arm-smmu/arm-smmu.c | 13 +++++++++++++ drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 6f72c4d208ca..d20ce4d57df2 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1450,6 +1450,18 @@ static void arm_smmu_release_device(struct device *dev) iommu_fwspec_free(dev); } +static void arm_smmu_probe_finalize(struct device *dev) +{ + struct arm_smmu_master_cfg *cfg; + struct arm_smmu_device *smmu; + + cfg = dev_iommu_priv_get(dev); + smmu = cfg->smmu; + + if (smmu->impl->probe_finalize) + smmu->impl->probe_finalize(smmu, dev); +} + static struct iommu_group *arm_smmu_device_group(struct device *dev) { struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); @@ -1569,6 +1581,7 @@ static struct iommu_ops arm_smmu_ops = { .iova_to_phys = arm_smmu_iova_to_phys, .probe_device = arm_smmu_probe_device, .release_device = arm_smmu_release_device, + .probe_finalize = arm_smmu_probe_finalize, .device_group = arm_smmu_device_group, .enable_nesting = arm_smmu_enable_nesting, .set_pgtable_quirks = arm_smmu_set_pgtable_quirks, diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index c31a59d35c64..147c95e7c59c 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -439,6 +439,7 @@ struct arm_smmu_impl { struct device *dev, int start); void (*write_s2cr)(struct arm_smmu_device *smmu, int idx); void (*write_sctlr)(struct arm_smmu_device *smmu, int idx, u32 reg); + void (*probe_finalize)(struct arm_smmu_device *smmu, struct device *dev); }; #define INVALID_SMENDX -1 From patchwork Thu Jun 3 16:46:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B29BC47096 for ; Thu, 3 Jun 2021 16:49:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDA41613F3 for ; Thu, 3 Jun 2021 16:49:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDA41613F3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7kRAh5aq81IUyGtT/nKwcBf3rdSisaZrlGc1HV+1zCI=; b=sQWcDItknRoDsF UTlTH3xnhGszfMSBpExqT+TN1TZvWaiUAqoqGSaESSQag3kDLPjc/m6335pKKH5fD9ysXruxBasCK Nc/eux43hNs/I85goUMGkhl2Bpkt9c8GatwOqaZY1+3zkXC90fIucAWQboxP7laarF3YsQ7RpDAHe q/B2YjLpmXZq4Uk2hng+M8+J7gmBBBVWCDS70HSv4fhWpzmNw/vWksQHtmmM2juz8G/33fJ8XS++d 9d9qMIDpkEg6nxsOlx2ZWfhyenG1VAjSUswYNoSzDkiPbuNvaRbWvcL3UHlwQIKIz+Fh9bXVR83mu IiN2DT2fUhWwd8YDmFVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqTc-009b55-DX; Thu, 03 Jun 2021 16:45:48 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqSz-009ari-Mm for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:45:11 +0000 Received: by mail-ed1-x52c.google.com with SMTP id r11so7858023edt.13 for ; Thu, 03 Jun 2021 09:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+HPQE7Wu/U0PWuANbUnRRMUxt8XYMXfvMeqtWgsxX2A=; b=DWF1ND1JoYhbiNCUKUNApwzdJwbAPEEjKJCscMNFabqzF0tNNXz7EcVUvM1Tu4YRBn 2yvREMF0gPfCEqXIj3VITXosJ7x4mqAfHFUIF4saEgKMCDPuTr4luvSAw3NLt3uyaCsD zSRt6d1AAvqam5MRDt0PVUfvuRkUshgG8UNWbtq4RY5Qjud+PKV7ncvC5MlLcoEC+vOQ kBNatm2qVH9LKug8VOBfojI1yfvtyfwCl6KP/HwEx0pUWmr3pv8hgyQHVWmM7Wzf2HY4 Ccko9vjgsRbuqVaw+GwvlJmG1rKA3p2TNiI5MVsk9rovNCzTmn6PxEFmpYknh9BQKKIj Nb0g== 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=+HPQE7Wu/U0PWuANbUnRRMUxt8XYMXfvMeqtWgsxX2A=; b=qb2KhmzrK4XPokmkq8uRrsOO6THdiW3gpLO7atbKU0bWWPWomETueppCU/9M/BjNO+ j06Rr6+zWKQdspAP1pa6CXmofawP8OY/oEMuiPPZScvb6p92RJZwJfzP7Mz6OfICML0z D4RpLs2pqecgSKxBMNFgF4k+KczQDcBs57SS1i223Fop8Al52y7ybIh1PQw/iw72Gqyw GMILznR1AW/mW9ouWN0Os9LuIZPJCbganIGdmnf3D6ndgiOIZ50wgpyaMh8o9WBDGBFJ WSW4CYwhFl9tlOdMPMuATU9l5mmzP2k2yj1CIaix3gDRENeaOGdJ7YNtbaNuDUl1PDrZ is+Q== X-Gm-Message-State: AOAM5328aReSzRhSlvRW6lyHwLMJBuyZkCtpjvB1WnE5omwF8xxpI+5Y jtH1Y1AGkxcpjQ3mHaYiSXM= X-Google-Smtp-Source: ABdhPJyAuiwn93zwB01paf3aYl4lIS4qBDAzg3kRCeqosdXGXGE/rGMikrDkYrapoNqHcGJ3U/ZmSA== X-Received: by 2002:aa7:cdd8:: with SMTP id h24mr407362edw.276.1622738707944; Thu, 03 Jun 2021 09:45:07 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id i15sm1743989ejk.30.2021.06.03.09.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:06 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 4/9] iommu/arm-smmu: tegra: Detect number of instances at runtime Date: Thu, 3 Jun 2021 18:46:27 +0200 Message-Id: <20210603164632.1000458-5-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094509_780023_9CAA410A X-CRM114-Status: GOOD ( 24.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding Parse the reg property in device tree and detect the number of instances represented by a device tree node. This is subsequently needed in order to support single-instance SMMUs with the Tegra implementation because additional programming is needed to properly configure the SID override registers in the memory controller. Signed-off-by: Thierry Reding --- Changes in v3: - move .probe_finalize initialization to later patch Changes in v2: - provide a separate implementation to simplify single instances drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 57 ++++++++++++++------ 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c index 29117444e5a0..23889090eb01 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c @@ -20,13 +20,19 @@ * The third instance usage is through standard arm-smmu driver itself and * is out of scope of this implementation. */ -#define NUM_SMMU_INSTANCES 2 +#define MAX_SMMU_INSTANCES 2 struct nvidia_smmu { - struct arm_smmu_device smmu; - void __iomem *bases[NUM_SMMU_INSTANCES]; + struct arm_smmu_device smmu; + void __iomem *bases[MAX_SMMU_INSTANCES]; + unsigned int num_instances; }; +static inline struct nvidia_smmu *to_nvidia_smmu(struct arm_smmu_device *smmu) +{ + return container_of(smmu, struct nvidia_smmu, smmu); +} + static inline void __iomem *nvidia_smmu_page(struct arm_smmu_device *smmu, unsigned int inst, int page) { @@ -47,9 +53,10 @@ static u32 nvidia_smmu_read_reg(struct arm_smmu_device *smmu, static void nvidia_smmu_write_reg(struct arm_smmu_device *smmu, int page, int offset, u32 val) { + struct nvidia_smmu *nvidia = to_nvidia_smmu(smmu); unsigned int i; - for (i = 0; i < NUM_SMMU_INSTANCES; i++) { + for (i = 0; i < nvidia->num_instances; i++) { void __iomem *reg = nvidia_smmu_page(smmu, i, page) + offset; writel_relaxed(val, reg); @@ -67,9 +74,10 @@ static u64 nvidia_smmu_read_reg64(struct arm_smmu_device *smmu, static void nvidia_smmu_write_reg64(struct arm_smmu_device *smmu, int page, int offset, u64 val) { + struct nvidia_smmu *nvidia = to_nvidia_smmu(smmu); unsigned int i; - for (i = 0; i < NUM_SMMU_INSTANCES; i++) { + for (i = 0; i < nvidia->num_instances; i++) { void __iomem *reg = nvidia_smmu_page(smmu, i, page) + offset; writeq_relaxed(val, reg); @@ -79,6 +87,7 @@ static void nvidia_smmu_write_reg64(struct arm_smmu_device *smmu, static void nvidia_smmu_tlb_sync(struct arm_smmu_device *smmu, int page, int sync, int status) { + struct nvidia_smmu *nvidia = to_nvidia_smmu(smmu); unsigned int delay; arm_smmu_writel(smmu, page, sync, 0); @@ -90,7 +99,7 @@ static void nvidia_smmu_tlb_sync(struct arm_smmu_device *smmu, int page, u32 val = 0; unsigned int i; - for (i = 0; i < NUM_SMMU_INSTANCES; i++) { + for (i = 0; i < nvidia->num_instances; i++) { void __iomem *reg; reg = nvidia_smmu_page(smmu, i, page) + status; @@ -112,9 +121,10 @@ static void nvidia_smmu_tlb_sync(struct arm_smmu_device *smmu, int page, static int nvidia_smmu_reset(struct arm_smmu_device *smmu) { + struct nvidia_smmu *nvidia = to_nvidia_smmu(smmu); unsigned int i; - for (i = 0; i < NUM_SMMU_INSTANCES; i++) { + for (i = 0; i < nvidia->num_instances; i++) { u32 val; void __iomem *reg = nvidia_smmu_page(smmu, i, ARM_SMMU_GR0) + ARM_SMMU_GR0_sGFSR; @@ -157,8 +167,9 @@ static irqreturn_t nvidia_smmu_global_fault(int irq, void *dev) unsigned int inst; irqreturn_t ret = IRQ_NONE; struct arm_smmu_device *smmu = dev; + struct nvidia_smmu *nvidia = to_nvidia_smmu(smmu); - for (inst = 0; inst < NUM_SMMU_INSTANCES; inst++) { + for (inst = 0; inst < nvidia->num_instances; inst++) { irqreturn_t irq_ret; irq_ret = nvidia_smmu_global_fault_inst(irq, smmu, inst); @@ -202,11 +213,13 @@ static irqreturn_t nvidia_smmu_context_fault(int irq, void *dev) struct arm_smmu_device *smmu; struct iommu_domain *domain = dev; struct arm_smmu_domain *smmu_domain; + struct nvidia_smmu *nvidia; smmu_domain = container_of(domain, struct arm_smmu_domain, domain); smmu = smmu_domain->smmu; + nvidia = to_nvidia_smmu(smmu); - for (inst = 0; inst < NUM_SMMU_INSTANCES; inst++) { + for (inst = 0; inst < nvidia->num_instances; inst++) { irqreturn_t irq_ret; /* @@ -235,12 +248,16 @@ static const struct arm_smmu_impl nvidia_smmu_impl = { .context_fault = nvidia_smmu_context_fault, }; +static const struct arm_smmu_impl nvidia_smmu_single_impl = { +}; + struct arm_smmu_device *nvidia_smmu_impl_init(struct arm_smmu_device *smmu) { struct resource *res; struct device *dev = smmu->dev; struct nvidia_smmu *nvidia_smmu; struct platform_device *pdev = to_platform_device(dev); + unsigned int i; nvidia_smmu = devm_krealloc(dev, smmu, sizeof(*nvidia_smmu), GFP_KERNEL); if (!nvidia_smmu) @@ -248,16 +265,24 @@ struct arm_smmu_device *nvidia_smmu_impl_init(struct arm_smmu_device *smmu) /* Instance 0 is ioremapped by arm-smmu.c. */ nvidia_smmu->bases[0] = smmu->base; + nvidia_smmu->num_instances++; - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (!res) - return ERR_PTR(-ENODEV); + for (i = 1; i < MAX_SMMU_INSTANCES; i++) { + res = platform_get_resource(pdev, IORESOURCE_MEM, i); + if (!res) + break; - nvidia_smmu->bases[1] = devm_ioremap_resource(dev, res); - if (IS_ERR(nvidia_smmu->bases[1])) - return ERR_CAST(nvidia_smmu->bases[1]); + nvidia_smmu->bases[i] = devm_ioremap_resource(dev, res); + if (IS_ERR(nvidia_smmu->bases[i])) + return ERR_CAST(nvidia_smmu->bases[i]); + + nvidia_smmu->num_instances++; + } - nvidia_smmu->smmu.impl = &nvidia_smmu_impl; + if (nvidia_smmu->num_instances == 1) + nvidia_smmu->smmu.impl = &nvidia_smmu_single_impl; + else + nvidia_smmu->smmu.impl = &nvidia_smmu_impl; return &nvidia_smmu->smmu; } From patchwork Thu Jun 3 16:46:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53B62C47097 for ; Thu, 3 Jun 2021 16:51:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1D14F61026 for ; Thu, 3 Jun 2021 16:51:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D14F61026 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9goOd8hGu2BTrRN0n1v+rchZGO/defDtpzcN0OnSQLY=; b=QPeVTpvAQ4ooAy 12yqdn2oMYqXNVaIm+lHYDdg6D5xHi2IZNQgihVTzlUDfEaPXIw2PPyyc1dZmBEdH3KBto2MbgvN+ 7K+ZlBoHNg/ZSuujaIh31LmZnL9gaZDJiAoV1g/L7gA6Gj8ndLg5QoJYA7sK1jBd69+Z5rU3yYGuv Jj9noTvCu6lMvmZ9zB328dODxp+jmzeDYEdQEiJ0e4sS0PrHrZIIsgPyLX+Z3BsKKOoc3i3YvEr5R U0a7VqAIB81dS6L7h0KOMo3m2+ai8zqPyVHOlq2/YnxXNqNSK6DrMgp1ZV0OXIPwOPXfkSjWQpxzc WNRUMYKg82RLuo0HYhlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqWl-009cVK-GM; Thu, 03 Jun 2021 16:49:04 +0000 Received: from mail-ej1-f45.google.com ([209.85.218.45]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqTz-009bGL-SY for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:46:13 +0000 Received: by mail-ej1-f45.google.com with SMTP id gb17so10200631ejc.8 for ; Thu, 03 Jun 2021 09:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q3vxZtPVoclQabdKu022J8j0BPxOTzbzHvAOrHFrxRM=; b=nCy2Pei61aDfzvs4928hmMwnDYIIH7Kyz5O4fr0CjUBTvkobQ3sXNehrHbmJOvSMc8 TnNE9862hQ+u83Y/Trx7opcN+acqRhmQVlvUXcUbL4cKLEyeU/3nA+TpEs88aE1MHKPm c2AN/K9D9DtBkL542gzuygAFllKXCdefULBJbV5VUjx+XrVSjE7inUpzGlhwWJ2yA39H Hr4eDcBdVJMAPqnt4/oM5GTR78xq2TyEos1UQJQT1qgTBNWlpvwDsGdPrbFiauKOkp55 brhxP1ndXoybpApJ9PjVeSJxy5GKn468gLR7SmwH7ojvESVMXkWj3566fmjbXP6dQgRS +Mxg== 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=Q3vxZtPVoclQabdKu022J8j0BPxOTzbzHvAOrHFrxRM=; b=sKYIDYY/P1jZYexYEpfWoEQqynTVd4uJT9vMXRv0FMt4BAIITSzAhdn1pImjYDvwIA INm1a2p2VvnAcuoTBxDTKC0UhZwA3284HWJESlAfQ6K2btvnVmjPFbZN9drP+/V1xpkV p5oetAA/mfc2EUTP50e1pqCBCofh5LNk8Q3F5J2McJIc9g+9P0HDzrzjOTLnkwsACpVA sDApq51LwxxqSnScCgQ7Ule6TQQsKCQZCy3xVeL2V8wXR5yHNuHHoJjbql+NKvBdXJjy Fj/+2jMDOuFF4ZpLI9b4jJ0iGki0twT5Co68Q76hh7Dya84/T7qdcs1FVL143uLLxiBm xaXA== X-Gm-Message-State: AOAM53040YxAS+c9Ia2ciISDe4DhkilM/YDbCGzExaADwnjTxeFCz2fT sKCguqiZ1/lnc2t6Mi4zo7A= X-Google-Smtp-Source: ABdhPJwZKsVDgQ4s+syaQdJ937cW3DiuFbKhKlpbFpj+N4SV2wqKmmbAD8UlzoPKh6HdVcjfz+X/9w== X-Received: by 2002:a17:906:a017:: with SMTP id p23mr280153ejy.460.1622738710108; Thu, 03 Jun 2021 09:45:10 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id p10sm1455596edy.86.2021.06.03.09.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:09 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 5/9] iommu/arm-smmu: tegra: Implement SID override programming Date: Thu, 3 Jun 2021 18:46:28 +0200 Message-Id: <20210603164632.1000458-6-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094611_970210_3DC60796 X-CRM114-Status: GOOD ( 22.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding The secure firmware keeps some SID override registers set as passthrough in order to allow devices such as the display controller to operate with no knowledge of SMMU translations until an operating system driver takes over. This is needed in order to seamlessly transition from the firmware framebuffer to the OS framebuffer. Upon successfully attaching a device to the SMMU and in the process creating identity mappings for memory regions that are being accessed, the Tegra implementation will call into the memory controller driver to program the override SIDs appropriately. Signed-off-by: Thierry Reding --- Changes in v3: - move .probe_finalize initialization to this patch drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 33 ++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c index 23889090eb01..01e9b50b10a1 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c @@ -7,6 +7,8 @@ #include #include +#include + #include "arm-smmu.h" /* @@ -15,10 +17,17 @@ * interleaved IOVA accesses across them and translates accesses from * non-isochronous HW devices. * Third one is used for translating accesses from isochronous HW devices. + * + * In addition, the SMMU driver needs to coordinate with the memory controller + * driver to ensure that the right SID override is programmed for any given + * memory client. This is necessary to allow for use-case such as seamlessly + * handing over the display controller configuration from the firmware to the + * kernel. + * * This implementation supports programming of the two instances that must - * be programmed identically. - * The third instance usage is through standard arm-smmu driver itself and - * is out of scope of this implementation. + * be programmed identically and takes care of invoking the memory controller + * driver for SID override programming after devices have been attached to an + * SMMU instance. */ #define MAX_SMMU_INSTANCES 2 @@ -26,6 +35,7 @@ struct nvidia_smmu { struct arm_smmu_device smmu; void __iomem *bases[MAX_SMMU_INSTANCES]; unsigned int num_instances; + struct tegra_mc *mc; }; static inline struct nvidia_smmu *to_nvidia_smmu(struct arm_smmu_device *smmu) @@ -237,6 +247,17 @@ static irqreturn_t nvidia_smmu_context_fault(int irq, void *dev) return ret; } +static void nvidia_smmu_probe_finalize(struct arm_smmu_device *smmu, struct device *dev) +{ + struct nvidia_smmu *nvidia = to_nvidia_smmu(smmu); + int err; + + err = tegra_mc_probe_device(nvidia->mc, dev); + if (err < 0) + dev_err(smmu->dev, "memory controller probe failed for %s: %d\n", + dev_name(dev), err); +} + static const struct arm_smmu_impl nvidia_smmu_impl = { .read_reg = nvidia_smmu_read_reg, .write_reg = nvidia_smmu_write_reg, @@ -246,9 +267,11 @@ static const struct arm_smmu_impl nvidia_smmu_impl = { .tlb_sync = nvidia_smmu_tlb_sync, .global_fault = nvidia_smmu_global_fault, .context_fault = nvidia_smmu_context_fault, + .probe_finalize = nvidia_smmu_probe_finalize, }; static const struct arm_smmu_impl nvidia_smmu_single_impl = { + .probe_finalize = nvidia_smmu_probe_finalize, }; struct arm_smmu_device *nvidia_smmu_impl_init(struct arm_smmu_device *smmu) @@ -263,6 +286,10 @@ struct arm_smmu_device *nvidia_smmu_impl_init(struct arm_smmu_device *smmu) if (!nvidia_smmu) return ERR_PTR(-ENOMEM); + nvidia_smmu->mc = devm_tegra_memory_controller_get(dev); + if (IS_ERR(nvidia_smmu->mc)) + return ERR_CAST(nvidia_smmu->mc); + /* Instance 0 is ioremapped by arm-smmu.c. */ nvidia_smmu->bases[0] = smmu->base; nvidia_smmu->num_instances++; From patchwork Thu Jun 3 16:46:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CE8DC47096 for ; Thu, 3 Jun 2021 16:50:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4790C613B1 for ; Thu, 3 Jun 2021 16:50:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4790C613B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OUwR7CeAUHJjilKNG77O4Ls/0jmE4fO5bqqgHATxflU=; b=AaoiHKkHdD0UG5 YFLFEiLoV1dqXvNVXrYh3scCZNd9aDESxu1G+RuA7YnwfmaKMBmxaM38B3tZ0In8EYs/sBH09tSUh WgOfIjFzBEkXxbAVNj8+o7PDkK7MOSy2PhK/W76H6AuxnHhA5zFdRbF6VyJgwXCddJFRdNpR2ZgGH D9PXh1HefQiZleGxifrxFmBIyQ/3BtD6pZ4h4aJv0RiHIF393V3AyCwkmlrH1imQjzVjHNrTY+HNk rSKlFYf7cKVp4gq4yr2a/ZgcNOUxL/xMjBlR2tmptzNXrvbehOasHv0It/7kYH20SqecHhL4ZJz9o kOGGTKe6eP13NsZXYZiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqUQ-009bSv-Uq; Thu, 03 Jun 2021 16:46:39 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqT4-009ass-6b for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:45:15 +0000 Received: by mail-ed1-x536.google.com with SMTP id g18so5898090edq.8 for ; Thu, 03 Jun 2021 09:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r8fGUpVpptMRBfRxglvA8AvxNT0zJcmuot8FSf94QpQ=; b=Mrsq9SXzuGTG87HBigTQmdjHKtQRZcvmcijXZy0iHk8e8caUNdUOM25vJm0ajCrxks LYbrnBw3UPxmQis3WBDa4V+KEDL1Vei8VmCI6hui5y3CzL+dbEncV0o+ivy7R8nK3dPJ LqZl0YI9vvPE2k5i6RP23IpMFw+1++nnZfcPnBDyKmiQYeNAKnV3H/sETmvp9DZyKvW4 iJqLcPktC23EY6MQ7wHC/9ExVlmEDxOaypiyzfgI4ghYGOaJzQ+Oqc65RGC62bcUQO/W bFiz5OwCDWcaZOBlwbIHIFuUhj7BOzDLN2/G22fNMfx0ZkzawJJpiCgEAsyzAVD/4Z6Q uSVg== 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=r8fGUpVpptMRBfRxglvA8AvxNT0zJcmuot8FSf94QpQ=; b=qMLrxbJ1ufmBa6ldm4CapL/sd4u+2iyaQX2VoCzOO6oD3rXjAp265N8uAoFDOeSp4L uEAaN56RE4KZY9V8AG2xwN56G3S0409F+4G7gApez1OQWVGtqWzixHEOMT0PcTAdf5Bf 1QXatTKFwEVTUWDhtI52C/we2ZBaFMJ2CRk50DUiWYVEe1yeDXE6zeISBmcQOe/NVixH 0xKIAtKbMH5jMkapGvr6hx7wgvFGd8hYt/FD0GCE+oM2YSO9Yhk4WBQ+lfqIH7bGDzop YhaHscPczxiAjTgkFytC3rQh71GjgW5/yQTAU7GJvZ16v00+m/iyPc/d3ctVkiANDHcE NN9Q== X-Gm-Message-State: AOAM531dwVHPfxhlioh3NFeMTPjCdw2luTviq+6c/R0M7j8GC0DfhxVI uFXvq5mrBuKH4N2fVbPcQc8= X-Google-Smtp-Source: ABdhPJyv8jWy2m1Ygx1oXaeKL6HrcQqVoQpZlQ2h/P1i3CxsxCxRctVO/8Y/6oidTLC0t+bmxRs0TQ== X-Received: by 2002:a05:6402:1c83:: with SMTP id cy3mr428442edb.108.1622738712418; Thu, 03 Jun 2021 09:45:12 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id o4sm1906443edc.94.2021.06.03.09.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:11 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 6/9] iommu/arm-smmu: Use Tegra implementation on Tegra186 Date: Thu, 3 Jun 2021 18:46:29 +0200 Message-Id: <20210603164632.1000458-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094514_261292_C66630DF X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding Tegra186 requires the same SID override programming as Tegra194 in order to seamlessly transition from the firmware framebuffer to the Linux framebuffer, so the Tegra implementation needs to be used on Tegra186 devices as well. Signed-off-by: Thierry Reding --- drivers/iommu/arm/arm-smmu/arm-smmu-impl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c b/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c index 136872e77195..9f465e146799 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c @@ -211,7 +211,8 @@ struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu) if (of_property_read_bool(np, "calxeda,smmu-secure-config-access")) smmu->impl = &calxeda_impl; - if (of_device_is_compatible(np, "nvidia,tegra194-smmu")) + if (of_device_is_compatible(np, "nvidia,tegra194-smmu") || + of_device_is_compatible(np, "nvidia,tegra186-smmu")) return nvidia_smmu_impl_init(smmu); smmu = qcom_smmu_impl_init(smmu); From patchwork Thu Jun 3 16:46:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A66EC47096 for ; Thu, 3 Jun 2021 16:50:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC60561026 for ; Thu, 3 Jun 2021 16:50:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC60561026 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0/TgddI3GzzI0GxjlCyn0nt3HF1HXdwtaIzf+7GHvaE=; b=gfP7wg+jZr/76t EOTl3ZanBllazZzHE/xg2K8xKXk8Z17/Loh12pa0ln5vTmm3Bd4W8wluouuQpxjk0Dy3/GzkJq0mr GT6+896xdWdqqH4thnXHKbx0swGQ+rI4tbip4Hm4oIsVU5w+vCtso2hgbZzgOe+2f1Dng7dSpp8r6 lwVkeWDBqwY1hsUJ2du1KARW0VBhrysgv7skqiVACSIhXyY/lWrx3b0qXeuMNRDwYsiektoreIjDq 6C6HyG/2Dg66jUannnNI7PhalUbdWlgQzU1f7JoDu/fPgohQJualiZAyo6TY80XunwOw38qWqPZm0 CIrkzWV/kssOLucmUVeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqUq-009bfF-2i; Thu, 03 Jun 2021 16:47:04 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqTG-009awV-LX for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:45:29 +0000 Received: by mail-lf1-x12b.google.com with SMTP id i9so9771879lfe.13 for ; Thu, 03 Jun 2021 09:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=emaUd/s+I/7zAGqRMV6GpYb0EGNWgcoNn6kxenQlqUg=; b=X+mC/YDJZh7NmSy5AKXhH6ARRZ6oNxVKb/QJsn+SBF7ahQKMfHahbwSNEiL2Erg7LG KAIJWZAP3OPXIYMkchZXHXRGEXi9IEzRqKXi2i+b4zeWsDj7qtbbwOtF4hOD+NhzdFZU xXCHpSlQbkimCyf6KTkGbzxuY9PZtv+P7korKxfdeUrSB3L4cQlFDpsgbUQdTv19ri0R cu4InkLernM4E03VSIMzCxmgrsSh/iAW0vzB6rVrPtn2UirqvAStXtERcvwidauasmbX 1D85368AXktRu4RFzKkpVLBrMxgmDVextvBSHk3Z/VhTNCKA7qZJVOH3LeNUfHST6gIY lU7A== 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=emaUd/s+I/7zAGqRMV6GpYb0EGNWgcoNn6kxenQlqUg=; b=Kw5LfnqwTQMWL52NOyeveCd5xMsJv4KQg3z2zYb+z3y/fvqjb9cJ6vAtKhSAY3Avnc mUdWix18FwSO9c8PQwzRMqHRDxzhGlRdu15aQC9BAfqVxSndSDRkOdknKrPTTKCSpzZl GVU5ewbzx08UY+roGDEUXx0t8JQ6XUNE7rrJDGeL7hOBfjGiCw6mzIOycYBGqGcTMGKZ fuh9kI/qBTLB03UPOkQz9vRq4tSj/ysMaBGAleh74VxgdflaFPJbAff+2Gpgxuek3bNS 4m8Z6cSR2pxWgn4+D+1ZSsnGW6CfXWczjJSuKsIDTiNoTpcr2GfFAdP+FJvdjACGPyKm 5pNQ== X-Gm-Message-State: AOAM530EM/IT4ItxHbgMhaSgXT5hSnC6VP6EjmiQqxVA5QzaryVVb+n7 9cswrziavqEomN29MoAcCX4NqDk4rHg= X-Google-Smtp-Source: ABdhPJxGHiqaz78ebiDKvbPuVlWxMu7idWE6kmjhgmMCpZ9tWDxf/zizOL8QBl192mfnuRUYJPqtmw== X-Received: by 2002:a17:906:b317:: with SMTP id n23mr293860ejz.324.1622738714387; Thu, 03 Jun 2021 09:45:14 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id ck3sm168205edb.56.2021.06.03.09.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:13 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 7/9] arm64: tegra: Use correct compatible string for Tegra186 SMMU Date: Thu, 3 Jun 2021 18:46:30 +0200 Message-Id: <20210603164632.1000458-8-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094526_740111_EDE9E15C X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding The SMMU found on Tegra186 requires interoperation with the memory controller in order to program stream ID overrides. The generic ARM SMMU 500 compatible is therefore inaccurate. Replace it with a more correct, SoC-specific compatible string. Signed-off-by: Thierry Reding --- arch/arm64/boot/dts/nvidia/tegra186.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/nvidia/tegra186.dtsi b/arch/arm64/boot/dts/nvidia/tegra186.dtsi index 9f75bbf00cf7..a173f40256ae 100644 --- a/arch/arm64/boot/dts/nvidia/tegra186.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra186.dtsi @@ -1082,7 +1082,7 @@ pci@3,0 { }; smmu: iommu@12000000 { - compatible = "arm,mmu-500"; + compatible = "nvidia,tegra186-smmu", "nvidia,smmu-500"; reg = <0 0x12000000 0 0x800000>; interrupts = , , From patchwork Thu Jun 3 16:46:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A705C47082 for ; Thu, 3 Jun 2021 16:51:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BED6461028 for ; Thu, 3 Jun 2021 16:51:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BED6461028 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bjh/SknD6XyrwM4M+KkRkoGxr3t/KaAipbVs8jEJOUk=; b=TDt3zt9sNMKc7H RiziWeQ3tFJH6WX9Sgqp+gR+28NLjKk6FL8Dg0lIDOetiFcTxEkH5iKOLFS+9VfB4/WZjD32vZeCf ykCCedzjX/UjF/UqfR6rjKABO400yY4iYi+LqngQ+eRBaOJy+ZSmqZOwL2GoLuLNsKFdb5Vw9n8SZ TRUTqhYuafMqNrN2gn2loboq6xwUAT3YKAc2H6XaWY2MP/lPqOIeNznQBVUnE8GUcRSpvVTH884gH W7KtMn+6D0ZhxDluu6NvU7QeY6oVTZKHxSOpBeyDjp2trC04UpLMxWnPdpVDFL04jYafA2ovCdCJU 4lvNd1d/7w9Ma2iygd7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqXX-009cpp-I4; Thu, 03 Jun 2021 16:49:51 +0000 Received: from mail-ej1-f44.google.com ([209.85.218.44]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqU6-009bJ0-EC for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:46:19 +0000 Received: by mail-ej1-f44.google.com with SMTP id ce15so10226708ejb.4 for ; Thu, 03 Jun 2021 09:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3H7kBWayn0qcK+eEtFN4Gu4RL12HhriWydsuWv48WfA=; b=o4IqvhKmUTIACSLrHJkEOSt7oTgtqvG/5HrLn07ZKa/OaEDSkMZG1avPxUQIqkmSR2 bMekXpKSxwLV5vBgVHXMMKfqKts0nYqKYr6++YN2Uu3RZhoGLAszF1n8GPSEp0+xw/rR YrUh7rAsahyaI4EXC0sg+2A41hl6TO48aoKc9kF8BmKyNe2N2fxXeg/DQ3Ropb+hs57x vhxlhNZGTtGWACKXALSHj6RaxA+EVVXU/V8Pgd1cGfdxegdLKhOE52tu8sgK5+ugRWvu JB9rmXdWgOLD5XhTYEviQ6wycyLOK+4NSMZzAddhIBGFI6j97mOg06v9cEgWvmLC2CRl JmNQ== 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=3H7kBWayn0qcK+eEtFN4Gu4RL12HhriWydsuWv48WfA=; b=UUAD8gSe5LgA0p1axIEEJnh1MXWBKm8/mr4EJiVxiEV5ZaGOLcIwunfn2qlYFbkGC2 fOo4E3pid6JEn5VS/ko996XRXwUDxlMusMaNrdJjNRJ7rD787btd8y2tghHNMCAmtCz0 E3C5n6GEYlBe0G9k5xr+dmGqtNjIZCd3+fR1/i4ZFPHHPypHwC1IIQrpw4hxa0lltE6R 5aXXyQ1OxIQ7TTTQVFVJeFybhoF7Ojy++sZ86Gu7fXJK2Y66efOYRoqzs5ur8eGll1C2 AInp5CqwNmmTsdSrEqRbPR0xqhX6BaaB95Mh13Ix1PGvCD2rpEiTk+aVIVhyV9Bp4Pw6 sLgQ== X-Gm-Message-State: AOAM530LaDnv9YKIbn+cOB7FfJ+e968sYyC+Qgk1NIOPoP4dLB4eQOg7 Tb8VL5AG6N//luxKRe2ErrY= X-Google-Smtp-Source: ABdhPJxJfBtQcyTw2ggGblUJb62+CJQ05s0vQk3KGuzRkVGKlycyNp8C3hL1VzrU2RP4pgDypiWnYA== X-Received: by 2002:a17:906:27d3:: with SMTP id k19mr274262ejc.368.1622738716690; Thu, 03 Jun 2021 09:45:16 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id bh3sm1741560ejb.19.2021.06.03.09.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:15 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 8/9] arm64: tegra: Hook up memory controller to SMMU on Tegra186 Date: Thu, 3 Jun 2021 18:46:31 +0200 Message-Id: <20210603164632.1000458-9-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094618_526177_F4D31997 X-CRM114-Status: GOOD ( 12.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding On Tegra186 and later, the memory controller needs to be programmed in coordination with any of the ARM SMMU instances to configure the stream ID used for each memory client. To support this, add a phandle reference to the memory controller to the SMMU device tree node. Signed-off-by: Thierry Reding --- arch/arm64/boot/dts/nvidia/tegra186.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/boot/dts/nvidia/tegra186.dtsi b/arch/arm64/boot/dts/nvidia/tegra186.dtsi index a173f40256ae..d02f6bf3e2ca 100644 --- a/arch/arm64/boot/dts/nvidia/tegra186.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra186.dtsi @@ -1152,6 +1152,8 @@ smmu: iommu@12000000 { stream-match-mask = <0x7f80>; #global-interrupts = <1>; #iommu-cells = <1>; + + nvidia,memory-controller = <&mc>; }; host1x@13e00000 { From patchwork Thu Jun 3 16:46:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B73E3C47096 for ; Thu, 3 Jun 2021 16:53:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86A41613B1 for ; Thu, 3 Jun 2021 16:53:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86A41613B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kp0HKiuL9jvig7FuqILK/aqL0QqeYl/nPDSk+JdYfSU=; b=TOuMsS2LYB2WFf vsLnw6iKV0bNeOIqEyZmvJal3YkUTBPPZuSPkeh5PfB6+u7cL7yck3qwRq/zUGtsFwNhCRbgjx31o AlwSHPFf7Z10cnJs7uN+hw88R3pCPFcX8dcXE1RDb4A+H8gDa5QOh7hrV2scVjrrZ00+gZd2pGhNK 5lcKxAs72WrKvkGiXOMiGmInpt3xVs3DnfM5uOY1BZLm1sc9BTnJQk4AakpszYat8Gii3md3raIw6 YLdhGXvMkonK8CeJuS+Zl0sYQSVbSk3fT7FNftpSLodL942/35zlu6yYSJp1aVDbrgYRncWaGEWec QmFoUqscII1IbXziJN+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqYp-009dNz-IY; Thu, 03 Jun 2021 16:51:12 +0000 Received: from mail-ed1-f41.google.com ([209.85.208.41]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqU8-009bKD-FY for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:46:22 +0000 Received: by mail-ed1-f41.google.com with SMTP id t3so7887298edc.7 for ; Thu, 03 Jun 2021 09:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I2z89MxdxvGWhUJU/SEJ4QU2zKbMDk6xwIYV6O3cHbw=; b=DnVc3eGpHw8uTgSt7cOpizBr/x6zHc6dY5npOOIj0aW7DwrTYmk2iu9MlKBcq1EdPC eU/0BhqS3ZTvMzlZ1RgNaO3qIplnQhbJm4aOBmMcv8eurVhLJMDqtFUPgBR4U4m+ktyr gCu7AJq5n4UoJAGvcyVzYwNu6Y2PEAh4E9qhLNt5W5s8JyWp315B1EQMuI772Eiz/Rj0 /AeRrVNqyGQcD53ZsA8gYcFth9XW7svrwVeEQMX8GVdOyfFT8EYG1N37bLF0n3NXeDNw gf07B4BZKWQvUoRpYjcA2u5znH87BxqfDXmvykM5UAKP8OniCoSdIeWWi4eUPgNHECTQ GSWw== 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=I2z89MxdxvGWhUJU/SEJ4QU2zKbMDk6xwIYV6O3cHbw=; b=N3RAG8PHS017HyHkgZIs/p66QIQMBPWV2hmNUbRsuTS/DH4TQ6Kv2sKVpONyd+IGA2 T0vqFEVUp2zf2AzfsXwT0plSmRj4/38JRdY2XzUZKGHwyohDER+THPgJ4l/fOupFokqH 7F2OWcAvJyrFVSV5KlhnVVV0xUbIgbPzQyWrfNO38uSb85hULgINh6ktdz6bGykerpP2 sf1iFA9R1/g7zTg0uHzqQIbWp8VEu6phSTmEJzZNWkRrkDLdrSoW0OiLAwvIqJaphRZq uyVKxcJgIcEIMI4B79SWUB/udc9eJY1TSCaQbAZ9QcOSFCaFpINeWiUDQlEg/jjiEkl4 NnZQ== X-Gm-Message-State: AOAM533ps2YpwM1/zJElhXDUcHity3wvxJj9SQ0nWDbTtaJPA9TkMafi qCVG3qQR3zO1cTJAX0MBTwhi6pcJANE= X-Google-Smtp-Source: ABdhPJxnUDf8q5rYtZky60JkpGjvO01nPDdEy3yO1dQIOKvNDd/qUnT8hBVfgtEX1JIEnP/krtSlaw== X-Received: by 2002:a05:6402:416:: with SMTP id q22mr424114edv.204.1622738718619; Thu, 03 Jun 2021 09:45:18 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id y25sm1987038edt.17.2021.06.03.09.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:17 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 9/9] arm64: tegra: Enable SMMU support on Tegra194 Date: Thu, 3 Jun 2021 18:46:32 +0200 Message-Id: <20210603164632.1000458-10-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094620_564401_638FBEB9 X-CRM114-Status: GOOD ( 11.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding Add the device tree node for the dual-SMMU found on Tegra194 and hook up peripherals such as host1x, BPMP, HDA, SDMMC, EQOS and VIC. Signed-off-by: Thierry Reding --- arch/arm64/boot/dts/nvidia/tegra194.dtsi | 86 ++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi index ee71e0d9f895..94e1d8f1a79f 100644 --- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi @@ -62,6 +62,7 @@ ethernet@2490000 { interconnects = <&mc TEGRA194_MEMORY_CLIENT_EQOSR &emc>, <&mc TEGRA194_MEMORY_CLIENT_EQOSW &emc>; interconnect-names = "dma-mem", "write"; + iommus = <&smmu TEGRA194_SID_EQOS>; status = "disabled"; snps,write-requests = <1>; @@ -733,6 +734,7 @@ sdmmc1: mmc@3400000 { interconnects = <&mc TEGRA194_MEMORY_CLIENT_SDMMCRA &emc>, <&mc TEGRA194_MEMORY_CLIENT_SDMMCWA &emc>; interconnect-names = "dma-mem", "write"; + iommus = <&smmu TEGRA194_SID_SDMMC1>; nvidia,pad-autocal-pull-up-offset-3v3-timeout = <0x07>; nvidia,pad-autocal-pull-down-offset-3v3-timeout = @@ -759,6 +761,7 @@ sdmmc3: mmc@3440000 { interconnects = <&mc TEGRA194_MEMORY_CLIENT_SDMMCR &emc>, <&mc TEGRA194_MEMORY_CLIENT_SDMMCW &emc>; interconnect-names = "dma-mem", "write"; + iommus = <&smmu TEGRA194_SID_SDMMC3>; nvidia,pad-autocal-pull-up-offset-1v8 = <0x00>; nvidia,pad-autocal-pull-down-offset-1v8 = <0x7a>; nvidia,pad-autocal-pull-up-offset-3v3-timeout = <0x07>; @@ -790,6 +793,7 @@ sdmmc4: mmc@3460000 { interconnects = <&mc TEGRA194_MEMORY_CLIENT_SDMMCRAB &emc>, <&mc TEGRA194_MEMORY_CLIENT_SDMMCWAB &emc>; interconnect-names = "dma-mem", "write"; + iommus = <&smmu TEGRA194_SID_SDMMC4>; nvidia,pad-autocal-pull-up-offset-hs400 = <0x00>; nvidia,pad-autocal-pull-down-offset-hs400 = <0x00>; nvidia,pad-autocal-pull-up-offset-1v8-timeout = <0x0a>; @@ -821,6 +825,7 @@ hda@3510000 { interconnects = <&mc TEGRA194_MEMORY_CLIENT_HDAR &emc>, <&mc TEGRA194_MEMORY_CLIENT_HDAW &emc>; interconnect-names = "dma-mem", "write"; + iommus = <&smmu TEGRA194_SID_HDA>; status = "disabled"; }; @@ -1300,6 +1305,84 @@ pmc: pmc@c360000 { interrupt-controller; }; + smmu: iommu@12000000 { + compatible = "nvidia,tegra194-smmu", "nvidia,smmu-500"; + reg = <0x12000000 0x800000>, + <0x11000000 0x800000>; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + stream-match-mask = <0x7f80>; + #global-interrupts = <2>; + #iommu-cells = <1>; + + nvidia,memory-controller = <&mc>; + status = "okay"; + }; + host1x@13e00000 { compatible = "nvidia,tegra194-host1x"; reg = <0x13e00000 0x10000>, @@ -1319,6 +1402,7 @@ host1x@13e00000 { ranges = <0x15000000 0x15000000 0x01000000>; interconnects = <&mc TEGRA194_MEMORY_CLIENT_HOST1XDMAR &emc>; interconnect-names = "dma-mem"; + iommus = <&smmu TEGRA194_SID_HOST1X>; display-hub@15200000 { compatible = "nvidia,tegra194-display"; @@ -1430,6 +1514,7 @@ vic@15340000 { interconnects = <&mc TEGRA194_MEMORY_CLIENT_VICSRD &emc>, <&mc TEGRA194_MEMORY_CLIENT_VICSWR &emc>; interconnect-names = "dma-mem", "write"; + iommus = <&smmu TEGRA194_SID_VIC>; }; dpaux0: dpaux@155c0000 { @@ -2136,6 +2221,7 @@ bpmp: bpmp { <&mc TEGRA194_MEMORY_CLIENT_BPMPDMAR &emc>, <&mc TEGRA194_MEMORY_CLIENT_BPMPDMAW &emc>; interconnect-names = "read", "write", "dma-mem", "dma-write"; + iommus = <&smmu TEGRA194_SID_BPMP>; bpmp_i2c: i2c { compatible = "nvidia,tegra186-bpmp-i2c";