Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4438794pxb; Mon, 21 Feb 2022 21:38:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+4CWAHWhF5iN72hgP050uRoOkuCoi4QnN9Ix6su64O3TlYb2pMErRmbNEM1bxucx2vbTa X-Received: by 2002:a05:6a00:1704:b0:4cc:c8d7:e54a with SMTP id h4-20020a056a00170400b004ccc8d7e54amr23465255pfc.16.1645508322068; Mon, 21 Feb 2022 21:38:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645508322; cv=none; d=google.com; s=arc-20160816; b=p/83tewDJWcdzdoe920aCcpuvZFqvYwXFT7/a0KE/uJdV6mG9zYpqoqda4idlpXOgg baaV8r813Nf+4sBUOHSSYlvPEep04iaS4CpDUa9Gcg/ucDl46zYoOFP+DnD9Cm40j7en prEGm+pfMjgh019vT9bj+Y5I9JuUPkKTmP+FnqoYTQ2ZsDs9QqxaoRcpZernPf5nFEXl ikO9BxnHVrf7b2AE/6/DqgMhP7D4wxPCigJwak1x1VIHPpwvq8CGWBUtIEUbV1vSk8EY YiEcbgisGN9/lentXZM2kncgBbKPws/S8gqua12GnZeDXv0lyGmMrrDrVExYN5EmnF84 pMOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Cbh14+tf3RlQjgmoKOC/m9u4BnwaRP9y3quGxX96FSI=; b=Qkcvx3qHROZEFhwy6ngaIv1BvHQTSfCVhxmDw2I+xVlcH6t0ZyzpAUuxvEAvjwoTt9 BZQKO5Y81fHYNmNzVhaXgWWSjT3lc22dhpDJ917/J0NmwV3xUze74DkFMeRloH/W852l 1rrsGRuJrzWl3lcwVyl4h8sQruR4oC62Hwy8mWP2ePvrsUJfOAGG8BnUX9VeBEoml0ok Huc3OaJS9Pf88g5BYDOqK02Uz1GrUDA+EzT54OtY+GQ5mT4RvcLAzMrp8mwZm/+eefut /YSnN0YVOTQGz+beuzIFqbe83ZwSEzfCPTkOin+EVbc3MUHIMV68/IWlgKDpPZv8AZS8 T4/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b="jhA/4QXJ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q2si11142426pfk.174.2022.02.21.21.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:38:42 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b="jhA/4QXJ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BC52D9F381; Mon, 21 Feb 2022 21:05:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381486AbiBURMq (ORCPT + 99 others); Mon, 21 Feb 2022 12:12:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237880AbiBURMo (ORCPT ); Mon, 21 Feb 2022 12:12:44 -0500 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE98C14024; Mon, 21 Feb 2022 09:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Cbh14+tf3RlQjgmoKOC/m9u4BnwaRP9y3quGxX96FSI=; b=jhA/4QXJ9SC3/vv4U/UbbXUYnM AFPLrTXhyYEUM/FjH0rg8HRpPJ750cSDMf8AW4LT3BYRVB+Ib26IRJ/RM69rjja74gzRYCgnqMk+a tfoW1rLKoTOfrBaYZhNGbqE4Wsc4PutIf3RvPFDyM2PBXMunzVP1tu25N/DR/DxdTtEeEiWbEijxv UQtTSY3zvh339M4V2jvsBZXKtctRTk+uFuLmdylbC79Ew2vW5R0GFf4EADGQKbosyHaf71OLN5h9O HZxSiVCydytd3bnua3Mti6l3EC0fr0hhGqbVJqfDOEMDuEhkkZp8UBQSUqY1bTGvhLoofcKjToZOU hht37tLg==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=[192.168.1.10]) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nMCEL-0004yN-An; Mon, 21 Feb 2022 19:12:09 +0200 Message-ID: Date: Mon, 21 Feb 2022 19:12:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Subject: Re: [PATCH v3 1/9] dt-bindings: host1x: Add memory-contexts property Content-Language: en-US To: Robin Murphy , Mikko Perttunen , thierry.reding@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, will@kernel.org, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20220218113952.3077606-1-mperttunen@nvidia.com> <20220218113952.3077606-2-mperttunen@nvidia.com> <48ac567b-37e8-1fa2-c389-536e276fdd2c@arm.com> <2e9c4ea5-6bbd-9724-0f4e-ed25f7294aa2@kapsi.fi> <56cf458b-080b-2e22-69d7-039ff7d0b56a@arm.com> From: Mikko Perttunen In-Reply-To: <56cf458b-080b-2e22-69d7-039ff7d0b56a@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 91.158.25.70 X-SA-Exim-Mail-From: cyndis@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/21/22 18:58, Robin Murphy wrote: > On 2022-02-21 15:28, Mikko Perttunen wrote: >> On 2/21/22 17:23, Robin Murphy wrote: >>> On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: >>>> Add schema information for the memory-contexts property used to >>>> specify context stream IDs. This uses the standard iommu-map property >>>> inside a child node. >>> >>> Couldn't you simply make "iommu-map" an allowed property on the >>> host1x node itself? From a DT perspective I'm not sure the >>> intermediate node really fits meaningfully, and I can't see that it >>> serves much purpose in practice either, other than perhaps defeating >>> fw_devlink. >>> >>> Robin. >> >> The stream IDs described here are not used by the host1x device >> itself, so I don't think I can. Host1x's memory transactions still go >> through the stream ID specified in its 'iommus' property, these stream >> IDs are used by engines (typically in addition to the stream ID >> specified in their own nodes). >> >> Host1x 'iommus' -- Channel commands >> Engine 'iommus' -- Engine firmware (and data if context isolation is >> not enabled) >> memory-contexts 'iommu-map' -- Data used by engines. > > Right, that still appears to match my understanding, that as far as > software sees, the host1x is effectively acting as a bridge to the > engines in itself. Even if it's not physically routing traffic in and/or > out, the host1x device is the place where the context IDs *logically* > exist, and thus owns the mapping between context IDs and the StreamIDs > emitted by any engine working in a given context. > > Consider a PCIe root complex with integrated endpoints - chances are the > RCiEPs have their own physical interfaces to issue DMA directly into the > SoC interconnect, but that doesn't change how we describe the PCI > Requester ID to StreamID mapping at the root complex, since the RC still > logically owns the RID space. You can think of a RID as being "consumed" > at the RC by indexing into config space to ultimately gain control of > the corresponding endpoint, just like context IDs are "consumed" at the >  host1x by generating commands to ultimately cause some engine to > operate in the correct address space. > > You don't have to pretend the host1x uses a context for its own > command-fetching (or whatever) traffic either - it's always been > intended that the "iommus" and "iommu-map" properties should happily be > able to coexist on the same node, since they serve distinctly different > purposes. If it doesn't work in practice then we've got a bug to fix > somewhere. > Interesting, I had assumed that they were exclusive but indeed comparing with PCIe this makes sense. I'll look into it. > If the context-switching mechanism was some distinct self-contained > thing bolted on beside the other host1x functionality then describing it > as a separate level of DT hierarchy might be more justifiable, but > that's not the impression I'm getting from skimming the rest of the > series. Just reading of the names of things in patch #6, my intuitive > reaction is that clearly each host1x owns 9 StreamIDs, one for general > stuff and 8 for contexts. Adding the knowledge that technically the > context StreamIDs end up delegated to other host1x-controlled engines > still doesn't shift the paradigm. I don't believe we need a level of DT > structure purely to help document what the iommu-map means for host1x - > the binding can do that just fine. Theoretically there can be any number of these stream IDs, but indeed, there is quite specific HW support for this in Host1x. Thanks for your help once again! Mikko > > Thanks, > Robin. > >> (Perhaps I should add this information to various places in more >> abundance and clarity.) >> >> Mikko >> >>> >>>> Signed-off-by: Mikko Perttunen >>>> --- >>>> v3: >>>> * New patch >>>> --- >>>>   .../bindings/display/tegra/nvidia,tegra20-host1x.yaml  | 10 >>>> ++++++++++ >>>>   1 file changed, 10 insertions(+) >>>> >>>> diff --git >>>> a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml >>>> b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml >>>> >>>> index 4fd513efb0f7..3ac0fde54a16 100644 >>>> --- >>>> a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml >>>> >>>> +++ >>>> b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml >>>> >>>> @@ -144,6 +144,16 @@ allOf: >>>>           reset-names: >>>>             maxItems: 1 >>>> +        memory-contexts: >>>> +          type: object >>>> +          properties: >>>> +            iommu-map: >>>> +              description: Specification of stream IDs available >>>> for memory context device >>>> +                use. Should be a mapping of IDs 0..n to IOMMU >>>> entries corresponding to >>>> +                usable stream IDs. >>>> +          required: >>>> +            - iommu-map >>>> + >>>>         required: >>>>           - reg-names >>