Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1046339pxb; Wed, 6 Apr 2022 07:27:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVwKUEntRaoNqQDlsfj1qApvx088XyxmYASdxhbFRYVOUgVX8vgPSV8Whf3veYkpkr+Om4 X-Received: by 2002:a17:902:d481:b0:154:7f0b:62fb with SMTP id c1-20020a170902d48100b001547f0b62fbmr9003306plg.41.1649255267497; Wed, 06 Apr 2022 07:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649255267; cv=none; d=google.com; s=arc-20160816; b=yRmmf6MzJcJj1skOR2gAVNEl+N88ZQJ02Gh5fXpezqmA3ipw7zNGxMOTwQInukxcFA EDo+GMPhSKspH5TJIBaTNc/YAmkT4GF0heBH7ciGI5t4ISkSDuTan8R7ds1LvZvJjAJF /ex9T7/m6lARBqK+iEn1BCJcakAZ34kK0HrWgJsZOxv3dZzD+PeBNAXFqp1262h833x/ SI65Gj8niFraDlr8sEo4UnsskO9rxgR0l1TRExxU5n32P06n+bc5Chlfsnfcpj7DAWUW PfYWziQ68p5D/YBgDYLhxBn/9iQHnJw8G2cNobx4j5uUvEAOMjw/RZuwTVgNHfZc74ul CuAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=PvBaVRFAnY/ORDXxtA7VK6NPEsfRZG+u0pw044v6QD0=; b=cVbU189K97MTgUxC16Fva8l9q9eLVOFlUPlfFGOqZMdNH0JZW2ZBolwdi0cqpa29f5 DkKibc/e0rYayUNgs0OiQHAFMIsORBQ9kBXro/hMbWb0ulzXdE1BpFrMGSZ/F+3R117S RiVb70t3qI9h+cGIvBsefpUDMBEKBX3LTeJzb/RyUQlpCYFONn1DoQfhKvPxADPArNpm pppOQkMvXhohsRMhGqFOLklNoyoCEjw39sViTG9LdEG8WYnbSiwnh75Yhf2/AiOfPP+J ZOj/qb6rdIWI0jyzV9fkU3jCgLsBi6oArqimiA54zYT1qlYJ/UNeziCa5vbMfHzx5bke s6oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QjfOHTep; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w2-20020a170902e88200b001544c9777e0si17582289plg.95.2022.04.06.07.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:27:47 -0700 (PDT) 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=pass header.i=@bootlin.com header.s=gm1 header.b=QjfOHTep; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DDC70349514; Wed, 6 Apr 2022 05:09:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235108AbiDFLVh (ORCPT + 99 others); Wed, 6 Apr 2022 07:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245473AbiDFLU7 (ORCPT ); Wed, 6 Apr 2022 07:20:59 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73897488582; Wed, 6 Apr 2022 00:41:51 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 8206024000E; Wed, 6 Apr 2022 07:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1649230909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PvBaVRFAnY/ORDXxtA7VK6NPEsfRZG+u0pw044v6QD0=; b=QjfOHTepZwXd5T6HN/mX5v71tbA9htl+dE1rSpmoV7tL19875uFjQNjgrAbs02TkOaWeMv 9mSalcjui6EjmOqZ4EdV0EO4VXQ0Qu+5N718q9Jib5yyto3lyg4S+R6WX5NGuSmW6XzfTD kIrhjt4vv2pXQTH361h3SLqrtQyJDRP0sbjditUu7QEUvVTLeYSrliPrIyesodbCVCLkvq YS32ew/tBOYBVpAatyytk8q4jtF9DXEpH0+3G2j6hOJrtf/yfBABdjxrHsuS1TKw31wnFX BBevqEIuquORrd6Zj8N7dmFtd7FUoZYGCz6aC6qbf0PzVZXDuEHoM885ZOcjcA== Date: Wed, 6 Apr 2022 09:40:19 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Rob Herring Cc: Lizhi Hou , Sonal Santan , Philipp Zabel , Frank Rowand , Lars Povlsen , Steen Hegelund , Microchip Linux Driver Support , Thomas Petazzoni , Alexandre Belloni , Allan Nielsen , "linux-kernel@vger.kernel.org" , devicetree@vger.kernel.org, Stefano Stabellini , Hans de Goede , Mark Brown Subject: Re: [PATCH v2 0/3] add fwnode support to reset subsystem Message-ID: <20220406094019.670a2956@fixe.home> In-Reply-To: References: <20220324141237.297207-1-clement.leger@bootlin.com> <20220405092434.6e424ed4@fixe.home> <20220405175120.23fc6b2a@fixe.home> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 Le Tue, 5 Apr 2022 12:11:51 -0500, Rob Herring a =C3=A9crit : > On Tue, Apr 5, 2022 at 10:52 AM Cl=C3=A9ment L=C3=A9ger wrote: > > > > Le Tue, 5 Apr 2022 09:47:20 -0500, > > Rob Herring a =C3=A9crit : > > =20 [...] > > > > I also tried loading an overlay from a driver on an ACPI based system. > > Their patch is (I guess) targeting the specific problem that there is > > no base DT when using ACPI. However, Mark Brown feedback was not to > > mix OF and ACPI: =20 >=20 > I agree there. I don't think we should use DT bindings in ACPI tables > which is already happening. In this case, I think what's described by > ACPI and DT must be completely disjoint. I think that's the case here > as everything is downstream of the PCIe device. Yes, there is no references to the host devices (at least in my case). >=20 > > "That seems like it's opening a can of worms that might be best left > > closed." > > > > But I would be interested to know how the Xilinx guys are doing that > > on x86/ACPI based system. =20 >=20 > They aren't, yet... Ok... [...] >=20 >=20 > > > I've told the Xilinx folks the same thing, but I would separate this > > > into 2 parts. First is just h/w work in a DT based system. Second is > > > creating a base tree an overlay can be applied to. The first part sho= uld > > > be pretty straightforward. We already have PCI bus bindings. The only > > > tricky part is getting address translation working from leaf device t= hru > > > the PCI bus to host bus, but support for that should all be in place > > > (given we support ISA buses off of PCI bus). The second part will > > > require generating PCI DT nodes at runtime. That may be needed for bo= th > > > DT and ACPI systems as we don't always describe all the PCI hierarchy > > > in DT. =20 > > > > But then, if the driver generate the nodes, it will most probably > > have to describe the nodes by hardcoding them right ? =20 >=20 > No, the kernel already maintains its own tree of devices. You just > need to use that to generate the tree. That's really not much more > than nodes with a 'reg' property encoding the device and function > numbers. Just to clarified a point, my PCI device exposes multiple peripherals behind one single PCI function. To be sure I understood what you are suggesting, you propose to create a DT node from the PCI driver that has been probed dynamically matching this same PCI device with a 'reg' property. I also think this would requires to generate some 'pci-ranges' to remap the downstream devices that are described in the DTBO, finally, load the overlay to be apply under this newly created node. Is that right ? >=20 > We already support matching a PCI device to a DT node. The PCI > subsystem checks if there is a corresponding DT node for each PCI > device created and sets the of_node pointer if there is. For > OpenFirmware systems (PPC), there always is a node. For FDT, we > generally don't have a node unless there are additional > non-discoverable properties. Hikey960 is an example with PCI device > nodes in the DT as it has a soldered down PCIe switch with downstream > devices and non-discoverable properties (e.g. reset GPIO for each > port). >=20 > > Or probably load > > some dtbo from the FS. If so, I would then have to describe the card > > for both ACPI and DT. How is that better than using a single software > > node description for both ACPI/OF based systems ? Or maybe I missed > > something, but the device description won't come out of thin air I > > guess. =20 >=20 > What you would have to load is a DT overlay describing all your > downstream devices. >=20 > We support DTBs (including DTBOs) built into the kernel already, so > whether it's built into the kernel or in the FS is up to you really. Indeed. >=20 > > Also, when saying "That may be needed for both DT and ACPI systems", do > > you actually meant that ACPI overlay should be described for ACPI based > > systems and DT overlays for DT based ones ? =20 >=20 > No, as I said: "I think DT overlays is the right (or only) solution > here." ACPI overlays doesn't seem like a workable solution because it > can't describe your downstream devices. Ok, so you are actually really suggesting to use OF overlays on ACPI based systems. If so, I'm ok with that. >=20 > The reason generating nodes may be needed on DT systems as well is > that all PCI devices are not described in DT systems either. >=20 > > If so, some subsystems do > > not even support ACPI (reset for instance which is need for my > > PCI card but that is not the only one). So how to accomodate both ? This > > would result in having 2 separate descriptions for ACPI and OF and > > potentially non working with ACPI description. > > > > Software nodes have the advantage of being independent from the > > description systems used (ACPI/OF). If switching susbsystems to use > > fwnode, this would also allows to accomodate easily for all nodes types > > and potentially factorize some code. =20 >=20 > It's not independent. You are effectively creating the DT nodes with C > code. Are these not DT bindings: >=20 > > static const struct property_entry ddr_clk_props[] =3D { > > PROPERTY_ENTRY_U32("clock-frequency", 30000000), > > PROPERTY_ENTRY_U32("#clock-cells", 0), > > {} > > }; =20 >=20 > Sure looks like DT bindings to me. I don't think moving them into the > kernel as sw nodes avoids any of the potential pitfalls of mixing ACPI > and DT. For example, what happens when you have a downstream sw node > device that wants to do DMA allocations and transfers? I suspect that > sw nodes can't really handle more than trivial cases. When integrating with fwnode, the subsystem support will be almost the same as the one with OF. But I agree that it requires certain level of subsystem modifications to support fwnode. >=20 >=20 > > > That could work either by the PCI subsystem creating nodes as it > > > populates devices or your driver could make a request to populate nod= es > > > for its hierarchy. That's not a hard problem to solve. That's what > > > OpenFirmware implementations do already. =20 > > > > This would also require to get address translation working with ACPI > > based systems since the PCI bus isn't described with DT on such > > systems. I'm not sure how trivial it is. Or it would require to add PCI > > root complex entries into the device-tree to allow adress translation > > to work using the existing system probably. =20 >=20 > It would require all that most likely. Maybe there's some shortcuts we > can take. All the necessary information is maintained by the kernel > already. Normally it's populated from the firmware into the kernel > structures. But here we need the opposite direction. >=20 >=20 > > > https://lore.kernel.org/lkml/20220216050056.311496-1-lizhi.hou@xilinx= .com/ =20 > > > > Looking at the feedback of the previous series that I mentionned, > > absolutely nobody agreed on the solution to be adopted. I asked for a > > consensus but I only got an answer from Hans de Goede which was ok > > with the fwnode way. I would be really glad to have some consensus on > > that in order to implement a final solution (and if the OF overlays is > > the one to be used, I'll use it). =20 >=20 > Yes, that's a challenge, but buried in some patch series is not going > to get you there. Sorry, indeed, you were not on the series were the discussion took place. I'll think about that next time. > I am trying to widen the discussion because it is a > problem that's been on my radar for some time. Thanks for the proposal, maybe we can achieve something that will suit everybody and solve the current problems. --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com