oofff that was to fast, sorry. Wrong sg_count in unmapping.
---
- pluto.c was still issuing use_sg == 0 commands down to
fc.c, which was already converted. Fix that by adding
a member to hold the inquiry_sg in struct fcp_cmnd
and using it when mapping/unmapping of command payload,
if needed.
- Also fix a compilation warning in pluto_info() now that
driver can be compiled not only on sparc.
- Stop using struct scsi_cmnd members that will be removed
soon.
Signed-off-by: Boaz Harrosh <[EMAIL PROTECTED]>
---
drivers/fc4/fc.c | 23 +++++++++++++----------
drivers/fc4/fcp_impl.h | 2 ++
drivers/scsi/pluto.c | 21 +++++++++++++--------
3 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c
index 48c3b62..631e4ad 100644
--- a/drivers/fc4/fc.c
+++ b/drivers/fc4/fc.c
@@ -429,11 +429,13 @@ static inline void fcp_scsi_receive(fc_channel *fc, int
token, int status, fc_hd
if (sense_len > sizeof(SCpnt->sense_buffer)) sense_len
= sizeof(SCpnt->sense_buffer);
memcpy(SCpnt->sense_buffer, ((char *)(rsp+1)),
sense_len);
}
-
- if (fcmd->data)
- dma_unmap_sg(fc->dev, scsi_sglist(SCpnt),
- scsi_sg_count(SCpnt),
- SCpnt->sc_data_direction);
+
+ if (fcmd->data) {
+ struct scatterlist *sg = fcmd->inquiry_sg ?
+ fcmd->inquiry_sg : scsi_sglist(SCpnt);
+
+ dma_unmap_sg(fc->dev, sg, 1, SCpnt->sc_data_direction);
+ }
break;
default:
host_status=DID_ERROR; /* FIXME */
@@ -776,12 +778,11 @@ static int fcp_scsi_queue_it(fc_channel *fc, struct
scsi_cmnd *SCpnt,
} else
fcp_cntl = FCP_CNTL_QTYPE_UNTAGGED;
- if (!scsi_bufflen(SCpnt)) {
+ if (!scsi_bufflen(SCpnt) && !fcmd->inquiry_sg) {
cmd->fcp_cntl = fcp_cntl;
fcmd->data = (dma_addr_t)NULL;
} else {
struct scatterlist *sg;
- int nents;
switch (SCpnt->cmnd[0]) {
case WRITE_6:
@@ -792,9 +793,11 @@ static int fcp_scsi_queue_it(fc_channel *fc, struct
scsi_cmnd *SCpnt,
cmd->fcp_cntl = (FCP_CNTL_READ | fcp_cntl);
break;
}
- sg = scsi_sglist(SCpnt);
- nents = dma_map_sg(fc->dev, sg, scsi_sg_count(SCpnt),
- SCpnt->sc_data_direction);
+ sg = fcmd->inquiry_sg ? fcmd->inquiry_sg :
+ scsi_sglist(SCpnt);
+
+ BUG_ON(scsi_sg_count(SCpnt) > 1);
+ dma_map_sg(fc->dev, sg, 1, SCpnt->sc_data_direction);
fcmd->data = sg_dma_address(sg);
cmd->fcp_data_len = sg_dma_len(sg);
}
diff --git a/drivers/fc4/fcp_impl.h b/drivers/fc4/fcp_impl.h
index 41fa149..728f36d 100644
--- a/drivers/fc4/fcp_impl.h
+++ b/drivers/fc4/fcp_impl.h
@@ -39,6 +39,7 @@ struct _fc_channel;
typedef struct fcp_cmnd {
struct fcp_cmnd *next;
struct fcp_cmnd *prev;
+ struct scatterlist *inquiry_sg;
unsigned short proto;
unsigned short token;
unsigned int did;
@@ -138,6 +139,7 @@ extern fc_channel *fc_channels;
#define FC_STATUS_NO_SEQ_INIT 0x29
#define FC_STATUS_TIMED_OUT -1
#define FC_STATUS_BAD_RSP -2
+#define FC_INQUIRY_SIZE 256
void fcp_queue_empty(fc_channel *);
int fcp_init(fc_channel *);
diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
index e598a90..df231d3 100644
--- a/drivers/scsi/pluto.c
+++ b/drivers/scsi/pluto.c
@@ -14,6 +14,8 @@
#include <linux/proc_fs.h>
#include <linux/stat.h>
#include <linux/init.h>
+#include <linux/scatterlist.h>
+
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
#endif
@@ -46,7 +48,8 @@ static struct ctrl_inquiry {
struct Scsi_Host host;
struct pluto pluto;
Scsi_Cmnd cmd;
- char inquiry[256];
+ char inquiry[FC_INQUIRY_SIZE];
+ struct scatterlist inquiry_sg;
fc_channel *fc;
} *fcs __initdata;
static int fcscount __initdata = 0;
@@ -120,6 +123,7 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
Scsi_Cmnd *SCpnt;
struct Scsi_Host *host;
struct pluto *pluto;
+ fcp_cmnd *fcmd;
if (i == fcscount) break;
if (fc->posmap) continue;
@@ -141,6 +145,7 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
SCpnt = &(fcs[i].cmd);
host = &(fcs[i].host);
pluto = (struct pluto *)host->hostdata;
+ fcmd = ((fcp_cmnd *)&(SCpnt->SCp));
pluto->fc = fc;
@@ -154,9 +159,10 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
SCpnt->cmd_len = COMMAND_SIZE(INQUIRY);
SCpnt->request->cmd_flags &= ~REQ_STARTED;
-
- SCpnt->request_bufflen = 256;
- SCpnt->request_buffer = fcs[i].inquiry;
+ SCpnt->sc_data_direction = DMA_FROM_DEVICE;
+
+ sg_init_one(&fcs[i].inquiry_sg, &fcs[i].inquiry, 256);
+ fcmd->inquiry_sg = &fcs[i].inquiry_sg;
PLD(("set up %d %08lx\n", i, (long)SCpnt))
i++;
}
@@ -271,16 +277,15 @@ int pluto_release(struct Scsi_Host *host)
const char *pluto_info(struct Scsi_Host *host)
{
- static char buf[128], *p;
+ static char buf[128];
struct pluto *pluto = (struct pluto *) host->hostdata;
sprintf(buf, "SUN SparcSTORAGE Array %s fw %s serial %s %dx%d on %s",
pluto->rev_str, pluto->fw_rev_str, pluto->serial_str,
host->max_channel, host->max_id, pluto->fc->name);
#ifdef __sparc__
- p = strchr(buf, 0);
- sprintf(p, " PROM node %x", pluto->fc->dev->prom_node);
-#endif
+ sprintf(buf + strlen(buf), " PROM node %x", pluto->fc->dev->prom_node);
+#endif
return buf;
}
--
1.5.3.1
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html