Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6
authorLinus Torvalds <torvalds@g5.osdl.org>
Thu, 15 Dec 2005 02:40:02 +0000 (18:40 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 15 Dec 2005 02:40:02 +0000 (18:40 -0800)
14 files changed:
drivers/scsi/ibmvscsi/ibmvscsi.h
drivers/scsi/ibmvscsi/iseries_vscsi.c
drivers/scsi/ibmvscsi/rpa_vscsi.c
drivers/scsi/megaraid.c
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
drivers/scsi/sd.c
drivers/scsi/sr.c
drivers/scsi/st.c
drivers/scsi/sym53c8xx_2/sym_hipd.c
include/scsi/scsi_cmnd.h

index 8bec0438dc8a9151f3aed2b04a717a0ee6a65be2..5b0edd1f19213e3d97c173c4659659e5c63b6891 100644 (file)
@@ -100,7 +100,7 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue,
 void ibmvscsi_release_crq_queue(struct crq_queue *queue,
                                struct ibmvscsi_host_data *hostdata,
                                int max_requests);
-void ibmvscsi_reset_crq_queue(struct crq_queue *queue,
+int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
                              struct ibmvscsi_host_data *hostdata);
 
 void ibmvscsi_handle_crq(struct viosrp_crq *crq,
index 1045872b01752fe93d3976c3b6e77a99086dc696..ce15d9e3962114f5f49d84df48de41814291ce79 100644 (file)
@@ -117,9 +117,10 @@ void ibmvscsi_release_crq_queue(struct crq_queue *queue,
  *
  * no-op for iSeries
  */
-void ibmvscsi_reset_crq_queue(struct crq_queue *queue,
+int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
                              struct ibmvscsi_host_data *hostdata)
 {
+       return 0;
 }
 
 /**
index 8bf5652f106090ab75ec922a747e11bf0d1b2ad0..75db2f5c545e999d2b06b313560bf3610447bdd5 100644 (file)
@@ -230,6 +230,11 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue,
        rc = plpar_hcall_norets(H_REG_CRQ,
                                vdev->unit_address,
                                queue->msg_token, PAGE_SIZE);
+       if (rc == H_Resource) 
+               /* maybe kexecing and resource is busy. try a reset */
+               rc = ibmvscsi_reset_crq_queue(queue,
+                                             hostdata);
+
        if (rc == 2) {
                /* Adapter is good, but other end is not ready */
                printk(KERN_WARNING "ibmvscsi: Partner adapter not ready\n");
@@ -281,7 +286,7 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue,
  * @hostdata:  ibmvscsi_host_data of host
  *
  */
-void ibmvscsi_reset_crq_queue(struct crq_queue *queue,
+int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
                              struct ibmvscsi_host_data *hostdata)
 {
        int rc;
@@ -309,4 +314,5 @@ void ibmvscsi_reset_crq_queue(struct crq_queue *queue,
                printk(KERN_WARNING
                       "ibmvscsi: couldn't register crq--rc 0x%x\n", rc);
        }
+       return rc;
 }
index f9792528e33fb473d7e03314d5318b4aa0863ef9..578143e93a6f3b6c8afa4d64e1b7cda7e7a05515 100644 (file)
@@ -664,7 +664,7 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
                                        sg->offset;
                        } else
                                buf = cmd->request_buffer;
-                       memset(cmd->request_buffer, 0, cmd->cmnd[4]);
+                       memset(buf, 0, cmd->cmnd[4]);
                        if (cmd->use_sg) {
                                struct scatterlist *sg;
 
index 7096945ea2344be3f9ace82ef02618b99585cc39..7b3efd5312975547ac0e36c3ae971e4018649c36 100644 (file)
@@ -2476,17 +2476,9 @@ typedef struct scsi_qla_host {
  */
 #define LOOP_TRANSITION(ha) \
        (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
-        test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
-
-#define LOOP_NOT_READY(ha) \
-       ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
-         test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) || \
-         test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
-         test_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) || \
+        test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
         atomic_read(&ha->loop_state) == LOOP_DOWN)
 
-#define LOOP_RDY(ha)   (!LOOP_NOT_READY(ha))
-
 #define TGT_Q(ha, t) (ha->otgt[t])
 
 #define to_qla_host(x)         ((scsi_qla_host_t *) (x)->hostdata)
index 2d720121a0d36fea181edc21dbc701349dab6731..c46d2469b85f9e6e22c617fb71ece366de4a4552 100644 (file)
@@ -1259,7 +1259,7 @@ qla2x00_configure_hba(scsi_qla_host_t *ha)
        rval = qla2x00_get_adapter_id(ha,
            &loop_id, &al_pa, &area, &domain, &topo);
        if (rval != QLA_SUCCESS) {
-               if (LOOP_NOT_READY(ha) || atomic_read(&ha->loop_down_timer) ||
+               if (LOOP_TRANSITION(ha) || atomic_read(&ha->loop_down_timer) ||
                    (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) {
                        DEBUG2(printk("%s(%ld) Loop is in a transition state\n",
                            __func__, ha->host_no));
@@ -1796,7 +1796,7 @@ qla2x00_configure_loop(scsi_qla_host_t *ha)
        }
 
        if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) {
-               if (LOOP_NOT_READY(ha)) {
+               if (LOOP_TRANSITION(ha)) {
                        rval = QLA_FUNCTION_FAILED;
                } else {
                        rval = qla2x00_configure_fabric(ha);
@@ -2369,7 +2369,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
                if (qla2x00_is_reserved_id(ha, loop_id))
                        continue;
 
-               if (atomic_read(&ha->loop_down_timer) || LOOP_NOT_READY(ha))
+               if (atomic_read(&ha->loop_down_timer) || LOOP_TRANSITION(ha))
                        break;
 
                if (swl != NULL) {
index 09afc0f06bd4819d4dc9fd9c4650b2cda521454b..5181d966fecba13be29a57c8d1c7e7cc84b753f4 100644 (file)
@@ -909,6 +909,21 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
                        resid = resid_len;
                        cp->resid = resid;
                        CMD_RESID_LEN(cp) = resid;
+
+                       if (!lscsi_status &&
+                           ((unsigned)(cp->request_bufflen - resid) <
+                            cp->underflow)) {
+                               qla_printk(KERN_INFO, ha,
+                                   "scsi(%ld:%d:%d:%d): Mid-layer underflow "
+                                   "detected (%x of %x bytes)...returning "
+                                   "error status.\n", ha->host_no,
+                                   cp->device->channel, cp->device->id,
+                                   cp->device->lun, resid,
+                                   cp->request_bufflen);
+
+                               cp->result = DID_ERROR << 16;
+                               break;
+                       }
                }
                cp->result = DID_OK << 16 | lscsi_status;
 
index 18c5d252301441b287735e74b0dfae07c48b75af..c0ae9e965f6f26f71d591456280fbb4dad11a912 100644 (file)
@@ -422,10 +422,15 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
  **/
 static void scsi_eh_done(struct scsi_cmnd *scmd)
 {
+       struct completion     *eh_action;
+
        SCSI_LOG_ERROR_RECOVERY(3,
                printk("%s scmd: %p result: %x\n",
                        __FUNCTION__, scmd, scmd->result));
-       complete(scmd->device->host->eh_action);
+
+       eh_action = scmd->device->host->eh_action;
+       if (eh_action)
+               complete(eh_action);
 }
 
 /**
index ce9d73a292e2a0f273992efd56e7cb7370f2bbc0..dc249cb970ea49589d5f351585695a560a437c0b 100644 (file)
@@ -1085,6 +1085,26 @@ static void scsi_generic_done(struct scsi_cmnd *cmd)
        scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0);
 }
 
+void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd, int retries)
+{
+       struct request *req = cmd->request;
+
+       BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
+       memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
+       cmd->cmd_len = req->cmd_len;
+       if (!req->data_len)
+               cmd->sc_data_direction = DMA_NONE;
+       else if (rq_data_dir(req) == WRITE)
+               cmd->sc_data_direction = DMA_TO_DEVICE;
+       else
+               cmd->sc_data_direction = DMA_FROM_DEVICE;
+       
+       cmd->transfersize = req->data_len;
+       cmd->allowed = retries;
+       cmd->timeout_per_command = req->timeout;
+}
+EXPORT_SYMBOL_GPL(scsi_setup_blk_pc_cmnd);
+
 static int scsi_prep_fn(struct request_queue *q, struct request *req)
 {
        struct scsi_device *sdev = q->queuedata;
@@ -1220,18 +1240,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
                                goto kill;
                        }
                } else {
-                       memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
-                       cmd->cmd_len = req->cmd_len;
-                       if (rq_data_dir(req) == WRITE)
-                               cmd->sc_data_direction = DMA_TO_DEVICE;
-                       else if (req->data_len)
-                               cmd->sc_data_direction = DMA_FROM_DEVICE;
-                       else
-                               cmd->sc_data_direction = DMA_NONE;
-                       
-                       cmd->transfersize = req->data_len;
-                       cmd->allowed = 3;
-                       cmd->timeout_per_command = req->timeout;
+                       scsi_setup_blk_pc_cmnd(cmd, 3);
                        cmd->done = scsi_generic_done;
                }
        }
index 8613a1317712c9d40df22c26dc546d1c8b6aea28..03fcbab30033976abcd4d21f5a2bde5016510ecd 100644 (file)
@@ -245,24 +245,10 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
         * SG_IO from block layer already setup, just copy cdb basically
         */
        if (blk_pc_request(rq)) {
-               if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd))
-                       return 0;
-
-               memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
-               SCpnt->cmd_len = rq->cmd_len;
-               if (rq_data_dir(rq) == WRITE)
-                       SCpnt->sc_data_direction = DMA_TO_DEVICE;
-               else if (rq->data_len)
-                       SCpnt->sc_data_direction = DMA_FROM_DEVICE;
-               else
-                       SCpnt->sc_data_direction = DMA_NONE;
-
-               this_count = rq->data_len;
+               scsi_setup_blk_pc_cmnd(SCpnt, SD_PASSTHROUGH_RETRIES);
                if (rq->timeout)
                        timeout = rq->timeout;
 
-               SCpnt->transfersize = rq->data_len;
-               SCpnt->allowed = SD_PASSTHROUGH_RETRIES;
                goto queue;
        }
 
index d68cea753bb2222629db977d5ebf37614dc9c093..fb4012b5c1884b8117a0b2155dd634879352acd7 100644 (file)
@@ -320,25 +320,11 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
         * these are already setup, just copy cdb basically
         */
        if (SCpnt->request->flags & REQ_BLOCK_PC) {
-               struct request *rq = SCpnt->request;
+               scsi_setup_blk_pc_cmnd(SCpnt, MAX_RETRIES);
 
-               if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd))
-                       return 0;
-
-               memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
-               SCpnt->cmd_len = rq->cmd_len;
-               if (!rq->data_len)
-                       SCpnt->sc_data_direction = DMA_NONE;
-               else if (rq_data_dir(rq) == WRITE)
-                       SCpnt->sc_data_direction = DMA_TO_DEVICE;
-               else
-                       SCpnt->sc_data_direction = DMA_FROM_DEVICE;
-
-               this_count = rq->data_len;
-               if (rq->timeout)
-                       timeout = rq->timeout;
+               if (SCpnt->timeout_per_command)
+                       timeout = SCpnt->timeout_per_command;
 
-               SCpnt->transfersize = rq->data_len;
                goto queue;
        }
 
index 7ac6ea141fffafcfc56c0b26b4b269e7aab61ac4..dd592f6a252962cb42f00f09ef5342651985f294 100644 (file)
@@ -4194,27 +4194,10 @@ static void st_intr(struct scsi_cmnd *SCpnt)
  */
 static int st_init_command(struct scsi_cmnd *SCpnt)
 {
-       struct request *rq;
-
        if (!(SCpnt->request->flags & REQ_BLOCK_PC))
                return 0;
 
-       rq = SCpnt->request;
-       if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd))
-               return 0;
-
-       memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
-       SCpnt->cmd_len = rq->cmd_len;
-
-       if (rq_data_dir(rq) == WRITE)
-               SCpnt->sc_data_direction = DMA_TO_DEVICE;
-       else if (rq->data_len)
-               SCpnt->sc_data_direction = DMA_FROM_DEVICE;
-       else
-               SCpnt->sc_data_direction = DMA_NONE;
-
-       SCpnt->timeout_per_command = rq->timeout;
-       SCpnt->transfersize = rq->data_len;
+       scsi_setup_blk_pc_cmnd(SCpnt, 0);
        SCpnt->done = st_intr;
        return 1;
 }
index a7420cad4547d068951fe768408f6f6a150db102..1564ca203a3e6b0d62217fd4a8c2529689215eeb 100644 (file)
@@ -1405,7 +1405,6 @@ static void sym_check_goals(struct sym_hcb *np, struct scsi_target *starget,
                goal->iu = 0;
                goal->dt = 0;
                goal->qas = 0;
-               goal->period = 0;
                goal->offset = 0;
                return;
        }
@@ -1465,7 +1464,8 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp
         * Many devices implement PPR in a buggy way, so only use it if we
         * really want to.
         */
-       if (goal->iu || goal->dt || goal->qas || (goal->period < 0xa)) {
+       if (goal->offset &&
+           (goal->iu || goal->dt || goal->qas || (goal->period < 0xa))) {
                nego = NS_PPR;
        } else if (spi_width(starget) != goal->width) {
                nego = NS_WIDE;
index 7529f4388bb46df6655e61364217c78e2199ea18..20da282d4abbb78041fd5f1bacc868dcc1a021a2 100644 (file)
@@ -151,5 +151,6 @@ extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
 extern void scsi_put_command(struct scsi_cmnd *);
 extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int);
 extern void scsi_finish_command(struct scsi_cmnd *cmd);
+extern void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd, int retries);
 
 #endif /* _SCSI_SCSI_CMND_H */