diff mbox series

[SRU,Bionic] ata: do not schedule hot plug if it is a sas host

Message ID 20180503200635.13988-1-dann.frazier@canonical.com
State New
Headers show
Series [SRU,Bionic] ata: do not schedule hot plug if it is a sas host | expand

Commit Message

dann frazier May 3, 2018, 8:06 p.m. UTC
From: Jason Yan <yanaijie@huawei.com>

BugLink: https://bugs.launchpad.net/bugs/1768948

We've got a kernel panic when using sata disk with sas controller:

[115946.152283] Unable to handle kernel NULL pointer dereference at virtual address 000007d8
[115946.223963] CPU: 0 PID: 22175 Comm: kworker/0:1 Tainted: G   W OEL  4.14.0 #1
[115946.232925] Workqueue: events ata_scsi_hotplug
[115946.237938] task: ffff8021ee50b180 task.stack: ffff00000d5d0000
[115946.244717] PC is at sas_find_dev_by_rphy+0x44/0x114
[115946.250224] LR is at sas_find_dev_by_rphy+0x3c/0x114
......
[115946.355701] Process kworker/0:1 (pid: 22175, stack limit = 0xffff00000d5d0000)
[115946.363369] Call trace:
[115946.456356] [<ffff000008878a9c>] sas_find_dev_by_rphy+0x44/0x114
[115946.462908] [<ffff000008878b8c>] sas_target_alloc+0x20/0x5c
[115946.469408] [<ffff00000885a31c>] scsi_alloc_target+0x250/0x308
[115946.475781] [<ffff00000885ba30>] __scsi_add_device+0xb0/0x154
[115946.481991] [<ffff0000088b520c>] ata_scsi_scan_host+0x180/0x218
[115946.488367] [<ffff0000088b53d8>] ata_scsi_hotplug+0xb0/0xcc
[115946.494801] [<ffff0000080ebd70>] process_one_work+0x144/0x390
[115946.501115] [<ffff0000080ec100>] worker_thread+0x144/0x418
[115946.507093] [<ffff0000080f2c98>] kthread+0x10c/0x138
[115946.512792] [<ffff0000080855dc>] ret_from_fork+0x10/0x18

We found that Ding Xiang has reported a similar bug before:
https://patchwork.kernel.org/patch/9179817/

And this bug still exists in mainline. Since libsas handles hotplug and
device adding/removing itself, do not need to schedule ata hot plug task
here if it is a sas host.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
Cc: Ding Xiang <dingxiang@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: Tejun Heo <tj@kernel.org>
(cherry picked from commit 6f54120e17e311fd7ac42b9ec2a0611caa5b46ad)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
---
 drivers/ata/libata-eh.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kleber Sacilotto de Souza May 8, 2018, 2:57 p.m. UTC | #1
On 05/03/18 22:06, dann frazier wrote:
> From: Jason Yan <yanaijie@huawei.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1768948
> 
> We've got a kernel panic when using sata disk with sas controller:
> 
> [115946.152283] Unable to handle kernel NULL pointer dereference at virtual address 000007d8
> [115946.223963] CPU: 0 PID: 22175 Comm: kworker/0:1 Tainted: G   W OEL  4.14.0 #1
> [115946.232925] Workqueue: events ata_scsi_hotplug
> [115946.237938] task: ffff8021ee50b180 task.stack: ffff00000d5d0000
> [115946.244717] PC is at sas_find_dev_by_rphy+0x44/0x114
> [115946.250224] LR is at sas_find_dev_by_rphy+0x3c/0x114
> ......
> [115946.355701] Process kworker/0:1 (pid: 22175, stack limit = 0xffff00000d5d0000)
> [115946.363369] Call trace:
> [115946.456356] [<ffff000008878a9c>] sas_find_dev_by_rphy+0x44/0x114
> [115946.462908] [<ffff000008878b8c>] sas_target_alloc+0x20/0x5c
> [115946.469408] [<ffff00000885a31c>] scsi_alloc_target+0x250/0x308
> [115946.475781] [<ffff00000885ba30>] __scsi_add_device+0xb0/0x154
> [115946.481991] [<ffff0000088b520c>] ata_scsi_scan_host+0x180/0x218
> [115946.488367] [<ffff0000088b53d8>] ata_scsi_hotplug+0xb0/0xcc
> [115946.494801] [<ffff0000080ebd70>] process_one_work+0x144/0x390
> [115946.501115] [<ffff0000080ec100>] worker_thread+0x144/0x418
> [115946.507093] [<ffff0000080f2c98>] kthread+0x10c/0x138
> [115946.512792] [<ffff0000080855dc>] ret_from_fork+0x10/0x18
> 
> We found that Ding Xiang has reported a similar bug before:
> https://patchwork.kernel.org/patch/9179817/
> 
> And this bug still exists in mainline. Since libsas handles hotplug and
> device adding/removing itself, do not need to schedule ata hot plug task
> here if it is a sas host.
> 
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> Cc: Ding Xiang <dingxiang@huawei.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Tejun Heo <tj@kernel.org>
> (cherry picked from commit 6f54120e17e311fd7ac42b9ec2a0611caa5b46ad)
> Signed-off-by: dann frazier <dann.frazier@canonical.com>
> ---
>  drivers/ata/libata-eh.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index 11c3137d7b0a..c016829a38fd 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -815,7 +815,8 @@ void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
>  
>  	if (ap->pflags & ATA_PFLAG_LOADING)
>  		ap->pflags &= ~ATA_PFLAG_LOADING;
> -	else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
> +	else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) &&
> +		!(ap->flags & ATA_FLAG_SAS_HOST))
>  		schedule_delayed_work(&ap->hotplug_task, 0);
>  
>  	if (ap->pflags & ATA_PFLAG_RECOVERED)
> 

Hi Dann,

Just for documentation purpose, could you please update the bug
description to add a "[Fix]" section describing briefly why this patch
fixes the issue?

Otherwise it looks good:

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>


Thanks,
Kleber
dann frazier May 8, 2018, 9:31 p.m. UTC | #2
On Tue, May 8, 2018 at 8:57 AM, Kleber Souza <kleber.souza@canonical.com> wrote:
> On 05/03/18 22:06, dann frazier wrote:
>> From: Jason Yan <yanaijie@huawei.com>
>>
>> BugLink: https://bugs.launchpad.net/bugs/1768948
>>
>> We've got a kernel panic when using sata disk with sas controller:
>>
>> [115946.152283] Unable to handle kernel NULL pointer dereference at virtual address 000007d8
>> [115946.223963] CPU: 0 PID: 22175 Comm: kworker/0:1 Tainted: G   W OEL  4.14.0 #1
>> [115946.232925] Workqueue: events ata_scsi_hotplug
>> [115946.237938] task: ffff8021ee50b180 task.stack: ffff00000d5d0000
>> [115946.244717] PC is at sas_find_dev_by_rphy+0x44/0x114
>> [115946.250224] LR is at sas_find_dev_by_rphy+0x3c/0x114
>> ......
>> [115946.355701] Process kworker/0:1 (pid: 22175, stack limit = 0xffff00000d5d0000)
>> [115946.363369] Call trace:
>> [115946.456356] [<ffff000008878a9c>] sas_find_dev_by_rphy+0x44/0x114
>> [115946.462908] [<ffff000008878b8c>] sas_target_alloc+0x20/0x5c
>> [115946.469408] [<ffff00000885a31c>] scsi_alloc_target+0x250/0x308
>> [115946.475781] [<ffff00000885ba30>] __scsi_add_device+0xb0/0x154
>> [115946.481991] [<ffff0000088b520c>] ata_scsi_scan_host+0x180/0x218
>> [115946.488367] [<ffff0000088b53d8>] ata_scsi_hotplug+0xb0/0xcc
>> [115946.494801] [<ffff0000080ebd70>] process_one_work+0x144/0x390
>> [115946.501115] [<ffff0000080ec100>] worker_thread+0x144/0x418
>> [115946.507093] [<ffff0000080f2c98>] kthread+0x10c/0x138
>> [115946.512792] [<ffff0000080855dc>] ret_from_fork+0x10/0x18
>>
>> We found that Ding Xiang has reported a similar bug before:
>> https://patchwork.kernel.org/patch/9179817/
>>
>> And this bug still exists in mainline. Since libsas handles hotplug and
>> device adding/removing itself, do not need to schedule ata hot plug task
>> here if it is a sas host.
>>
>> Signed-off-by: Jason Yan <yanaijie@huawei.com>
>> Cc: Ding Xiang <dingxiang@huawei.com>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Tejun Heo <tj@kernel.org>
>> (cherry picked from commit 6f54120e17e311fd7ac42b9ec2a0611caa5b46ad)
>> Signed-off-by: dann frazier <dann.frazier@canonical.com>
>> ---
>>  drivers/ata/libata-eh.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
>> index 11c3137d7b0a..c016829a38fd 100644
>> --- a/drivers/ata/libata-eh.c
>> +++ b/drivers/ata/libata-eh.c
>> @@ -815,7 +815,8 @@ void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
>>
>>       if (ap->pflags & ATA_PFLAG_LOADING)
>>               ap->pflags &= ~ATA_PFLAG_LOADING;
>> -     else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
>> +     else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) &&
>> +             !(ap->flags & ATA_FLAG_SAS_HOST))
>>               schedule_delayed_work(&ap->hotplug_task, 0);
>>
>>       if (ap->pflags & ATA_PFLAG_RECOVERED)
>>
>
> Hi Dann,
>
> Just for documentation purpose, could you please update the bug
> description to add a "[Fix]" section describing briefly why this patch
> fixes the issue?

Done.

> Otherwise it looks good:
>
> Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

Thanks!

  -dann
Stefan Bader May 22, 2018, 5:04 p.m. UTC | #3
On 03.05.2018 22:06, dann frazier wrote:
> From: Jason Yan <yanaijie@huawei.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1768948
> 
> We've got a kernel panic when using sata disk with sas controller:
> 
> [115946.152283] Unable to handle kernel NULL pointer dereference at virtual address 000007d8
> [115946.223963] CPU: 0 PID: 22175 Comm: kworker/0:1 Tainted: G   W OEL  4.14.0 #1
> [115946.232925] Workqueue: events ata_scsi_hotplug
> [115946.237938] task: ffff8021ee50b180 task.stack: ffff00000d5d0000
> [115946.244717] PC is at sas_find_dev_by_rphy+0x44/0x114
> [115946.250224] LR is at sas_find_dev_by_rphy+0x3c/0x114
> ......
> [115946.355701] Process kworker/0:1 (pid: 22175, stack limit = 0xffff00000d5d0000)
> [115946.363369] Call trace:
> [115946.456356] [<ffff000008878a9c>] sas_find_dev_by_rphy+0x44/0x114
> [115946.462908] [<ffff000008878b8c>] sas_target_alloc+0x20/0x5c
> [115946.469408] [<ffff00000885a31c>] scsi_alloc_target+0x250/0x308
> [115946.475781] [<ffff00000885ba30>] __scsi_add_device+0xb0/0x154
> [115946.481991] [<ffff0000088b520c>] ata_scsi_scan_host+0x180/0x218
> [115946.488367] [<ffff0000088b53d8>] ata_scsi_hotplug+0xb0/0xcc
> [115946.494801] [<ffff0000080ebd70>] process_one_work+0x144/0x390
> [115946.501115] [<ffff0000080ec100>] worker_thread+0x144/0x418
> [115946.507093] [<ffff0000080f2c98>] kthread+0x10c/0x138
> [115946.512792] [<ffff0000080855dc>] ret_from_fork+0x10/0x18
> 
> We found that Ding Xiang has reported a similar bug before:
> https://patchwork.kernel.org/patch/9179817/
> 
> And this bug still exists in mainline. Since libsas handles hotplug and
> device adding/removing itself, do not need to schedule ata hot plug task
> here if it is a sas host.
> 
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> Cc: Ding Xiang <dingxiang@huawei.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Tejun Heo <tj@kernel.org>
> (cherry picked from commit 6f54120e17e311fd7ac42b9ec2a0611caa5b46ad)
> Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>

> ---
>  drivers/ata/libata-eh.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index 11c3137d7b0a..c016829a38fd 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -815,7 +815,8 @@ void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
>  
>  	if (ap->pflags & ATA_PFLAG_LOADING)
>  		ap->pflags &= ~ATA_PFLAG_LOADING;
> -	else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
> +	else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) &&
> +		!(ap->flags & ATA_FLAG_SAS_HOST))
>  		schedule_delayed_work(&ap->hotplug_task, 0);
>  
>  	if (ap->pflags & ATA_PFLAG_RECOVERED)
>
Stefan Bader May 23, 2018, 9:04 a.m. UTC | #4
Applied to bionic master-next.

-Stefan
diff mbox series

Patch

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 11c3137d7b0a..c016829a38fd 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -815,7 +815,8 @@  void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
 
 	if (ap->pflags & ATA_PFLAG_LOADING)
 		ap->pflags &= ~ATA_PFLAG_LOADING;
-	else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
+	else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) &&
+		!(ap->flags & ATA_FLAG_SAS_HOST))
 		schedule_delayed_work(&ap->hotplug_task, 0);
 
 	if (ap->pflags & ATA_PFLAG_RECOVERED)