]> Pileus Git - ~andy/linux/blobdiff - drivers/target/target_core_transport.c
OMAPDSS: DISPC: add dispc_mgr_get_sync_lost_irq()
[~andy/linux] / drivers / target / target_core_transport.c
index d96d9aa3a4960e4b1656ba75f3d95b278de67e46..c33baff86aa699deacd04bd873e3c31fa5569cf5 100644 (file)
@@ -1539,6 +1539,27 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
        if (sgl_count != 0) {
                BUG_ON(!sgl);
 
+               /*
+                * A work-around for tcm_loop as some userspace code via
+                * scsi-generic do not memset their associated read buffers,
+                * so go ahead and do that here for type non-data CDBs.  Also
+                * note that this is currently guaranteed to be a single SGL
+                * for this case by target core in target_setup_cmd_from_cdb()
+                * -> transport_generic_cmd_sequencer().
+                */
+               if (!(se_cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) &&
+                    se_cmd->data_direction == DMA_FROM_DEVICE) {
+                       unsigned char *buf = NULL;
+
+                       if (sgl)
+                               buf = kmap(sg_page(sgl)) + sgl->offset;
+
+                       if (buf) {
+                               memset(buf, 0, sgl->length);
+                               kunmap(sg_page(sgl));
+                       }
+               }
+
                rc = transport_generic_map_mem_to_cmd(se_cmd, sgl, sgl_count,
                                sgl_bidi, sgl_bidi_count);
                if (rc != 0) {