Commit 57cbd78e authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: mesh: Move the SCSI pointer to private command data

Set .cmd_size in the SCSI host template instead of using the SCSI pointer
from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer
from struct scsi_cmnd.

Link: https://lore.kernel.org/r/20220218195117.25689-35-bvanassche@acm.orgReviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 96e77a27
...@@ -586,10 +586,12 @@ static void mesh_done(struct mesh_state *ms, int start_next) ...@@ -586,10 +586,12 @@ static void mesh_done(struct mesh_state *ms, int start_next)
ms->current_req = NULL; ms->current_req = NULL;
tp->current_req = NULL; tp->current_req = NULL;
if (cmd) { if (cmd) {
struct scsi_pointer *scsi_pointer = mesh_scsi_pointer(cmd);
set_host_byte(cmd, ms->stat); set_host_byte(cmd, ms->stat);
set_status_byte(cmd, cmd->SCp.Status); set_status_byte(cmd, scsi_pointer->Status);
if (ms->stat == DID_OK) if (ms->stat == DID_OK)
scsi_msg_to_host_byte(cmd, cmd->SCp.Message); scsi_msg_to_host_byte(cmd, scsi_pointer->Message);
if (DEBUG_TARGET(cmd)) { if (DEBUG_TARGET(cmd)) {
printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n", printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n",
cmd->result, ms->data_ptr, scsi_bufflen(cmd)); cmd->result, ms->data_ptr, scsi_bufflen(cmd));
...@@ -603,7 +605,7 @@ static void mesh_done(struct mesh_state *ms, int start_next) ...@@ -603,7 +605,7 @@ static void mesh_done(struct mesh_state *ms, int start_next)
} }
#endif #endif
} }
cmd->SCp.this_residual -= ms->data_ptr; scsi_pointer->this_residual -= ms->data_ptr;
scsi_done(cmd); scsi_done(cmd);
} }
if (start_next) { if (start_next) {
...@@ -1171,7 +1173,7 @@ static void handle_msgin(struct mesh_state *ms) ...@@ -1171,7 +1173,7 @@ static void handle_msgin(struct mesh_state *ms)
if (ms->n_msgin < msgin_length(ms)) if (ms->n_msgin < msgin_length(ms))
goto reject; goto reject;
if (cmd) if (cmd)
cmd->SCp.Message = code; mesh_scsi_pointer(cmd)->Message = code;
switch (code) { switch (code) {
case COMMAND_COMPLETE: case COMMAND_COMPLETE:
break; break;
...@@ -1262,7 +1264,7 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd) ...@@ -1262,7 +1264,7 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd)
if (cmd) { if (cmd) {
int nseg; int nseg;
cmd->SCp.this_residual = scsi_bufflen(cmd); mesh_scsi_pointer(cmd)->this_residual = scsi_bufflen(cmd);
nseg = scsi_dma_map(cmd); nseg = scsi_dma_map(cmd);
BUG_ON(nseg < 0); BUG_ON(nseg < 0);
...@@ -1592,10 +1594,13 @@ static void cmd_complete(struct mesh_state *ms) ...@@ -1592,10 +1594,13 @@ static void cmd_complete(struct mesh_state *ms)
break; break;
case statusing: case statusing:
if (cmd) { if (cmd) {
cmd->SCp.Status = mr->fifo; struct scsi_pointer *scsi_pointer =
mesh_scsi_pointer(cmd);
scsi_pointer->Status = mr->fifo;
if (DEBUG_TARGET(cmd)) if (DEBUG_TARGET(cmd))
printk(KERN_DEBUG "mesh: status is %x\n", printk(KERN_DEBUG "mesh: status is %x\n",
cmd->SCp.Status); scsi_pointer->Status);
} }
ms->msgphase = msg_in; ms->msgphase = msg_in;
break; break;
...@@ -1837,6 +1842,7 @@ static struct scsi_host_template mesh_template = { ...@@ -1837,6 +1842,7 @@ static struct scsi_host_template mesh_template = {
.sg_tablesize = SG_ALL, .sg_tablesize = SG_ALL,
.cmd_per_lun = 2, .cmd_per_lun = 2,
.max_segment_size = 65535, .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) static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
......
...@@ -8,6 +8,17 @@ ...@@ -8,6 +8,17 @@
#ifndef _MESH_H #ifndef _MESH_H
#define _MESH_H #define _MESH_H
struct mesh_cmd_priv {
struct scsi_pointer scsi_pointer;
};
static inline struct scsi_pointer *mesh_scsi_pointer(struct scsi_cmnd *cmd)
{
struct mesh_cmd_priv *mcmd = scsi_cmd_priv(cmd);
return &mcmd->scsi_pointer;
}
/* /*
* Registers in the MESH controller. * Registers in the MESH controller.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment