<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/scsi, branch v4.4.85</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>scsi: qla2xxx: Get mutex lock before checking optrom_state</title>
<updated>2017-08-11T16:08:57+00:00</updated>
<author>
<name>Milan P. Gandhi</name>
<email>mgandhi@redhat.com</email>
</author>
<published>2016-12-24T16:32:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1e43b2d064741a6f4d4c55c4f9146c1e92e1d06a'/>
<id>1e43b2d064741a6f4d4c55c4f9146c1e92e1d06a</id>
<content type='text'>
[ Upstream commit c7702b8c22712a06080e10f1d2dee1a133ec8809 ]

There is a race condition with qla2xxx optrom functions where one thread
might modify optrom buffer, optrom_state while other thread is still
reading from it.

In couple of crashes, it was found that we had successfully passed the
following 'if' check where we confirm optrom_state to be
QLA_SREADING. But by the time we acquired mutex lock to proceed with
memory_read_from_buffer function, some other thread/process had already
modified that option rom buffer and optrom_state from QLA_SREADING to
QLA_SWAITING. Then we got ha-&gt;optrom_buffer 0x0 and crashed the system:

        if (ha-&gt;optrom_state != QLA_SREADING)
                return 0;

        mutex_lock(&amp;ha-&gt;optrom_mutex);
        rval = memory_read_from_buffer(buf, count, &amp;off, ha-&gt;optrom_buffer,
            ha-&gt;optrom_region_size);
        mutex_unlock(&amp;ha-&gt;optrom_mutex);

With current optrom function we get following crash due to a race
condition:

[ 1479.466679] BUG: unable to handle kernel NULL pointer dereference at           (null)
[ 1479.466707] IP: [&lt;ffffffff81326756&gt;] memcpy+0x6/0x110
[...]
[ 1479.473673] Call Trace:
[ 1479.474296]  [&lt;ffffffff81225cbc&gt;] ? memory_read_from_buffer+0x3c/0x60
[ 1479.474941]  [&lt;ffffffffa01574dc&gt;] qla2x00_sysfs_read_optrom+0x9c/0xc0 [qla2xxx]
[ 1479.475571]  [&lt;ffffffff8127e76b&gt;] read+0xdb/0x1f0
[ 1479.476206]  [&lt;ffffffff811fdf9e&gt;] vfs_read+0x9e/0x170
[ 1479.476839]  [&lt;ffffffff811feb6f&gt;] SyS_read+0x7f/0xe0
[ 1479.477466]  [&lt;ffffffff816964c9&gt;] system_call_fastpath+0x16/0x1b

Below patch modifies qla2x00_sysfs_read_optrom,
qla2x00_sysfs_write_optrom functions to get the mutex_lock before
checking ha-&gt;optrom_state to avoid similar crashes.

The patch was applied and tested and same crashes were no longer
observed again.

Tested-by: Milan P. Gandhi &lt;mgandhi@redhat.com&gt;
Signed-off-by: Milan P. Gandhi &lt;mgandhi@redhat.com&gt;
Reviewed-by: Laurence Oberman &lt;loberman@redhat.com&gt;
Acked-by: Himanshu Madhani &lt;himanshu.madhani@cavium.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit c7702b8c22712a06080e10f1d2dee1a133ec8809 ]

There is a race condition with qla2xxx optrom functions where one thread
might modify optrom buffer, optrom_state while other thread is still
reading from it.

In couple of crashes, it was found that we had successfully passed the
following 'if' check where we confirm optrom_state to be
QLA_SREADING. But by the time we acquired mutex lock to proceed with
memory_read_from_buffer function, some other thread/process had already
modified that option rom buffer and optrom_state from QLA_SREADING to
QLA_SWAITING. Then we got ha-&gt;optrom_buffer 0x0 and crashed the system:

        if (ha-&gt;optrom_state != QLA_SREADING)
                return 0;

        mutex_lock(&amp;ha-&gt;optrom_mutex);
        rval = memory_read_from_buffer(buf, count, &amp;off, ha-&gt;optrom_buffer,
            ha-&gt;optrom_region_size);
        mutex_unlock(&amp;ha-&gt;optrom_mutex);

With current optrom function we get following crash due to a race
condition:

[ 1479.466679] BUG: unable to handle kernel NULL pointer dereference at           (null)
[ 1479.466707] IP: [&lt;ffffffff81326756&gt;] memcpy+0x6/0x110
[...]
[ 1479.473673] Call Trace:
[ 1479.474296]  [&lt;ffffffff81225cbc&gt;] ? memory_read_from_buffer+0x3c/0x60
[ 1479.474941]  [&lt;ffffffffa01574dc&gt;] qla2x00_sysfs_read_optrom+0x9c/0xc0 [qla2xxx]
[ 1479.475571]  [&lt;ffffffff8127e76b&gt;] read+0xdb/0x1f0
[ 1479.476206]  [&lt;ffffffff811fdf9e&gt;] vfs_read+0x9e/0x170
[ 1479.476839]  [&lt;ffffffff811feb6f&gt;] SyS_read+0x7f/0xe0
[ 1479.477466]  [&lt;ffffffff816964c9&gt;] system_call_fastpath+0x16/0x1b

Below patch modifies qla2x00_sysfs_read_optrom,
qla2x00_sysfs_write_optrom functions to get the mutex_lock before
checking ha-&gt;optrom_state to avoid similar crashes.

The patch was applied and tested and same crashes were no longer
observed again.

Tested-by: Milan P. Gandhi &lt;mgandhi@redhat.com&gt;
Signed-off-by: Milan P. Gandhi &lt;mgandhi@redhat.com&gt;
Reviewed-by: Laurence Oberman &lt;loberman@redhat.com&gt;
Acked-by: Himanshu Madhani &lt;himanshu.madhani@cavium.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: snic: Return error code on memory allocation failure</title>
<updated>2017-08-07T02:19:47+00:00</updated>
<author>
<name>Burak Ok</name>
<email>burak-kernel@bur0k.de</email>
</author>
<published>2016-12-21T13:45:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=32b850a626c5cc2895826a856bc7872d3b04efe0'/>
<id>32b850a626c5cc2895826a856bc7872d3b04efe0</id>
<content type='text'>
[ Upstream commit 0371adcdaca92912baaa3256ed13e058a016e62d ]

If a call to mempool_create_slab_pool() in snic_probe() returns NULL,
return -ENOMEM to indicate failure. mempool_creat_slab_pool() only fails
if it cannot allocate memory.

https://bugzilla.kernel.org/show_bug.cgi?id=189061

Reported-by: bianpan2010@ruc.edu.cn
Signed-off-by: Burak Ok &lt;burak-kernel@bur0k.de&gt;
Signed-off-by: Andreas Schaertl &lt;andreas.schaertl@fau.de&gt;
Acked-by: Narsimhulu Musini &lt;nmusini@cisco.com&gt;
Reviewed-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 0371adcdaca92912baaa3256ed13e058a016e62d ]

If a call to mempool_create_slab_pool() in snic_probe() returns NULL,
return -ENOMEM to indicate failure. mempool_creat_slab_pool() only fails
if it cannot allocate memory.

https://bugzilla.kernel.org/show_bug.cgi?id=189061

Reported-by: bianpan2010@ruc.edu.cn
Signed-off-by: Burak Ok &lt;burak-kernel@bur0k.de&gt;
Signed-off-by: Andreas Schaertl &lt;andreas.schaertl@fau.de&gt;
Acked-by: Narsimhulu Musini &lt;nmusini@cisco.com&gt;
Reviewed-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: fnic: Avoid sending reset to firmware when another reset is in progress</title>
<updated>2017-08-07T02:19:47+00:00</updated>
<author>
<name>Satish Kharat</name>
<email>satishkh@cisco.com</email>
</author>
<published>2016-12-14T21:20:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=27eb77b5544ef30e9532bef984b637f9039f4e28'/>
<id>27eb77b5544ef30e9532bef984b637f9039f4e28</id>
<content type='text'>
[ Upstream commit 9698b6f473555a722bf81a3371998427d5d27bde ]

This fix is to avoid calling fnic_fw_reset_handler through
fnic_host_reset when a finc reset is alreay in progress.

Signed-off-by: Satish Kharat &lt;satishkh@cisco.com&gt;
Signed-off-by: Sesidhar Baddela &lt;sebaddel@cisco.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 9698b6f473555a722bf81a3371998427d5d27bde ]

This fix is to avoid calling fnic_fw_reset_handler through
fnic_host_reset when a finc reset is alreay in progress.

Signed-off-by: Satish Kharat &lt;satishkh@cisco.com&gt;
Signed-off-by: Sesidhar Baddela &lt;sebaddel@cisco.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mpt3sas: Don't overreach ioc-&gt;reply_post[] during initialization</title>
<updated>2017-08-07T02:19:41+00:00</updated>
<author>
<name>Calvin Owens</name>
<email>calvinowens@fb.com</email>
</author>
<published>2016-03-18T19:45:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=658f9c65ee8ce70662b8301291310ba12b0dac7a'/>
<id>658f9c65ee8ce70662b8301291310ba12b0dac7a</id>
<content type='text'>
commit 5ec8a1753bc29efa7e4b1391d691c9c719b30257 upstream.

In _base_make_ioc_operational(), we walk ioc-&gt;reply_queue_list and pull
a pointer out of successive elements of ioc-&gt;reply_post[] for each entry
in that list if RDPQ is enabled.

Since the code pulls the pointer for the next iteration at the bottom of
the loop, it triggers the a KASAN dump on the final iteration:

    BUG: KASAN: slab-out-of-bounds in _base_make_ioc_operational+0x47b7/0x47e0 [mpt3sas] at addr ffff880754816ab0
    Read of size 8 by task modprobe/305
    &lt;snip&gt;
    Call Trace:
     [&lt;ffffffff81dfc591&gt;] dump_stack+0x4d/0x6c
     [&lt;ffffffff814c9689&gt;] print_trailer+0xf9/0x150
     [&lt;ffffffff814ceda4&gt;] object_err+0x34/0x40
     [&lt;ffffffff814d1231&gt;] kasan_report_error+0x221/0x530
     [&lt;ffffffff814d1673&gt;] __asan_report_load8_noabort+0x43/0x50
     [&lt;ffffffffa0043637&gt;] _base_make_ioc_operational+0x47b7/0x47e0 [mpt3sas]
     [&lt;ffffffffa0049a51&gt;] mpt3sas_base_attach+0x1991/0x2120 [mpt3sas]
     [&lt;ffffffffa0053c93&gt;] _scsih_probe+0xeb3/0x16b0 [mpt3sas]
     [&lt;ffffffff81ebd047&gt;] local_pci_probe+0xc7/0x170
     [&lt;ffffffff81ebf2cf&gt;] pci_device_probe+0x20f/0x290
     [&lt;ffffffff820d50cd&gt;] really_probe+0x17d/0x600
     [&lt;ffffffff820d56a3&gt;] __driver_attach+0x153/0x190
     [&lt;ffffffff820cffac&gt;] bus_for_each_dev+0x11c/0x1a0
     [&lt;ffffffff820d421d&gt;] driver_attach+0x3d/0x50
     [&lt;ffffffff820d378a&gt;] bus_add_driver+0x44a/0x5f0
     [&lt;ffffffff820d666c&gt;] driver_register+0x18c/0x3b0
     [&lt;ffffffff81ebcb76&gt;] __pci_register_driver+0x156/0x200
     [&lt;ffffffffa00c8135&gt;] _mpt3sas_init+0x135/0x1000 [mpt3sas]
     [&lt;ffffffff81000423&gt;] do_one_initcall+0x113/0x2b0
     [&lt;ffffffff813caa5a&gt;] do_init_module+0x1d0/0x4d8
     [&lt;ffffffff81273909&gt;] load_module+0x6729/0x8dc0
     [&lt;ffffffff81276123&gt;] SYSC_init_module+0x183/0x1a0
     [&lt;ffffffff8127625e&gt;] SyS_init_module+0xe/0x10
     [&lt;ffffffff828fe7d7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6a

Fix this by pulling the value at the beginning of the loop.

Signed-off-by: Calvin Owens &lt;calvinowens@fb.com&gt;
Reviewed-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Reviewed-by: Jens Axboe &lt;axboe@fb.com&gt;
Acked-by: Chaitra Basappa &lt;chaitra.basappa@broadcom.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Amit Pundir &lt;amit.pundir@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 5ec8a1753bc29efa7e4b1391d691c9c719b30257 upstream.

In _base_make_ioc_operational(), we walk ioc-&gt;reply_queue_list and pull
a pointer out of successive elements of ioc-&gt;reply_post[] for each entry
in that list if RDPQ is enabled.

Since the code pulls the pointer for the next iteration at the bottom of
the loop, it triggers the a KASAN dump on the final iteration:

    BUG: KASAN: slab-out-of-bounds in _base_make_ioc_operational+0x47b7/0x47e0 [mpt3sas] at addr ffff880754816ab0
    Read of size 8 by task modprobe/305
    &lt;snip&gt;
    Call Trace:
     [&lt;ffffffff81dfc591&gt;] dump_stack+0x4d/0x6c
     [&lt;ffffffff814c9689&gt;] print_trailer+0xf9/0x150
     [&lt;ffffffff814ceda4&gt;] object_err+0x34/0x40
     [&lt;ffffffff814d1231&gt;] kasan_report_error+0x221/0x530
     [&lt;ffffffff814d1673&gt;] __asan_report_load8_noabort+0x43/0x50
     [&lt;ffffffffa0043637&gt;] _base_make_ioc_operational+0x47b7/0x47e0 [mpt3sas]
     [&lt;ffffffffa0049a51&gt;] mpt3sas_base_attach+0x1991/0x2120 [mpt3sas]
     [&lt;ffffffffa0053c93&gt;] _scsih_probe+0xeb3/0x16b0 [mpt3sas]
     [&lt;ffffffff81ebd047&gt;] local_pci_probe+0xc7/0x170
     [&lt;ffffffff81ebf2cf&gt;] pci_device_probe+0x20f/0x290
     [&lt;ffffffff820d50cd&gt;] really_probe+0x17d/0x600
     [&lt;ffffffff820d56a3&gt;] __driver_attach+0x153/0x190
     [&lt;ffffffff820cffac&gt;] bus_for_each_dev+0x11c/0x1a0
     [&lt;ffffffff820d421d&gt;] driver_attach+0x3d/0x50
     [&lt;ffffffff820d378a&gt;] bus_add_driver+0x44a/0x5f0
     [&lt;ffffffff820d666c&gt;] driver_register+0x18c/0x3b0
     [&lt;ffffffff81ebcb76&gt;] __pci_register_driver+0x156/0x200
     [&lt;ffffffffa00c8135&gt;] _mpt3sas_init+0x135/0x1000 [mpt3sas]
     [&lt;ffffffff81000423&gt;] do_one_initcall+0x113/0x2b0
     [&lt;ffffffff813caa5a&gt;] do_init_module+0x1d0/0x4d8
     [&lt;ffffffff81273909&gt;] load_module+0x6729/0x8dc0
     [&lt;ffffffff81276123&gt;] SYSC_init_module+0x183/0x1a0
     [&lt;ffffffff8127625e&gt;] SyS_init_module+0xe/0x10
     [&lt;ffffffff828fe7d7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6a

Fix this by pulling the value at the beginning of the loop.

Signed-off-by: Calvin Owens &lt;calvinowens@fb.com&gt;
Reviewed-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Reviewed-by: Jens Axboe &lt;axboe@fb.com&gt;
Acked-by: Chaitra Basappa &lt;chaitra.basappa@broadcom.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Amit Pundir &lt;amit.pundir@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: lpfc: avoid double free of resource identifiers</title>
<updated>2017-07-05T12:37:20+00:00</updated>
<author>
<name>Roberto Sassu</name>
<email>rsassu@suse.de</email>
</author>
<published>2017-01-11T10:06:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=be91b09750bf6c68076b3ce68d234d0d0829d2e0'/>
<id>be91b09750bf6c68076b3ce68d234d0d0829d2e0</id>
<content type='text'>
[ Upstream commit cd60be4916ae689387d04b86b6fc15931e4c95ae ]

Set variables initialized in lpfc_sli4_alloc_resource_identifiers() to
NULL if an error occurred. Otherwise, lpfc_sli4_driver_resource_unset()
attempts to free the memory again.

Signed-off-by: Roberto Sassu &lt;rsassu@suse.de&gt;
Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Acked-by: James Smart &lt;james.smart@broadcom.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit cd60be4916ae689387d04b86b6fc15931e4c95ae ]

Set variables initialized in lpfc_sli4_alloc_resource_identifiers() to
NULL if an error occurred. Otherwise, lpfc_sli4_driver_resource_unset()
attempts to free the memory again.

Signed-off-by: Roberto Sassu &lt;rsassu@suse.de&gt;
Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Acked-by: James Smart &lt;james.smart@broadcom.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: virtio_scsi: Reject commands when virtqueue is broken</title>
<updated>2017-07-05T12:37:19+00:00</updated>
<author>
<name>Eric Farman</name>
<email>farman@linux.vnet.ibm.com</email>
</author>
<published>2017-01-13T17:48:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=666c821b0ae39f40aa30ef1de71e4e5083f6a165'/>
<id>666c821b0ae39f40aa30ef1de71e4e5083f6a165</id>
<content type='text'>
[ Upstream commit 773c7220e22d193e5667c352fcbf8d47eefc817f ]

In the case of a graceful set of detaches, where the virtio-scsi-ccw
disk is removed from the guest prior to the controller, the guest
behaves quite normally.  Specifically, the detach gets us into
sd_sync_cache to issue a Synchronize Cache(10) command, which
immediately fails (and is retried a couple of times) because the device
has been removed.  Later, the removal of the controller sees two CRWs
presented, but there's no further indication of the removal from the
guest viewpoint.

 [   17.217458] sd 0:0:0:0: [sda] Synchronizing SCSI cache
 [   17.219257] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
 [   21.449400] crw_info : CRW reports slct=0, oflw=0, chn=1, rsc=3, anc=0, erc=4, rsid=2
 [   21.449406] crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=0, erc=4, rsid=0

However, on s390, the SCSI disks can be removed "by surprise" when an
entire controller (host) is removed and all associated disks are removed
via the loop in scsi_forget_host.  The same call to sd_sync_cache is
made, but because the controller has already been removed, the
Synchronize Cache(10) command is neither issued (and then failed) nor
rejected.

That the I/O isn't returned means the guest cannot have other devices
added nor removed, and other tasks (such as shutdown or reboot) issued
by the guest will not complete either.  The virtio ring has already been
marked as broken (via virtio_break_device in virtio_ccw_remove), but we
still attempt to queue the command only to have it remain there.  The
calling sequence provides a bit of distinction for us:

  virtscsi_queuecommand()
   -&gt; virtscsi_kick_cmd()
    -&gt; virtscsi_add_cmd()
     -&gt; virtqueue_add_sgs()
      -&gt; virtqueue_add()
         if success
           return 0
         elseif vq-&gt;broken or vring_mapping_error()
           return -EIO
         else
           return -ENOSPC

A return of ENOSPC is generally a temporary condition, so returning
"host busy" from virtscsi_queuecommand makes sense here, to have it
redriven in a moment or two.  But the EIO return code is more of a
permanent error and so it would be wise to return the I/O itself and
allow the calling thread to finish gracefully.  The result is these four
kernel messages in the guest (the fourth one does not occur prior to
this patch):

 [   22.921562] crw_info : CRW reports slct=0, oflw=0, chn=1, rsc=3, anc=0, erc=4, rsid=2
 [   22.921580] crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=0, erc=4, rsid=0
 [   22.921978] sd 0:0:0:0: [sda] Synchronizing SCSI cache
 [   22.921993] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK

I opted to fill in the same response data that is returned from the more
graceful device detach, where the disk device is removed prior to the
controller device.

Signed-off-by: Eric Farman &lt;farman@linux.vnet.ibm.com&gt;
Reviewed-by: Fam Zheng &lt;famz@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 773c7220e22d193e5667c352fcbf8d47eefc817f ]

In the case of a graceful set of detaches, where the virtio-scsi-ccw
disk is removed from the guest prior to the controller, the guest
behaves quite normally.  Specifically, the detach gets us into
sd_sync_cache to issue a Synchronize Cache(10) command, which
immediately fails (and is retried a couple of times) because the device
has been removed.  Later, the removal of the controller sees two CRWs
presented, but there's no further indication of the removal from the
guest viewpoint.

 [   17.217458] sd 0:0:0:0: [sda] Synchronizing SCSI cache
 [   17.219257] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
 [   21.449400] crw_info : CRW reports slct=0, oflw=0, chn=1, rsc=3, anc=0, erc=4, rsid=2
 [   21.449406] crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=0, erc=4, rsid=0

However, on s390, the SCSI disks can be removed "by surprise" when an
entire controller (host) is removed and all associated disks are removed
via the loop in scsi_forget_host.  The same call to sd_sync_cache is
made, but because the controller has already been removed, the
Synchronize Cache(10) command is neither issued (and then failed) nor
rejected.

That the I/O isn't returned means the guest cannot have other devices
added nor removed, and other tasks (such as shutdown or reboot) issued
by the guest will not complete either.  The virtio ring has already been
marked as broken (via virtio_break_device in virtio_ccw_remove), but we
still attempt to queue the command only to have it remain there.  The
calling sequence provides a bit of distinction for us:

  virtscsi_queuecommand()
   -&gt; virtscsi_kick_cmd()
    -&gt; virtscsi_add_cmd()
     -&gt; virtqueue_add_sgs()
      -&gt; virtqueue_add()
         if success
           return 0
         elseif vq-&gt;broken or vring_mapping_error()
           return -EIO
         else
           return -ENOSPC

A return of ENOSPC is generally a temporary condition, so returning
"host busy" from virtscsi_queuecommand makes sense here, to have it
redriven in a moment or two.  But the EIO return code is more of a
permanent error and so it would be wise to return the I/O itself and
allow the calling thread to finish gracefully.  The result is these four
kernel messages in the guest (the fourth one does not occur prior to
this patch):

 [   22.921562] crw_info : CRW reports slct=0, oflw=0, chn=1, rsc=3, anc=0, erc=4, rsid=2
 [   22.921580] crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=0, erc=4, rsid=0
 [   22.921978] sd 0:0:0:0: [sda] Synchronizing SCSI cache
 [   22.921993] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK

I opted to fill in the same response data that is returned from the more
graceful device detach, where the disk device is removed prior to the
controller device.

Signed-off-by: Eric Farman &lt;farman@linux.vnet.ibm.com&gt;
Reviewed-by: Fam Zheng &lt;famz@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>qla2xxx: Fix erroneous invalid handle message</title>
<updated>2017-07-05T12:37:16+00:00</updated>
<author>
<name>Quinn Tran</name>
<email>quinn.tran@cavium.com</email>
</author>
<published>2016-12-24T02:06:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=50e18570d8ea12338f13e8835381a087773f8f08'/>
<id>50e18570d8ea12338f13e8835381a087773f8f08</id>
<content type='text'>
[ Upstream commit 4f060736f29a960aba8e781a88837464756200a8 ]

Termination of Immediate Notify IOCB was using wrong
IOCB handle. IOCB completion code was unable to find
appropriate code path due to wrong handle.

Following message is seen in the logs.

"Error entry - invalid handle/queue (ffff)."

Signed-off-by: Quinn Tran &lt;quinn.tran@cavium.com&gt;
Signed-off-by: Himanshu Madhani &lt;himanshu.madhani@cavium.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
[ bvanassche: Fixed word order in patch title ]
Signed-off-by: Bart Van Assche &lt;bart.vanassche@sandisk.com&gt;

Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 4f060736f29a960aba8e781a88837464756200a8 ]

Termination of Immediate Notify IOCB was using wrong
IOCB handle. IOCB completion code was unable to find
appropriate code path due to wrong handle.

Following message is seen in the logs.

"Error entry - invalid handle/queue (ffff)."

Signed-off-by: Quinn Tran &lt;quinn.tran@cavium.com&gt;
Signed-off-by: Himanshu Madhani &lt;himanshu.madhani@cavium.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
[ bvanassche: Fixed word order in patch title ]
Signed-off-by: Bart Van Assche &lt;bart.vanassche@sandisk.com&gt;

Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: lpfc: Set elsiocb contexts to NULL after freeing it</title>
<updated>2017-07-05T12:37:16+00:00</updated>
<author>
<name>Johannes Thumshirn</name>
<email>jthumshirn@suse.de</email>
</author>
<published>2017-01-10T11:05:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8c721e38055a36c881a904c1b4a5b6fd80c67edd'/>
<id>8c721e38055a36c881a904c1b4a5b6fd80c67edd</id>
<content type='text'>
[ Upstream commit 8667f515952feefebb3c0f8d9a9266c91b101a46 ]

Set the elsiocb contexts to NULL after freeing as others depend on it.

Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Acked-by: Dick Kennedy &lt;dick.kennedy@broadcom.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 8667f515952feefebb3c0f8d9a9266c91b101a46 ]

Set the elsiocb contexts to NULL after freeing as others depend on it.

Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Acked-by: Dick Kennedy &lt;dick.kennedy@broadcom.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: sd: Fix wrong DPOFUA disable in sd_read_cache_type</title>
<updated>2017-07-05T12:37:16+00:00</updated>
<author>
<name>Damien Le Moal</name>
<email>damien.lemoal@wdc.com</email>
</author>
<published>2017-01-12T06:25:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=5c982bac211ccc3923519a980f2e9a53ea8e6b60'/>
<id>5c982bac211ccc3923519a980f2e9a53ea8e6b60</id>
<content type='text'>
[ Upstream commit 26f2819772af891dee2843e1f8662c58e5129d5f ]

Zoned block devices force the use of READ/WRITE(16) commands by setting
sdkp-&gt;use_16_for_rw and clearing sdkp-&gt;use_10_for_rw. This result in
DPOFUA always being disabled for these drives as the assumed use of
the deprecated READ/WRITE(6) commands only looks at sdkp-&gt;use_10_for_rw.
Strenghten the test by also checking that sdkp-&gt;use_16_for_rw is false.

Signed-off-by: Damien Le Moal &lt;damien.lemoal@wdc.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 26f2819772af891dee2843e1f8662c58e5129d5f ]

Zoned block devices force the use of READ/WRITE(16) commands by setting
sdkp-&gt;use_16_for_rw and clearing sdkp-&gt;use_10_for_rw. This result in
DPOFUA always being disabled for these drives as the assumed use of
the deprecated READ/WRITE(6) commands only looks at sdkp-&gt;use_10_for_rw.
Strenghten the test by also checking that sdkp-&gt;use_16_for_rw is false.

Signed-off-by: Damien Le Moal &lt;damien.lemoal@wdc.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: qla2xxx: don't disable a not previously enabled PCI device</title>
<updated>2017-06-14T11:16:25+00:00</updated>
<author>
<name>Johannes Thumshirn</name>
<email>jthumshirn@suse.de</email>
</author>
<published>2017-05-23T14:50:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=93d03807f39595d47d4c89ece7207ec94971dad7'/>
<id>93d03807f39595d47d4c89ece7207ec94971dad7</id>
<content type='text'>
commit ddff7ed45edce4a4c92949d3c61cd25d229c4a14 upstream.

When pci_enable_device() or pci_enable_device_mem() fail in
qla2x00_probe_one() we bail out but do a call to
pci_disable_device(). This causes the dev_WARN_ON() in
pci_disable_device() to trigger, as the device wasn't enabled
previously.

So instead of taking the 'probe_out' error path we can directly return
*iff* one of the pci_enable_device() calls fails.

Additionally rename the 'probe_out' goto label's name to the more
descriptive 'disable_device'.

Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Fixes: e315cd28b9ef ("[SCSI] qla2xxx: Code changes for qla data structure refactoring")
Reviewed-by: Bart Van Assche &lt;bart.vanassche@sandisk.com&gt;
Reviewed-by: Giridhar Malavali &lt;giridhar.malavali@cavium.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit ddff7ed45edce4a4c92949d3c61cd25d229c4a14 upstream.

When pci_enable_device() or pci_enable_device_mem() fail in
qla2x00_probe_one() we bail out but do a call to
pci_disable_device(). This causes the dev_WARN_ON() in
pci_disable_device() to trigger, as the device wasn't enabled
previously.

So instead of taking the 'probe_out' error path we can directly return
*iff* one of the pci_enable_device() calls fails.

Additionally rename the 'probe_out' goto label's name to the more
descriptive 'disable_device'.

Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Fixes: e315cd28b9ef ("[SCSI] qla2xxx: Code changes for qla data structure refactoring")
Reviewed-by: Bart Van Assche &lt;bart.vanassche@sandisk.com&gt;
Reviewed-by: Giridhar Malavali &lt;giridhar.malavali@cavium.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
</feed>
