diff options
Diffstat (limited to 'drivers/scsi/mesh.c')
| -rw-r--r-- | drivers/scsi/mesh.c | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index c9dc7740e9e7..768b85eecc8f 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * SCSI low-level driver for the MESH (Macintosh Enhanced SCSI Hardware) * bus adaptor found on Power Macintosh computers. @@ -30,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> @@ -53,7 +54,7 @@ #define KERN_DEBUG KERN_WARNING #endif -MODULE_AUTHOR("Paul Mackerras (paulus@samba.org)"); +MODULE_AUTHOR("Paul Mackerras <paulus@samba.org>"); MODULE_DESCRIPTION("PowerMac MESH SCSI driver"); MODULE_LICENSE("GPL"); @@ -341,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. @@ -594,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)); @@ -610,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); @@ -992,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; @@ -1002,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; @@ -1044,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; @@ -1176,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; @@ -1267,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); @@ -1356,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; } @@ -1453,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 */ @@ -1596,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; @@ -1625,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; @@ -1711,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 */ @@ -1760,6 +1762,7 @@ static int mesh_suspend(struct macio_dev *mdev, pm_message_t mesg) case PM_EVENT_SUSPEND: case PM_EVENT_HIBERNATE: case PM_EVENT_FREEZE: + case PM_EVENT_POWEROFF: break; default: return 0; @@ -1828,7 +1831,7 @@ static int mesh_shutdown(struct macio_dev *mdev) return 0; } -static struct scsi_host_template mesh_template = { +static const struct scsi_host_template mesh_template = { .proc_name = "mesh", .name = "MESH", .queuecommand = mesh_queue, @@ -1839,6 +1842,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) @@ -1879,11 +1883,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; @@ -1988,7 +1987,7 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) return -ENODEV; } -static int mesh_remove(struct macio_dev *mdev) +static void mesh_remove(struct macio_dev *mdev) { struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev); struct Scsi_Host *mesh_host = ms->host; @@ -2015,11 +2014,8 @@ static int mesh_remove(struct macio_dev *mdev) macio_release_resources(mdev); scsi_host_put(mesh_host); - - return 0; } - static struct of_device_id mesh_match[] = { { |
