linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
       [not found] <cover.1391077731.git.mohit.kumar@st.com>
@ 2014-01-30 10:48 ` Mohit Kumar
  2014-01-30 11:43   ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 9+ messages in thread
From: Mohit Kumar @ 2014-01-30 10:48 UTC (permalink / raw)
  To: arnd
  Cc: Pratyush Anand, Mohit Kumar, Kishon Vijay Abraham I, spear-devel,
	linux-kernel

From: Pratyush Anand <pratyush.anand@st.com>

PCIe RC drivers are initialized with subsys_initcall. Few PCIe drivers
like SPEAr13xx needs phy drivers to be initialized.

Therefore initialize phy core driver with subsys_initcall to avoid
calling of phy_get before phy_class is created.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Cc: Mohit Kumar <mohit.kumar@st.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: spear-devel@list.st.com
Cc: linux-kernel@vger.kernel.org
---
 drivers/phy/phy-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 03cf8fb..fa73101 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -685,7 +685,7 @@ static int __init phy_core_init(void)
 
 	return 0;
 }
-module_init(phy_core_init);
+subsys_initcall(phy_core_init);
 
 static void __exit phy_core_exit(void)
 {
-- 
1.7.0.1


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

* Re: [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
  2014-01-30 10:48 ` [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall Mohit Kumar
@ 2014-01-30 11:43   ` Kishon Vijay Abraham I
  2014-01-30 11:52     ` Pratyush Anand
  0 siblings, 1 reply; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2014-01-30 11:43 UTC (permalink / raw)
  To: Mohit Kumar, arnd; +Cc: Pratyush Anand, spear-devel, linux-kernel

Hi,

On Thursday 30 January 2014 04:18 PM, Mohit Kumar wrote:
> From: Pratyush Anand <pratyush.anand@st.com>
> 
> PCIe RC drivers are initialized with subsys_initcall. Few PCIe drivers
> like SPEAr13xx needs phy drivers to be initialized.

Instead change PCIe RC drivers to module init. Phy drivers should be loaded
very early otherwise. (Hint: drivers/Makefile).

Thanks
Kishon
> 
> Therefore initialize phy core driver with subsys_initcall to avoid
> calling of phy_get before phy_class is created.
> 
> Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
> Cc: Mohit Kumar <mohit.kumar@st.com>
> Cc: Kishon Vijay Abraham I <kishon@ti.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: spear-devel@list.st.com
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/phy/phy-core.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 03cf8fb..fa73101 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -685,7 +685,7 @@ static int __init phy_core_init(void)
>  
>  	return 0;
>  }
> -module_init(phy_core_init);
> +subsys_initcall(phy_core_init);
>  
>  static void __exit phy_core_exit(void)
>  {
> 


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

* Re: [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
  2014-01-30 11:43   ` Kishon Vijay Abraham I
@ 2014-01-30 11:52     ` Pratyush Anand
  2014-01-30 12:10       ` Kishon Vijay Abraham I
                         ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Pratyush Anand @ 2014-01-30 11:52 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Mohit KUMAR DCG, arnd, spear-devel, linux-kernel, Bjorn Helgaas

On Thu, Jan 30, 2014 at 07:43:37PM +0800, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Thursday 30 January 2014 04:18 PM, Mohit Kumar wrote:
> > From: Pratyush Anand <pratyush.anand@st.com>
> > 
> > PCIe RC drivers are initialized with subsys_initcall. Few PCIe drivers
> > like SPEAr13xx needs phy drivers to be initialized.
> 
> Instead change PCIe RC drivers to module init. Phy drivers should be loaded
> very early otherwise. (Hint: drivers/Makefile).

I think PCIe RC driver can not be made module init. Bjorn can comment
better.

All PCIe card drivers are initialized with module init. RC driver must
have been initialized before any card driver initialization.
Currently, card drivers does not have deferred probe concept, so I am
not sure if keeping RC driver as module init will work always.

By the way, is there any side effect of loading phy driver very early?

Regards
Pratyush
> 
> Thanks
> Kishon
> > 
> > Therefore initialize phy core driver with subsys_initcall to avoid
> > calling of phy_get before phy_class is created.
> > 
> > Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
> > Cc: Mohit Kumar <mohit.kumar@st.com>
> > Cc: Kishon Vijay Abraham I <kishon@ti.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: spear-devel@list.st.com
> > Cc: linux-kernel@vger.kernel.org
> > ---
> >  drivers/phy/phy-core.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> > index 03cf8fb..fa73101 100644
> > --- a/drivers/phy/phy-core.c
> > +++ b/drivers/phy/phy-core.c
> > @@ -685,7 +685,7 @@ static int __init phy_core_init(void)
> >  
> >  	return 0;
> >  }
> > -module_init(phy_core_init);
> > +subsys_initcall(phy_core_init);
> >  
> >  static void __exit phy_core_exit(void)
> >  {
> > 
> 

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

* Re: [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
  2014-01-30 11:52     ` Pratyush Anand
@ 2014-01-30 12:10       ` Kishon Vijay Abraham I
  2014-01-30 12:15       ` Pratyush Anand
  2014-01-30 12:44       ` Arnd Bergmann
  2 siblings, 0 replies; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2014-01-30 12:10 UTC (permalink / raw)
  To: Pratyush Anand
  Cc: Mohit KUMAR DCG, arnd, spear-devel, linux-kernel, Bjorn Helgaas

Hi,

On Thursday 30 January 2014 05:22 PM, Pratyush Anand wrote:
> On Thu, Jan 30, 2014 at 07:43:37PM +0800, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Thursday 30 January 2014 04:18 PM, Mohit Kumar wrote:
>>> From: Pratyush Anand <pratyush.anand@st.com>
>>>
>>> PCIe RC drivers are initialized with subsys_initcall. Few PCIe drivers
>>> like SPEAr13xx needs phy drivers to be initialized.
>>
>> Instead change PCIe RC drivers to module init. Phy drivers should be loaded
>> very early otherwise. (Hint: drivers/Makefile).
> 
> I think PCIe RC driver can not be made module init. Bjorn can comment
> better.

Why not? I have used it for DRA7xx without any issues (I'll send that one
upstream once the PIPE3 phy part gets clear).
> 
> All PCIe card drivers are initialized with module init. RC driver must
> have been initialized before any card driver initialization.
> Currently, card drivers does not have deferred probe concept, so I am
> not sure if keeping RC driver as module init will work always.

the card drivers will anyway be probed only after RC driver comes up no?
> 
> By the way, is there any side effect of loading phy driver very early?

I assume you meant 'is there any side effect of using subsys_initcall?', since
phy driver is loaded early anyway.
The answer is no just that module_init is common one and more people prefer to
use module_init. (btw initial versions of phy-core had susbsys_initcall before
it got changed to use module_init)

Thanks
Kishon

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

* Re: [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
  2014-01-30 11:52     ` Pratyush Anand
  2014-01-30 12:10       ` Kishon Vijay Abraham I
@ 2014-01-30 12:15       ` Pratyush Anand
  2014-01-30 12:25         ` Kishon Vijay Abraham I
  2014-01-30 12:44       ` Arnd Bergmann
  2 siblings, 1 reply; 9+ messages in thread
From: Pratyush Anand @ 2014-01-30 12:15 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Mohit KUMAR DCG, arnd, spear-devel, linux-kernel, Bjorn Helgaas

On Thu, Jan 30, 2014 at 07:52:12PM +0800, Pratyush ANAND wrote:
> On Thu, Jan 30, 2014 at 07:43:37PM +0800, Kishon Vijay Abraham I wrote:
> > Hi,
> > 
> > On Thursday 30 January 2014 04:18 PM, Mohit Kumar wrote:
> > > From: Pratyush Anand <pratyush.anand@st.com>
> > > 
> > > PCIe RC drivers are initialized with subsys_initcall. Few PCIe drivers
> > > like SPEAr13xx needs phy drivers to be initialized.
> > 
> > Instead change PCIe RC drivers to module init. Phy drivers should be loaded
> > very early otherwise. (Hint: drivers/Makefile).

>From hint, you mean that if makefile has pci entry (and hence RC
driver entry) before card drivers entry, then it insures that rc
driver's probe is called before card driver's probe?
I think, yes.
And if yes, then what you say is acceptable :)

Regards
Pratyush
> 
> I think PCIe RC driver can not be made module init. Bjorn can comment
> better.
> 
> All PCIe card drivers are initialized with module init. RC driver must
> have been initialized before any card driver initialization.
> Currently, card drivers does not have deferred probe concept, so I am
> not sure if keeping RC driver as module init will work always.
> 
> By the way, is there any side effect of loading phy driver very early?
> 
> Regards
> Pratyush
> > 
> > Thanks
> > Kishon
> > > 
> > > Therefore initialize phy core driver with subsys_initcall to avoid
> > > calling of phy_get before phy_class is created.
> > > 
> > > Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
> > > Cc: Mohit Kumar <mohit.kumar@st.com>
> > > Cc: Kishon Vijay Abraham I <kishon@ti.com>
> > > Cc: Arnd Bergmann <arnd@arndb.de>
> > > Cc: spear-devel@list.st.com
> > > Cc: linux-kernel@vger.kernel.org
> > > ---
> > >  drivers/phy/phy-core.c |    2 +-
> > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> > > index 03cf8fb..fa73101 100644
> > > --- a/drivers/phy/phy-core.c
> > > +++ b/drivers/phy/phy-core.c
> > > @@ -685,7 +685,7 @@ static int __init phy_core_init(void)
> > >  
> > >  	return 0;
> > >  }
> > > -module_init(phy_core_init);
> > > +subsys_initcall(phy_core_init);
> > >  
> > >  static void __exit phy_core_exit(void)
> > >  {
> > > 
> > 

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

* Re: [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
  2014-01-30 12:15       ` Pratyush Anand
@ 2014-01-30 12:25         ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2014-01-30 12:25 UTC (permalink / raw)
  To: Pratyush Anand
  Cc: Mohit KUMAR DCG, arnd, spear-devel, linux-kernel, Bjorn Helgaas

On Thursday 30 January 2014 05:45 PM, Pratyush Anand wrote:
> On Thu, Jan 30, 2014 at 07:52:12PM +0800, Pratyush ANAND wrote:
>> On Thu, Jan 30, 2014 at 07:43:37PM +0800, Kishon Vijay Abraham I wrote:
>>> Hi,
>>>
>>> On Thursday 30 January 2014 04:18 PM, Mohit Kumar wrote:
>>>> From: Pratyush Anand <pratyush.anand@st.com>
>>>>
>>>> PCIe RC drivers are initialized with subsys_initcall. Few PCIe drivers
>>>> like SPEAr13xx needs phy drivers to be initialized.
>>>
>>> Instead change PCIe RC drivers to module init. Phy drivers should be loaded
>>> very early otherwise. (Hint: drivers/Makefile).
> 
> From hint, you mean that if makefile has pci entry (and hence RC
> driver entry) before card drivers entry, then it insures that rc
> driver's probe is called before card driver's probe?

That's right but here I was referring to PHY and PCI.

Thanks
Kishon

> I think, yes.
> And if yes, then what you say is acceptable :)
> 
> Regards
> Pratyush
>>
>> I think PCIe RC driver can not be made module init. Bjorn can comment
>> better.
>>
>> All PCIe card drivers are initialized with module init. RC driver must
>> have been initialized before any card driver initialization.
>> Currently, card drivers does not have deferred probe concept, so I am
>> not sure if keeping RC driver as module init will work always.
>>
>> By the way, is there any side effect of loading phy driver very early?
>>
>> Regards
>> Pratyush
>>>
>>> Thanks
>>> Kishon
>>>>
>>>> Therefore initialize phy core driver with subsys_initcall to avoid
>>>> calling of phy_get before phy_class is created.
>>>>
>>>> Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
>>>> Cc: Mohit Kumar <mohit.kumar@st.com>
>>>> Cc: Kishon Vijay Abraham I <kishon@ti.com>
>>>> Cc: Arnd Bergmann <arnd@arndb.de>
>>>> Cc: spear-devel@list.st.com
>>>> Cc: linux-kernel@vger.kernel.org
>>>> ---
>>>>  drivers/phy/phy-core.c |    2 +-
>>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
>>>> index 03cf8fb..fa73101 100644
>>>> --- a/drivers/phy/phy-core.c
>>>> +++ b/drivers/phy/phy-core.c
>>>> @@ -685,7 +685,7 @@ static int __init phy_core_init(void)
>>>>  
>>>>  	return 0;
>>>>  }
>>>> -module_init(phy_core_init);
>>>> +subsys_initcall(phy_core_init);
>>>>  
>>>>  static void __exit phy_core_exit(void)
>>>>  {
>>>>
>>>


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

* Re: [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
  2014-01-30 11:52     ` Pratyush Anand
  2014-01-30 12:10       ` Kishon Vijay Abraham I
  2014-01-30 12:15       ` Pratyush Anand
@ 2014-01-30 12:44       ` Arnd Bergmann
  2014-01-31  3:48         ` Pratyush Anand
  2 siblings, 1 reply; 9+ messages in thread
From: Arnd Bergmann @ 2014-01-30 12:44 UTC (permalink / raw)
  To: Pratyush Anand
  Cc: Kishon Vijay Abraham I, Mohit KUMAR DCG, spear-devel,
	linux-kernel, Bjorn Helgaas

On Thursday 30 January 2014, Pratyush Anand wrote:
> On Thu, Jan 30, 2014 at 07:43:37PM +0800, Kishon Vijay Abraham I wrote:
> > Hi,
> > 
> > On Thursday 30 January 2014 04:18 PM, Mohit Kumar wrote:
> > > From: Pratyush Anand <pratyush.anand@st.com>
> > > 
> > > PCIe RC drivers are initialized with subsys_initcall. Few PCIe drivers
> > > like SPEAr13xx needs phy drivers to be initialized.
> > 
> > Instead change PCIe RC drivers to module init. Phy drivers should be loaded
> > very early otherwise. (Hint: drivers/Makefile).
> 
> I think PCIe RC driver can not be made module init. Bjorn can comment
> better.

I don't think there is any problem here: the PCI devices will only appear
after the PCIe root bus has been probed. All drivers using the regular
pci_driver framework should work fine even if they are loaded before the
device is found. There are a handful of drivers using 'pci_get_device'
rather than pci_register_driver, and those will break. As far as I can
tell, those drivers are all x86 specific, and you should not worry about
them.

Having the PHY driver get initialized after the PCI root driver should
also work, but it requires correct handling of -EPROBE_DEFER: if phy_get
returns this error, the PCI driver must silently return the same error
from its probe() function so it will get called again at a later time
(after some other devices have been probed successfully).

	Arnd

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

* Re: [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
  2014-01-30 12:44       ` Arnd Bergmann
@ 2014-01-31  3:48         ` Pratyush Anand
  2014-01-31 15:25           ` Arnd Bergmann
  0 siblings, 1 reply; 9+ messages in thread
From: Pratyush Anand @ 2014-01-31  3:48 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Kishon Vijay Abraham I, Mohit KUMAR DCG, spear-devel,
	linux-kernel, Bjorn Helgaas

On Thu, Jan 30, 2014 at 08:44:58PM +0800, Arnd Bergmann wrote:
> On Thursday 30 January 2014, Pratyush Anand wrote:
> > On Thu, Jan 30, 2014 at 07:43:37PM +0800, Kishon Vijay Abraham I wrote:
> > > Hi,
> > > 
> > > On Thursday 30 January 2014 04:18 PM, Mohit Kumar wrote:
> > > > From: Pratyush Anand <pratyush.anand@st.com>
> > > > 
> > > > PCIe RC drivers are initialized with subsys_initcall. Few PCIe drivers
> > > > like SPEAr13xx needs phy drivers to be initialized.
> > > 
> > > Instead change PCIe RC drivers to module init. Phy drivers should be loaded
> > > very early otherwise. (Hint: drivers/Makefile).
> > 
> > I think PCIe RC driver can not be made module init. Bjorn can comment
> > better.
> 
> I don't think there is any problem here: the PCI devices will only appear
> after the PCIe root bus has been probed. All drivers using the regular
> pci_driver framework should work fine even if they are loaded before the
> device is found. There are a handful of drivers using 'pci_get_device'
> rather than pci_register_driver, and those will break. As far as I can
> tell, those drivers are all x86 specific, and you should not worry about
> them.
> 
> Having the PHY driver get initialized after the PCI root driver should
> also work, but it requires correct handling of -EPROBE_DEFER: if phy_get

I had issue with phy-core driver getting initialized after pcie rc
driver. I found a kernel crash, as devm_phy_get was called before
phy_class was created. I think this too need to be fixed, we should
not see a crash.

Anyway, I will keep spear phy and rc driver both with module_init and
-EPROBE_DEFER implementation.

Regards
Pratyush
> returns this error, the PCI driver must silently return the same error
> from its probe() function so it will get called again at a later time
> (after some other devices have been probed successfully).
> 
> 	Arnd

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

* Re: [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall
  2014-01-31  3:48         ` Pratyush Anand
@ 2014-01-31 15:25           ` Arnd Bergmann
  0 siblings, 0 replies; 9+ messages in thread
From: Arnd Bergmann @ 2014-01-31 15:25 UTC (permalink / raw)
  To: Pratyush Anand
  Cc: Kishon Vijay Abraham I, Mohit KUMAR DCG, spear-devel,
	linux-kernel, Bjorn Helgaas

On Friday 31 January 2014, Pratyush Anand wrote:
> > Having the PHY driver get initialized after the PCI root driver should
> > also work, but it requires correct handling of -EPROBE_DEFER: if phy_get
> 
> I had issue with phy-core driver getting initialized after pcie rc
> driver. I found a kernel crash, as devm_phy_get was called before
> phy_class was created. I think this too need to be fixed, we should
> not see a crash.

Yes, agreed. This should be trivial to do though.

> Anyway, I will keep spear phy and rc driver both with module_init and
> -EPROBE_DEFER implementation.

Ok.

	Arnd

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

end of thread, other threads:[~2014-01-31 15:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1391077731.git.mohit.kumar@st.com>
2014-01-30 10:48 ` [PATCH V3 4/8] phy: Initialize phy core with subsys_initcall Mohit Kumar
2014-01-30 11:43   ` Kishon Vijay Abraham I
2014-01-30 11:52     ` Pratyush Anand
2014-01-30 12:10       ` Kishon Vijay Abraham I
2014-01-30 12:15       ` Pratyush Anand
2014-01-30 12:25         ` Kishon Vijay Abraham I
2014-01-30 12:44       ` Arnd Bergmann
2014-01-31  3:48         ` Pratyush Anand
2014-01-31 15:25           ` Arnd Bergmann

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