Re: [PATCH 2/3] PCI: of: create DT nodes for PCI devices if they do not exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le Tue, 3 May 2022 09:12:06 -0500,
Rob Herring <robh@xxxxxxxxxx> a écrit :

> On Wed, Apr 27, 2022 at 11:45:01AM +0200, Clément Léger wrote:
> > In order to apply overlays to PCI device nodes, the nodes must first
> > exist. This commit add support to populate a skeleton tree for PCI bus
> > and devices. These nodes can then be used by drivers to apply overlays.
> >   
> 
> While I implemented this creating the nodes as the PCI devices are 
> created, I think probably we're going to want to create the device node 
> and any needed parent nodes on demand. Otherwise, just turning on 
> CONFIG_OF could break platforms.

Ok, so this creation would potentially be done on request from some PCI
driver that want to apply it's overlay on the tree. Should I actually
add some function such as of_pci_apply_overlay() which would create the
PCI node tree if not present and apply the overlay to the of_node that
is associated to the PCIe device ?

> 
> One potential issue is that fwnode assumes there is either a DT node or 
> ACPI node. With this, we have the potential for both. I'm not sure how 
> much that's going to be an issue.

Not sure either but that's better not to play with that.

> 
> > Co-developed-by: Rob Herring <robh@xxxxxxxxxx>
> > Signed-off-by: Rob Herring <robh@xxxxxxxxxx>
> > Signed-off-by: Clément Léger <clement.leger@xxxxxxxxxxx>
> > ---
> >  drivers/pci/of.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 184 insertions(+)
> > 
> > diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> > index cb2e8351c2cc..f2325708726e 100644
> > --- a/drivers/pci/of.c
> > +++ b/drivers/pci/of.c
> > @@ -16,12 +16,194 @@
> >  #include "pci.h"
> >  
> >  #ifdef CONFIG_PCI
> > +static int of_pci_add_property(struct of_changeset *ocs, struct device_node *np,
> > +			       const char *name, const void *value, int length)  
> 
> Nothing really PCI specific about this function.
> 
> The kernel support for creating nodes and properties is pretty poor. We 
> should improve it with functions like this (in drivers/of/). Maybe the 
> changeset part should be separate though. We have some cases of creating 
> properties or nodes already, and whatever new APIs we make those 
> cases should be able to use them. And if they are converted, then it can 
> be merged sooner rather than when all the PCI parts are ready.

Ok, so this will be done as a first separate series to add property
creation then.

> > +
> > +static int of_pci_add_cells_props(struct device_node *node,
> > +				  struct of_changeset *cs, int n_addr_cells,
> > +				  int n_size_cells)
> > +{
> > +	__be32 val;
> > +	int ret;
> > +
> > +	ret = of_pci_add_property(cs, node, "ranges", NULL, 0);  
> 
> The host bridge node is going to need to fill in 'ranges'. Empty ranges 
> is not valid when there's a change in number of cells.

Ok, wasn't aware of that. If I understand, I'll need to obtain the
range of PCI addresses that are behind the bridge to fill in this
ranges property right ?

> 
> The root node also will need "#address-cells" and "#size-cells".
>  

Ok.


-- 
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux