From: "Clément Léger" <clement.leger@bootlin.com>
To: Rob Herring <robh@kernel.org>
Cc: Lizhi Hou <lizhi.hou@xilinx.com>,
Sonal Santan <sonal.santan@xilinx.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Frank Rowand <frowand.list@gmail.com>,
Lars Povlsen <lars.povlsen@microchip.com>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Allan Nielsen <allan.nielsen@microchip.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
devicetree@vger.kernel.org,
Stefano Stabellini <sstabellini@kernel.org>,
Hans de Goede <hdegoede@redhat.com>,
Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v2 0/3] add fwnode support to reset subsystem
Date: Wed, 6 Apr 2022 09:40:19 +0200 [thread overview]
Message-ID: <20220406094019.670a2956@fixe.home> (raw)
In-Reply-To: <CAL_JsqLdBcAw1KPnrATHqEngRWkx6moxDODH1xV67EKAufc6_w@mail.gmail.com>
Le Tue, 5 Apr 2022 12:11:51 -0500,
Rob Herring <robh@kernel.org> a écrit :
> On Tue, Apr 5, 2022 at 10:52 AM Clément Léger <clement.leger@bootlin.com> wrote:
> >
> > Le Tue, 5 Apr 2022 09:47:20 -0500,
> > Rob Herring <robh@kernel.org> a écrit :
> >
[...]
> >
> > 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:
>
> 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).
>
> > "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.
>
> They aren't, yet...
Ok...
[...]
>
>
> > > 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 should
> > > be pretty straightforward. We already have PCI bus bindings. The only
> > > tricky part is getting address translation working from leaf device thru
> > > 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 both
> > > DT and ACPI systems as we don't always describe all the PCI hierarchy
> > > in DT.
> >
> > But then, if the driver generate the nodes, it will most probably
> > have to describe the nodes by hardcoding them right ?
>
> 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 ?
>
> 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).
>
> > 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.
>
> What you would have to load is a DT overlay describing all your
> downstream devices.
>
> 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.
>
> > 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 ?
>
> 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.
>
> The reason generating nodes may be needed on DT systems as well is
> that all PCI devices are not described in DT systems either.
>
> > 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.
>
> It's not independent. You are effectively creating the DT nodes with C
> code. Are these not DT bindings:
>
> > static const struct property_entry ddr_clk_props[] = {
> > PROPERTY_ENTRY_U32("clock-frequency", 30000000),
> > PROPERTY_ENTRY_U32("#clock-cells", 0),
> > {}
> > };
>
> 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.
>
>
> > > That could work either by the PCI subsystem creating nodes as it
> > > populates devices or your driver could make a request to populate nodes
> > > for its hierarchy. That's not a hard problem to solve. That's what
> > > OpenFirmware implementations do already.
> >
> > 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.
>
> 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.
>
>
> > > https://lore.kernel.org/lkml/20220216050056.311496-1-lizhi.hou@xilinx.com/
> >
> > 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).
>
> 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.
--
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com
next prev parent reply other threads:[~2022-04-06 11:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 14:12 [PATCH v2 0/3] add fwnode support to reset subsystem Clément Léger
2022-03-24 14:12 ` [PATCH v2 1/3] of: add function to convert fwnode_reference_args to of_phandle_args Clément Léger
2022-03-24 14:12 ` [PATCH v2 2/3] reset: add support for fwnode Clément Léger
2022-03-24 14:12 ` [PATCH v2 3/3] reset: mchp: sparx5: set fwnode field of reset controller Clément Léger
2022-04-04 17:41 ` [PATCH v2 0/3] add fwnode support to reset subsystem Rob Herring
2022-04-05 7:24 ` Clément Léger
2022-04-05 14:47 ` Rob Herring
2022-04-05 15:51 ` Clément Léger
2022-04-05 17:11 ` Rob Herring
2022-04-05 21:28 ` Rob Herring
2022-04-06 7:52 ` Clément Léger
2022-04-06 13:04 ` Rob Herring
2022-04-06 7:40 ` Clément Léger [this message]
2022-04-06 13:19 ` Rob Herring
2022-04-06 13:33 ` Alexandre Belloni
2022-04-06 13:36 ` Clément Léger
2022-04-08 15:48 ` Clément Léger
2022-04-25 10:21 ` Philipp Zabel
2022-04-25 11:18 ` Clément Léger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220406094019.670a2956@fixe.home \
--to=clement.leger@bootlin.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=allan.nielsen@microchip.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=hdegoede@redhat.com \
--cc=lars.povlsen@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.hou@xilinx.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=sonal.santan@xilinx.com \
--cc=sstabellini@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).