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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0FB12C531DC for ; Wed, 21 Aug 2024 08:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Type:MIME-Version:References:Message-ID:Subject:To:Date:From:Reply-To :Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WArzVvvD78lqDslWIGWtUOH/nDlCZabytUDmTejWvRw=; b=wY2hdmO+VhVxMzpAdWeGjDjCrB wMQR9oy+KJkEQRRIQMg48IglMupMq056Jw41B1Xnje80KhnjjmfI6V0vqUrZ0S4Aac8bGG0si71pP KwChGSCgUP1Y8ObjuGLWACbDRCKpuhdt0E/r3dbLwZD7CWqgzE+EtD0APCI5reaCqKoEZXNYVF3Cc Xl5KTne55mibsIW+FVFiCX6YRjpN3F/LQWYLcNVk89R9Wnwy5JQMib3GXmX046dRUyCimLDoiLw8P wJ+IX8L2G9WIlyHgZu8iyLAzJkzgMVQtt4nyKgZ2mHNdB78HJyeSuJbRNk41uaqKEGehcoxVUFbGQ HgazIWqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sggZE-000000081nM-3a5B; Wed, 21 Aug 2024 08:19:44 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sggYV-000000081eh-1fqt for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 08:19:01 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5320d8155b4so8307540e87.3 for ; Wed, 21 Aug 2024 01:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1724228337; x=1724833137; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=WArzVvvD78lqDslWIGWtUOH/nDlCZabytUDmTejWvRw=; b=Wt+yM1DPZbz9qYFzMHg4vNkwmWzI9sf0W/z3+gfR8tKNzBsIk2e2VSkQMZHfotxPiA 7OPEidHewrz6oVQ3Jh3LnpnFh3bsvgJYEeFEfywmSQjIwmcRvDh0AJKSlp2FtWKNQpNh XbaH+l3zOMaxprIgbUnVfx6PikO01XgdO4yDFx7B9vWLKS1fA+mVs8JsH2FnitKU0KnP j57IS+v87smDtkf06oR7JoomUNnkrqgOOGiF+CWl/Mq29SeI2D2uBvCc+80ozwyOdPHD 5qiIpmn1BbdR9xq0S0gEX0j7oRVjmfnmtcod2FQt4H56K52rT15oG3CL6lhysZLNqrSL xonw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724228337; x=1724833137; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WArzVvvD78lqDslWIGWtUOH/nDlCZabytUDmTejWvRw=; b=TYaRBlgOaYcL/LxxqOkYlHwyh53XMs1Ofc7WDinBERtELMq0Y8P3sHyoUW4+TrDR7x +0inxorJoXCi/Swzje+tUzffcMHVeUaJNCLQ4th0CmHYcqlQVA1LRaMk/AvzTmV/XDeG 9A93vGckA3QaSAiSJLDYq3eyqre/FQ0jV+dejWoEOTNY4u4rFPraHq3WcEewnphN2+2K QYAUMJ1GAIXKXuxBCk976EDn1HNt6nRQJ4XTUKn6qDyX/ZapSN7vYgcRqbgDRnhZ5kPP +WiB+/OgLHOYWCGkd01Ac8v15AJZqrb/qfJWc2dWlEuJT587Jy6xFMKnCQvVKN9TSQZF C8Uw== X-Forwarded-Encrypted: i=1; AJvYcCUUj4obG39SWUHvmoWxfC2Mx5dya7ZxKZr04q4k312Sc58sJ79YuSpHUZSCk1NtqmI7oLAlkvUqvx59SamCt+IJ@lists.infradead.org X-Gm-Message-State: AOJu0YyTLKtUeAFdj0/GhM8aUbbgHUTYME9BFFPhywaeOua78qtZHfon w2HMQyvZwSaJRvwCRaN+VA3IILi3n+22qF6FgcV0Qy3kd1DzYjbJpLv7acfepp0= X-Google-Smtp-Source: AGHT+IEL8Q9c8iW6LU5Zvu1ChEfBIQpUuvo6C3xns0qZKNHZdslM5QCPSgRla9iNvwZuRV2iyiygYA== X-Received: by 2002:a05:6512:3092:b0:52e:f4b4:6ec1 with SMTP id 2adb3069b0e04-533485994fcmr644542e87.46.1724228336862; Wed, 21 Aug 2024 01:18:56 -0700 (PDT) Received: from localhost ([87.13.33.30]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3dd33ef56adsm3210337b6e.50.2024.08.21.01.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 01:18:56 -0700 (PDT) From: Andrea della Porta X-Google-Original-From: Andrea della Porta Date: Wed, 21 Aug 2024 10:18:59 +0200 To: Rob Herring Subject: Re: [PATCH 04/11] of: address: Preserve the flags portion on 1:1 dma-ranges mapping Message-ID: Mail-Followup-To: Rob Herring , Andrea della Porta , Michael Turquette , Stephen Boyd , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Linus Walleij , Catalin Marinas , Will Deacon , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nicolas Ferre , Claudiu Beznea , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Saravana Kannan , Bjorn Helgaas , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, Lee Jones , Andrew Lunn , Stefan Wahren References: <5ca13a5b01c6c737f07416be53eb05b32811da21.1724159867.git.andrea.porta@suse.com> <20240821001618.GA2309328-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240821001618.GA2309328-robh@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_011859_468211_8E3B9A95 X-CRM114-Status: GOOD ( 28.85 ) 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: Andrew Lunn , Catalin Marinas , Michael Turquette , Claudiu Beznea , Eric Dumazet , Dragan Cvetic , Will Deacon , linux-clk@vger.kernel.org, linux-arch@vger.kernel.org, Florian Fainelli , Lee Jones , Saravana Kannan , Broadcom internal kernel review list , linux-pci@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Linus Walleij , devicetree@vger.kernel.org, Conor Dooley , Arnd Bergmann , linux-gpio@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Bjorn Helgaas , Andrea della Porta , linux-arm-kernel@lists.infradead.org, Derek Kiernan , Stephen Boyd , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Stefan Wahren , netdev@vger.kernel.org, Krzysztof Kozlowski , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Rob, On 19:16 Tue 20 Aug , Rob Herring wrote: > On Tue, Aug 20, 2024 at 04:36:06PM +0200, Andrea della Porta wrote: > > A missing or empty dma-ranges in a DT node implies a 1:1 mapping for dma > > translations. In this specific case, rhe current behaviour is to zero out > > typo Fixed, thanks! > > > the entire specifier so that the translation could be carried on as an > > offset from zero. This includes address specifier that has flags (e.g. > > PCI ranges). > > Once the flags portion has been zeroed, the translation chain is broken > > since the mapping functions will check the upcoming address specifier > > What does "upcoming address" mean? Sorry for the confusion, this means "address specifier (with valid flags) fed to the translating functions and for which we are looking for a translation". While this address has some valid flags set, it will fail the translation step since the ranges it is matched against have flags zeroed out by the 1:1 mapping condition. > > > against mismatching flags, always failing the 1:1 mapping and its entire > > purpose of always succeeding. > > Set to zero only the address portion while passing the flags through. > > Can you point me to what the failing DT looks like. I'm puzzled how > things would have worked for anyone. > The following is a simplified and lightly edited) version of the resulting DT from RPi5: pci@0,0 { #address-cells = <0x03>; #size-cells = <0x02>; ...... device_type = "pci"; compatible = "pci14e4,2712\0pciclass,060400\0pciclass,0604"; ranges = <0x82000000 0x00 0x00 0x82000000 0x00 0x00 0x00 0x600000>; reg = <0x00 0x00 0x00 0x00 0x00>; ...... rp1@0 { #address-cells = <0x02>; #size-cells = <0x02>; compatible = "simple-bus"; ranges = <0xc0 0x40000000 0x01 0x00 0x00 0x00 0x400000>; dma-ranges = <0x10 0x00 0x43000000 0x10 0x00 0x10 0x00>; ...... }; }; The pci@0,0 bridge node is automatically created by virtue of CONFIG_PCI_DYNAMIC_OF_NODES, and has no dma-ranges, hence it implies 1:1 dma mappings (flags for this mapping are set to zero). The rp1@0 node has dma-ranges with flags set (0x43000000). Since 0x43000000 != 0x00 any translation will fail. Regarding why no one has really complained about that: AFAIK this could very well be an unusual scenario that is arising now that we have real use case for platform devices behind a PCI endpoint and devices populated dynamically from dtb overlay. Many thanks, Andrea > > > > > Signed-off-by: Andrea della Porta > > --- > > drivers/of/address.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/of/address.c b/drivers/of/address.c > > index d669ce25b5f9..5a6d55a67aa8 100644 > > --- a/drivers/of/address.c > > +++ b/drivers/of/address.c > > @@ -443,7 +443,8 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, > > } > > if (ranges == NULL || rlen == 0) { > > offset = of_read_number(addr, na); > > - memset(addr, 0, pna * 4); > > + /* copy the address while preserving the flags */ > > + memset(addr + pbus->flag_cells, 0, (pna - pbus->flag_cells) * 4); > > pr_debug("empty ranges; 1:1 translation\n"); > > goto finish; > > } > > -- > > 2.35.3 > >