linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: kirin: Fix section mismatch warning
@ 2018-09-19  5:38 Nathan Chancellor
  2018-09-19 10:29 ` Lorenzo Pieralisi
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2018-09-19  5:38 UTC (permalink / raw)
  To: Xiaowei Song, Binghui Wang, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, Nick Desaulniers, Nathan Chancellor

WARNING: vmlinux.o(.text+0x4758cc): Section mismatch in reference from
the function kirin_pcie_probe() to the function
.init.text:kirin_add_pcie_port()
The function kirin_pcie_probe() references
the function __init kirin_add_pcie_port().
This is often because kirin_pcie_probe lacks a __init
annotation or the annotation of kirin_add_pcie_port is wrong.

Remove '__init' from kirin_add_pcie_port so there is no mismatch.

Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/pci/controller/dwc/pcie-kirin.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
index 5352e0c3be82..9b599296205d 100644
--- a/drivers/pci/controller/dwc/pcie-kirin.c
+++ b/drivers/pci/controller/dwc/pcie-kirin.c
@@ -467,8 +467,8 @@ static int kirin_pcie_add_msi(struct dw_pcie *pci,
 	return 0;
 }
 
-static int __init kirin_add_pcie_port(struct dw_pcie *pci,
-				      struct platform_device *pdev)
+static int kirin_add_pcie_port(struct dw_pcie *pci,
+			       struct platform_device *pdev)
 {
 	int ret;
 
-- 
2.19.0


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

* Re: [PATCH] PCI: kirin: Fix section mismatch warning
  2018-09-19  5:38 [PATCH] PCI: kirin: Fix section mismatch warning Nathan Chancellor
@ 2018-09-19 10:29 ` Lorenzo Pieralisi
  2018-09-19 17:35   ` Nick Desaulniers
  0 siblings, 1 reply; 6+ messages in thread
From: Lorenzo Pieralisi @ 2018-09-19 10:29 UTC (permalink / raw)
  To: Nathan Chancellor, Xiaowei Song, Binghui Wang
  Cc: Bjorn Helgaas, linux-pci, linux-kernel, Nick Desaulniers

Xiaowei, Binghui,

On Tue, Sep 18, 2018 at 10:38:29PM -0700, Nathan Chancellor wrote:
> WARNING: vmlinux.o(.text+0x4758cc): Section mismatch in reference from
> the function kirin_pcie_probe() to the function
> .init.text:kirin_add_pcie_port()
> The function kirin_pcie_probe() references
> the function __init kirin_add_pcie_port().
> This is often because kirin_pcie_probe lacks a __init
> annotation or the annotation of kirin_add_pcie_port is wrong.
> 
> Remove '__init' from kirin_add_pcie_port so there is no mismatch.

I think that instead of removing __init section tag we should add
it to kirin_pcie_probe().

Please let me know and ACK accordingly.

Lorenzo

> Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/pci/controller/dwc/pcie-kirin.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index 5352e0c3be82..9b599296205d 100644
> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -467,8 +467,8 @@ static int kirin_pcie_add_msi(struct dw_pcie *pci,
>  	return 0;
>  }
>  
> -static int __init kirin_add_pcie_port(struct dw_pcie *pci,
> -				      struct platform_device *pdev)
> +static int kirin_add_pcie_port(struct dw_pcie *pci,
> +			       struct platform_device *pdev)
>  {
>  	int ret;
>  
> -- 
> 2.19.0
> 

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

* Re: [PATCH] PCI: kirin: Fix section mismatch warning
  2018-09-19 10:29 ` Lorenzo Pieralisi
@ 2018-09-19 17:35   ` Nick Desaulniers
  2018-09-19 17:58     ` Nathan Chancellor
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2018-09-19 17:35 UTC (permalink / raw)
  To: lorenzo.pieralisi
  Cc: Nathan Chancellor, songxiaowei, wangbinghui, bhelgaas, linux-pci,
	LKML, Greg KH

On Wed, Sep 19, 2018 at 3:29 AM Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
>
> Xiaowei, Binghui,
>
> On Tue, Sep 18, 2018 at 10:38:29PM -0700, Nathan Chancellor wrote:
> > WARNING: vmlinux.o(.text+0x4758cc): Section mismatch in reference from
> > the function kirin_pcie_probe() to the function
> > .init.text:kirin_add_pcie_port()
> > The function kirin_pcie_probe() references
> > the function __init kirin_add_pcie_port().
> > This is often because kirin_pcie_probe lacks a __init
> > annotation or the annotation of kirin_add_pcie_port is wrong.
> >
> > Remove '__init' from kirin_add_pcie_port so there is no mismatch.
>
> I think that instead of removing __init section tag we should add
> it to kirin_pcie_probe().

A bunch of these functions have a single call site, with a mix of __init:

kirin_pcie_probe() ->
  kirin_add_pcie_port() ->  // __init
    kirin_pcie_add_msi()

But it looks like probe functions should be marked init:
$ cd drivers; grep -r __init | grep probe

seems to turn up quite a lot of *probe() functions that are marked __init.
https://www.tldp.org/LDP/lkmpg/2.4/html/x281.htm has more info, and
from reading that, it seems that it's a no-op for a module that's
marked loadable.

So I agree; __init should be added to kirin_pcie_probe(), but also
kirin_pcie_add_msi().  That way if the module is statically compiled
into the kernel image, these functions with a single call site get
cleaned up after init.

Nathan, would you mind sending a v2?

>
> Please let me know and ACK accordingly.
>
> Lorenzo
>
> > Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >  drivers/pci/controller/dwc/pcie-kirin.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> > index 5352e0c3be82..9b599296205d 100644
> > --- a/drivers/pci/controller/dwc/pcie-kirin.c
> > +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> > @@ -467,8 +467,8 @@ static int kirin_pcie_add_msi(struct dw_pcie *pci,
> >       return 0;
> >  }
> >
> > -static int __init kirin_add_pcie_port(struct dw_pcie *pci,
> > -                                   struct platform_device *pdev)
> > +static int kirin_add_pcie_port(struct dw_pcie *pci,
> > +                            struct platform_device *pdev)
> >  {
> >       int ret;
> >
> > --
> > 2.19.0
> >



-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] PCI: kirin: Fix section mismatch warning
  2018-09-19 17:35   ` Nick Desaulniers
@ 2018-09-19 17:58     ` Nathan Chancellor
  2018-09-19 18:35       ` Nick Desaulniers
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2018-09-19 17:58 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: lorenzo.pieralisi, songxiaowei, wangbinghui, bhelgaas, linux-pci,
	LKML, Greg KH

On Wed, Sep 19, 2018 at 10:35:55AM -0700, Nick Desaulniers wrote:
> On Wed, Sep 19, 2018 at 3:29 AM Lorenzo Pieralisi
> <lorenzo.pieralisi@arm.com> wrote:
> >
> > Xiaowei, Binghui,
> >
> > On Tue, Sep 18, 2018 at 10:38:29PM -0700, Nathan Chancellor wrote:
> > > WARNING: vmlinux.o(.text+0x4758cc): Section mismatch in reference from
> > > the function kirin_pcie_probe() to the function
> > > .init.text:kirin_add_pcie_port()
> > > The function kirin_pcie_probe() references
> > > the function __init kirin_add_pcie_port().
> > > This is often because kirin_pcie_probe lacks a __init
> > > annotation or the annotation of kirin_add_pcie_port is wrong.
> > >
> > > Remove '__init' from kirin_add_pcie_port so there is no mismatch.
> >
> > I think that instead of removing __init section tag we should add
> > it to kirin_pcie_probe().
> 
> A bunch of these functions have a single call site, with a mix of __init:
> 
> kirin_pcie_probe() ->
>   kirin_add_pcie_port() ->  // __init
>     kirin_pcie_add_msi()
> 
> But it looks like probe functions should be marked init:
> $ cd drivers; grep -r __init | grep probe
> 
> seems to turn up quite a lot of *probe() functions that are marked __init.
> https://www.tldp.org/LDP/lkmpg/2.4/html/x281.htm has more info, and
> from reading that, it seems that it's a no-op for a module that's
> marked loadable.
> 
> So I agree; __init should be added to kirin_pcie_probe(), but also
> kirin_pcie_add_msi().  That way if the module is statically compiled
> into the kernel image, these functions with a single call site get
> cleaned up after init.
> 
> Nathan, would you mind sending a v2?
> 

Hi Nick and Lorenzo,

I had tested adding __init to both kirin_pcie_probe and
kirin_pcie_add_msi but ran into this warning:

WARNING: vmlinux.o(.data+0x68b78): Section mismatch in reference from
the variable kirin_pcie_driver to the function
.init.text:kirin_pcie_probe()
The variable kirin_pcie_driver references                      
the function __init kirin_pcie_probe()

Doing a quick 'grep -r __init | grep platform_driver' doesn't show any
'static struct platform_driver' constructs marked as __init, leading me
to believe this patch is the proper solution.

I'm happy to hear otherwise, thank you both for the quick responses,
Nathan

> >
> > Please let me know and ACK accordingly.
> >
> > Lorenzo
> >
> > > Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
> > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > ---
> > >  drivers/pci/controller/dwc/pcie-kirin.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> > > index 5352e0c3be82..9b599296205d 100644
> > > --- a/drivers/pci/controller/dwc/pcie-kirin.c
> > > +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> > > @@ -467,8 +467,8 @@ static int kirin_pcie_add_msi(struct dw_pcie *pci,
> > >       return 0;
> > >  }
> > >
> > > -static int __init kirin_add_pcie_port(struct dw_pcie *pci,
> > > -                                   struct platform_device *pdev)
> > > +static int kirin_add_pcie_port(struct dw_pcie *pci,
> > > +                            struct platform_device *pdev)
> > >  {
> > >       int ret;
> > >
> > > --
> > > 2.19.0
> > >
> 
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers

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

* Re: [PATCH] PCI: kirin: Fix section mismatch warning
  2018-09-19 17:58     ` Nathan Chancellor
@ 2018-09-19 18:35       ` Nick Desaulniers
  2018-09-19 18:48         ` Nathan Chancellor
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2018-09-19 18:35 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: lorenzo.pieralisi, songxiaowei, wangbinghui, bhelgaas, linux-pci,
	LKML, Greg KH

On Wed, Sep 19, 2018 at 10:58 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Wed, Sep 19, 2018 at 10:35:55AM -0700, Nick Desaulniers wrote:
> > On Wed, Sep 19, 2018 at 3:29 AM Lorenzo Pieralisi
> > <lorenzo.pieralisi@arm.com> wrote:
> > >
> > > Xiaowei, Binghui,
> > >
> > > On Tue, Sep 18, 2018 at 10:38:29PM -0700, Nathan Chancellor wrote:
> > > > WARNING: vmlinux.o(.text+0x4758cc): Section mismatch in reference from
> > > > the function kirin_pcie_probe() to the function
> > > > .init.text:kirin_add_pcie_port()
> > > > The function kirin_pcie_probe() references
> > > > the function __init kirin_add_pcie_port().
> > > > This is often because kirin_pcie_probe lacks a __init
> > > > annotation or the annotation of kirin_add_pcie_port is wrong.
> > > >
> > > > Remove '__init' from kirin_add_pcie_port so there is no mismatch.
> > >
> > > I think that instead of removing __init section tag we should add
> > > it to kirin_pcie_probe().
> >
> > A bunch of these functions have a single call site, with a mix of __init:
> >
> > kirin_pcie_probe() ->
> >   kirin_add_pcie_port() ->  // __init
> >     kirin_pcie_add_msi()
> >
> > But it looks like probe functions should be marked init:
> > $ cd drivers; grep -r __init | grep probe
> >
> > seems to turn up quite a lot of *probe() functions that are marked __init.
> > https://www.tldp.org/LDP/lkmpg/2.4/html/x281.htm has more info, and
> > from reading that, it seems that it's a no-op for a module that's
> > marked loadable.
> >
> > So I agree; __init should be added to kirin_pcie_probe(), but also
> > kirin_pcie_add_msi().  That way if the module is statically compiled
> > into the kernel image, these functions with a single call site get
> > cleaned up after init.
> >
> > Nathan, would you mind sending a v2?
> >
>
> Hi Nick and Lorenzo,
>
> I had tested adding __init to both kirin_pcie_probe and
> kirin_pcie_add_msi but ran into this warning:
>
> WARNING: vmlinux.o(.data+0x68b78): Section mismatch in reference from
> the variable kirin_pcie_driver to the function

I think we want builtin_platform_driver_probe() here.

Try removing the probe reference from the declaration of
kirin_pcie_driver, and then calling

builtin_platform_driver_probe(kirin_pcie_driver, kirin_pcie_probe);

Does that fix the section mismatches, while keeping as much in __init
as possible?

> .init.text:kirin_pcie_probe()
> The variable kirin_pcie_driver references
> the function __init kirin_pcie_probe()
>
> Doing a quick 'grep -r __init | grep platform_driver' doesn't show any
> 'static struct platform_driver' constructs marked as __init, leading me
> to believe this patch is the proper solution.
>
> I'm happy to hear otherwise, thank you both for the quick responses,
> Nathan
>
> > >
> > > Please let me know and ACK accordingly.
> > >
> > > Lorenzo
> > >
> > > > Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
> > > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > > ---
> > > >  drivers/pci/controller/dwc/pcie-kirin.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> > > > index 5352e0c3be82..9b599296205d 100644
> > > > --- a/drivers/pci/controller/dwc/pcie-kirin.c
> > > > +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> > > > @@ -467,8 +467,8 @@ static int kirin_pcie_add_msi(struct dw_pcie *pci,
> > > >       return 0;
> > > >  }
> > > >
> > > > -static int __init kirin_add_pcie_port(struct dw_pcie *pci,
> > > > -                                   struct platform_device *pdev)
> > > > +static int kirin_add_pcie_port(struct dw_pcie *pci,
> > > > +                            struct platform_device *pdev)
> > > >  {
> > > >       int ret;
> > > >
> > > > --
> > > > 2.19.0
> > > >
> >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] PCI: kirin: Fix section mismatch warning
  2018-09-19 18:35       ` Nick Desaulniers
@ 2018-09-19 18:48         ` Nathan Chancellor
  0 siblings, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2018-09-19 18:48 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: lorenzo.pieralisi, songxiaowei, wangbinghui, bhelgaas, linux-pci,
	LKML, Greg KH

On Wed, Sep 19, 2018 at 11:35:45AM -0700, Nick Desaulniers wrote:
> On Wed, Sep 19, 2018 at 10:58 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > On Wed, Sep 19, 2018 at 10:35:55AM -0700, Nick Desaulniers wrote:
> > > On Wed, Sep 19, 2018 at 3:29 AM Lorenzo Pieralisi
> > > <lorenzo.pieralisi@arm.com> wrote:
> > > >
> > > > Xiaowei, Binghui,
> > > >
> > > > On Tue, Sep 18, 2018 at 10:38:29PM -0700, Nathan Chancellor wrote:
> > > > > WARNING: vmlinux.o(.text+0x4758cc): Section mismatch in reference from
> > > > > the function kirin_pcie_probe() to the function
> > > > > .init.text:kirin_add_pcie_port()
> > > > > The function kirin_pcie_probe() references
> > > > > the function __init kirin_add_pcie_port().
> > > > > This is often because kirin_pcie_probe lacks a __init
> > > > > annotation or the annotation of kirin_add_pcie_port is wrong.
> > > > >
> > > > > Remove '__init' from kirin_add_pcie_port so there is no mismatch.
> > > >
> > > > I think that instead of removing __init section tag we should add
> > > > it to kirin_pcie_probe().
> > >
> > > A bunch of these functions have a single call site, with a mix of __init:
> > >
> > > kirin_pcie_probe() ->
> > >   kirin_add_pcie_port() ->  // __init
> > >     kirin_pcie_add_msi()
> > >
> > > But it looks like probe functions should be marked init:
> > > $ cd drivers; grep -r __init | grep probe
> > >
> > > seems to turn up quite a lot of *probe() functions that are marked __init.
> > > https://www.tldp.org/LDP/lkmpg/2.4/html/x281.htm has more info, and
> > > from reading that, it seems that it's a no-op for a module that's
> > > marked loadable.
> > >
> > > So I agree; __init should be added to kirin_pcie_probe(), but also
> > > kirin_pcie_add_msi().  That way if the module is statically compiled
> > > into the kernel image, these functions with a single call site get
> > > cleaned up after init.
> > >
> > > Nathan, would you mind sending a v2?
> > >
> >
> > Hi Nick and Lorenzo,
> >
> > I had tested adding __init to both kirin_pcie_probe and
> > kirin_pcie_add_msi but ran into this warning:
> >
> > WARNING: vmlinux.o(.data+0x68b78): Section mismatch in reference from
> > the variable kirin_pcie_driver to the function
> 
> I think we want builtin_platform_driver_probe() here.
> 
> Try removing the probe reference from the declaration of
> kirin_pcie_driver, and then calling
> 
> builtin_platform_driver_probe(kirin_pcie_driver, kirin_pcie_probe);
> 
> Does that fix the section mismatches, while keeping as much in __init
> as possible?
> 

Hi Nick,

Thank you for that suggestion, it worked. I will send a v2 for review
shortly.

Nathan

> > .init.text:kirin_pcie_probe()
> > The variable kirin_pcie_driver references
> > the function __init kirin_pcie_probe()
> >
> > Doing a quick 'grep -r __init | grep platform_driver' doesn't show any
> > 'static struct platform_driver' constructs marked as __init, leading me
> > to believe this patch is the proper solution.
> >
> > I'm happy to hear otherwise, thank you both for the quick responses,
> > Nathan
> >
> > > >
> > > > Please let me know and ACK accordingly.
> > > >
> > > > Lorenzo
> > > >
> > > > > Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
> > > > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > > > ---
> > > > >  drivers/pci/controller/dwc/pcie-kirin.c | 4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> > > > > index 5352e0c3be82..9b599296205d 100644
> > > > > --- a/drivers/pci/controller/dwc/pcie-kirin.c
> > > > > +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> > > > > @@ -467,8 +467,8 @@ static int kirin_pcie_add_msi(struct dw_pcie *pci,
> > > > >       return 0;
> > > > >  }
> > > > >
> > > > > -static int __init kirin_add_pcie_port(struct dw_pcie *pci,
> > > > > -                                   struct platform_device *pdev)
> > > > > +static int kirin_add_pcie_port(struct dw_pcie *pci,
> > > > > +                            struct platform_device *pdev)
> > > > >  {
> > > > >       int ret;
> > > > >
> > > > > --
> > > > > 2.19.0
> > > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > ~Nick Desaulniers
> 
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers

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

end of thread, other threads:[~2018-09-19 18:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-19  5:38 [PATCH] PCI: kirin: Fix section mismatch warning Nathan Chancellor
2018-09-19 10:29 ` Lorenzo Pieralisi
2018-09-19 17:35   ` Nick Desaulniers
2018-09-19 17:58     ` Nathan Chancellor
2018-09-19 18:35       ` Nick Desaulniers
2018-09-19 18:48         ` Nathan Chancellor

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