* Re: section mismatch with a platform driver
2008-10-13 9:28 ` Neshama Parhoti
@ 2008-10-13 9:43 ` Gilad Ben-Yossef
2008-10-13 11:11 ` Neshama Parhoti
2008-10-13 9:50 ` Adrian Bunk
2008-10-13 16:01 ` Randy Dunlap
2 siblings, 1 reply; 13+ messages in thread
From: Gilad Ben-Yossef @ 2008-10-13 9:43 UTC (permalink / raw)
To: Neshama Parhoti; +Cc: Adrian Bunk, linux-kernel
Neshama Parhoti wrote:
> Hi Adrian and thank you for the help!
>
> On Mon, Oct 13, 2008 at 10:51 AM, Adrian Bunk <bunk@kernel.org> wrote:
>
>> On Mon, Oct 13, 2008 at 10:19:05AM +0200, Neshama Parhoti wrote:
>>
>>> WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
>>> .init.text:my_probe_func (between 'my_platform_struct' and
>>> 'debug_level_variable')
>>>
>>> If I understand correctly, it shouts about my probe function being
>>> referenced from the data section:
>>>
>>> static struct platform_driver my_platform_struct = {
>>> .probe = my_probe_func,
>>> .remove = my_remove,
>>> .suspend = my_suspend,
>>> .resume = my_resume,
>>> .driver = {
>>> .name = DRIVER_NAME,
>>> },
>>> };
>>>
>>>
>> It complains about "my_probe_func", and that's not even in the code
>> you posted.
>>
>
> It happens even if I use an empty function like this:
>
> static int __init my_probe_func(struct platform_device *pdev)
> {
> return 0;
> }
>
>
> any idea what's the problem ?
>
That __init macro marks the probe function as "throw after init" - it
tells the compiler to put this function in a separate ELF section that
the kernel automatically frees when module init is done, but you are
referencing this function in a structure that is not marked as "throw
after init".
Can't be sure without seeing the whole picture, but the most probable
solution is to drop that __init from the probe function. It's seems
wrong as in theory the probe function can be called at any time in the
life of the kernel, not just in this module init, even if in practice
this will never happen, as I suspect is the case with such a platform
driver.
Gilad
--
Gilad Ben-Yossef
Chief Coffee Drinker
Codefidence Ltd.
The code is free, your time isn't.(TM)
Web: http://codefidence.com
Email: gilad@codefidence.com
Office: +972-8-9316883 ext. 201
Fax: +972-8-9316885
Mobile: +972-52-8260388
The Doctor: Don't worry, Reinette, just a nightmare.
Everyone has nightmares. Even monsters from under the
bed have nightmares, don't you, monster?
Reinette: What do monsters have nightmares about?
The Doctor: Me!
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: section mismatch with a platform driver
2008-10-13 9:43 ` Gilad Ben-Yossef
@ 2008-10-13 11:11 ` Neshama Parhoti
0 siblings, 0 replies; 13+ messages in thread
From: Neshama Parhoti @ 2008-10-13 11:11 UTC (permalink / raw)
To: Gilad Ben-Yossef; +Cc: Adrian Bunk, linux-kernel
On Mon, Oct 13, 2008 at 11:43 AM, Gilad Ben-Yossef
<gilad@codefidence.com> wrote:
> Can't be sure without seeing the whole picture, but the most probable
> solution is to drop that __init from the probe function. It's seems wrong as
> in theory the probe function can be called at any time in the life of the
> kernel, not just in this module init, even if in practice this will never
> happen, as I suspect is the case with such a platform driver.
Yes, thanks, removing that macro did make the warning go away.
That's weird because I was using other in-tree drivers as a template for this,
and they don't have this section mismatch problem...
>
> Gilad
>
>
>
> --
> Gilad Ben-Yossef Chief Coffee Drinker
>
> Codefidence Ltd.
> The code is free, your time isn't.(TM)
>
> Web: http://codefidence.com
> Email: gilad@codefidence.com
> Office: +972-8-9316883 ext. 201
> Fax: +972-8-9316885
> Mobile: +972-52-8260388
>
> The Doctor: Don't worry, Reinette, just a nightmare. Everyone
> has nightmares. Even monsters from under the bed have nightmares,
> don't you, monster?
> Reinette: What do monsters have nightmares about?
> The Doctor: Me!
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: section mismatch with a platform driver
2008-10-13 9:28 ` Neshama Parhoti
2008-10-13 9:43 ` Gilad Ben-Yossef
@ 2008-10-13 9:50 ` Adrian Bunk
2008-10-13 11:13 ` Neshama Parhoti
2008-10-13 16:01 ` Randy Dunlap
2 siblings, 1 reply; 13+ messages in thread
From: Adrian Bunk @ 2008-10-13 9:50 UTC (permalink / raw)
To: Neshama Parhoti; +Cc: linux-kernel
On Mon, Oct 13, 2008 at 11:28:23AM +0200, Neshama Parhoti wrote:
> Hi Adrian and thank you for the help!
>
> On Mon, Oct 13, 2008 at 10:51 AM, Adrian Bunk <bunk@kernel.org> wrote:
> > On Mon, Oct 13, 2008 at 10:19:05AM +0200, Neshama Parhoti wrote:
> >> WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
> >> .init.text:my_probe_func (between 'my_platform_struct' and
> >> 'debug_level_variable')
> >>
> >> If I understand correctly, it shouts about my probe function being
> >> referenced from the data section:
> >>
> >> static struct platform_driver my_platform_struct = {
> >> .probe = my_probe_func,
^^^^^
Ah, you had your example wrong and silently edited your quoted email.
> >> .remove = my_remove,
> >> .suspend = my_suspend,
> >> .resume = my_resume,
> >> .driver = {
> >> .name = DRIVER_NAME,
> >> },
> >> };
> >>
> > It complains about "my_probe_func", and that's not even in the code
> > you posted.
>
> It happens even if I use an empty function like this:
>
> static int __init my_probe_func(struct platform_device *pdev)
> {
> return 0;
> }
>
> any idea what's the problem ?
The function has a wrong name.
> thanks again!
> pnesh
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: section mismatch with a platform driver
2008-10-13 9:28 ` Neshama Parhoti
2008-10-13 9:43 ` Gilad Ben-Yossef
2008-10-13 9:50 ` Adrian Bunk
@ 2008-10-13 16:01 ` Randy Dunlap
2008-10-13 16:29 ` Neshama Parhoti
2 siblings, 1 reply; 13+ messages in thread
From: Randy Dunlap @ 2008-10-13 16:01 UTC (permalink / raw)
To: Neshama Parhoti; +Cc: Adrian Bunk, linux-kernel
On Mon, 13 Oct 2008 11:28:23 +0200 Neshama Parhoti wrote:
> Hi Adrian and thank you for the help!
>
> On Mon, Oct 13, 2008 at 10:51 AM, Adrian Bunk <bunk@kernel.org> wrote:
> > On Mon, Oct 13, 2008 at 10:19:05AM +0200, Neshama Parhoti wrote:
> >> WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
> >> .init.text:my_probe_func (between 'my_platform_struct' and
> >> 'debug_level_variable')
> >>
> >> If I understand correctly, it shouts about my probe function being
> >> referenced from the data section:
> >>
> >> static struct platform_driver my_platform_struct = {
> >> .probe = my_probe_func,
> >> .remove = my_remove,
> >> .suspend = my_suspend,
> >> .resume = my_resume,
> >> .driver = {
> >> .name = DRIVER_NAME,
> >> },
> >> };
> >>
> > It complains about "my_probe_func", and that's not even in the code
> > you posted.
>
> It happens even if I use an empty function like this:
>
> static int __init my_probe_func(struct platform_device *pdev)
> {
> return 0;
> }
>
>
> any idea what's the problem ?
A probe function can be called at any time -- i.e., after system init
has completed, so discarding the __init function my_probe_func() is BAD,
dangerous, BUGgy.
---
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: section mismatch with a platform driver
2008-10-13 16:01 ` Randy Dunlap
@ 2008-10-13 16:29 ` Neshama Parhoti
2008-10-13 16:31 ` Randy Dunlap
0 siblings, 1 reply; 13+ messages in thread
From: Neshama Parhoti @ 2008-10-13 16:29 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Adrian Bunk, linux-kernel
On Mon, Oct 13, 2008 at 6:01 PM, Randy Dunlap <randy.dunlap@oracle.com> wrote:
> A probe function can be called at any time -- i.e., after system init
> has completed, so discarding the __init function my_probe_func() is BAD,
> dangerous, BUGgy.
Thanks for the explanation!
Does that mean that all drivers with __init in their probe functions are bogus ?
>
> ---
> ~Randy
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: section mismatch with a platform driver
2008-10-13 16:29 ` Neshama Parhoti
@ 2008-10-13 16:31 ` Randy Dunlap
2008-10-13 18:58 ` Neshama Parhoti
0 siblings, 1 reply; 13+ messages in thread
From: Randy Dunlap @ 2008-10-13 16:31 UTC (permalink / raw)
To: Neshama Parhoti; +Cc: Adrian Bunk, linux-kernel
Neshama Parhoti wrote:
> On Mon, Oct 13, 2008 at 6:01 PM, Randy Dunlap <randy.dunlap@oracle.com> wrote:
>> A probe function can be called at any time -- i.e., after system init
>> has completed, so discarding the __init function my_probe_func() is BAD,
>> dangerous, BUGgy.
>
> Thanks for the explanation!
>
> Does that mean that all drivers with __init in their probe functions are bogus ?
It depends. If your platform doesn't support hotplug, then it's possible
that the probe function is only called during system init, so it would be OK.
And in general, if a kernel is built without hotplug support, then the
__init probe functions are probably safe. But I'm not sure about it.
--
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: section mismatch with a platform driver
2008-10-13 16:31 ` Randy Dunlap
@ 2008-10-13 18:58 ` Neshama Parhoti
2008-10-13 19:00 ` Randy Dunlap
2008-10-13 20:22 ` sniper
0 siblings, 2 replies; 13+ messages in thread
From: Neshama Parhoti @ 2008-10-13 18:58 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Adrian Bunk, linux-kernel
On Mon, Oct 13, 2008 at 6:31 PM, Randy Dunlap <randy.dunlap@oracle.com> wrote:
>> Does that mean that all drivers with __init in their probe functions are bogus ?
>
> It depends. If your platform doesn't support hotplug, then it's possible
> that the probe function is only called during system init, so it would be OK.
Hmm any idea then why did it give me a section mismatch warning ?
Thanks!!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: section mismatch with a platform driver
2008-10-13 18:58 ` Neshama Parhoti
@ 2008-10-13 19:00 ` Randy Dunlap
2008-10-13 20:22 ` sniper
1 sibling, 0 replies; 13+ messages in thread
From: Randy Dunlap @ 2008-10-13 19:00 UTC (permalink / raw)
To: Neshama Parhoti; +Cc: Adrian Bunk, linux-kernel
Neshama Parhoti wrote:
> On Mon, Oct 13, 2008 at 6:31 PM, Randy Dunlap <randy.dunlap@oracle.com> wrote:
>>> Does that mean that all drivers with __init in their probe functions are bogus ?
>> It depends. If your platform doesn't support hotplug, then it's possible
>> that the probe function is only called during system init, so it would be OK.
>
> Hmm any idea then why did it give me a section mismatch warning ?
Just because the probe function is marked __init.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: section mismatch with a platform driver
2008-10-13 18:58 ` Neshama Parhoti
2008-10-13 19:00 ` Randy Dunlap
@ 2008-10-13 20:22 ` sniper
1 sibling, 0 replies; 13+ messages in thread
From: sniper @ 2008-10-13 20:22 UTC (permalink / raw)
To: Neshama Parhoti; +Cc: Randy Dunlap, Adrian Bunk, linux-kernel
There are some examples in kernel as following:
static struct platform_driver my_platform_driver = {
.probe = my_probe_func,
.remove = __devexit_p(my_remove),
.suspend = my_suspend,
.resume = my_resume,
.driver = {
.name = DRIVER_NAME,
},
};
static int __devinit my_probe_func(struct platform_device *pdev)
{
return 0;
}
note that my_platform_*driver*, it let this variable can refer to
init/exit sections.
You can find the explanation in /scripts/mod/modpost.c:
/* symbols in .data that may refer to init/exit sections */
static const char *symbol_white_list[] =
{
"*driver",
"*_template", /* scsi uses *_template a lot */
"*_timer", /* arm uses ops structures named _timer a lot */
"*_sht", /* scsi also used *_sht to some extent */
"*_ops",
"*_probe",
"*_probe_one",
"*_console",
NULL
};
On Tue, Oct 14, 2008 at 2:58 AM, Neshama Parhoti <pneshama@gmail.com> wrote:
> On Mon, Oct 13, 2008 at 6:31 PM, Randy Dunlap <randy.dunlap@oracle.com> wrote:
>>> Does that mean that all drivers with __init in their probe functions are bogus ?
>>
>> It depends. If your platform doesn't support hotplug, then it's possible
>> that the probe function is only called during system init, so it would be OK.
>
> Hmm any idea then why did it give me a section mismatch warning ?
>
> Thanks!!
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 13+ messages in thread