1. 29 Apr, 2019 21 commits
  2. 19 Apr, 2019 5 commits
  3. 16 Apr, 2019 14 commits
    • Li Zhong's avatar
      scsi: core: map PQ=1, PDT=other values to SCSI_SCAN_TARGET_PRESENT · 948e922f
      Li Zhong authored
      commit 84961f28 ("[SCSI] Don't add scsi_device for devices that return
      PQ=1, PDT=0x1f") returns SCSI_SCAN_TARGET_PRESENT if inquiry returns PQ=1,
      and PDT = 0x1f. However, from the scsi spec, it seemed setting PQ=1, and
      PDT to the type it is capable to support, can also mean the device is not
      connected. E.g. we see an IBM/2145 returns PQ=1 and PDT=0 for a non-mapped
      lun (details attached at the end).
      
      This patch changes the check condition a bit, so the check don't require
      PTD to be 0x1f when PQ=1.
      
      $ echo 0 0 1 > /sys/class/scsi_host/host1/scan
      [ 2483.722186] scsi 1:0:0:1: scsi scan: INQUIRY pass 1 length 36
      [ 2483.725687] scsi 1:0:0:1: scsi scan: INQUIRY successful with code 0x0
      [ 2483.729171] scsi 1:0:0:1: scsi scan: INQUIRY pass 2 length 109
      [ 2483.732481] scsi 1:0:0:1: scsi scan: INQUIRY successful with code 0x0
      [ 2483.735911] scsi 1:0:0:1: Direct-Access     IBM      2145             0000 PQ: 1 ANSI: 6
      [ 2483.741282] scsi 1:0:0:1: Attached scsi generic sg2 type 0
      
      $ tail /proc/scsi/scsi
      Attached devices:
      Host: scsi1 Channel: 00 Id: 00 Lun: 00
        Vendor: IBM      Model: 2145             Rev: 0000
        Type:   Direct-Access                    ANSI  SCSI revision: 06
      Host: scsi0 Channel: 00 Id: 00 Lun: 00
        Vendor: IBM      Model: 2145             Rev: 0000
        Type:   Direct-Access                    ANSI  SCSI revision: 06
      Host: scsi1 Channel: 00 Id: 00 Lun: 01
        Vendor: IBM      Model: 2145             Rev: 0000
        Type:   Direct-Access                    ANSI  SCSI revision: 06
      
      $ lsscsi
      [0:0:0:0]    disk    IBM      2145             0000  /dev/sdb
      [1:0:0:0]    disk    IBM      2145             0000  /dev/sda
      [1:0:0:1]    disk    IBM      2145             0000  -
      Signed-off-by: default avatarLi Zhong <lizhongfs@gmail.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      948e922f
    • YueHaibing's avatar
      scsi: megaraid_sas: Make megasas_host_device_list_query() static · 7c3f8ca8
      YueHaibing authored
      Fix sparse warning:
      
      drivers/scsi/megaraid/megaraid_sas_base.c:4652:1: warning:
       symbol 'megasas_host_device_list_query' was not declared. Should it be static?
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      7c3f8ca8
    • Stanley Chu's avatar
      scsi: ufs: Print real incorrect request response code · e0347d89
      Stanley Chu authored
      If UFS device responds an unknown request response code, we can not know
      what it was via logs because the code is replaced by "DID_ERROR << 16"
      before log printing.
      
      Fix this to provide precise request response code information for easier
      issue breakdown.
      Signed-off-by: default avatarStanley Chu <stanley.chu@mediatek.com>
      Reviewed-by: default avatarTomas Winkler <tomas.winkler@intel.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      e0347d89
    • Varun Prakash's avatar
    • Varun Prakash's avatar
      scsi: libcxgbi: update route finding logic · 74dea0be
      Varun Prakash authored
      To support vlan and bridge devices first find route using ifindex 0, if
      route is not found through net device associated with input scsi host then
      find route using ifindex of net device.
      Signed-off-by: default avatarVarun Prakash <varun@chelsio.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      74dea0be
    • Varun Prakash's avatar
      scsi: libcxgbi: find cxgbi device by MAC address · ffcd686b
      Varun Prakash authored
      If cxgbi_device_find_by_netdev() returns NULL then find cxgbi device by MAC
      address.
      Signed-off-by: default avatarVarun Prakash <varun@chelsio.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      ffcd686b
    • Ming Lei's avatar
      scsi: core: don't hold device refcount in IO path · 18c4f0a4
      Ming Lei authored
      scsi_device's refcount is always grabbed in IO path.
      
      Turns out it isn't necessary, because blk_queue_cleanup() will drain any
      in-flight IOs, then cancel timeout/requeue work, and SCSI's requeue_work is
      canceled too in __scsi_remove_device().
      
      Also scsi_device won't go away until blk_cleanup_queue() is done.
      
      So don't hold the refcount in IO path, especially the refcount isn't
      required in IO path since blk_queue_enter() / blk_queue_exit() is
      introduced in the legacy block layer.
      
      Cc: Dongli Zhang <dongli.zhang@oracle.com>
      Cc: James Smart <james.smart@broadcom.com>
      Cc: Bart Van Assche <bart.vanassche@wdc.com>
      Cc: linux-scsi@vger.kernel.org,
      Cc: Martin K . Petersen <martin.petersen@oracle.com>,
      Cc: Christoph Hellwig <hch@lst.de>,
      Cc: James E . J . Bottomley <jejb@linux.vnet.ibm.com>,
      Cc: jianchao wang <jianchao.w.wang@oracle.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      18c4f0a4
    • Himanshu Madhani's avatar
      scsi: qla2xxx: Fix read offset in qla24xx_load_risc_flash() · 1710ac17
      Himanshu Madhani authored
      This patch fixes regression introduced by commit f8f97b0c ("scsi:
      qla2xxx: Cleanups for NVRAM/Flash read/write path") where flash read/write
      routine cleanup left out code which resulted into checksum failure leading
      to use-after-free stack during driver load.
      
      Following stack trace is seen in the log file
      
      qla2xxx [0000:00:00.0]-0005: : QLogic Fibre Channel HBA Driver: 10.01.00.16-k.
      qla2xxx [0000:00:0b.0]-001d: : Found an ISP2532 irq 11 iobase 0x0000000000f47f03.
      qla2xxx [0000:00:0b.0]-00cd:8: ISP Firmware failed checksum.
      qla2xxx [0000:00:0b.0]-00cf:8: Setup chip ****FAILED****.
      qla2xxx [0000:00:0b.0]-00d6:8: Failed to initialize adapter - Adapter flags 2.
      ==================================================================
      BUG: KASAN: use-after-free in __list_del_entry_valid+0x15/0xd0
      Read of size 8 at addr ffff8880ca05a490 by task modprobe/857
      
      CPU: 0 PID: 857 Comm: modprobe Not tainted 5.1.0-rc1-dbg+ #4
      Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
      Call Trace:
        dump_stack+0x86/0xca
        print_address_description+0x6c/0x234
        ? __list_del_entry_valid+0x15/0xd0
        kasan_report.cold.3+0x1b/0x34
        ? __list_del_entry_valid+0x15/0xd0
        ? __kmem_cache_shutdown.cold.95+0xf5/0x176
        ? __list_del_entry_valid+0x15/0xd0
        __asan_load8+0x54/0x90
        __list_del_entry_valid+0x15/0xd0
        dma_pool_destroy+0x4f/0x260
        ? dma_free_attrs+0xb4/0xd0
        qla2x00_mem_free+0x529/0xcc0 [qla2xxx]
        ? kobject_put+0xdb/0x230
        qla2x00_probe_one+0x2b5e/0x45f0 [qla2xxx]
        ? qla2xxx_pci_error_detected+0x210/0x210 [qla2xxx]
        ? match_held_lock+0x20/0x240
        ? find_held_lock+0xca/0xf0
        ? mark_held_locks+0x86/0xb0
        ? _raw_spin_unlock_irqrestore+0x52/0x60
        ? __pm_runtime_resume+0x5b/0xb0
        ? lockdep_hardirqs_on+0x185/0x260
        ? _raw_spin_unlock_irqrestore+0x52/0x60
        ? trace_hardirqs_on+0x24/0x130
        ? preempt_count_sub+0x13/0xc0
        ? _raw_spin_unlock_irqrestore+0x3d/0x60
        pci_device_probe+0x154/0x1e0
        really_probe+0x17d/0x540
        ? device_driver_attach+0x90/0x90
        driver_probe_device+0x113/0x170
        ? device_driver_attach+0x90/0x90
        device_driver_attach+0x88/0x90
        __driver_attach+0xb5/0x190
        bus_for_each_dev+0xf8/0x160
        ? subsys_dev_iter_exit+0x10/0x10
        ? kasan_check_read+0x11/0x20
        ? preempt_count_sub+0x13/0xc0
        ? _raw_spin_unlock+0x2c/0x50
        driver_attach+0x26/0x30
        bus_add_driver+0x238/0x2f0
        driver_register+0xd7/0x150
        __pci_register_driver+0xd5/0xe0
        ? 0xffffffffa06c8000
        qla2x00_module_init+0x208/0x254 [qla2xxx]
        do_one_initcall+0xc0/0x3c9
        ? trace_event_raw_event_initcall_finish+0x150/0x150
        ? __kasan_kmalloc.constprop.5+0xc7/0xd0
        ? kasan_unpoison_shadow+0x35/0x50
        ? kasan_poison_shadow+0x2f/0x40
        ? __asan_register_globals+0x5a/0x70
        do_init_module+0x103/0x330
        load_module+0x36df/0x3b70
        ? fsnotify+0x611/0x640
        ? module_frob_arch_sections+0x20/0x20
        ? kernel_read+0x74/0xa0
        ? kasan_check_write+0x14/0x20
        ? kernel_read_file+0x25e/0x320
        ? do_mmap+0x42c/0x6c0
        __do_sys_finit_module+0x133/0x1c0
        ? __do_sys_finit_module+0x133/0x1c0
        ? __do_sys_init_module+0x210/0x210
        ? fput_many+0x1b/0xc0
        ? fput+0xe/0x10
        ? do_syscall_64+0x14/0x210
        ? entry_SYSCALL_64_after_hwframe+0x49/0xbe
        __x64_sys_finit_module+0x3e/0x50
        do_syscall_64+0x72/0x210
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x7f8bd5c03219
      Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 47 fc 0c 00 f7 d8 64 89 01 48
      RSP: 002b:00007fff9d11de98 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      RAX: ffffffffffffffda RBX: 000055ef21596b50 RCX: 00007f8bd5c03219
      RDX: 0000000000000000 RSI: 000055ef21596570 RDI: 0000000000000004
      RBP: 000055ef21596570 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000
      R13: 000055ef21596c80 R14: 0000000000040000 R15: 000055ef21596b50
      
      Allocated by task 857:
        save_stack+0x43/0xd0
        __kasan_kmalloc.constprop.5+0xc7/0xd0
        kasan_kmalloc+0x9/0x10
        kmem_cache_alloc_trace+0x144/0x300
        dma_pool_create+0xb5/0x3b0
        qla2x00_mem_alloc+0xb98/0x1ad0 [qla2xxx]
        qla2x00_probe_one+0xe28/0x45f0 [qla2xxx]
        pci_device_probe+0x154/0x1e0
        really_probe+0x17d/0x540
        driver_probe_device+0x113/0x170
        device_driver_attach+0x88/0x90
        __driver_attach+0xb5/0x190
        bus_for_each_dev+0xf8/0x160
        driver_attach+0x26/0x30
        bus_add_driver+0x238/0x2f0
        driver_register+0xd7/0x150
        __pci_register_driver+0xd5/0xe0
        qla2x00_module_init+0x208/0x254 [qla2xxx]
        do_one_initcall+0xc0/0x3c9
        do_init_module+0x103/0x330
        load_module+0x36df/0x3b70
        __do_sys_finit_module+0x133/0x1c0
        __x64_sys_finit_module+0x3e/0x50
        do_syscall_64+0x72/0x210
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Freed by task 857:
        save_stack+0x43/0xd0
        __kasan_slab_free+0x139/0x190
        kasan_slab_free+0xe/0x10
        kfree+0xf0/0x2c0
        dma_pool_destroy+0x24c/0x260
        qla2x00_mem_free+0x529/0xcc0 [qla2xxx]
        qla2x00_free_device+0x167/0x1b0 [qla2xxx]
        qla2x00_probe_one+0x2b28/0x45f0 [qla2xxx]
        pci_device_probe+0x154/0x1e0
        really_probe+0x17d/0x540
        driver_probe_device+0x113/0x170
        device_driver_attach+0x88/0x90
        __driver_attach+0xb5/0x190
        bus_for_each_dev+0xf8/0x160
        driver_attach+0x26/0x30
        bus_add_driver+0x238/0x2f0
        driver_register+0xd7/0x150
        __pci_register_driver+0xd5/0xe0
        qla2x00_module_init+0x208/0x254 [qla2xxx]
        do_one_initcall+0xc0/0x3c9
        do_init_module+0x103/0x330
        load_module+0x36df/0x3b70
        __do_sys_finit_module+0x133/0x1c0
        __x64_sys_finit_module+0x3e/0x50
        do_syscall_64+0x72/0x210
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      The buggy address belongs to the object at ffff8880ca05a400
        which belongs to the cache kmalloc-192 of size 192
      The buggy address is located 144 bytes inside of
        192-byte region [ffff8880ca05a400, ffff8880ca05a4c0)
      The buggy address belongs to the page:
      page:ffffea0003281680 count:1 mapcount:0 mapping:ffff88811bf03380 index:0x0 compound_mapcount: 0
      flags: 0x4000000000010200(slab|head)
      raw: 4000000000010200 0000000000000000 0000000c00000001 ffff88811bf03380
      raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
        ffff8880ca05a380: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
        ffff8880ca05a400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      >ffff8880ca05a480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                                ^
        ffff8880ca05a500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        ffff8880ca05a580: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
      ==================================================================
      
      Fixes: f8f97b0c ("scsi: qla2xxx: Cleanups for NVRAM/Flash read/write path")
      Reported-by: default avatarBart Van Assche <bvanassche@acm.org>
      Tested-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      1710ac17
    • Bart Van Assche's avatar
      scsi: qla2xxx: Move qla2x00_set_fcport_state() from a .h into a .c file · a630bdc5
      Bart Van Assche authored
      The qla2x00_set_fcport_state() function is not in the hot path so move its
      definition from a .h into a .c file.
      
      Cc: Himanshu Madhani <hmadhani@marvell.com>
      Cc: Giridhar Malavali <gmalavali@marvell.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Acked-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      a630bdc5
    • Bart Van Assche's avatar
      scsi: qla2xxx: Remove two superfluous casts · 81bcf1c5
      Bart Van Assche authored
      Casting a void pointer into another pointer before assigning the pointer to
      a variable is not useful. Hence remove such casts.
      
      Cc: Himanshu Madhani <hmadhani@marvell.com>
      Cc: Giridhar Malavali <gmalavali@marvell.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Acked-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      81bcf1c5
    • Bart Van Assche's avatar
      scsi: qla2xxx: Remove qla_tgt_cmd.data_work and qla_tgt_cmd.data_work_free · bb63e47b
      Bart Van Assche authored
      The 'data_work' and 'data_work_free' member variables are set but never
      used. Hence remove both member variables. See also commit 6bcbb317
      ("qla2xxx: Fix incorrect tcm_qla2xxx_free_cmd use during TMR ABORT (v2)").
      
      Cc: Himanshu Madhani <hmadhani@marvell.com>
      Cc: Giridhar Malavali <gmalavali@marvell.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Acked-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      bb63e47b
    • Bart Van Assche's avatar
      scsi: qla2xxx: Move the <linux/io-64-nonatomic-lo-hi.h> include directive · 9dfb59a0
      Bart Van Assche authored
      The <linux/io-64-nonatomic-lo-hi.h> header file is included because of the
      readq() macro. Since that macro is only used in qla_nx.c, move that include
      statement into qla_nx.c.
      
      Cc: Himanshu Madhani <hmadhani@marvell.com>
      Cc: Giridhar Malavali <gmalavali@marvell.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Acked-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      9dfb59a0
    • Bart Van Assche's avatar
      scsi: qla2xxx: Declare qla24xx_build_scsi_crc_2_iocbs() static · c20605ed
      Bart Van Assche authored
      Since qla24xx_build_scsi_crc_2_iocbs() is only used inside a single source
      file, declare this function static.
      
      Cc: Himanshu Madhani <hmadhani@marvell.com>
      Cc: Giridhar Malavali <gmalavali@marvell.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Acked-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c20605ed
    • Bart Van Assche's avatar
      scsi: qla2xxx: Move the port_state_str[] definition from a .h to a .c file · c4dc7cd3
      Bart Van Assche authored
      Reduce the size of the qla2xxx kernel module by moving an array definition
      from a .h into a .c file.
      
      Cc: Himanshu Madhani <hmadhani@marvell.com>
      Cc: Giridhar Malavali <gmalavali@marvell.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Acked-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c4dc7cd3