Re: [PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration

2013-02-15 Thread Bjorn Helgaas
On Wed, Feb 13, 2013 at 5:59 AM, Rafael J. Wysocki  wrote:
> On Tuesday, February 12, 2013 05:54:08 PM Yinghai Lu wrote:
>> On Tue, Feb 12, 2013 at 4:16 PM, Rafael J. Wysocki  wrote:
>> > From: Rafael J. Wysocki 
>> >
>> > After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module)
>> > the pci_slot driver's .add() callback routine, acpi_pci_slot_add(),
>> > is executed from within acpi_pci_root_add() before the PCI devices on
>> > the bus are enumerated and that triggers the WARN_ON() in
>> > kobject_get():
>> >
>> > WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 
>> > kobject_get+0x33/0x40()
>> > Hardware name: PORTEGE R500
>> > Modules linked in:
>> > Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160
>> > Call Trace:
>> >  [] warn_slowpath_common+0x7a/0xb0
>> >  [] warn_slowpath_null+0x15/0x20
>> >  [] kobject_get+0x33/0x40
>> >  [] get_device+0x12/0x30
>> >  [] register_slot+0x243/0x295
>> >  [] ? trace_hardirqs_on+0xd/0x10
>> >  [] acpi_ns_walk_namespace+0x10f/0x24a
>> >  [] ? walk_p2p_bridge+0x13b/0x13b
>> >  [] ? walk_p2p_bridge+0x13b/0x13b
>> >  [] acpi_walk_namespace+0xe9/0x132
>> >  [] ? walk_p2p_bridge+0x13b/0x13b
>> >  [] walk_p2p_bridge+0xf8/0x13b
>> >  [] ? acpi_os_signal_semaphore+0x76/0x87
>> >  [] ? walk_p2p_bridge+0x13b/0x13b
>> >  [] acpi_ns_walk_namespace+0x10f/0x24a
>> >  [] ? do_sta_before_sun+0x2b/0x2b
>> >  [] ? do_sta_before_sun+0x2b/0x2b
>> >  [] acpi_walk_namespace+0xe9/0x132
>> >  [] ? acpi_pci_root_add+0x3e7/0x49a
>> >  [] acpi_pci_slot_add+0xb2/0x103
>> >  [] ? walk_p2p_bridge+0x13b/0x13b
>> >  [] acpi_pci_root_add+0x3ff/0x49a
>> >
>> > which means that pci_bus->dev used in register_slot() has not been
>> > registered yet at that point.
>> >
>> > To fix this use the observation that before commit 1aeae82
>> > acpi_pci_slot_add() was always run after pci_bus_add_devices()
>> > and that happened to the acpiphp's .add() callback routine too.
>> > Thus it is safe to reorder acpi_pci_root_add() to make the PCI root
>> > drivers' .add() callbacks be run after pci_bus_add_devices(), so do
>> > that.
>> >
>> > This approach was previously proposed by Myron Stowe.
>> >
>> > References: https://patchwork.kernel.org/patch/1848781/
>> > Signed-off-by: Rafael J. Wysocki 
>> > ---
>> >
>> > The commit mentioned in the changelog above is in linux-pm.git/linux-next.
>> >
>> > Thanks,
>> > Rafael
>> >
>> > ---
>> >  drivers/acpi/pci_root.c |   13 -
>> >  1 file changed, 8 insertions(+), 5 deletions(-)
>> >
>> > Index: test/drivers/acpi/pci_root.c
>> > ===
>> > --- test.orig/drivers/acpi/pci_root.c
>> > +++ test/drivers/acpi/pci_root.c
>> > @@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi
>> > if (system_state != SYSTEM_BOOTING)
>> > pci_assign_unassigned_bus_resources(root->bus);
>> >
>> > +   /* need to after hot-added ioapic is registered */
>> > +   if (system_state != SYSTEM_BOOTING)
>> > +   pci_enable_bridges(root->bus);
>> > +
>> > +   pci_bus_add_devices(root->bus);
>> > +
>> > mutex_lock(_pci_root_lock);
>> > +
>> > list_for_each_entry(driver, _pci_drivers, node)
>> > if (driver->add)
>> > driver->add(root);
>> > -   mutex_unlock(_pci_root_lock);
>> >
>> > -   /* need to after hot-added ioapic is registered */
>> > -   if (system_state != SYSTEM_BOOTING)
>> > -   pci_enable_bridges(root->bus);
>> > +   mutex_unlock(_pci_root_lock);
>> >
>> > -   pci_bus_add_devices(root->bus);
>> > return 1;
>> >
>> >  out_del_root:
>> >
>>
>> No, we don't need this after
>>
>> | commit 4f535093cf8f6da8cfda7c36c2c1ecd2e9586ee4
>> | PCI: Put pci_dev in device tree as early as possible
>>
>> in pci/next.
>>
>> So we can move that Jiang's patch from your tree to Bjorn's tree?
>
> OK, I'm dropping that patch from my tree, then (hopefully, no one has merged
> my acpi-cleanup branch yet).
>
> Bjorn, could you pick up https://patchwork.kernel.org/patch/2003771/ please?

I applied this to my next branch for v3.9:

commit ab1a2e038ff2336502e95ec6492c0364a9fc70d0
Author: Jiang Liu 
Date:   Sat Jan 19 00:07:42 2013 +0800

ACPI / PCI: Make pci_slot built-in only, not a module

As discussed in thread at https://patchwork.kernel.org/patch/1946851/,
there's no value in supporting CONFIG_ACPI_PCI_SLOT=m any more.
So change Kconfig and code to only support building pci_slot as
built-in driver.

Thanks!

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration

2013-02-15 Thread Bjorn Helgaas
On Wed, Feb 13, 2013 at 5:59 AM, Rafael J. Wysocki r...@sisk.pl wrote:
 On Tuesday, February 12, 2013 05:54:08 PM Yinghai Lu wrote:
 On Tue, Feb 12, 2013 at 4:16 PM, Rafael J. Wysocki r...@sisk.pl wrote:
  From: Rafael J. Wysocki rafael.j.wyso...@intel.com
 
  After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module)
  the pci_slot driver's .add() callback routine, acpi_pci_slot_add(),
  is executed from within acpi_pci_root_add() before the PCI devices on
  the bus are enumerated and that triggers the WARN_ON() in
  kobject_get():
 
  WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 
  kobject_get+0x33/0x40()
  Hardware name: PORTEGE R500
  Modules linked in:
  Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160
  Call Trace:
   [8103d38a] warn_slowpath_common+0x7a/0xb0
   [8103d3d5] warn_slowpath_null+0x15/0x20
   [812f99b3] kobject_get+0x33/0x40
   [81452b82] get_device+0x12/0x30
   [8138df7b] register_slot+0x243/0x295
   [810a7b6d] ? trace_hardirqs_on+0xd/0x10
   [8137b7b9] acpi_ns_walk_namespace+0x10f/0x24a
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [8137bdc3] acpi_walk_namespace+0xe9/0x132
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [8138dcf5] walk_p2p_bridge+0xf8/0x13b
   [8134d606] ? acpi_os_signal_semaphore+0x76/0x87
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [8137b7b9] acpi_ns_walk_namespace+0x10f/0x24a
   [8138dbfd] ? do_sta_before_sun+0x2b/0x2b
   [8138dbfd] ? do_sta_before_sun+0x2b/0x2b
   [8137bdc3] acpi_walk_namespace+0xe9/0x132
   [81356071] ? acpi_pci_root_add+0x3e7/0x49a
   [8138e07f] acpi_pci_slot_add+0xb2/0x103
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [81356089] acpi_pci_root_add+0x3ff/0x49a
 
  which means that pci_bus-dev used in register_slot() has not been
  registered yet at that point.
 
  To fix this use the observation that before commit 1aeae82
  acpi_pci_slot_add() was always run after pci_bus_add_devices()
  and that happened to the acpiphp's .add() callback routine too.
  Thus it is safe to reorder acpi_pci_root_add() to make the PCI root
  drivers' .add() callbacks be run after pci_bus_add_devices(), so do
  that.
 
  This approach was previously proposed by Myron Stowe.
 
  References: https://patchwork.kernel.org/patch/1848781/
  Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
  ---
 
  The commit mentioned in the changelog above is in linux-pm.git/linux-next.
 
  Thanks,
  Rafael
 
  ---
   drivers/acpi/pci_root.c |   13 -
   1 file changed, 8 insertions(+), 5 deletions(-)
 
  Index: test/drivers/acpi/pci_root.c
  ===
  --- test.orig/drivers/acpi/pci_root.c
  +++ test/drivers/acpi/pci_root.c
  @@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi
  if (system_state != SYSTEM_BOOTING)
  pci_assign_unassigned_bus_resources(root-bus);
 
  +   /* need to after hot-added ioapic is registered */
  +   if (system_state != SYSTEM_BOOTING)
  +   pci_enable_bridges(root-bus);
  +
  +   pci_bus_add_devices(root-bus);
  +
  mutex_lock(acpi_pci_root_lock);
  +
  list_for_each_entry(driver, acpi_pci_drivers, node)
  if (driver-add)
  driver-add(root);
  -   mutex_unlock(acpi_pci_root_lock);
 
  -   /* need to after hot-added ioapic is registered */
  -   if (system_state != SYSTEM_BOOTING)
  -   pci_enable_bridges(root-bus);
  +   mutex_unlock(acpi_pci_root_lock);
 
  -   pci_bus_add_devices(root-bus);
  return 1;
 
   out_del_root:
 

 No, we don't need this after

 | commit 4f535093cf8f6da8cfda7c36c2c1ecd2e9586ee4
 | PCI: Put pci_dev in device tree as early as possible

 in pci/next.

 So we can move that Jiang's patch from your tree to Bjorn's tree?

 OK, I'm dropping that patch from my tree, then (hopefully, no one has merged
 my acpi-cleanup branch yet).

 Bjorn, could you pick up https://patchwork.kernel.org/patch/2003771/ please?

I applied this to my next branch for v3.9:

commit ab1a2e038ff2336502e95ec6492c0364a9fc70d0
Author: Jiang Liu liu...@gmail.com
Date:   Sat Jan 19 00:07:42 2013 +0800

ACPI / PCI: Make pci_slot built-in only, not a module

As discussed in thread at https://patchwork.kernel.org/patch/1946851/,
there's no value in supporting CONFIG_ACPI_PCI_SLOT=m any more.
So change Kconfig and code to only support building pci_slot as
built-in driver.

Thanks!

Bjorn
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration

2013-02-13 Thread Rafael J. Wysocki
On Tuesday, February 12, 2013 05:54:08 PM Yinghai Lu wrote:
> On Tue, Feb 12, 2013 at 4:16 PM, Rafael J. Wysocki  wrote:
> > From: Rafael J. Wysocki 
> >
> > After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module)
> > the pci_slot driver's .add() callback routine, acpi_pci_slot_add(),
> > is executed from within acpi_pci_root_add() before the PCI devices on
> > the bus are enumerated and that triggers the WARN_ON() in
> > kobject_get():
> >
> > WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 
> > kobject_get+0x33/0x40()
> > Hardware name: PORTEGE R500
> > Modules linked in:
> > Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160
> > Call Trace:
> >  [] warn_slowpath_common+0x7a/0xb0
> >  [] warn_slowpath_null+0x15/0x20
> >  [] kobject_get+0x33/0x40
> >  [] get_device+0x12/0x30
> >  [] register_slot+0x243/0x295
> >  [] ? trace_hardirqs_on+0xd/0x10
> >  [] acpi_ns_walk_namespace+0x10f/0x24a
> >  [] ? walk_p2p_bridge+0x13b/0x13b
> >  [] ? walk_p2p_bridge+0x13b/0x13b
> >  [] acpi_walk_namespace+0xe9/0x132
> >  [] ? walk_p2p_bridge+0x13b/0x13b
> >  [] walk_p2p_bridge+0xf8/0x13b
> >  [] ? acpi_os_signal_semaphore+0x76/0x87
> >  [] ? walk_p2p_bridge+0x13b/0x13b
> >  [] acpi_ns_walk_namespace+0x10f/0x24a
> >  [] ? do_sta_before_sun+0x2b/0x2b
> >  [] ? do_sta_before_sun+0x2b/0x2b
> >  [] acpi_walk_namespace+0xe9/0x132
> >  [] ? acpi_pci_root_add+0x3e7/0x49a
> >  [] acpi_pci_slot_add+0xb2/0x103
> >  [] ? walk_p2p_bridge+0x13b/0x13b
> >  [] acpi_pci_root_add+0x3ff/0x49a
> >
> > which means that pci_bus->dev used in register_slot() has not been
> > registered yet at that point.
> >
> > To fix this use the observation that before commit 1aeae82
> > acpi_pci_slot_add() was always run after pci_bus_add_devices()
> > and that happened to the acpiphp's .add() callback routine too.
> > Thus it is safe to reorder acpi_pci_root_add() to make the PCI root
> > drivers' .add() callbacks be run after pci_bus_add_devices(), so do
> > that.
> >
> > This approach was previously proposed by Myron Stowe.
> >
> > References: https://patchwork.kernel.org/patch/1848781/
> > Signed-off-by: Rafael J. Wysocki 
> > ---
> >
> > The commit mentioned in the changelog above is in linux-pm.git/linux-next.
> >
> > Thanks,
> > Rafael
> >
> > ---
> >  drivers/acpi/pci_root.c |   13 -
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > Index: test/drivers/acpi/pci_root.c
> > ===
> > --- test.orig/drivers/acpi/pci_root.c
> > +++ test/drivers/acpi/pci_root.c
> > @@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi
> > if (system_state != SYSTEM_BOOTING)
> > pci_assign_unassigned_bus_resources(root->bus);
> >
> > +   /* need to after hot-added ioapic is registered */
> > +   if (system_state != SYSTEM_BOOTING)
> > +   pci_enable_bridges(root->bus);
> > +
> > +   pci_bus_add_devices(root->bus);
> > +
> > mutex_lock(_pci_root_lock);
> > +
> > list_for_each_entry(driver, _pci_drivers, node)
> > if (driver->add)
> > driver->add(root);
> > -   mutex_unlock(_pci_root_lock);
> >
> > -   /* need to after hot-added ioapic is registered */
> > -   if (system_state != SYSTEM_BOOTING)
> > -   pci_enable_bridges(root->bus);
> > +   mutex_unlock(_pci_root_lock);
> >
> > -   pci_bus_add_devices(root->bus);
> > return 1;
> >
> >  out_del_root:
> >
> 
> No, we don't need this after
> 
> | commit 4f535093cf8f6da8cfda7c36c2c1ecd2e9586ee4
> | PCI: Put pci_dev in device tree as early as possible
> 
> in pci/next.
> 
> So we can move that Jiang's patch from your tree to Bjorn's tree?

OK, I'm dropping that patch from my tree, then (hopefully, no one has merged
my acpi-cleanup branch yet).

Bjorn, could you pick up https://patchwork.kernel.org/patch/2003771/ please?

Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration

2013-02-13 Thread Rafael J. Wysocki
On Tuesday, February 12, 2013 05:54:08 PM Yinghai Lu wrote:
 On Tue, Feb 12, 2013 at 4:16 PM, Rafael J. Wysocki r...@sisk.pl wrote:
  From: Rafael J. Wysocki rafael.j.wyso...@intel.com
 
  After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module)
  the pci_slot driver's .add() callback routine, acpi_pci_slot_add(),
  is executed from within acpi_pci_root_add() before the PCI devices on
  the bus are enumerated and that triggers the WARN_ON() in
  kobject_get():
 
  WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 
  kobject_get+0x33/0x40()
  Hardware name: PORTEGE R500
  Modules linked in:
  Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160
  Call Trace:
   [8103d38a] warn_slowpath_common+0x7a/0xb0
   [8103d3d5] warn_slowpath_null+0x15/0x20
   [812f99b3] kobject_get+0x33/0x40
   [81452b82] get_device+0x12/0x30
   [8138df7b] register_slot+0x243/0x295
   [810a7b6d] ? trace_hardirqs_on+0xd/0x10
   [8137b7b9] acpi_ns_walk_namespace+0x10f/0x24a
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [8137bdc3] acpi_walk_namespace+0xe9/0x132
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [8138dcf5] walk_p2p_bridge+0xf8/0x13b
   [8134d606] ? acpi_os_signal_semaphore+0x76/0x87
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [8137b7b9] acpi_ns_walk_namespace+0x10f/0x24a
   [8138dbfd] ? do_sta_before_sun+0x2b/0x2b
   [8138dbfd] ? do_sta_before_sun+0x2b/0x2b
   [8137bdc3] acpi_walk_namespace+0xe9/0x132
   [81356071] ? acpi_pci_root_add+0x3e7/0x49a
   [8138e07f] acpi_pci_slot_add+0xb2/0x103
   [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
   [81356089] acpi_pci_root_add+0x3ff/0x49a
 
  which means that pci_bus-dev used in register_slot() has not been
  registered yet at that point.
 
  To fix this use the observation that before commit 1aeae82
  acpi_pci_slot_add() was always run after pci_bus_add_devices()
  and that happened to the acpiphp's .add() callback routine too.
  Thus it is safe to reorder acpi_pci_root_add() to make the PCI root
  drivers' .add() callbacks be run after pci_bus_add_devices(), so do
  that.
 
  This approach was previously proposed by Myron Stowe.
 
  References: https://patchwork.kernel.org/patch/1848781/
  Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
  ---
 
  The commit mentioned in the changelog above is in linux-pm.git/linux-next.
 
  Thanks,
  Rafael
 
  ---
   drivers/acpi/pci_root.c |   13 -
   1 file changed, 8 insertions(+), 5 deletions(-)
 
  Index: test/drivers/acpi/pci_root.c
  ===
  --- test.orig/drivers/acpi/pci_root.c
  +++ test/drivers/acpi/pci_root.c
  @@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi
  if (system_state != SYSTEM_BOOTING)
  pci_assign_unassigned_bus_resources(root-bus);
 
  +   /* need to after hot-added ioapic is registered */
  +   if (system_state != SYSTEM_BOOTING)
  +   pci_enable_bridges(root-bus);
  +
  +   pci_bus_add_devices(root-bus);
  +
  mutex_lock(acpi_pci_root_lock);
  +
  list_for_each_entry(driver, acpi_pci_drivers, node)
  if (driver-add)
  driver-add(root);
  -   mutex_unlock(acpi_pci_root_lock);
 
  -   /* need to after hot-added ioapic is registered */
  -   if (system_state != SYSTEM_BOOTING)
  -   pci_enable_bridges(root-bus);
  +   mutex_unlock(acpi_pci_root_lock);
 
  -   pci_bus_add_devices(root-bus);
  return 1;
 
   out_del_root:
 
 
 No, we don't need this after
 
 | commit 4f535093cf8f6da8cfda7c36c2c1ecd2e9586ee4
 | PCI: Put pci_dev in device tree as early as possible
 
 in pci/next.
 
 So we can move that Jiang's patch from your tree to Bjorn's tree?

OK, I'm dropping that patch from my tree, then (hopefully, no one has merged
my acpi-cleanup branch yet).

Bjorn, could you pick up https://patchwork.kernel.org/patch/2003771/ please?

Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration

2013-02-12 Thread Yinghai Lu
On Tue, Feb 12, 2013 at 4:16 PM, Rafael J. Wysocki  wrote:
> From: Rafael J. Wysocki 
>
> After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module)
> the pci_slot driver's .add() callback routine, acpi_pci_slot_add(),
> is executed from within acpi_pci_root_add() before the PCI devices on
> the bus are enumerated and that triggers the WARN_ON() in
> kobject_get():
>
> WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 
> kobject_get+0x33/0x40()
> Hardware name: PORTEGE R500
> Modules linked in:
> Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160
> Call Trace:
>  [] warn_slowpath_common+0x7a/0xb0
>  [] warn_slowpath_null+0x15/0x20
>  [] kobject_get+0x33/0x40
>  [] get_device+0x12/0x30
>  [] register_slot+0x243/0x295
>  [] ? trace_hardirqs_on+0xd/0x10
>  [] acpi_ns_walk_namespace+0x10f/0x24a
>  [] ? walk_p2p_bridge+0x13b/0x13b
>  [] ? walk_p2p_bridge+0x13b/0x13b
>  [] acpi_walk_namespace+0xe9/0x132
>  [] ? walk_p2p_bridge+0x13b/0x13b
>  [] walk_p2p_bridge+0xf8/0x13b
>  [] ? acpi_os_signal_semaphore+0x76/0x87
>  [] ? walk_p2p_bridge+0x13b/0x13b
>  [] acpi_ns_walk_namespace+0x10f/0x24a
>  [] ? do_sta_before_sun+0x2b/0x2b
>  [] ? do_sta_before_sun+0x2b/0x2b
>  [] acpi_walk_namespace+0xe9/0x132
>  [] ? acpi_pci_root_add+0x3e7/0x49a
>  [] acpi_pci_slot_add+0xb2/0x103
>  [] ? walk_p2p_bridge+0x13b/0x13b
>  [] acpi_pci_root_add+0x3ff/0x49a
>
> which means that pci_bus->dev used in register_slot() has not been
> registered yet at that point.
>
> To fix this use the observation that before commit 1aeae82
> acpi_pci_slot_add() was always run after pci_bus_add_devices()
> and that happened to the acpiphp's .add() callback routine too.
> Thus it is safe to reorder acpi_pci_root_add() to make the PCI root
> drivers' .add() callbacks be run after pci_bus_add_devices(), so do
> that.
>
> This approach was previously proposed by Myron Stowe.
>
> References: https://patchwork.kernel.org/patch/1848781/
> Signed-off-by: Rafael J. Wysocki 
> ---
>
> The commit mentioned in the changelog above is in linux-pm.git/linux-next.
>
> Thanks,
> Rafael
>
> ---
>  drivers/acpi/pci_root.c |   13 -
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> Index: test/drivers/acpi/pci_root.c
> ===
> --- test.orig/drivers/acpi/pci_root.c
> +++ test/drivers/acpi/pci_root.c
> @@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi
> if (system_state != SYSTEM_BOOTING)
> pci_assign_unassigned_bus_resources(root->bus);
>
> +   /* need to after hot-added ioapic is registered */
> +   if (system_state != SYSTEM_BOOTING)
> +   pci_enable_bridges(root->bus);
> +
> +   pci_bus_add_devices(root->bus);
> +
> mutex_lock(_pci_root_lock);
> +
> list_for_each_entry(driver, _pci_drivers, node)
> if (driver->add)
> driver->add(root);
> -   mutex_unlock(_pci_root_lock);
>
> -   /* need to after hot-added ioapic is registered */
> -   if (system_state != SYSTEM_BOOTING)
> -   pci_enable_bridges(root->bus);
> +   mutex_unlock(_pci_root_lock);
>
> -   pci_bus_add_devices(root->bus);
> return 1;
>
>  out_del_root:
>

No, we don't need this after

| commit 4f535093cf8f6da8cfda7c36c2c1ecd2e9586ee4
| PCI: Put pci_dev in device tree as early as possible

in pci/next.

So we can move that Jiang's patch from your tree to Bjorn's tree?

Thanks

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration

2013-02-12 Thread Rafael J. Wysocki
From: Rafael J. Wysocki 

After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module)
the pci_slot driver's .add() callback routine, acpi_pci_slot_add(),
is executed from within acpi_pci_root_add() before the PCI devices on
the bus are enumerated and that triggers the WARN_ON() in
kobject_get():

WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 
kobject_get+0x33/0x40()
Hardware name: PORTEGE R500
Modules linked in:
Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160
Call Trace:
 [] warn_slowpath_common+0x7a/0xb0
 [] warn_slowpath_null+0x15/0x20
 [] kobject_get+0x33/0x40
 [] get_device+0x12/0x30
 [] register_slot+0x243/0x295
 [] ? trace_hardirqs_on+0xd/0x10
 [] acpi_ns_walk_namespace+0x10f/0x24a
 [] ? walk_p2p_bridge+0x13b/0x13b
 [] ? walk_p2p_bridge+0x13b/0x13b
 [] acpi_walk_namespace+0xe9/0x132
 [] ? walk_p2p_bridge+0x13b/0x13b
 [] walk_p2p_bridge+0xf8/0x13b
 [] ? acpi_os_signal_semaphore+0x76/0x87
 [] ? walk_p2p_bridge+0x13b/0x13b
 [] acpi_ns_walk_namespace+0x10f/0x24a
 [] ? do_sta_before_sun+0x2b/0x2b
 [] ? do_sta_before_sun+0x2b/0x2b
 [] acpi_walk_namespace+0xe9/0x132
 [] ? acpi_pci_root_add+0x3e7/0x49a
 [] acpi_pci_slot_add+0xb2/0x103
 [] ? walk_p2p_bridge+0x13b/0x13b
 [] acpi_pci_root_add+0x3ff/0x49a

which means that pci_bus->dev used in register_slot() has not been
registered yet at that point.

To fix this use the observation that before commit 1aeae82
acpi_pci_slot_add() was always run after pci_bus_add_devices()
and that happened to the acpiphp's .add() callback routine too.
Thus it is safe to reorder acpi_pci_root_add() to make the PCI root
drivers' .add() callbacks be run after pci_bus_add_devices(), so do
that.

This approach was previously proposed by Myron Stowe.

References: https://patchwork.kernel.org/patch/1848781/
Signed-off-by: Rafael J. Wysocki 
---

The commit mentioned in the changelog above is in linux-pm.git/linux-next.

Thanks,
Rafael

---
 drivers/acpi/pci_root.c |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

Index: test/drivers/acpi/pci_root.c
===
--- test.orig/drivers/acpi/pci_root.c
+++ test/drivers/acpi/pci_root.c
@@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi
if (system_state != SYSTEM_BOOTING)
pci_assign_unassigned_bus_resources(root->bus);
 
+   /* need to after hot-added ioapic is registered */
+   if (system_state != SYSTEM_BOOTING)
+   pci_enable_bridges(root->bus);
+
+   pci_bus_add_devices(root->bus);
+
mutex_lock(_pci_root_lock);
+
list_for_each_entry(driver, _pci_drivers, node)
if (driver->add)
driver->add(root);
-   mutex_unlock(_pci_root_lock);
 
-   /* need to after hot-added ioapic is registered */
-   if (system_state != SYSTEM_BOOTING)
-   pci_enable_bridges(root->bus);
+   mutex_unlock(_pci_root_lock);
 
-   pci_bus_add_devices(root->bus);
return 1;
 
 out_del_root:

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration

2013-02-12 Thread Rafael J. Wysocki
From: Rafael J. Wysocki rafael.j.wyso...@intel.com

After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module)
the pci_slot driver's .add() callback routine, acpi_pci_slot_add(),
is executed from within acpi_pci_root_add() before the PCI devices on
the bus are enumerated and that triggers the WARN_ON() in
kobject_get():

WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 
kobject_get+0x33/0x40()
Hardware name: PORTEGE R500
Modules linked in:
Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160
Call Trace:
 [8103d38a] warn_slowpath_common+0x7a/0xb0
 [8103d3d5] warn_slowpath_null+0x15/0x20
 [812f99b3] kobject_get+0x33/0x40
 [81452b82] get_device+0x12/0x30
 [8138df7b] register_slot+0x243/0x295
 [810a7b6d] ? trace_hardirqs_on+0xd/0x10
 [8137b7b9] acpi_ns_walk_namespace+0x10f/0x24a
 [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
 [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
 [8137bdc3] acpi_walk_namespace+0xe9/0x132
 [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
 [8138dcf5] walk_p2p_bridge+0xf8/0x13b
 [8134d606] ? acpi_os_signal_semaphore+0x76/0x87
 [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
 [8137b7b9] acpi_ns_walk_namespace+0x10f/0x24a
 [8138dbfd] ? do_sta_before_sun+0x2b/0x2b
 [8138dbfd] ? do_sta_before_sun+0x2b/0x2b
 [8137bdc3] acpi_walk_namespace+0xe9/0x132
 [81356071] ? acpi_pci_root_add+0x3e7/0x49a
 [8138e07f] acpi_pci_slot_add+0xb2/0x103
 [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
 [81356089] acpi_pci_root_add+0x3ff/0x49a

which means that pci_bus-dev used in register_slot() has not been
registered yet at that point.

To fix this use the observation that before commit 1aeae82
acpi_pci_slot_add() was always run after pci_bus_add_devices()
and that happened to the acpiphp's .add() callback routine too.
Thus it is safe to reorder acpi_pci_root_add() to make the PCI root
drivers' .add() callbacks be run after pci_bus_add_devices(), so do
that.

This approach was previously proposed by Myron Stowe.

References: https://patchwork.kernel.org/patch/1848781/
Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
---

The commit mentioned in the changelog above is in linux-pm.git/linux-next.

Thanks,
Rafael

---
 drivers/acpi/pci_root.c |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

Index: test/drivers/acpi/pci_root.c
===
--- test.orig/drivers/acpi/pci_root.c
+++ test/drivers/acpi/pci_root.c
@@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi
if (system_state != SYSTEM_BOOTING)
pci_assign_unassigned_bus_resources(root-bus);
 
+   /* need to after hot-added ioapic is registered */
+   if (system_state != SYSTEM_BOOTING)
+   pci_enable_bridges(root-bus);
+
+   pci_bus_add_devices(root-bus);
+
mutex_lock(acpi_pci_root_lock);
+
list_for_each_entry(driver, acpi_pci_drivers, node)
if (driver-add)
driver-add(root);
-   mutex_unlock(acpi_pci_root_lock);
 
-   /* need to after hot-added ioapic is registered */
-   if (system_state != SYSTEM_BOOTING)
-   pci_enable_bridges(root-bus);
+   mutex_unlock(acpi_pci_root_lock);
 
-   pci_bus_add_devices(root-bus);
return 1;
 
 out_del_root:

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration

2013-02-12 Thread Yinghai Lu
On Tue, Feb 12, 2013 at 4:16 PM, Rafael J. Wysocki r...@sisk.pl wrote:
 From: Rafael J. Wysocki rafael.j.wyso...@intel.com

 After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module)
 the pci_slot driver's .add() callback routine, acpi_pci_slot_add(),
 is executed from within acpi_pci_root_add() before the PCI devices on
 the bus are enumerated and that triggers the WARN_ON() in
 kobject_get():

 WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 
 kobject_get+0x33/0x40()
 Hardware name: PORTEGE R500
 Modules linked in:
 Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160
 Call Trace:
  [8103d38a] warn_slowpath_common+0x7a/0xb0
  [8103d3d5] warn_slowpath_null+0x15/0x20
  [812f99b3] kobject_get+0x33/0x40
  [81452b82] get_device+0x12/0x30
  [8138df7b] register_slot+0x243/0x295
  [810a7b6d] ? trace_hardirqs_on+0xd/0x10
  [8137b7b9] acpi_ns_walk_namespace+0x10f/0x24a
  [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
  [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
  [8137bdc3] acpi_walk_namespace+0xe9/0x132
  [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
  [8138dcf5] walk_p2p_bridge+0xf8/0x13b
  [8134d606] ? acpi_os_signal_semaphore+0x76/0x87
  [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
  [8137b7b9] acpi_ns_walk_namespace+0x10f/0x24a
  [8138dbfd] ? do_sta_before_sun+0x2b/0x2b
  [8138dbfd] ? do_sta_before_sun+0x2b/0x2b
  [8137bdc3] acpi_walk_namespace+0xe9/0x132
  [81356071] ? acpi_pci_root_add+0x3e7/0x49a
  [8138e07f] acpi_pci_slot_add+0xb2/0x103
  [8138dd38] ? walk_p2p_bridge+0x13b/0x13b
  [81356089] acpi_pci_root_add+0x3ff/0x49a

 which means that pci_bus-dev used in register_slot() has not been
 registered yet at that point.

 To fix this use the observation that before commit 1aeae82
 acpi_pci_slot_add() was always run after pci_bus_add_devices()
 and that happened to the acpiphp's .add() callback routine too.
 Thus it is safe to reorder acpi_pci_root_add() to make the PCI root
 drivers' .add() callbacks be run after pci_bus_add_devices(), so do
 that.

 This approach was previously proposed by Myron Stowe.

 References: https://patchwork.kernel.org/patch/1848781/
 Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
 ---

 The commit mentioned in the changelog above is in linux-pm.git/linux-next.

 Thanks,
 Rafael

 ---
  drivers/acpi/pci_root.c |   13 -
  1 file changed, 8 insertions(+), 5 deletions(-)

 Index: test/drivers/acpi/pci_root.c
 ===
 --- test.orig/drivers/acpi/pci_root.c
 +++ test/drivers/acpi/pci_root.c
 @@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi
 if (system_state != SYSTEM_BOOTING)
 pci_assign_unassigned_bus_resources(root-bus);

 +   /* need to after hot-added ioapic is registered */
 +   if (system_state != SYSTEM_BOOTING)
 +   pci_enable_bridges(root-bus);
 +
 +   pci_bus_add_devices(root-bus);
 +
 mutex_lock(acpi_pci_root_lock);
 +
 list_for_each_entry(driver, acpi_pci_drivers, node)
 if (driver-add)
 driver-add(root);
 -   mutex_unlock(acpi_pci_root_lock);

 -   /* need to after hot-added ioapic is registered */
 -   if (system_state != SYSTEM_BOOTING)
 -   pci_enable_bridges(root-bus);
 +   mutex_unlock(acpi_pci_root_lock);

 -   pci_bus_add_devices(root-bus);
 return 1;

  out_del_root:


No, we don't need this after

| commit 4f535093cf8f6da8cfda7c36c2c1ecd2e9586ee4
| PCI: Put pci_dev in device tree as early as possible

in pci/next.

So we can move that Jiang's patch from your tree to Bjorn's tree?

Thanks

Yinghai
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/