• Xiang Chen's avatar
    scsi: hisi_sas: Replace in_softirq() check in hisi_sas_task_exec() · 550c0d89
    Xiang Chen authored
    For IOs from upper layer, preemption may be disabled as it may be called by
    function __blk_mq_delay_run_hw_queue which will call get_cpu() (it disables
    preemption). So if flags HISI_SAS_REJECT_CMD_BIT is set in function
    hisi_sas_task_exec(), it may disable preempt twice after down() and up()
    which will cause following call trace:
    
    BUG: scheduling while atomic: fio/60373/0x00000002
    Call trace:
    dump_backtrace+0x0/0x150
    show_stack+0x24/0x30
    dump_stack+0xa0/0xc4
    __schedule_bug+0x68/0x88
    __schedule+0x4b8/0x548
    schedule+0x40/0xd0
    schedule_timeout+0x200/0x378
    __down+0x78/0xc8
    down+0x54/0x70
    hisi_sas_task_exec.isra.10+0x598/0x8d8 [hisi_sas_main]
    hisi_sas_queue_command+0x28/0x38 [hisi_sas_main]
    sas_queuecommand+0x168/0x1b0 [libsas]
    scsi_queue_rq+0x2ac/0x980
    blk_mq_dispatch_rq_list+0xb0/0x550
    blk_mq_do_dispatch_sched+0x6c/0x110
    blk_mq_sched_dispatch_requests+0x114/0x1d8
    __blk_mq_run_hw_queue+0xb8/0x130
    __blk_mq_delay_run_hw_queue+0x1c0/0x220
    blk_mq_run_hw_queue+0xb0/0x128
    blk_mq_sched_insert_requests+0xdc/0x208
    blk_mq_flush_plug_list+0x1b4/0x3a0
    blk_flush_plug_list+0xdc/0x110
    blk_finish_plug+0x3c/0x50
    blkdev_direct_IO+0x404/0x550
    generic_file_read_iter+0x9c/0x848
    blkdev_read_iter+0x50/0x78
    aio_read+0xc8/0x170
    io_submit_one+0x1fc/0x8d8
    __arm64_sys_io_submit+0xdc/0x280
    el0_svc_common.constprop.0+0xe0/0x1e0
    el0_svc_handler+0x34/0x90
    el0_svc+0x10/0x14
    ...
    
    To solve the issue, check preemptible() to avoid disabling preempt multiple
    when flag HISI_SAS_REJECT_CMD_BIT is set.
    
    Link: https://lore.kernel.org/r/1571926105-74636-5-git-send-email-john.garry@huawei.comSigned-off-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
    Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    550c0d89
hisi_sas_main.c 101 KB