diff mbox

[v3,part2,15/20] PCI, EDAC: use hotplug-safe PCI bus iterators to walk PCI buses

Message ID 1369583597-3801-16-git-send-email-jiang.liu@huawei.com
State Rejected
Headers show

Commit Message

Jiang Liu May 26, 2013, 3:53 p.m. UTC
Enhance EDAC drviers to use hotplug-safe iterators to walk PCI buses.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/edac/i7core_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bjorn Helgaas June 17, 2013, 8:18 p.m. UTC | #1
On Sun, May 26, 2013 at 11:53:12PM +0800, Jiang Liu wrote:
> Enhance EDAC drviers to use hotplug-safe iterators to walk PCI buses.
> 
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
> Cc: Doug Thompson <dougthompson@xmission.com>
> Cc: linux-edac@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/edac/i7core_edac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
> index 0ec3e95..7146e10 100644
> --- a/drivers/edac/i7core_edac.c
> +++ b/drivers/edac/i7core_edac.c
> @@ -1296,7 +1296,7 @@ static unsigned i7core_pci_lastbus(void)
>  	int last_bus = 0, bus;
>  	struct pci_bus *b = NULL;
>  
> -	while ((b = pci_find_next_bus(b)) != NULL) {
> +	for_each_pci_root_bus(b) {

This doesn't look equivalent.  Previously, we iterated over all PCI
buses, so we returned the highest bus number seen anywhere.  Now we
only look at root buses, so we return the highest bus number of any
root bus.  But if that root bus has a bridge on it, obviously the
bus on the other side has a higher number.

Even with that fix, a hot-add at the same time i7core_probe() runs
could mean an incorrect result.  This is all very i7 topology-dependent,
so I don't think the PCI core can do anything more than avoid oopses
from traversing lists incorrectly.

Bjorn

>  		bus = b->number;
>  		edac_dbg(0, "Found bus %d\n", bus);
>  		if (bus > last_bus)
> -- 
> 1.8.1.2
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiang Liu June 18, 2013, 4:33 p.m. UTC | #2
On 06/18/2013 04:18 AM, Bjorn Helgaas wrote:
> On Sun, May 26, 2013 at 11:53:12PM +0800, Jiang Liu wrote:
>> Enhance EDAC drviers to use hotplug-safe iterators to walk PCI buses.
>>
>> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>> Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
>> Cc: Doug Thompson <dougthompson@xmission.com> r
>> Cc: linux-edac@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>>  drivers/edac/i7core_edac.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
>> index 0ec3e95..7146e10 100644
>> --- a/drivers/edac/i7core_edac.c
>> +++ b/drivers/edac/i7core_edac.c
>> @@ -1296,7 +1296,7 @@ static unsigned i7core_pci_lastbus(void)
>>  	int last_bus = 0, bus;
>>  	struct pci_bus *b = NULL;
>>  
>> -	while ((b = pci_find_next_bus(b)) != NULL) {
>> +	for_each_pci_root_bus(b) {
> 
> This doesn't look equivalent.  Previously, we iterated over all PCI
> buses, so we returned the highest bus number seen anywhere.  Now we
> only look at root buses, so we return the highest bus number of any
> root bus.  But if that root bus has a bridge on it, obviously the
> bus on the other side has a higher number.
Hi Bjorn,
	I think the name pci_find_next_bus() is misleading, it should be named
pci_find_next_root_bus() actually because it returns next root bus indeed.

> 
> Even with that fix, a hot-add at the same time i7core_probe() runs
> could mean an incorrect result.  This is all very i7 topology-dependent,
> so I don't think the PCI core can do anything more than avoid oopses
> from traversing lists incorrectly.
Yeah, it's very architecture specific. I think i7core_edac assume no PCI
root bus hotplug on i7 platforms because it's desktop or mobile processors.

> 
> Bjorn
> 
>>  		bus = b->number;
>>  		edac_dbg(0, "Found bus %d\n", bus);
>>  		if (bus > last_bus)
>> -- 
>> 1.8.1.2
>>

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas June 26, 2013, 3 a.m. UTC | #3
On Tue, Jun 18, 2013 at 10:33 AM, Jiang Liu <liuj97@gmail.com> wrote:
> On 06/18/2013 04:18 AM, Bjorn Helgaas wrote:
>> On Sun, May 26, 2013 at 11:53:12PM +0800, Jiang Liu wrote:
>>> Enhance EDAC drviers to use hotplug-safe iterators to walk PCI buses.
>>>
>>> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>>> Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
>>> Cc: Doug Thompson <dougthompson@xmission.com> r
>>> Cc: linux-edac@vger.kernel.org
>>> Cc: linux-kernel@vger.kernel.org
>>> ---
>>>  drivers/edac/i7core_edac.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
>>> index 0ec3e95..7146e10 100644
>>> --- a/drivers/edac/i7core_edac.c
>>> +++ b/drivers/edac/i7core_edac.c
>>> @@ -1296,7 +1296,7 @@ static unsigned i7core_pci_lastbus(void)
>>>      int last_bus = 0, bus;
>>>      struct pci_bus *b = NULL;
>>>
>>> -    while ((b = pci_find_next_bus(b)) != NULL) {
>>> +    for_each_pci_root_bus(b) {
>>
>> This doesn't look equivalent.  Previously, we iterated over all PCI
>> buses, so we returned the highest bus number seen anywhere.  Now we
>> only look at root buses, so we return the highest bus number of any
>> root bus.  But if that root bus has a bridge on it, obviously the
>> bus on the other side has a higher number.
> Hi Bjorn,
>         I think the name pci_find_next_bus() is misleading, it should be named
> pci_find_next_root_bus() actually because it returns next root bus indeed.

Oh, you forgot to mention that critical bit of information!  That
should be in the changelog of every patch that changes a call to
pci_find_next_bus().

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 0ec3e95..7146e10 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -1296,7 +1296,7 @@  static unsigned i7core_pci_lastbus(void)
 	int last_bus = 0, bus;
 	struct pci_bus *b = NULL;
 
-	while ((b = pci_find_next_bus(b)) != NULL) {
+	for_each_pci_root_bus(b) {
 		bus = b->number;
 		edac_dbg(0, "Found bus %d\n", bus);
 		if (bus > last_bus)