diff options
Diffstat (limited to 'drivers/scsi/mesh.c')
-rw-r--r-- | drivers/scsi/mesh.c | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index 74fb50644678..84b541a57b7b 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c @@ -31,14 +31,14 @@ #include <linux/reboot.h> #include <linux/spinlock.h> #include <linux/pci.h> +#include <linux/pgtable.h> #include <asm/dbdma.h> #include <asm/io.h> -#include <asm/pgtable.h> #include <asm/prom.h> #include <asm/irq.h> #include <asm/hydra.h> #include <asm/processor.h> -#include <asm/machdep.h> +#include <asm/setup.h> #include <asm/pmac_feature.h> #include <asm/macio.h> @@ -342,15 +342,6 @@ static inline void mesh_flush_io(volatile struct mesh_regs __iomem *mr) } -/* - * Complete a SCSI command - */ -static void mesh_completed(struct mesh_state *ms, struct scsi_cmnd *cmd) -{ - (*cmd->scsi_done)(cmd); -} - - /* Called with meshinterrupt disabled, initialize the chipset * and eventually do the initial bus reset. The lock must not be * held since we can schedule. @@ -595,9 +586,12 @@ static void mesh_done(struct mesh_state *ms, int start_next) ms->current_req = NULL; tp->current_req = NULL; if (cmd) { - cmd->result = (ms->stat << 16) | cmd->SCp.Status; + struct mesh_cmd_priv *mcmd = mesh_priv(cmd); + + set_host_byte(cmd, ms->stat); + set_status_byte(cmd, mcmd->status); if (ms->stat == DID_OK) - cmd->result |= cmd->SCp.Message << 8; + scsi_msg_to_host_byte(cmd, mcmd->message); if (DEBUG_TARGET(cmd)) { printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n", cmd->result, ms->data_ptr, scsi_bufflen(cmd)); @@ -611,8 +605,8 @@ static void mesh_done(struct mesh_state *ms, int start_next) } #endif } - cmd->SCp.this_residual -= ms->data_ptr; - mesh_completed(ms, cmd); + mcmd->this_residual -= ms->data_ptr; + scsi_done(cmd); } if (start_next) { out_8(&ms->mesh->sequence, SEQ_ENBRESEL); @@ -993,9 +987,9 @@ static void handle_reset(struct mesh_state *ms) for (tgt = 0; tgt < 8; ++tgt) { tp = &ms->tgts[tgt]; if ((cmd = tp->current_req) != NULL) { - cmd->result = DID_RESET << 16; + set_host_byte(cmd, DID_RESET); tp->current_req = NULL; - mesh_completed(ms, cmd); + scsi_done(cmd); } ms->tgts[tgt].sdtr_state = do_sdtr; ms->tgts[tgt].sync_params = ASYNC_PARAMS; @@ -1003,8 +997,8 @@ static void handle_reset(struct mesh_state *ms) ms->current_req = NULL; while ((cmd = ms->request_q) != NULL) { ms->request_q = (struct scsi_cmnd *) cmd->host_scribble; - cmd->result = DID_RESET << 16; - mesh_completed(ms, cmd); + set_host_byte(cmd, DID_RESET); + scsi_done(cmd); } ms->phase = idle; ms->msgphase = msg_none; @@ -1045,6 +1039,8 @@ static void handle_error(struct mesh_state *ms) while ((in_8(&mr->bus_status1) & BS1_RST) != 0) udelay(1); printk("done\n"); + if (ms->dma_started) + halt_dma(ms); handle_reset(ms); /* request_q is empty, no point in mesh_start() */ return; @@ -1177,7 +1173,7 @@ static void handle_msgin(struct mesh_state *ms) if (ms->n_msgin < msgin_length(ms)) goto reject; if (cmd) - cmd->SCp.Message = code; + mesh_priv(cmd)->message = code; switch (code) { case COMMAND_COMPLETE: break; @@ -1268,7 +1264,7 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd) if (cmd) { int nseg; - cmd->SCp.this_residual = scsi_bufflen(cmd); + mesh_priv(cmd)->this_residual = scsi_bufflen(cmd); nseg = scsi_dma_map(cmd); BUG_ON(nseg < 0); @@ -1357,7 +1353,8 @@ static void halt_dma(struct mesh_state *ms) ms->conn_tgt, ms->data_ptr, scsi_bufflen(cmd), ms->tgts[ms->conn_tgt].data_goes_out); } - scsi_dma_unmap(cmd); + if (cmd) + scsi_dma_unmap(cmd); ms->dma_started = 0; } @@ -1454,7 +1451,7 @@ static void cmd_complete(struct mesh_state *ms) /* huh? we expected a phase mismatch */ ms->n_msgin = 0; ms->msgphase = msg_in; - /* fall through */ + fallthrough; case msg_in: /* should have some message bytes in fifo */ @@ -1597,10 +1594,12 @@ static void cmd_complete(struct mesh_state *ms) break; case statusing: if (cmd) { - cmd->SCp.Status = mr->fifo; + struct mesh_cmd_priv *mcmd = mesh_priv(cmd); + + mcmd->status = mr->fifo; if (DEBUG_TARGET(cmd)) printk(KERN_DEBUG "mesh: status is %x\n", - cmd->SCp.Status); + mcmd->status); } ms->msgphase = msg_in; break; @@ -1626,11 +1625,10 @@ static void cmd_complete(struct mesh_state *ms) * Called by midlayer with host locked to queue a new * request */ -static int mesh_queue_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) +static int mesh_queue_lck(struct scsi_cmnd *cmd) { struct mesh_state *ms; - cmd->scsi_done = done; cmd->host_scribble = NULL; ms = (struct mesh_state *) cmd->device->host->hostdata; @@ -1712,6 +1710,9 @@ static int mesh_host_reset(struct scsi_cmnd *cmd) spin_lock_irqsave(ms->host->host_lock, flags); + if (ms->dma_started) + halt_dma(ms); + /* Reset the controller & dbdma channel */ out_le32(&md->control, (RUN|PAUSE|FLUSH|WAKE) << 16); /* stop dma */ out_8(&mr->exception, 0xff); /* clear all exception bits */ @@ -1840,6 +1841,7 @@ static struct scsi_host_template mesh_template = { .sg_tablesize = SG_ALL, .cmd_per_lun = 2, .max_segment_size = 65535, + .cmd_size = sizeof(struct mesh_cmd_priv), }; static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) @@ -1880,11 +1882,6 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) goto out_release; } - /* Old junk for root discovery, that will die ultimately */ -#if !defined(MODULE) - note_scsi_host(mesh, mesh_host); -#endif - mesh_host->base = macio_resource_start(mdev, 0); mesh_host->irq = macio_irq(mdev, 0); ms = (struct mesh_state *) mesh_host->hostdata; |