diff mbox series

PCI: use local_pci_probe when best selected cpu is offline

Message ID 20240529111947.1549556-1-zhanghongchen@loongson.cn (mailing list archive)
State Superseded
Delegated to: Bjorn Helgaas
Headers show
Series PCI: use local_pci_probe when best selected cpu is offline | expand

Commit Message

Hongchen Zhang May 29, 2024, 11:19 a.m. UTC
When the best selected cpu is offline, work_on_cpu will stuck
forever. Therefore, in this case, we should call
local_pci_probe instead of work_on_cpu.

Cc: <stable@vger.kernel.org>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
---
 drivers/pci/pci-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Huacai Chen June 4, 2024, 2:57 p.m. UTC | #1
Hi, Hongchen,

On Wed, May 29, 2024 at 7:19 PM Hongchen Zhang
<zhanghongchen@loongson.cn> wrote:
The title should be better like this:
PCI: Use local_pci_probe() when best selected CPU is offline

>
> When the best selected cpu is offline, work_on_cpu will stuck
> forever. Therefore, in this case, we should call
> local_pci_probe instead of work_on_cpu.

It is better to reword like this:

When the best selected CPU is offline, work_on_cpu() will stuck forever.
This can be happen if a node is online while all its CPUs are offline
(we can use "maxcpus=1" without "nr_cpus=1" to reproduce it), Therefore,
in this case, we should call local_pci_probe() instead of work_on_cpu().

Huacai

>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
> ---
>  drivers/pci/pci-driver.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index af2996d0d17f..32a99828e6a3 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -386,7 +386,7 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
>                 free_cpumask_var(wq_domain_mask);
>         }
>
> -       if (cpu < nr_cpu_ids)
> +       if ((cpu < nr_cpu_ids) && cpu_online(cpu))
>                 error = work_on_cpu(cpu, local_pci_probe, &ddi);
>         else
>                 error = local_pci_probe(&ddi);
> --
> 2.33.0
>
>
Hongchen Zhang June 5, 2024, 1:41 a.m. UTC | #2
On 2024/6/4 下午10:57, Huacai Chen wrote:
> Hi, Hongchen,
> 
> On Wed, May 29, 2024 at 7:19 PM Hongchen Zhang
> <zhanghongchen@loongson.cn> wrote:
> The title should be better like this:
> PCI: Use local_pci_probe() when best selected CPU is offline
> 
>>
>> When the best selected cpu is offline, work_on_cpu will stuck
>> forever. Therefore, in this case, we should call
>> local_pci_probe instead of work_on_cpu.
> 
> It is better to reword like this:
> 
> When the best selected CPU is offline, work_on_cpu() will stuck forever.
> This can be happen if a node is online while all its CPUs are offline
> (we can use "maxcpus=1" without "nr_cpus=1" to reproduce it), Therefore,
> in this case, we should call local_pci_probe() instead of work_on_cpu().
> 
OK, Let me modify the log and send V2.
> Huacai
> 
>>
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
>> Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
>> ---
>>   drivers/pci/pci-driver.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
>> index af2996d0d17f..32a99828e6a3 100644
>> --- a/drivers/pci/pci-driver.c
>> +++ b/drivers/pci/pci-driver.c
>> @@ -386,7 +386,7 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
>>                  free_cpumask_var(wq_domain_mask);
>>          }
>>
>> -       if (cpu < nr_cpu_ids)
>> +       if ((cpu < nr_cpu_ids) && cpu_online(cpu))
>>                  error = work_on_cpu(cpu, local_pci_probe, &ddi);
>>          else
>>                  error = local_pci_probe(&ddi);
>> --
>> 2.33.0
>>
>>
diff mbox series

Patch

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index af2996d0d17f..32a99828e6a3 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -386,7 +386,7 @@  static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
 		free_cpumask_var(wq_domain_mask);
 	}
 
-	if (cpu < nr_cpu_ids)
+	if ((cpu < nr_cpu_ids) && cpu_online(cpu))
 		error = work_on_cpu(cpu, local_pci_probe, &ddi);
 	else
 		error = local_pci_probe(&ddi);