Commit fc3fdfcc authored by Boaz Harrosh's avatar Boaz Harrosh Committed by James Bottomley

[SCSI] aha1542: convert to accessors and !use_sg cleanup

 - convert to accessors and !use_sg cleanup
Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent cc0455fa
...@@ -51,15 +51,6 @@ ...@@ -51,15 +51,6 @@
#define SCSI_BUF_PA(address) isa_virt_to_bus(address) #define SCSI_BUF_PA(address) isa_virt_to_bus(address)
#define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset) #define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset)
static void BAD_DMA(void *address, unsigned int length)
{
printk(KERN_CRIT "buf vaddress %p paddress 0x%lx length %d\n",
address,
SCSI_BUF_PA(address),
length);
panic("Buffer at physical address > 16Mb used for aha1542");
}
static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, static void BAD_SG_DMA(Scsi_Cmnd * SCpnt,
struct scatterlist *sgp, struct scatterlist *sgp,
int nseg, int nseg,
...@@ -597,8 +588,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) ...@@ -597,8 +588,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
unchar target = SCpnt->device->id; unchar target = SCpnt->device->id;
unchar lun = SCpnt->device->lun; unchar lun = SCpnt->device->lun;
unsigned long flags; unsigned long flags;
void *buff = SCpnt->request_buffer; int bufflen = scsi_bufflen(SCpnt);
int bufflen = SCpnt->request_bufflen;
int mbo; int mbo;
struct mailbox *mb; struct mailbox *mb;
struct ccb *ccb; struct ccb *ccb;
...@@ -689,42 +679,29 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) ...@@ -689,42 +679,29 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen); memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen);
if (SCpnt->use_sg) { if (bufflen) {
struct scatterlist *sg; struct scatterlist *sg;
struct chain *cptr; struct chain *cptr;
#ifdef DEBUG #ifdef DEBUG
unsigned char *ptr; unsigned char *ptr;
#endif #endif
int i; int i, sg_count = scsi_sg_count(SCpnt);
ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */
SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA); SCpnt->host_scribble = kmalloc(sizeof(*cptr)*sg_count,
GFP_KERNEL | GFP_DMA);
cptr = (struct chain *) SCpnt->host_scribble; cptr = (struct chain *) SCpnt->host_scribble;
if (cptr == NULL) { if (cptr == NULL) {
/* free the claimed mailbox slot */ /* free the claimed mailbox slot */
HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL; HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL;
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
} }
scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { scsi_for_each_sg(SCpnt, sg, sg_count, i) {
if (sg->length == 0 || SCpnt->use_sg > 16 ||
(((int) sg->offset) & 1) || (sg->length & 1)) {
unsigned char *ptr;
printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i);
scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) {
printk(KERN_CRIT "%d: %p %d\n", i,
sg_virt(sg), sg->length);
};
printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr);
ptr = (unsigned char *) &cptr[i];
for (i = 0; i < 18; i++)
printk("%02x ", ptr[i]);
panic("Foooooooood fight!");
};
any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg)); any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg));
if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD) if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD)
BAD_SG_DMA(SCpnt, sg, SCpnt->use_sg, i); BAD_SG_DMA(SCpnt, scsi_sglist(SCpnt), sg_count, i);
any2scsi(cptr[i].datalen, sg->length); any2scsi(cptr[i].datalen, sg->length);
}; };
any2scsi(ccb[mbo].datalen, SCpnt->use_sg * sizeof(struct chain)); any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain));
any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr));
#ifdef DEBUG #ifdef DEBUG
printk("cptr %x: ", cptr); printk("cptr %x: ", cptr);
...@@ -735,10 +712,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) ...@@ -735,10 +712,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
} else { } else {
ccb[mbo].op = 0; /* SCSI Initiator Command */ ccb[mbo].op = 0; /* SCSI Initiator Command */
SCpnt->host_scribble = NULL; SCpnt->host_scribble = NULL;
any2scsi(ccb[mbo].datalen, bufflen); any2scsi(ccb[mbo].datalen, 0);
if (buff && SCSI_BUF_PA(buff + bufflen - 1) > ISA_DMA_THRESHOLD) any2scsi(ccb[mbo].dataptr, 0);
BAD_DMA(buff, bufflen);
any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(buff));
}; };
ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */ ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */
ccb[mbo].rsalen = 16; ccb[mbo].rsalen = 16;
......
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