scsi: cxlflash: Yield to active send threads
authorUma Krishnan <ukrishn@linux.vnet.ibm.com>
Fri, 11 May 2018 19:04:46 +0000 (14:04 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 18 May 2018 15:22:09 +0000 (11:22 -0400)
commite0f76ad13085b730091256d7a2fbe3555f0686df
treeff6b5ef200605aa31ba0f54e16a5fed2d3320524
parent2f6bca202b78e2b63a62b46ff5dc26f300785e23
scsi: cxlflash: Yield to active send threads

The following Oops may be encountered if the device is reset, i.e. EEH
recovery, while there is heavy I/O traffic:

59:mon> t
[c000200db64bb680c008000009264c40 cxlflash_queuecommand+0x3b8/0x500
[cxlflash]
[c000200db64bb770c00000000090d3b0 scsi_dispatch_cmd+0x130/0x2f0
[c000200db64bb7f0c00000000090fdd8 scsi_request_fn+0x3c8/0x8d0
[c000200db64bb900c00000000067f528 __blk_run_queue+0x68/0xb0
[c000200db64bb930c00000000067ab80 __elv_add_request+0x140/0x3c0
[c000200db64bb9b0c00000000068daac blk_execute_rq_nowait+0xec/0x1a0
[c000200db64bba00c00000000068dbb0 blk_execute_rq+0x50/0xe0
[c000200db64bba50c0000000006b2040 sg_io+0x1f0/0x520
[c000200db64bbaf0c0000000006b2e94 scsi_cmd_ioctl+0x534/0x610
[c000200db64bbc20c000000000926208 sd_ioctl+0x118/0x280
[c000200db64bbcc0c00000000069f7ac blkdev_ioctl+0x7fc/0xe30
[c000200db64bbd20c000000000439204 block_ioctl+0x84/0xa0
[c000200db64bbd40c0000000003f8514 do_vfs_ioctl+0xd4/0xa00
[c000200db64bbde0c0000000003f8f04 SyS_ioctl+0xc4/0x130
[c000200db64bbe30c00000000000b184 system_call+0x58/0x6c

When there is no room to send the I/O request, the cached room is refreshed
by reading the memory mapped command room value from the AFU. The AFU
register mapping is refreshed during a reset, creating a race condition that
can lead to the Oops above.

During a device reset, the AFU should not be unmapped until all the active
send threads quiesce. An atomic counter, cmds_active, is currently used to
track internal AFU commands and quiesce during reset. This same counter can
also be used for the active send threads.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/cxlflash/main.c