From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 10A74C433B4 for ; Tue, 20 Apr 2021 17:28:25 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5F38B613B8 for ; Tue, 20 Apr 2021 17:28:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F38B613B8 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=desiato.20200630; 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=X+ntHAfRC1/oEJYIAMgQFYHTIcRmWaAayQiFjhlXbO8=; b=N76wT6RSyvfgLY1/JaWyPN45M P3t3jyaMCZ4ZmHuLLoGbRe/Tl7sr7lJ/wqHK0uPoF/51XzhQm87N8dftFmLzmnMS7E081ya2f7ysG EHVk+QDM6JXNOE8pO0GxslLFCiOCUe36EUUHZQ5A3SogRWgljtxcE+nJkDdw75O72h1dZiorrqLYq YgJA4xjuZflHL0jWReCkEtpl6rL0HT+zZnJxnDUO7Glq6D8j+leCK4SXrhKp7aSykwaTe6v+evpjc naEy8yqICVWvupz9oTA8uvYe7EcUjz8qZWa9t211WCUtUdtUr6rtLRy+cleJkmD4FhlJCrW4M1l6P LHHNLe5/A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYu98-00Cio2-L0; Tue, 20 Apr 2021 17:26:46 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYu8I-00CiYM-BQ for linux-arm-kernel@desiato.infradead.org; Tue, 20 Apr 2021 17:25:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=W5UrtoQDzYhhXQZ+XkLu2njhk4Xp/wDLXcLYbSMA/yg=; b=NN57iLlj0nrdIdd0XZwLfnihfP I32IYqxeNwQXPZzyl8fdtikJKC0pePDtwp0YQ9t05DJKDEFWpdyugDOAjnlDjqrtAZCaJs+39WHg/ YFQFl8oGC8goUWgO5gM17KILQh9VOUe0SRSGGWQxqeXccKO42eD/15iwpaF/P6b486GASr3+vrbva 6OWscyMMKdKUg5jQD/dckdV7I1jws4G6XEpNkxeWp7/cQMqo64ZmogFnyiNUj867YTpeTVHORaTLJ fGn9TtdJZR2zGUWg8OWE19iHcEktW+pddHMbly9VQ8XOpc7rzGja1L8o4GytKPFDw++MkdB1KNaiI F19RYtig==; Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYu8C-00CJLT-Fv for linux-arm-kernel@lists.infradead.org; Tue, 20 Apr 2021 17:25:53 +0000 Received: by mail-ej1-x636.google.com with SMTP id sd23so50811163ejb.12 for ; Tue, 20 Apr 2021 10:25:48 -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=W5UrtoQDzYhhXQZ+XkLu2njhk4Xp/wDLXcLYbSMA/yg=; b=XpwtLWOSoQR1QtEWD8GMgIN2RBFLB7cxWIEInu+qLwsVn1ly7V8iDqH95dlgRe0HhQ vpV0gFCYGpqXwzIvzHZviqQeOqKPuwfP02iFsidvQXbXO6Uyqt5AvN1vZIAtlpKGw0rX M8JUSEcdXVcCUehGTs1EG219XNqWcxWIoHyLMIvD2+++Fd6Y4xLuaqo/dnj/9i6zZ1P3 3FiOPCbfYvk4e1HL/7ojC5sFvncfgzcA4mvOdVWSFb3B5SjVZ9Q6cEtDZsN2LD7h6bl5 iUz793C/I3b+13v3KVi90MWAkvi4OkZdy1r/7ifxCgwFclz09JlfsEnz5642qQu5eFNC IMwA== 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=W5UrtoQDzYhhXQZ+XkLu2njhk4Xp/wDLXcLYbSMA/yg=; b=nbl/Ecr8iJK+/u1Uwdmz+YV06cKCPna+RzPyVOljNAgVMtRV/ppYwP3dCwOBQKCVig 6VGXlDmjqngruKCDDVUuBJ8Ien4o83SMd/oRMGz3ULBnVuqOf7JVinRNFQ3AX31A32iA 31/DarUBNRXuFfStPZkeuVOnqCS8hLJiwsjZQssOQEs4X5WPe5MqA5lZwiLDmsYR5fgZ P4YrYad99tVn9bPvlXRevbYeo6iwoZTpAJsA5tbGWtIsKETTnNQ3qI7nNAFDE4vSYrOk FHVd8TD1vAxdXqNl59Vt2G2rcul6ykDg2RaoymvcMrvMNtnMwucuT6fYMHLzCxAxlJz6 Bggg== X-Gm-Message-State: AOAM532jYrNevKtARdjFGAzh7gaS+Gfl9pKyigNkBN8Cu3h84Hucvk+G am1TTuc+pllmSI/pXOvwWHs= X-Google-Smtp-Source: ABdhPJwKl5oMBkMmu3QRwZHqPJ9Nw9u91Wp1V1p2Ah525YJNuiVx6SoahW6CizH+rRNSBL3vkoEEiA== X-Received: by 2002:a17:906:fb90:: with SMTP id lr16mr28515953ejb.173.1618939547098; Tue, 20 Apr 2021 10:25:47 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id t15sm15984883edr.55.2021.04.20.10.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 10:25:46 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Robin Murphy , Joerg Roedel , Krzysztof Kozlowski Subject: [PATCH v2 05/10] iommu/arm-smmu: tegra: Implement SID override programming Date: Tue, 20 Apr 2021 19:26:14 +0200 Message-Id: <20210420172619.3782831-6-thierry.reding@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420172619.3782831-1-thierry.reding@gmail.com> References: <20210420172619.3782831-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-20210420_102548_555308_1538C83B X-CRM114-Status: GOOD ( 22.03 ) 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: iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 32 ++++++++++++++++++-- 1 file changed, 29 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 0e547b29143d..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,6 +267,7 @@ 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 = { @@ -264,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++; -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel