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=-10.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 23037C43460 for ; Mon, 26 Apr 2021 14:11:51 +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 7C2996101B for ; Mon, 26 Apr 2021 14:11:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C2996101B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.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:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+mE4BEMwy5aapJfe2j98Jb5Qx5GJRg72U35cn853zDQ=; b=VhITCxVeagLL3JIDW1IHOxkJh /RM7YhidbW1f+7tpDHIN1g6uK3o7ouOCzs9FGANQtn+M7HuPMgxDdwGg3TCLjqcnII1vbhfb+vSC4 OrytSJKycD2iS2lMPuSotlTLo+lgl0L4fnJ9c9XwHhYkEfHc6s0qVddhpA+7bjBaEJL87TKPO74Fp 5TDJHxGue5QYhhKyNJpjRqnJ0Yg+tbh/hCkdMQ6HtVlZG3w+X4gWHoqGsI2GKN/ptord+UCBZLO4W otjLyyR1UWTGxin7QllgDaDCYdSdYRLHK5WYxIlmReMqAFLBQ9zTrOS4Jg1fOnQzcKEbpCNR6Piva r8gRgJrZA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lb1wK-007nGJ-2E; Mon, 26 Apr 2021 14:10:20 +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 1lb1wH-007nG4-3P for linux-arm-kernel@desiato.infradead.org; Mon, 26 Apr 2021 14:10:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=2ADebOh7mdB0pOynqo1V1oIiVpLH7xgzkBg1gH8EygY=; b=fCMfuUcqEXvU57anjJALbs3sfk sT7SjRx8pJBDMKoKXxygmZell3Snsbe8I3Q5Uba3bmNHIxt1obRAisLx1T0nrYMte+gkPJU1jifsU IM71ttq76EsHxfE4ZHz4ghcmBNJMC9+1Xw3rM+AgcNb4JeHcQ2FczVct+qX0fujpFYAmm9hSS4iOZ BSMVwtDbEXEEV74Cvc+YJR8NM+0h70ykN5IG/UymEcYMLkizw2FWeN1vRCGyX6wuxSTzYXN9it45L Nm/B04kNOuKSnJvuHz50d6kEWA6soD+aedM3HCpsg9voaH/UqSGIcKP0twockENfWCtZY68bIF44a A0VlRqZA==; Received: from youngberry.canonical.com ([91.189.89.112]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lb1wC-00G0C4-SF for linux-arm-kernel@lists.infradead.org; Mon, 26 Apr 2021 14:10:15 +0000 Received: from mail-ej1-f69.google.com ([209.85.218.69]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lb1w8-0006xX-PF for linux-arm-kernel@lists.infradead.org; Mon, 26 Apr 2021 14:10:08 +0000 Received: by mail-ej1-f69.google.com with SMTP id ji8-20020a1709079808b029037c921a9ea0so10238616ejc.9 for ; Mon, 26 Apr 2021 07:10:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2ADebOh7mdB0pOynqo1V1oIiVpLH7xgzkBg1gH8EygY=; b=KsT9+zHrXQ/o7QS/lJJYuM/YzYD2hs8+NwasrTeFT26iL05OM9FFSGR6XU2EttIPIX 7PB0VxtzujokwaSiqgtof35Bl5Sazg+SteWgEuLQbqlRN1OoMLi8/TRLBzF3WnjQ3grp UL1dn346DryXW+rhNJxNSQY8ddK4DYHtXSg8OytbR0bJOK8IlVzjejUIo7RsUBxDZBVt tnSP405gQ4OCPjVFtH44TLgYE9fM+mCFAjF9cFrQyVoMUyv7okyZ0kgTmmAgWem8umhW VIg1alxRGVryhyyK7I80I1YTYyJKVuKz7GbU0QnkdEZwvSMHfOtI4Oun8c2F17BseQpq TLxg== X-Gm-Message-State: AOAM530OA7JtmBclmHFHuQx2U2USv1syc1HoSFb0KF50iEy1uqcNG2O4 QOlsHOP1AyVWdouz8wE6NF/E0eUkTN+yEQ/6dhcGwhiS4mmYJPmsIzyaVK6STzWalhvEAy38UmF XArssgFn0rGdMd3x/sdsyt8PbRcbYBssHR14EhVW04QPay+RXndkE X-Received: by 2002:a50:ee88:: with SMTP id f8mr10726111edr.176.1619446208306; Mon, 26 Apr 2021 07:10:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaB1Db7KABg9TD1/UL3dQ5XfAGx3KjxU9sYwe/UocPCGa2sJj2AJlgIhi7ZrvToVrSsb83Tg== X-Received: by 2002:a50:ee88:: with SMTP id f8mr10726080edr.176.1619446208110; Mon, 26 Apr 2021 07:10:08 -0700 (PDT) Received: from [192.168.1.115] (xdsl-188-155-180-75.adslplus.ch. [188.155.180.75]) by smtp.gmail.com with ESMTPSA id m14sm14363432edr.45.2021.04.26.07.10.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 07:10:07 -0700 (PDT) Subject: Re: [PATCH v2 01/10] memory: tegra: Implement SID override programming To: Thierry Reding References: <20210420172619.3782831-1-thierry.reding@gmail.com> <20210420172619.3782831-2-thierry.reding@gmail.com> <03e2a655-7dbf-a729-75f6-98db353e2b91@canonical.com> From: Krzysztof Kozlowski Message-ID: <526942f8-861a-8b0f-66a2-42eda600fabe@canonical.com> Date: Mon, 26 Apr 2021 16:10:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210426_071013_079787_D82C3891 X-CRM114-Status: GOOD ( 28.82 ) 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: Will Deacon , Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , 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 On 26/04/2021 14:13, Thierry Reding wrote: > On Mon, Apr 26, 2021 at 10:28:43AM +0200, Krzysztof Kozlowski wrote: (...) >>> + >>> + 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) >> >> Is this part really build-time dependent? I don't see here any uses of >> IOMMU specific fields, so maybe this should be runtime choice based on >> enabled interconnect devices? > > Unfortunately it is. struct iommu_fwspec is an empty structure for > !CONFIG_IOMMU_API, so the code below that tries to access fwspec->ids > fails for !CONFIG_IOMMU_API configurations if we don't protect this with > the preprocessor guard. OK, thanks. > >> >>> + 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 1387747d574b..bbad6330008b 100644 >>> --- a/include/soc/tegra/mc.h >>> +++ b/include/soc/tegra/mc.h >>> @@ -176,6 +176,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 { >>> @@ -240,4 +241,6 @@ devm_tegra_memory_controller_get(struct device *dev) >>> } >>> #endif >>> >>> +int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev); >>> + >> >> What about !CONFIG_TEGRA_MC? I think arm-smmmu will fail. > > I think it doesn't fail because for !CONFIG_TEGRA_MC it basically throws > away most of nvidia_smmu_impl_init() already because ERR_PTR(-ENODEV) is > returned by devm_tegra_memory_controller_get() and so it unconditionally > fails early on already. > > I say I /think/ that happens because I can't reproduce a build failure > even if I manually tweak the .config such that ARM_SMMU is enabled and > TEGRA_MC is disabled. But I can't say I fully understand why it's > working, because, yes, the symbol definitely doesn't exist. But again, > if the compiler is clever enough to figure out that that function can't > be called anyway and doesn't even want it, why bother making it more > complicated than it has to be? Since you tested that case, it's fine. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel