diff mbox series

[08/11] aacraid: use scsi_host_quiesce() to wait for I/O to complete

Message ID 20191120103114.24723-9-hare@suse.de (mailing list archive)
State Superseded
Headers show
Series scsi: remove legacy cmd_list implementation | expand

Commit Message

Hannes Reinecke Nov. 20, 2019, 10:31 a.m. UTC
Instead of waiting for all I/O to complete by monitoring the
request tags we can as well call scsi_host_quiesce() and drop
the hand-crafted helpers.

Cc: Balsundar P <balsundar.p@microsemi.com>
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/aacraid/comminit.c | 35 ++---------------------------------
 1 file changed, 2 insertions(+), 33 deletions(-)

Comments

Bart Van Assche Nov. 20, 2019, 4:23 p.m. UTC | #1
On 11/20/19 2:31 AM, Hannes Reinecke wrote:
> Instead of waiting for all I/O to complete by monitoring the
> request tags we can as well call scsi_host_quiesce() and drop
> the hand-crafted helpers.
> 
> Cc: Balsundar P <balsundar.p@microsemi.com>
> Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/aacraid/comminit.c | 35 ++---------------------------------
>   1 file changed, 2 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
> index f75878d773cf..a01dca86eb37 100644
> --- a/drivers/scsi/aacraid/comminit.c
> +++ b/drivers/scsi/aacraid/comminit.c
> @@ -272,38 +272,6 @@ static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem,
>   	q->entries = qsize;
>   }
>   
> -static void aac_wait_for_io_completion(struct aac_dev *aac)
> -{
> -	unsigned long flagv = 0;
> -	int i = 0;
> -
> -	for (i = 60; i; --i) {
> -		struct scsi_device *dev;
> -		struct scsi_cmnd *command;
> -		int active = 0;
> -
> -		__shost_for_each_device(dev, aac->scsi_host_ptr) {
> -			spin_lock_irqsave(&dev->list_lock, flagv);
> -			list_for_each_entry(command, &dev->cmd_list, list) {
> -				if (command->SCp.phase == AAC_OWNER_FIRMWARE) {
> -					active++;
> -					break;
> -				}
> -			}
> -			spin_unlock_irqrestore(&dev->list_lock, flagv);
> -			if (active)
> -				break;
> -
> -		}
> -		/*
> -		 * We can exit If all the commands are complete
> -		 */
> -		if (active == 0)
> -			break;
> -		ssleep(1);
> -	}
> -}
> -
>   /**
>    *	aac_send_shutdown		-	shutdown an adapter
>    *	@dev: Adapter to shutdown
> @@ -326,7 +294,7 @@ int aac_send_shutdown(struct aac_dev * dev)
>   		mutex_unlock(&dev->ioctl_mutex);
>   	}
>   
> -	aac_wait_for_io_completion(dev);
> +	scsi_host_quiesce(dev->scsi_host_ptr);
>   
>   	fibctx = aac_fib_alloc(dev);
>   	if (!fibctx)
> @@ -352,6 +320,7 @@ int aac_send_shutdown(struct aac_dev * dev)
>   	if (aac_is_src(dev) &&
>   	     dev->msi_enabled)
>   		aac_set_intx_mode(dev);
> +	scsi_host_resume(dev->scsi_host_ptr);
>   	return status;
>   }

Can aac_wait_for_io_completion() be called from inside the aacraid SCSI 
host reset handler? Is it safe to call scsi_host_quiesce() from inside a 
host reset handler? Sorry that I sent you in the wrong direction with a 
previous comment.

Bart.
Balsundar.P@microchip.com Nov. 26, 2019, 8:29 a.m. UTC | #2
Thanks, Hannes
We are in the process of reviewing patches and will get back to you on this shortly

-----Original Message-----
From: Hannes Reinecke <hare@suse.de> 
Sent: Wednesday, November 20, 2019 16:01
To: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>; James Bottomley <james.bottomley@hansenpartnership.com>; linux-scsi@vger.kernel.org; Hannes Reinecke <hare@suse.de>; Balsundar P <balsundar.p@microsemi.com>; Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Subject: [PATCH 08/11] aacraid: use scsi_host_quiesce() to wait for I/O to complete

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Instead of waiting for all I/O to complete by monitoring the request tags we can as well call scsi_host_quiesce() and drop the hand-crafted helpers.

Cc: Balsundar P <balsundar.p@microsemi.com>
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/aacraid/comminit.c | 35 ++---------------------------------
 1 file changed, 2 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index f75878d773cf..a01dca86eb37 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -272,38 +272,6 @@ static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem,
        q->entries = qsize;
 }

-static void aac_wait_for_io_completion(struct aac_dev *aac) -{
-       unsigned long flagv = 0;
-       int i = 0;
-
-       for (i = 60; i; --i) {
-               struct scsi_device *dev;
-               struct scsi_cmnd *command;
-               int active = 0;
-
-               __shost_for_each_device(dev, aac->scsi_host_ptr) {
-                       spin_lock_irqsave(&dev->list_lock, flagv);
-                       list_for_each_entry(command, &dev->cmd_list, list) {
-                               if (command->SCp.phase == AAC_OWNER_FIRMWARE) {
-                                       active++;
-                                       break;
-                               }
-                       }
-                       spin_unlock_irqrestore(&dev->list_lock, flagv);
-                       if (active)
-                               break;
-
-               }
-               /*
-                * We can exit If all the commands are complete
-                */
-               if (active == 0)
-                       break;
-               ssleep(1);
-       }
-}
-
 /**
  *     aac_send_shutdown               -       shutdown an adapter
  *     @dev: Adapter to shutdown
@@ -326,7 +294,7 @@ int aac_send_shutdown(struct aac_dev * dev)
                mutex_unlock(&dev->ioctl_mutex);
        }

-       aac_wait_for_io_completion(dev);
+       scsi_host_quiesce(dev->scsi_host_ptr);

        fibctx = aac_fib_alloc(dev);
        if (!fibctx)
@@ -352,6 +320,7 @@ int aac_send_shutdown(struct aac_dev * dev)
        if (aac_is_src(dev) &&
             dev->msi_enabled)
                aac_set_intx_mode(dev);
+       scsi_host_resume(dev->scsi_host_ptr);
        return status;
 }

--
2.16.4
Balsundar.P@microchip.com Nov. 28, 2019, 11:45 a.m. UTC | #3
NAK

After applying this patch, while IOs were running on physical drive, 
issued controller reset from management utility.
Observed below call trace. It is from scsi_device_quiesce().

Nov 27 19:24:21 ubuntu kernel: [ 1330.799311] INFO: task arcconf:2386 blocked for more than 120 seconds.
Nov 27 19:24:21 ubuntu kernel: [ 1330.799841]       Not tainted 5.4.0-rc1+ #2
Nov 27 19:24:21 ubuntu kernel: [ 1330.800235] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Nov 27 19:24:21 ubuntu kernel: [ 1330.800678] arcconf         D    0  2386   2173 0x00004000
Nov 27 19:24:21 ubuntu kernel: [ 1330.800682] Call Trace:
Nov 27 19:24:21 ubuntu kernel: [ 1330.800699]  __schedule+0x291/0x6f0
Nov 27 19:24:21 ubuntu kernel: [ 1330.800703]  schedule+0x33/0xa0
Nov 27 19:24:21 ubuntu kernel: [ 1330.800710]  blk_mq_freeze_queue_wait+0x4b/0xb0
Nov 27 19:24:21 ubuntu kernel: [ 1330.800717]  ? wait_woken+0x80/0x80
Nov 27 19:24:21 ubuntu kernel: [ 1330.800721]  blk_mq_freeze_queue+0x1a/0x20
Nov 27 19:24:21 ubuntu kernel: [ 1330.800727]  scsi_device_quiesce+0x5d/0xb0
Nov 27 19:24:21 ubuntu kernel: [ 1330.800730]  scsi_host_quiesce+0x41/0x60
Nov 27 19:24:21 ubuntu kernel: [ 1330.800742]  aac_send_shutdown+0x7c/0x180 [aacraid]
Nov 27 19:24:21 ubuntu kernel: [ 1330.800749]  aac_reset_adapter+0x29f/0x760 [aacraid]
Nov 27 19:24:21 ubuntu kernel: [ 1330.800757]  ? security_capable+0x3f/0x60
Nov 27 19:24:21 ubuntu kernel: [ 1330.800762]  aac_store_reset_adapter+0x41/0x60 [aacraid]
Nov 27 19:24:21 ubuntu kernel: [ 1330.800770]  dev_attr_store+0x17/0x30
Nov 27 19:24:21 ubuntu kernel: [ 1330.800777]  sysfs_kf_write+0x3c/0x50
Nov 27 19:24:21 ubuntu kernel: [ 1330.800779]  kernfs_fop_write+0x125/0x1a0
Nov 27 19:24:21 ubuntu kernel: [ 1330.800785]  __vfs_write+0x1b/0x40
Nov 27 19:24:21 ubuntu kernel: [ 1330.800789]  vfs_write+0xb1/0x1a0
Nov 27 19:24:21 ubuntu kernel: [ 1330.800792]  ksys_write+0xa7/0xe0
Nov 27 19:24:21 ubuntu kernel: [ 1330.800795]  __x64_sys_write+0x1a/0x20
Nov 27 19:24:21 ubuntu kernel: [ 1330.800802]  do_syscall_64+0x57/0x190
Nov 27 19:24:21 ubuntu kernel: [ 1330.800806]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
Nov 27 19:24:21 ubuntu kernel: [ 1330.800810] RIP: 0033:0x7f67cfb7c2b7
Nov 27 19:24:21 ubuntu kernel: [ 1330.800819] Code: Bad RIP value.
Nov 27 19:24:21 ubuntu kernel: [ 1330.800821] RSP: 002b:00007ffeb23ca8c0 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
Nov 27 19:24:21 ubuntu kernel: [ 1330.800823] RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 00007f67cfb7c2b7
Nov 27 19:24:21 ubuntu kernel: [ 1330.800825] RDX: 0000000000000002 RSI: 00007ffeb23ca8f0 RDI: 0000000000000006
Nov 27 19:24:21 ubuntu kernel: [ 1330.800826] RBP: 00007ffeb23ca8f0 R08: 0000000000000000 R09: 0000000000000000
Nov 27 19:24:21 ubuntu kernel: [ 1330.800828] R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000002
Nov 27 19:24:21 ubuntu kernel: [ 1330.800829] R13: 00007ffeb23cad20 R14: 00007ffeb23cadf0 R15: 00007ffeb23cac60

-----Original Message-----
From: Hannes Reinecke <hare@suse.de> 
Sent: Wednesday, November 20, 2019 16:01
To: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>; James Bottomley <james.bottomley@hansenpartnership.com>; linux-scsi@vger.kernel.org; Hannes Reinecke <hare@suse.de>; Balsundar P <balsundar.p@microsemi.com>; Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Subject: [PATCH 08/11] aacraid: use scsi_host_quiesce() to wait for I/O to complete

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Instead of waiting for all I/O to complete by monitoring the request tags we can as well call scsi_host_quiesce() and drop the hand-crafted helpers.

Cc: Balsundar P <balsundar.p@microsemi.com>
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/aacraid/comminit.c | 35 ++---------------------------------
 1 file changed, 2 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index f75878d773cf..a01dca86eb37 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -272,38 +272,6 @@ static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem,
        q->entries = qsize;
 }

-static void aac_wait_for_io_completion(struct aac_dev *aac) -{
-       unsigned long flagv = 0;
-       int i = 0;
-
-       for (i = 60; i; --i) {
-               struct scsi_device *dev;
-               struct scsi_cmnd *command;
-               int active = 0;
-
-               __shost_for_each_device(dev, aac->scsi_host_ptr) {
-                       spin_lock_irqsave(&dev->list_lock, flagv);
-                       list_for_each_entry(command, &dev->cmd_list, list) {
-                               if (command->SCp.phase == AAC_OWNER_FIRMWARE) {
-                                       active++;
-                                       break;
-                               }
-                       }
-                       spin_unlock_irqrestore(&dev->list_lock, flagv);
-                       if (active)
-                               break;
-
-               }
-               /*
-                * We can exit If all the commands are complete
-                */
-               if (active == 0)
-                       break;
-               ssleep(1);
-       }
-}
-
 /**
  *     aac_send_shutdown               -       shutdown an adapter
  *     @dev: Adapter to shutdown
@@ -326,7 +294,7 @@ int aac_send_shutdown(struct aac_dev * dev)
                mutex_unlock(&dev->ioctl_mutex);
        }

-       aac_wait_for_io_completion(dev);
+       scsi_host_quiesce(dev->scsi_host_ptr);

        fibctx = aac_fib_alloc(dev);
        if (!fibctx)
@@ -352,6 +320,7 @@ int aac_send_shutdown(struct aac_dev * dev)
        if (aac_is_src(dev) &&
             dev->msi_enabled)
                aac_set_intx_mode(dev);
+       scsi_host_resume(dev->scsi_host_ptr);
        return status;
 }

--
2.16.4
Hannes Reinecke Nov. 28, 2019, 12:09 p.m. UTC | #4
On 11/28/19 12:45 PM, Balsundar.P@microchip.com wrote:
> NAK
> 
> After applying this patch, while IOs were running on physical drive, 
> issued controller reset from management utility.
> Observed below call trace. It is from scsi_device_quiesce().
> 
> Nov 27 19:24:21 ubuntu kernel: [ 1330.799311] INFO: task arcconf:2386 blocked for more than 120 seconds.
> Nov 27 19:24:21 ubuntu kernel: [ 1330.799841]       Not tainted 5.4.0-rc1+ #2
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800235] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800678] arcconf         D    0  2386   2173 0x00004000
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800682] Call Trace:
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800699]  __schedule+0x291/0x6f0
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800703]  schedule+0x33/0xa0
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800710]  blk_mq_freeze_queue_wait+0x4b/0xb0
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800717]  ? wait_woken+0x80/0x80
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800721]  blk_mq_freeze_queue+0x1a/0x20
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800727]  scsi_device_quiesce+0x5d/0xb0
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800730]  scsi_host_quiesce+0x41/0x60
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800742]  aac_send_shutdown+0x7c/0x180 [aacraid]
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800749]  aac_reset_adapter+0x29f/0x760 [aacraid]
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800757]  ? security_capable+0x3f/0x60
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800762]  aac_store_reset_adapter+0x41/0x60 [aacraid]
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800770]  dev_attr_store+0x17/0x30
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800777]  sysfs_kf_write+0x3c/0x50
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800779]  kernfs_fop_write+0x125/0x1a0
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800785]  __vfs_write+0x1b/0x40
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800789]  vfs_write+0xb1/0x1a0
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800792]  ksys_write+0xa7/0xe0
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800795]  __x64_sys_write+0x1a/0x20
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800802]  do_syscall_64+0x57/0x190
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800806]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800810] RIP: 0033:0x7f67cfb7c2b7
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800819] Code: Bad RIP value.
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800821] RSP: 002b:00007ffeb23ca8c0 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800823] RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 00007f67cfb7c2b7
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800825] RDX: 0000000000000002 RSI: 00007ffeb23ca8f0 RDI: 0000000000000006
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800826] RBP: 00007ffeb23ca8f0 R08: 0000000000000000 R09: 0000000000000000
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800828] R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000002
> Nov 27 19:24:21 ubuntu kernel: [ 1330.800829] R13: 00007ffeb23cad20 R14: 00007ffeb23cadf0 R15: 00007ffeb23cac60
> 
Thanks for testing.
I'll have a look at the call trace and will come back to you with an
updated version.

Cheers,

Hannes
Hannes Reinecke Dec. 4, 2019, 3:02 p.m. UTC | #5
On 11/28/19 1:09 PM, Hannes Reinecke wrote:
> On 11/28/19 12:45 PM, Balsundar.P@microchip.com wrote:
>> NAK
>>
>> After applying this patch, while IOs were running on physical drive, 
>> issued controller reset from management utility.
>> Observed below call trace. It is from scsi_device_quiesce().
>>
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.799311] INFO: task arcconf:2386 blocked for more than 120 seconds.
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.799841]       Not tainted 5.4.0-rc1+ #2
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800235] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800678] arcconf         D    0  2386   2173 0x00004000
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800682] Call Trace:
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800699]  __schedule+0x291/0x6f0
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800703]  schedule+0x33/0xa0
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800710]  blk_mq_freeze_queue_wait+0x4b/0xb0
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800717]  ? wait_woken+0x80/0x80
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800721]  blk_mq_freeze_queue+0x1a/0x20
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800727]  scsi_device_quiesce+0x5d/0xb0
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800730]  scsi_host_quiesce+0x41/0x60
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800742]  aac_send_shutdown+0x7c/0x180 [aacraid]
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800749]  aac_reset_adapter+0x29f/0x760 [aacraid]
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800757]  ? security_capable+0x3f/0x60
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800762]  aac_store_reset_adapter+0x41/0x60 [aacraid]
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800770]  dev_attr_store+0x17/0x30
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800777]  sysfs_kf_write+0x3c/0x50
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800779]  kernfs_fop_write+0x125/0x1a0
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800785]  __vfs_write+0x1b/0x40
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800789]  vfs_write+0xb1/0x1a0
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800792]  ksys_write+0xa7/0xe0
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800795]  __x64_sys_write+0x1a/0x20
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800802]  do_syscall_64+0x57/0x190
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800806]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800810] RIP: 0033:0x7f67cfb7c2b7
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800819] Code: Bad RIP value.
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800821] RSP: 002b:00007ffeb23ca8c0 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800823] RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 00007f67cfb7c2b7
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800825] RDX: 0000000000000002 RSI: 00007ffeb23ca8f0 RDI: 0000000000000006
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800826] RBP: 00007ffeb23ca8f0 R08: 0000000000000000 R09: 0000000000000000
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800828] R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000002
>> Nov 27 19:24:21 ubuntu kernel: [ 1330.800829] R13: 00007ffeb23cad20 R14: 00007ffeb23cadf0 R15: 00007ffeb23cac60
>>
> Thanks for testing.
> I'll have a look at the call trace and will come back to you with an
> updated version.
> 
After testing I've discovered that we can't use freeze_queue here.
Point is, when resetting the HBA there will be commands outstanding
(which will keep the q_usage_counter to non-zero), but we should _not_
terminate those commands as I/O processing will be resumed after reset.
Hence the blk_mq_freeze_queue_wait() will never complete.

So for the next iteration I've reverted back to use a busy iterator, as
we just need to complete the commands currently held by the firmware;
all other commands can (and should) be left alone.

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index f75878d773cf..a01dca86eb37 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -272,38 +272,6 @@  static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem,
 	q->entries = qsize;
 }
 
-static void aac_wait_for_io_completion(struct aac_dev *aac)
-{
-	unsigned long flagv = 0;
-	int i = 0;
-
-	for (i = 60; i; --i) {
-		struct scsi_device *dev;
-		struct scsi_cmnd *command;
-		int active = 0;
-
-		__shost_for_each_device(dev, aac->scsi_host_ptr) {
-			spin_lock_irqsave(&dev->list_lock, flagv);
-			list_for_each_entry(command, &dev->cmd_list, list) {
-				if (command->SCp.phase == AAC_OWNER_FIRMWARE) {
-					active++;
-					break;
-				}
-			}
-			spin_unlock_irqrestore(&dev->list_lock, flagv);
-			if (active)
-				break;
-
-		}
-		/*
-		 * We can exit If all the commands are complete
-		 */
-		if (active == 0)
-			break;
-		ssleep(1);
-	}
-}
-
 /**
  *	aac_send_shutdown		-	shutdown an adapter
  *	@dev: Adapter to shutdown
@@ -326,7 +294,7 @@  int aac_send_shutdown(struct aac_dev * dev)
 		mutex_unlock(&dev->ioctl_mutex);
 	}
 
-	aac_wait_for_io_completion(dev);
+	scsi_host_quiesce(dev->scsi_host_ptr);
 
 	fibctx = aac_fib_alloc(dev);
 	if (!fibctx)
@@ -352,6 +320,7 @@  int aac_send_shutdown(struct aac_dev * dev)
 	if (aac_is_src(dev) &&
 	     dev->msi_enabled)
 		aac_set_intx_mode(dev);
+	scsi_host_resume(dev->scsi_host_ptr);
 	return status;
 }