Re: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-14 Thread Konrad Rzeszutek Wilk
On Tue, Jun 11, 2013 at 01:08:14AM +0800, Jiang Liu wrote:
> On Tue 11 Jun 2013 12:58:01 AM CST, Konrad Rzeszutek Wilk wrote:
> > On Mon, Jun 10, 2013 at 12:50:46AM +0800, Jiang Liu wrote:
> >> On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote:
> >>> On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
>  On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
> > On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
> >> On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
> >>> Use new PCI interfaces to simplify xen-pcifront implementation:
> >>> 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
> >>>because pci_scan_bus_parented() is marked as __deprecated.This
> >>>also gets rid of a duplicated call of pci_bus_start_devices().
> >>> 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
> >>>open-coded private implementation.
> >>> 3) Use pci_set_host_bridge_release() to release data structures
> >>>associated with PCI root buses.
> >>> 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
> >>>count.
> >>>
> >>> This is also a preparation for coming PCI bus lock enhancement.
> >
> > With this patch from :
> >
> >  Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
> > testing
> >
> >
> > it blows up when detaching the device.
>  Hi Konrad,
> Thanks for testing! According to the log messages, this issue should
>  be related to pci bus reference counter management. Seems we have done
>  an extra(unbalanced) release of pci bus device.
> Will investigate it tomorrow!
> >>>
> >>> That is quite commendable that you are willing to look over this on
> >>> the weekend but I am not going to be able to rerun this test until
> >>> some time in the week. You could enjoy the weekend and just look at
> >>> this during the week.
> >>
> >> Hi Konrad,
> >>  We should have root-caused this bug, which is caused by
> >> for_each_pci_root_bus().
> >> Current implementation doesn't support root bus deletion when walking
> >> PCI root
> >> buses by for_each_pci_root_bus(). The reference counter
> >> (pci_bus->dev.knode_class.n_ref)
> >> becomes zero after returning from pci_remove_root_bus(), so it triggers
> >> kref warnings
> >> and double-free of klist_node object when we call
> >> pci_get_next_root_bus() to get the
> >> next PCI root bus.
> >>  So we will first revert to  list_for_each_entry_safe(bus, temp,
> >> _root_buses, node)
> >> and solve this issue in next version of for_each_pci_root_bus().
> >
> > That definitly solves the issue. Thanks!
> >
> > I used pci_lock_v3 of https://github.com/jiangliu/linux and the fix
> > below.
> >
> > Is there a new patchset you are going to be posting or a git branch
> > that I can look over?
> >
> > Thanks.
> Hi Konrad,
>  Really appreciate your support! I will try to post a new version 
> tomorrow,
> but I think there won't be big changes except addressing some review
> comments from you.

I also get this:

ERROR: "pci_set_host_bridge_release" [drivers/pci/xen-pcifront.ko] undefined!
ERROR: "pci_create_root_bus" [drivers/pci/xen-pcifront.ko] undefined!
ERROR: "pci_remove_root_bus" [drivers/pci/xen-pcifront.ko] undefined!
ERROR: "pci_stop_root_bus" [drivers/pci/xen-pcifront.ko] undefined!

when building it as a module.
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-14 Thread Konrad Rzeszutek Wilk
On Tue, Jun 11, 2013 at 01:08:14AM +0800, Jiang Liu wrote:
 On Tue 11 Jun 2013 12:58:01 AM CST, Konrad Rzeszutek Wilk wrote:
  On Mon, Jun 10, 2013 at 12:50:46AM +0800, Jiang Liu wrote:
  On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote:
  On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
  On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
  On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
  On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
  Use new PCI interfaces to simplify xen-pcifront implementation:
  1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
 because pci_scan_bus_parented() is marked as __deprecated.This
 also gets rid of a duplicated call of pci_bus_start_devices().
  2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
 open-coded private implementation.
  3) Use pci_set_host_bridge_release() to release data structures
 associated with PCI root buses.
  4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
 count.
 
  This is also a preparation for coming PCI bus lock enhancement.
 
  With this patch from :
 
   Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
  testing
 
 
  it blows up when detaching the device.
  Hi Konrad,
 Thanks for testing! According to the log messages, this issue should
  be related to pci bus reference counter management. Seems we have done
  an extra(unbalanced) release of pci bus device.
 Will investigate it tomorrow!
 
  That is quite commendable that you are willing to look over this on
  the weekend but I am not going to be able to rerun this test until
  some time in the week. You could enjoy the weekend and just look at
  this during the week.
 
  Hi Konrad,
   We should have root-caused this bug, which is caused by
  for_each_pci_root_bus().
  Current implementation doesn't support root bus deletion when walking
  PCI root
  buses by for_each_pci_root_bus(). The reference counter
  (pci_bus-dev.knode_class.n_ref)
  becomes zero after returning from pci_remove_root_bus(), so it triggers
  kref warnings
  and double-free of klist_node object when we call
  pci_get_next_root_bus() to get the
  next PCI root bus.
   So we will first revert to  list_for_each_entry_safe(bus, temp,
  pci_root_buses, node)
  and solve this issue in next version of for_each_pci_root_bus().
 
  That definitly solves the issue. Thanks!
 
  I used pci_lock_v3 of https://github.com/jiangliu/linux and the fix
  below.
 
  Is there a new patchset you are going to be posting or a git branch
  that I can look over?
 
  Thanks.
 Hi Konrad,
  Really appreciate your support! I will try to post a new version 
 tomorrow,
 but I think there won't be big changes except addressing some review
 comments from you.

I also get this:

ERROR: pci_set_host_bridge_release [drivers/pci/xen-pcifront.ko] undefined!
ERROR: pci_create_root_bus [drivers/pci/xen-pcifront.ko] undefined!
ERROR: pci_remove_root_bus [drivers/pci/xen-pcifront.ko] undefined!
ERROR: pci_stop_root_bus [drivers/pci/xen-pcifront.ko] undefined!

when building it as a module.
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-10 Thread Jiang Liu
On Tue 11 Jun 2013 12:58:01 AM CST, Konrad Rzeszutek Wilk wrote:
> On Mon, Jun 10, 2013 at 12:50:46AM +0800, Jiang Liu wrote:
>> On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote:
>>> On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
 On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
> On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
>> On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
>>> Use new PCI interfaces to simplify xen-pcifront implementation:
>>> 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
>>>because pci_scan_bus_parented() is marked as __deprecated.This
>>>also gets rid of a duplicated call of pci_bus_start_devices().
>>> 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
>>>open-coded private implementation.
>>> 3) Use pci_set_host_bridge_release() to release data structures
>>>associated with PCI root buses.
>>> 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
>>>count.
>>>
>>> This is also a preparation for coming PCI bus lock enhancement.
>
> With this patch from :
>
>  Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
> testing
>
>
> it blows up when detaching the device.
 Hi Konrad,
Thanks for testing! According to the log messages, this issue should
 be related to pci bus reference counter management. Seems we have done
 an extra(unbalanced) release of pci bus device.
Will investigate it tomorrow!
>>>
>>> That is quite commendable that you are willing to look over this on
>>> the weekend but I am not going to be able to rerun this test until
>>> some time in the week. You could enjoy the weekend and just look at
>>> this during the week.
>>
>> Hi Konrad,
>>  We should have root-caused this bug, which is caused by
>> for_each_pci_root_bus().
>> Current implementation doesn't support root bus deletion when walking
>> PCI root
>> buses by for_each_pci_root_bus(). The reference counter
>> (pci_bus->dev.knode_class.n_ref)
>> becomes zero after returning from pci_remove_root_bus(), so it triggers
>> kref warnings
>> and double-free of klist_node object when we call
>> pci_get_next_root_bus() to get the
>> next PCI root bus.
>>  So we will first revert to  list_for_each_entry_safe(bus, temp,
>> _root_buses, node)
>> and solve this issue in next version of for_each_pci_root_bus().
>
> That definitly solves the issue. Thanks!
>
> I used pci_lock_v3 of https://github.com/jiangliu/linux and the fix
> below.
>
> Is there a new patchset you are going to be posting or a git branch
> that I can look over?
>
> Thanks.
Hi Konrad,
 Really appreciate your support! I will try to post a new version 
tomorrow,
but I think there won't be big changes except addressing some review
comments from you.
Thanks!
Gerry
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-10 Thread Konrad Rzeszutek Wilk
On Mon, Jun 10, 2013 at 12:50:46AM +0800, Jiang Liu wrote:
> On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote:
> > On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
> >> On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
> >>> On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
>  On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
> > Use new PCI interfaces to simplify xen-pcifront implementation:
> > 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
> >because pci_scan_bus_parented() is marked as __deprecated.This
> >also gets rid of a duplicated call of pci_bus_start_devices().
> > 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
> >open-coded private implementation.
> > 3) Use pci_set_host_bridge_release() to release data structures
> >associated with PCI root buses.
> > 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
> >count.
> >
> > This is also a preparation for coming PCI bus lock enhancement.
> >>>
> >>> With this patch from :
> >>>
> >>>  Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
> >>> testing
> >>>
> >>>
> >>> it blows up when detaching the device.
> >> Hi Konrad,
> >>Thanks for testing! According to the log messages, this issue should
> >> be related to pci bus reference counter management. Seems we have done
> >> an extra(unbalanced) release of pci bus device.
> >>Will investigate it tomorrow!
> >
> > That is quite commendable that you are willing to look over this on
> > the weekend but I am not going to be able to rerun this test until
> > some time in the week. You could enjoy the weekend and just look at
> > this during the week.
> 
> Hi Konrad,
>  We should have root-caused this bug, which is caused by 
> for_each_pci_root_bus().
> Current implementation doesn't support root bus deletion when walking 
> PCI root
> buses by for_each_pci_root_bus(). The reference counter 
> (pci_bus->dev.knode_class.n_ref)
> becomes zero after returning from pci_remove_root_bus(), so it triggers 
> kref warnings
> and double-free of klist_node object when we call 
> pci_get_next_root_bus() to get the
> next PCI root bus.
>  So we will first revert to  list_for_each_entry_safe(bus, temp, 
> _root_buses, node)
> and solve this issue in next version of for_each_pci_root_bus().

That definitly solves the issue. Thanks!

I used pci_lock_v3 of https://github.com/jiangliu/linux and the fix
below.

Is there a new patchset you are going to be posting or a git branch
that I can look over?

Thanks.
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-10 Thread Konrad Rzeszutek Wilk
On Mon, Jun 10, 2013 at 12:50:46AM +0800, Jiang Liu wrote:
 On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote:
  On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
  On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
  On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
  On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
  Use new PCI interfaces to simplify xen-pcifront implementation:
  1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
 because pci_scan_bus_parented() is marked as __deprecated.This
 also gets rid of a duplicated call of pci_bus_start_devices().
  2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
 open-coded private implementation.
  3) Use pci_set_host_bridge_release() to release data structures
 associated with PCI root buses.
  4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
 count.
 
  This is also a preparation for coming PCI bus lock enhancement.
 
  With this patch from :
 
   Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
  testing
 
 
  it blows up when detaching the device.
  Hi Konrad,
 Thanks for testing! According to the log messages, this issue should
  be related to pci bus reference counter management. Seems we have done
  an extra(unbalanced) release of pci bus device.
 Will investigate it tomorrow!
 
  That is quite commendable that you are willing to look over this on
  the weekend but I am not going to be able to rerun this test until
  some time in the week. You could enjoy the weekend and just look at
  this during the week.
 
 Hi Konrad,
  We should have root-caused this bug, which is caused by 
 for_each_pci_root_bus().
 Current implementation doesn't support root bus deletion when walking 
 PCI root
 buses by for_each_pci_root_bus(). The reference counter 
 (pci_bus-dev.knode_class.n_ref)
 becomes zero after returning from pci_remove_root_bus(), so it triggers 
 kref warnings
 and double-free of klist_node object when we call 
 pci_get_next_root_bus() to get the
 next PCI root bus.
  So we will first revert to  list_for_each_entry_safe(bus, temp, 
 pci_root_buses, node)
 and solve this issue in next version of for_each_pci_root_bus().

That definitly solves the issue. Thanks!

I used pci_lock_v3 of https://github.com/jiangliu/linux and the fix
below.

Is there a new patchset you are going to be posting or a git branch
that I can look over?

Thanks.
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-10 Thread Jiang Liu
On Tue 11 Jun 2013 12:58:01 AM CST, Konrad Rzeszutek Wilk wrote:
 On Mon, Jun 10, 2013 at 12:50:46AM +0800, Jiang Liu wrote:
 On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote:
 On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
 On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
 On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
 On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
 Use new PCI interfaces to simplify xen-pcifront implementation:
 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
because pci_scan_bus_parented() is marked as __deprecated.This
also gets rid of a duplicated call of pci_bus_start_devices().
 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
open-coded private implementation.
 3) Use pci_set_host_bridge_release() to release data structures
associated with PCI root buses.
 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
count.

 This is also a preparation for coming PCI bus lock enhancement.

 With this patch from :

  Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
 testing


 it blows up when detaching the device.
 Hi Konrad,
Thanks for testing! According to the log messages, this issue should
 be related to pci bus reference counter management. Seems we have done
 an extra(unbalanced) release of pci bus device.
Will investigate it tomorrow!

 That is quite commendable that you are willing to look over this on
 the weekend but I am not going to be able to rerun this test until
 some time in the week. You could enjoy the weekend and just look at
 this during the week.

 Hi Konrad,
  We should have root-caused this bug, which is caused by
 for_each_pci_root_bus().
 Current implementation doesn't support root bus deletion when walking
 PCI root
 buses by for_each_pci_root_bus(). The reference counter
 (pci_bus-dev.knode_class.n_ref)
 becomes zero after returning from pci_remove_root_bus(), so it triggers
 kref warnings
 and double-free of klist_node object when we call
 pci_get_next_root_bus() to get the
 next PCI root bus.
  So we will first revert to  list_for_each_entry_safe(bus, temp,
 pci_root_buses, node)
 and solve this issue in next version of for_each_pci_root_bus().

 That definitly solves the issue. Thanks!

 I used pci_lock_v3 of https://github.com/jiangliu/linux and the fix
 below.

 Is there a new patchset you are going to be posting or a git branch
 that I can look over?

 Thanks.
Hi Konrad,
 Really appreciate your support! I will try to post a new version 
tomorrow,
but I think there won't be big changes except addressing some review
comments from you.
Thanks!
Gerry
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-09 Thread Jiang Liu
On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote:
> On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
>> On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
>>> On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
 On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
> Use new PCI interfaces to simplify xen-pcifront implementation:
> 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
>because pci_scan_bus_parented() is marked as __deprecated.This
>also gets rid of a duplicated call of pci_bus_start_devices().
> 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
>open-coded private implementation.
> 3) Use pci_set_host_bridge_release() to release data structures
>associated with PCI root buses.
> 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
>count.
>
> This is also a preparation for coming PCI bus lock enhancement.
>>>
>>> With this patch from :
>>>
>>>  Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
>>> testing
>>>
>>>
>>> it blows up when detaching the device.
>> Hi Konrad,
>>Thanks for testing! According to the log messages, this issue should
>> be related to pci bus reference counter management. Seems we have done
>> an extra(unbalanced) release of pci bus device.
>>Will investigate it tomorrow!
>
> That is quite commendable that you are willing to look over this on
> the weekend but I am not going to be able to rerun this test until
> some time in the week. You could enjoy the weekend and just look at
> this during the week.

Hi Konrad,
 We should have root-caused this bug, which is caused by 
for_each_pci_root_bus().
Current implementation doesn't support root bus deletion when walking 
PCI root
buses by for_each_pci_root_bus(). The reference counter 
(pci_bus->dev.knode_class.n_ref)
becomes zero after returning from pci_remove_root_bus(), so it triggers 
kref warnings
and double-free of klist_node object when we call 
pci_get_next_root_bus() to get the
next PCI root bus.
 So we will first revert to  list_for_each_entry_safe(bus, temp, 
_root_buses, node)
and solve this issue in next version of for_each_pci_root_bus().

Regards!
Gerry

---
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 6aa2c0f..6e577db 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -553,11 +553,11 @@ static int pcifront_rescan_root(struct 
pcifront_device *pdev,
 static void pcifront_free_roots(struct pcifront_device *pdev)
 {
struct pcifront_sd *sd;
-   struct pci_bus *bus;
+   struct pci_bus *bus, *temp;

dev_dbg(>xdev->dev, "cleaning up root buses\n");

-   for_each_pci_root_bus(bus) {
+   list_for_each_entry_safe(bus, temp, _root_buses, node) {
sd = bus->sysdata;
if (sd->pdev == pdev) {
pci_stop_root_bus(bus);
---

--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-09 Thread Jiang Liu
On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote:
 On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
 On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
 On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
 On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
 Use new PCI interfaces to simplify xen-pcifront implementation:
 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
because pci_scan_bus_parented() is marked as __deprecated.This
also gets rid of a duplicated call of pci_bus_start_devices().
 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
open-coded private implementation.
 3) Use pci_set_host_bridge_release() to release data structures
associated with PCI root buses.
 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
count.

 This is also a preparation for coming PCI bus lock enhancement.

 With this patch from :

  Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
 testing


 it blows up when detaching the device.
 Hi Konrad,
Thanks for testing! According to the log messages, this issue should
 be related to pci bus reference counter management. Seems we have done
 an extra(unbalanced) release of pci bus device.
Will investigate it tomorrow!

 That is quite commendable that you are willing to look over this on
 the weekend but I am not going to be able to rerun this test until
 some time in the week. You could enjoy the weekend and just look at
 this during the week.

Hi Konrad,
 We should have root-caused this bug, which is caused by 
for_each_pci_root_bus().
Current implementation doesn't support root bus deletion when walking 
PCI root
buses by for_each_pci_root_bus(). The reference counter 
(pci_bus-dev.knode_class.n_ref)
becomes zero after returning from pci_remove_root_bus(), so it triggers 
kref warnings
and double-free of klist_node object when we call 
pci_get_next_root_bus() to get the
next PCI root bus.
 So we will first revert to  list_for_each_entry_safe(bus, temp, 
pci_root_buses, node)
and solve this issue in next version of for_each_pci_root_bus().

Regards!
Gerry

---
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 6aa2c0f..6e577db 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -553,11 +553,11 @@ static int pcifront_rescan_root(struct 
pcifront_device *pdev,
 static void pcifront_free_roots(struct pcifront_device *pdev)
 {
struct pcifront_sd *sd;
-   struct pci_bus *bus;
+   struct pci_bus *bus, *temp;

dev_dbg(pdev-xdev-dev, cleaning up root buses\n);

-   for_each_pci_root_bus(bus) {
+   list_for_each_entry_safe(bus, temp, pci_root_buses, node) {
sd = bus-sysdata;
if (sd-pdev == pdev) {
pci_stop_root_bus(bus);
---

--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-07 Thread Konrad Rzeszutek Wilk
On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
> On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
> > On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
> >> On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
> >>> Use new PCI interfaces to simplify xen-pcifront implementation:
> >>> 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
> >>>because pci_scan_bus_parented() is marked as __deprecated.This
> >>>also gets rid of a duplicated call of pci_bus_start_devices().
> >>> 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
> >>>open-coded private implementation.
> >>> 3) Use pci_set_host_bridge_release() to release data structures
> >>>associated with PCI root buses.
> >>> 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
> >>>count.
> >>>
> >>> This is also a preparation for coming PCI bus lock enhancement.
> > 
> > With this patch from :
> > 
> >  Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
> > testing
> > 
> > 
> > it blows up when detaching the device.
> Hi Konrad,
>Thanks for testing! According to the log messages, this issue should
> be related to pci bus reference counter management. Seems we have done
> an extra(unbalanced) release of pci bus device.
>Will investigate it tomorrow!

That is quite commendable that you are willing to look over this on
the weekend but I am not going to be able to rerun this test until
some time in the week. You could enjoy the weekend and just look at
this during the week.
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-07 Thread Jiang Liu
On Fri 07 Jun 2013 10:50:24 PM CST, Konrad Rzeszutek Wilk wrote:
> On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
>> Use new PCI interfaces to simplify xen-pcifront implementation:
>> 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
>>because pci_scan_bus_parented() is marked as __deprecated.This
>>also gets rid of a duplicated call of pci_bus_start_devices().
>> 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
>>open-coded private implementation.
>> 3) Use pci_set_host_bridge_release() to release data structures
>>associated with PCI root buses.
>> 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
>>count.
>>
>> This is also a preparation for coming PCI bus lock enhancement.
>>
>> Signed-off-by: Jiang Liu 
>> Cc: Konrad Rzeszutek Wilk 
>> Cc: Jeremy Fitzhardinge 
>> Cc: xen-de...@lists.xensource.com
>> Cc: virtualizat...@lists.linux-foundation.org
>> Cc: linux-...@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>>  drivers/pci/xen-pcifront.c | 81 
>> ++
>>  1 file changed, 39 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 816cf94..6aa2c0f 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
..
>> @@ -480,12 +490,14 @@ static int pcifront_scan_root(struct pcifront_device 
>> *pdev,
>>  goto err_out;
>>  }
>>
>> -bus_entry->bus = b;
>> +pci_set_host_bridge_release(to_pci_host_bridge(b->bridge),
>> +pcifront_release_sd, sd);
>>
>> -list_add(_entry->list, >root_buses);
>> -
>> -/* pci_scan_bus_parented skips devices which do not have a have
>> -* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>> +/*
>> + * Every PCI physical device should have function 0, but that's not
>> + * true for xen.
>
> That is incorrect. There are two types of backends - one of them will
> start at zero, but the other might not.
Hi Konrad,
  Forgive my poor knowledge about Xen:(, so I will skip this change.
Regards!
Gerry
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-07 Thread Jiang Liu
On Fri 07 Jun 2013 10:50:24 PM CST, Konrad Rzeszutek Wilk wrote:
> On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
>> Use new PCI interfaces to simplify xen-pcifront implementation:
>> 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
>>because pci_scan_bus_parented() is marked as __deprecated.This
>>also gets rid of a duplicated call of pci_bus_start_devices().
>> 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
>>open-coded private implementation.
>> 3) Use pci_set_host_bridge_release() to release data structures
>>associated with PCI root buses.
>> 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
>>count.
>>
>> This is also a preparation for coming PCI bus lock enhancement.
>>
>> Signed-off-by: Jiang Liu 
>> Cc: Konrad Rzeszutek Wilk 
>> Cc: Jeremy Fitzhardinge 
>> Cc: xen-de...@lists.xensource.com
>> Cc: virtualizat...@lists.linux-foundation.org
>> Cc: linux-...@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>>  drivers/pci/xen-pcifront.c | 81 
>> ++
>>  1 file changed, 39 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 816cf94..6aa2c0f 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
..
>> @@ -480,12 +490,14 @@ static int pcifront_scan_root(struct pcifront_device 
>> *pdev,
>>  goto err_out;
>>  }
>>
>> -bus_entry->bus = b;
>> +pci_set_host_bridge_release(to_pci_host_bridge(b->bridge),
>> +pcifront_release_sd, sd);
>>
>> -list_add(_entry->list, >root_buses);
>> -
>> -/* pci_scan_bus_parented skips devices which do not have a have
>> -* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>> +/*
>> + * Every PCI physical device should have function 0, but that's not
>> + * true for xen.
>
> That is incorrect. There are two types of backends - one of them will
> start at zero, but the other might not.
Hi Konrad,
  Forgive my poor knowledge about Xen:(, so I will skip this change.
Regards!
Gerry
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-07 Thread Konrad Rzeszutek Wilk
On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
> Use new PCI interfaces to simplify xen-pcifront implementation:
> 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
>because pci_scan_bus_parented() is marked as __deprecated.This
>also gets rid of a duplicated call of pci_bus_start_devices().
> 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
>open-coded private implementation.
> 3) Use pci_set_host_bridge_release() to release data structures
>associated with PCI root buses.
> 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
>count.
> 
> This is also a preparation for coming PCI bus lock enhancement.
> 
> Signed-off-by: Jiang Liu 
> Cc: Konrad Rzeszutek Wilk 
> Cc: Jeremy Fitzhardinge 
> Cc: xen-de...@lists.xensource.com
> Cc: virtualizat...@lists.linux-foundation.org
> Cc: linux-...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/pci/xen-pcifront.c | 81 
> ++
>  1 file changed, 39 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 816cf94..6aa2c0f 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -25,11 +25,6 @@
>  #define INVALID_GRANT_REF (0)
>  #define INVALID_EVTCHN(-1)
>  
> -struct pci_bus_entry {
> - struct list_head list;
> - struct pci_bus *bus;
> -};
> -
>  #define _PDEVB_op_active (0)
>  #define PDEVB_op_active  (1 << (_PDEVB_op_active))
>  
> @@ -47,12 +42,12 @@ struct pcifront_device {
>   struct xen_pci_sharedinfo *sh_info;
>   struct work_struct op_work;
>   unsigned long flags;
> -
>  };
>  
>  struct pcifront_sd {
>   int domain;
>   struct pcifront_device *pdev;
> + struct resource busn_res;
>  };
>  
>  static inline struct pcifront_device *
> @@ -67,6 +62,12 @@ static inline void pcifront_init_sd(struct pcifront_sd *sd,
>  {
>   sd->domain = domain;
>   sd->pdev = pdev;
> +
> + /* Xen pci-backend doesn't export P2P bridges */
> + sd->busn_res.start = bus;
> + sd->busn_res.end = bus;
> + sd->busn_res.flags = IORESOURCE_BUS;
> + sd->busn_res.name = "PCI busn";
>  }
>  
>  static DEFINE_SPINLOCK(pcifront_dev_lock);
> @@ -441,12 +442,19 @@ static int pcifront_scan_bus(struct pcifront_device 
> *pdev,
>   return 0;
>  }
>  
> +static void pcifront_release_sd(struct pci_host_bridge *bridge)
> +{
> + struct pcifront_sd *sd = bridge->release_data;
> +
> + kfree(sd);
> +}
> +
>  static int pcifront_scan_root(struct pcifront_device *pdev,
>unsigned int domain, unsigned int bus)
>  {
>   struct pci_bus *b;
>   struct pcifront_sd *sd = NULL;
> - struct pci_bus_entry *bus_entry = NULL;
> + LIST_HEAD(resources);
>   int err = 0;
>  
>  #ifndef CONFIG_PCI_DOMAINS
> @@ -463,16 +471,18 @@ static int pcifront_scan_root(struct pcifront_device 
> *pdev,
>   dev_info(>xdev->dev, "Creating PCI Frontend Bus %04x:%02x\n",
>domain, bus);
>  
> - bus_entry = kmalloc(sizeof(*bus_entry), GFP_KERNEL);
> - sd = kmalloc(sizeof(*sd), GFP_KERNEL);
> - if (!bus_entry || !sd) {
> + sd = kzalloc(sizeof(*sd), GFP_KERNEL);
> + if (!sd) {
>   err = -ENOMEM;
>   goto err_out;
>   }
>   pcifront_init_sd(sd, domain, bus, pdev);
>  
> - b = pci_scan_bus_parented(>xdev->dev, bus,
> -   _bus_ops, sd);
> + pci_add_resource(, _resource);
> + pci_add_resource(, _resource);
> + pci_add_resource(, >busn_res);
> + b = pci_create_root_bus(>xdev->dev, bus, _bus_ops,
> + sd, );
>   if (!b) {
>   dev_err(>xdev->dev,
>   "Error creating PCI Frontend Bus!\n");
> @@ -480,12 +490,14 @@ static int pcifront_scan_root(struct pcifront_device 
> *pdev,
>   goto err_out;
>   }
>  
> - bus_entry->bus = b;
> + pci_set_host_bridge_release(to_pci_host_bridge(b->bridge),
> + pcifront_release_sd, sd);
>  
> - list_add(_entry->list, >root_buses);
> -
> - /* pci_scan_bus_parented skips devices which do not have a have
> - * devfn==0. The pcifront_scan_bus enumerates all devfn. */
> + /*
> +  * Every PCI physical device should have function 0, but that's not
> +  * true for xen.

That is incorrect. There are two types of backends - one of them will
start at zero, but the other might not.

> +  * So use pcifront_scan_bus() instead of pci_scan_child_bus().
> +  */
>   err = pcifront_scan_bus(pdev, domain, bus, b);
>  
>   /* Claim resources before going "live" with our devices */
> @@ -497,7 +509,6 @@ static int pcifront_scan_root(struct pcifront_device 
> *pdev,
>   return err;
>  
>  err_out:
> - kfree(bus_entry);
>   kfree(sd);
>  
>   return err;
> @@ -539,35 +550,19 @@ 

Re: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-07 Thread Konrad Rzeszutek Wilk
On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
 Use new PCI interfaces to simplify xen-pcifront implementation:
 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
because pci_scan_bus_parented() is marked as __deprecated.This
also gets rid of a duplicated call of pci_bus_start_devices().
 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
open-coded private implementation.
 3) Use pci_set_host_bridge_release() to release data structures
associated with PCI root buses.
 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
count.
 
 This is also a preparation for coming PCI bus lock enhancement.
 
 Signed-off-by: Jiang Liu jiang@huawei.com
 Cc: Konrad Rzeszutek Wilk konrad.w...@oracle.com
 Cc: Jeremy Fitzhardinge jer...@goop.org
 Cc: xen-de...@lists.xensource.com
 Cc: virtualizat...@lists.linux-foundation.org
 Cc: linux-...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org
 ---
  drivers/pci/xen-pcifront.c | 81 
 ++
  1 file changed, 39 insertions(+), 42 deletions(-)
 
 diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
 index 816cf94..6aa2c0f 100644
 --- a/drivers/pci/xen-pcifront.c
 +++ b/drivers/pci/xen-pcifront.c
 @@ -25,11 +25,6 @@
  #define INVALID_GRANT_REF (0)
  #define INVALID_EVTCHN(-1)
  
 -struct pci_bus_entry {
 - struct list_head list;
 - struct pci_bus *bus;
 -};
 -
  #define _PDEVB_op_active (0)
  #define PDEVB_op_active  (1  (_PDEVB_op_active))
  
 @@ -47,12 +42,12 @@ struct pcifront_device {
   struct xen_pci_sharedinfo *sh_info;
   struct work_struct op_work;
   unsigned long flags;
 -
  };
  
  struct pcifront_sd {
   int domain;
   struct pcifront_device *pdev;
 + struct resource busn_res;
  };
  
  static inline struct pcifront_device *
 @@ -67,6 +62,12 @@ static inline void pcifront_init_sd(struct pcifront_sd *sd,
  {
   sd-domain = domain;
   sd-pdev = pdev;
 +
 + /* Xen pci-backend doesn't export P2P bridges */
 + sd-busn_res.start = bus;
 + sd-busn_res.end = bus;
 + sd-busn_res.flags = IORESOURCE_BUS;
 + sd-busn_res.name = PCI busn;
  }
  
  static DEFINE_SPINLOCK(pcifront_dev_lock);
 @@ -441,12 +442,19 @@ static int pcifront_scan_bus(struct pcifront_device 
 *pdev,
   return 0;
  }
  
 +static void pcifront_release_sd(struct pci_host_bridge *bridge)
 +{
 + struct pcifront_sd *sd = bridge-release_data;
 +
 + kfree(sd);
 +}
 +
  static int pcifront_scan_root(struct pcifront_device *pdev,
unsigned int domain, unsigned int bus)
  {
   struct pci_bus *b;
   struct pcifront_sd *sd = NULL;
 - struct pci_bus_entry *bus_entry = NULL;
 + LIST_HEAD(resources);
   int err = 0;
  
  #ifndef CONFIG_PCI_DOMAINS
 @@ -463,16 +471,18 @@ static int pcifront_scan_root(struct pcifront_device 
 *pdev,
   dev_info(pdev-xdev-dev, Creating PCI Frontend Bus %04x:%02x\n,
domain, bus);
  
 - bus_entry = kmalloc(sizeof(*bus_entry), GFP_KERNEL);
 - sd = kmalloc(sizeof(*sd), GFP_KERNEL);
 - if (!bus_entry || !sd) {
 + sd = kzalloc(sizeof(*sd), GFP_KERNEL);
 + if (!sd) {
   err = -ENOMEM;
   goto err_out;
   }
   pcifront_init_sd(sd, domain, bus, pdev);
  
 - b = pci_scan_bus_parented(pdev-xdev-dev, bus,
 -   pcifront_bus_ops, sd);
 + pci_add_resource(resources, ioport_resource);
 + pci_add_resource(resources, iomem_resource);
 + pci_add_resource(resources, sd-busn_res);
 + b = pci_create_root_bus(pdev-xdev-dev, bus, pcifront_bus_ops,
 + sd, resources);
   if (!b) {
   dev_err(pdev-xdev-dev,
   Error creating PCI Frontend Bus!\n);
 @@ -480,12 +490,14 @@ static int pcifront_scan_root(struct pcifront_device 
 *pdev,
   goto err_out;
   }
  
 - bus_entry-bus = b;
 + pci_set_host_bridge_release(to_pci_host_bridge(b-bridge),
 + pcifront_release_sd, sd);
  
 - list_add(bus_entry-list, pdev-root_buses);
 -
 - /* pci_scan_bus_parented skips devices which do not have a have
 - * devfn==0. The pcifront_scan_bus enumerates all devfn. */
 + /*
 +  * Every PCI physical device should have function 0, but that's not
 +  * true for xen.

That is incorrect. There are two types of backends - one of them will
start at zero, but the other might not.

 +  * So use pcifront_scan_bus() instead of pci_scan_child_bus().
 +  */
   err = pcifront_scan_bus(pdev, domain, bus, b);
  
   /* Claim resources before going live with our devices */
 @@ -497,7 +509,6 @@ static int pcifront_scan_root(struct pcifront_device 
 *pdev,
   return err;
  
  err_out:
 - kfree(bus_entry);
   kfree(sd);
  
   return err;
 @@ -539,35 +550,19 @@ static int 

Re: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-07 Thread Jiang Liu
On Fri 07 Jun 2013 10:50:24 PM CST, Konrad Rzeszutek Wilk wrote:
 On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
 Use new PCI interfaces to simplify xen-pcifront implementation:
 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
because pci_scan_bus_parented() is marked as __deprecated.This
also gets rid of a duplicated call of pci_bus_start_devices().
 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
open-coded private implementation.
 3) Use pci_set_host_bridge_release() to release data structures
associated with PCI root buses.
 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
count.

 This is also a preparation for coming PCI bus lock enhancement.

 Signed-off-by: Jiang Liu jiang@huawei.com
 Cc: Konrad Rzeszutek Wilk konrad.w...@oracle.com
 Cc: Jeremy Fitzhardinge jer...@goop.org
 Cc: xen-de...@lists.xensource.com
 Cc: virtualizat...@lists.linux-foundation.org
 Cc: linux-...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org
 ---
  drivers/pci/xen-pcifront.c | 81 
 ++
  1 file changed, 39 insertions(+), 42 deletions(-)

 diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
 index 816cf94..6aa2c0f 100644
 --- a/drivers/pci/xen-pcifront.c
 +++ b/drivers/pci/xen-pcifront.c
..
 @@ -480,12 +490,14 @@ static int pcifront_scan_root(struct pcifront_device 
 *pdev,
  goto err_out;
  }

 -bus_entry-bus = b;
 +pci_set_host_bridge_release(to_pci_host_bridge(b-bridge),
 +pcifront_release_sd, sd);

 -list_add(bus_entry-list, pdev-root_buses);
 -
 -/* pci_scan_bus_parented skips devices which do not have a have
 -* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 +/*
 + * Every PCI physical device should have function 0, but that's not
 + * true for xen.

 That is incorrect. There are two types of backends - one of them will
 start at zero, but the other might not.
Hi Konrad,
  Forgive my poor knowledge about Xen:(, so I will skip this change.
Regards!
Gerry
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-07 Thread Jiang Liu
On Fri 07 Jun 2013 10:50:24 PM CST, Konrad Rzeszutek Wilk wrote:
 On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
 Use new PCI interfaces to simplify xen-pcifront implementation:
 1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
because pci_scan_bus_parented() is marked as __deprecated.This
also gets rid of a duplicated call of pci_bus_start_devices().
 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
open-coded private implementation.
 3) Use pci_set_host_bridge_release() to release data structures
associated with PCI root buses.
 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
count.

 This is also a preparation for coming PCI bus lock enhancement.

 Signed-off-by: Jiang Liu jiang@huawei.com
 Cc: Konrad Rzeszutek Wilk konrad.w...@oracle.com
 Cc: Jeremy Fitzhardinge jer...@goop.org
 Cc: xen-de...@lists.xensource.com
 Cc: virtualizat...@lists.linux-foundation.org
 Cc: linux-...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org
 ---
  drivers/pci/xen-pcifront.c | 81 
 ++
  1 file changed, 39 insertions(+), 42 deletions(-)

 diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
 index 816cf94..6aa2c0f 100644
 --- a/drivers/pci/xen-pcifront.c
 +++ b/drivers/pci/xen-pcifront.c
..
 @@ -480,12 +490,14 @@ static int pcifront_scan_root(struct pcifront_device 
 *pdev,
  goto err_out;
  }

 -bus_entry-bus = b;
 +pci_set_host_bridge_release(to_pci_host_bridge(b-bridge),
 +pcifront_release_sd, sd);

 -list_add(bus_entry-list, pdev-root_buses);
 -
 -/* pci_scan_bus_parented skips devices which do not have a have
 -* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 +/*
 + * Every PCI physical device should have function 0, but that's not
 + * true for xen.

 That is incorrect. There are two types of backends - one of them will
 start at zero, but the other might not.
Hi Konrad,
  Forgive my poor knowledge about Xen:(, so I will skip this change.
Regards!
Gerry
--
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: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation

2013-06-07 Thread Konrad Rzeszutek Wilk
On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote:
 On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote:
  On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote:
  On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote:
  Use new PCI interfaces to simplify xen-pcifront implementation:
  1) Use pci_create_root_bus() instead of pci_scan_bus_parented()
 because pci_scan_bus_parented() is marked as __deprecated.This
 also gets rid of a duplicated call of pci_bus_start_devices().
  2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of
 open-coded private implementation.
  3) Use pci_set_host_bridge_release() to release data structures
 associated with PCI root buses.
  4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference
 count.
 
  This is also a preparation for coming PCI bus lock enhancement.
  
  With this patch from :
  
   Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into 
  testing
  
  
  it blows up when detaching the device.
 Hi Konrad,
Thanks for testing! According to the log messages, this issue should
 be related to pci bus reference counter management. Seems we have done
 an extra(unbalanced) release of pci bus device.
Will investigate it tomorrow!

That is quite commendable that you are willing to look over this on
the weekend but I am not going to be able to rerun this test until
some time in the week. You could enjoy the weekend and just look at
this during the week.
--
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/