linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* About the "__refdata" tag in pci-keystone.c
@ 2021-09-27 10:33 Sergio M. Iglesias
  2021-09-27 15:31 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Sergio M. Iglesias @ 2021-09-27 10:33 UTC (permalink / raw)
  To: bhelgaas; +Cc: lorenzo.pieralisi, robh, kw, linux-pci, linux-kernel

Hello!

I have checked the "__refdata" tag that appears in the file
"drivers/pci/controller/dwc/pci-keystone.c" and it is needed. The tag has
been there since the creation of the file on commit 6e0832fa432e and
nothing has changed since that would make it redundant.

The reason it is needed is because the struct references "ks_pcie_probe",
which is a function tagged as "__init", so the compiler will most likely
complain about the "__refdata" being removed.

Should I send a patch to add a comment explaining why it is a necessary
tag as recommended in "include/linux/init.h"?
> [...] so optimally document why the __ref is needed and why it's OK).

Thanks for your time,
Sergio M. Iglesias.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: About the "__refdata" tag in pci-keystone.c
  2021-09-27 10:33 About the "__refdata" tag in pci-keystone.c Sergio M. Iglesias
@ 2021-09-27 15:31 ` Bjorn Helgaas
  2021-09-29 13:23   ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2021-09-27 15:31 UTC (permalink / raw)
  To: Sergio M. Iglesias
  Cc: bhelgaas, lorenzo.pieralisi, robh, kw, linux-pci, linux-kernel

On Mon, Sep 27, 2021 at 12:33:21PM +0200, Sergio M. Iglesias wrote:
> Hello!
> 
> I have checked the "__refdata" tag that appears in the file
> "drivers/pci/controller/dwc/pci-keystone.c" and it is needed. The tag has
> been there since the creation of the file on commit 6e0832fa432e and
> nothing has changed since that would make it redundant.
> 
> The reason it is needed is because the struct references "ks_pcie_probe",
> which is a function tagged as "__init", so the compiler will most likely
> complain about the "__refdata" being removed.
> 
> Should I send a patch to add a comment explaining why it is a necessary
> tag as recommended in "include/linux/init.h"?
> > [...] so optimally document why the __ref is needed and why it's OK).

Thanks a lot for looking into this.

I'm not yet convinced that either the __init or the __refdata is
necessary.  If there is a reason, it would not be "to silence a
compiler complaint"; it would be something like "the keystone platform
is different from all the other platforms because the other platforms
support X but keystone does not."

Also, there are a couple other .probe() functions that are marked
__init:

  $ git grep "static int .*_pci.*_probe" drivers/pci | grep __init
  drivers/pci/controller/dwc/pci-keystone.c:static int __init ks_pcie_probe(struct platform_device *pdev)
  drivers/pci/controller/dwc/pci-layerscape-ep.c:static int __init ls_pcie_ep_probe(struct platform_device *pdev)
  drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c:static int __init ls_pcie_g4_probe(struct platform_device *pdev)
  drivers/pci/controller/pci-ixp4xx.c:static int __init ixp4xx_pci_probe(struct platform_device *pdev)

and their platform_driver structs are not marked __refdata:

  $ git grep "static struct platform_driver" drivers/pci | grep __refdata
  drivers/pci/controller/dwc/pci-keystone.c:static struct platform_driver ks_pcie_driver __refdata = {

I think this should all be more consistent: either all these __init
and __refdata annotations should be removed, or they should be used by
many more drivers.

Bjorn

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: About the "__refdata" tag in pci-keystone.c
  2021-09-27 15:31 ` Bjorn Helgaas
@ 2021-09-29 13:23   ` Rob Herring
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Herring @ 2021-09-29 13:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Sergio M. Iglesias, Bjorn Helgaas, Lorenzo Pieralisi,
	Krzysztof Wilczynski, PCI, linux-kernel

On Mon, Sep 27, 2021 at 10:31 AM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Mon, Sep 27, 2021 at 12:33:21PM +0200, Sergio M. Iglesias wrote:
> > Hello!
> >
> > I have checked the "__refdata" tag that appears in the file
> > "drivers/pci/controller/dwc/pci-keystone.c" and it is needed. The tag has
> > been there since the creation of the file on commit 6e0832fa432e and
> > nothing has changed since that would make it redundant.
> >
> > The reason it is needed is because the struct references "ks_pcie_probe",
> > which is a function tagged as "__init", so the compiler will most likely
> > complain about the "__refdata" being removed.
> >
> > Should I send a patch to add a comment explaining why it is a necessary
> > tag as recommended in "include/linux/init.h"?
> > > [...] so optimally document why the __ref is needed and why it's OK).
>
> Thanks a lot for looking into this.
>
> I'm not yet convinced that either the __init or the __refdata is
> necessary.  If there is a reason, it would not be "to silence a
> compiler complaint"; it would be something like "the keystone platform
> is different from all the other platforms because the other platforms
> support X but keystone does not."
>
> Also, there are a couple other .probe() functions that are marked
> __init:
>
>   $ git grep "static int .*_pci.*_probe" drivers/pci | grep __init
>   drivers/pci/controller/dwc/pci-keystone.c:static int __init ks_pcie_probe(struct platform_device *pdev)
>   drivers/pci/controller/dwc/pci-layerscape-ep.c:static int __init ls_pcie_ep_probe(struct platform_device *pdev)
>   drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c:static int __init ls_pcie_g4_probe(struct platform_device *pdev)
>   drivers/pci/controller/pci-ixp4xx.c:static int __init ixp4xx_pci_probe(struct platform_device *pdev)
>
> and their platform_driver structs are not marked __refdata:
>
>   $ git grep "static struct platform_driver" drivers/pci | grep __refdata
>   drivers/pci/controller/dwc/pci-keystone.c:static struct platform_driver ks_pcie_driver __refdata = {
>
> I think this should all be more consistent: either all these __init
> and __refdata annotations should be removed, or they should be used by
> many more drivers.

__init should definitely be removed. There's no guarantee that probe
completes before init memory is freed even for built-in drivers.

Rob

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-29 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 10:33 About the "__refdata" tag in pci-keystone.c Sergio M. Iglesias
2021-09-27 15:31 ` Bjorn Helgaas
2021-09-29 13:23   ` Rob Herring

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).