Commit 9a53dd0c authored by Alan Cox's avatar Alan Cox Committed by Jens Axboe

[PATCH] Fix aha1542

Randy Dunlap included this with the 152x stuff which then got lost in
discussion about core changes and queueing reset. 154x doesnt need the
extra discussion. Also adds a fix to use mca-legacy as needed for 1640
right now
parent 15d6f88e
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/isapnp.h> #include <linux/isapnp.h>
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/mca.h> #include <linux/mca.h>
#include <linux/mca-legacy.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -597,8 +598,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) ...@@ -597,8 +598,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
unchar ahacmd = CMD_START_SCSI; unchar ahacmd = CMD_START_SCSI;
unchar direction; unchar direction;
unchar *cmd = (unchar *) SCpnt->cmnd; unchar *cmd = (unchar *) SCpnt->cmnd;
unchar target = SCpnt->target; unchar target = SCpnt->device->id;
unchar lun = SCpnt->lun; unchar lun = SCpnt->device->lun;
unsigned long flags; unsigned long flags;
void *buff = SCpnt->request_buffer; void *buff = SCpnt->request_buffer;
int bufflen = SCpnt->request_bufflen; int bufflen = SCpnt->request_bufflen;
...@@ -608,8 +609,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) ...@@ -608,8 +609,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
DEB(int i); DEB(int i);
mb = HOSTDATA(SCpnt->host)->mb; mb = HOSTDATA(SCpnt->device->host)->mb;
ccb = HOSTDATA(SCpnt->host)->ccb; ccb = HOSTDATA(SCpnt->device->host)->ccb;
DEB(if (target > 1) { DEB(if (target > 1) {
SCpnt->result = DID_TIME_OUT << 16; SCpnt->result = DID_TIME_OUT << 16;
...@@ -653,25 +654,25 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) ...@@ -653,25 +654,25 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
is how the host adapter will scan for them */ is how the host adapter will scan for them */
spin_lock_irqsave(&aha1542_lock, flags); spin_lock_irqsave(&aha1542_lock, flags);
mbo = HOSTDATA(SCpnt->host)->aha1542_last_mbo_used + 1; mbo = HOSTDATA(SCpnt->device->host)->aha1542_last_mbo_used + 1;
if (mbo >= AHA1542_MAILBOXES) if (mbo >= AHA1542_MAILBOXES)
mbo = 0; mbo = 0;
do { do {
if (mb[mbo].status == 0 && HOSTDATA(SCpnt->host)->SCint[mbo] == NULL) if (mb[mbo].status == 0 && HOSTDATA(SCpnt->device->host)->SCint[mbo] == NULL)
break; break;
mbo++; mbo++;
if (mbo >= AHA1542_MAILBOXES) if (mbo >= AHA1542_MAILBOXES)
mbo = 0; mbo = 0;
} while (mbo != HOSTDATA(SCpnt->host)->aha1542_last_mbo_used); } while (mbo != HOSTDATA(SCpnt->device->host)->aha1542_last_mbo_used);
if (mb[mbo].status || HOSTDATA(SCpnt->host)->SCint[mbo]) if (mb[mbo].status || HOSTDATA(SCpnt->device->host)->SCint[mbo])
panic("Unable to find empty mailbox for aha1542.\n"); panic("Unable to find empty mailbox for aha1542.\n");
HOSTDATA(SCpnt->host)->SCint[mbo] = SCpnt; /* This will effectively prevent someone else from HOSTDATA(SCpnt->device->host)->SCint[mbo] = SCpnt; /* This will effectively prevent someone else from
screwing with this cdb. */ screwing with this cdb. */
HOSTDATA(SCpnt->host)->aha1542_last_mbo_used = mbo; HOSTDATA(SCpnt->device->host)->aha1542_last_mbo_used = mbo;
spin_unlock_irqrestore(&aha1542_lock, flags); spin_unlock_irqrestore(&aha1542_lock, flags);
#ifdef DEBUG #ifdef DEBUG
...@@ -762,7 +763,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) ...@@ -762,7 +763,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
aha1542_stat()); aha1542_stat());
SCpnt->scsi_done = done; SCpnt->scsi_done = done;
mb[mbo].status = 1; mb[mbo].status = 1;
aha1542_out(SCpnt->host->io_port, &ahacmd, 1); /* start scsi command */ aha1542_out(SCpnt->device->host->io_port, &ahacmd, 1); /* start scsi command */
DEB(aha1542_stat()); DEB(aha1542_stat());
} else } else
printk("aha1542_queuecommand: done can't be NULL\n"); printk("aha1542_queuecommand: done can't be NULL\n");
...@@ -1356,7 +1357,7 @@ static int aha1542_abort(Scsi_Cmnd * SCpnt) ...@@ -1356,7 +1357,7 @@ static int aha1542_abort(Scsi_Cmnd * SCpnt)
*/ */
printk(KERN_ERR "aha1542.c: Unable to abort command for target %d\n", printk(KERN_ERR "aha1542.c: Unable to abort command for target %d\n",
SCpnt->target); SCpnt->device->id);
return FAILED; return FAILED;
} }
...@@ -1368,36 +1369,36 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt) ...@@ -1368,36 +1369,36 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)
{ {
unsigned long flags; unsigned long flags;
struct mailbox *mb; struct mailbox *mb;
unchar target = SCpnt->target; unchar target = SCpnt->device->id;
unchar lun = SCpnt->lun; unchar lun = SCpnt->device->lun;
int mbo; int mbo;
struct ccb *ccb; struct ccb *ccb;
unchar ahacmd = CMD_START_SCSI; unchar ahacmd = CMD_START_SCSI;
ccb = HOSTDATA(SCpnt->host)->ccb; ccb = HOSTDATA(SCpnt->device->host)->ccb;
mb = HOSTDATA(SCpnt->host)->mb; mb = HOSTDATA(SCpnt->device->host)->mb;
spin_lock_irqsave(&aha1542_lock, flags); spin_lock_irqsave(&aha1542_lock, flags);
mbo = HOSTDATA(SCpnt->host)->aha1542_last_mbo_used + 1; mbo = HOSTDATA(SCpnt->device->host)->aha1542_last_mbo_used + 1;
if (mbo >= AHA1542_MAILBOXES) if (mbo >= AHA1542_MAILBOXES)
mbo = 0; mbo = 0;
do { do {
if (mb[mbo].status == 0 && HOSTDATA(SCpnt->host)->SCint[mbo] == NULL) if (mb[mbo].status == 0 && HOSTDATA(SCpnt->device->host)->SCint[mbo] == NULL)
break; break;
mbo++; mbo++;
if (mbo >= AHA1542_MAILBOXES) if (mbo >= AHA1542_MAILBOXES)
mbo = 0; mbo = 0;
} while (mbo != HOSTDATA(SCpnt->host)->aha1542_last_mbo_used); } while (mbo != HOSTDATA(SCpnt->device->host)->aha1542_last_mbo_used);
if (mb[mbo].status || HOSTDATA(SCpnt->host)->SCint[mbo]) if (mb[mbo].status || HOSTDATA(SCpnt->device->host)->SCint[mbo])
panic("Unable to find empty mailbox for aha1542.\n"); panic("Unable to find empty mailbox for aha1542.\n");
HOSTDATA(SCpnt->host)->SCint[mbo] = SCpnt; /* This will effectively HOSTDATA(SCpnt->device->host)->SCint[mbo] = SCpnt; /* This will effectively
prevent someone else from prevent someone else from
screwing with this cdb. */ screwing with this cdb. */
HOSTDATA(SCpnt->host)->aha1542_last_mbo_used = mbo; HOSTDATA(SCpnt->device->host)->aha1542_last_mbo_used = mbo;
spin_unlock_irqrestore(&aha1542_lock, flags); spin_unlock_irqrestore(&aha1542_lock, flags);
any2scsi(mb[mbo].ccbptr, SCSI_BUF_PA(&ccb[mbo])); /* This gets trashed for some reason */ any2scsi(mb[mbo].ccbptr, SCSI_BUF_PA(&ccb[mbo])); /* This gets trashed for some reason */
...@@ -1415,9 +1416,9 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt) ...@@ -1415,9 +1416,9 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)
* Now tell the 1542 to flush all pending commands for this * Now tell the 1542 to flush all pending commands for this
* target * target
*/ */
aha1542_out(SCpnt->host->io_port, &ahacmd, 1); aha1542_out(SCpnt->device->host->io_port, &ahacmd, 1);
printk(KERN_WARNING "aha1542.c: Trying device reset for target %d\n", SCpnt->target); printk(KERN_WARNING "aha1542.c: Trying device reset for target %d\n", SCpnt->device->id);
return SUCCESS; return SUCCESS;
...@@ -1467,7 +1468,7 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) ...@@ -1467,7 +1468,7 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)
* we do this? Try this first, and we can add that later * we do this? Try this first, and we can add that later
* if it turns out to be useful. * if it turns out to be useful.
*/ */
outb(SCRST, CONTROL(SCpnt->host->io_port)); outb(SCRST, CONTROL(SCpnt->device->host->io_port));
/* /*
* Wait for the thing to settle down a bit. Unfortunately * Wait for the thing to settle down a bit. Unfortunately
...@@ -1476,11 +1477,11 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) ...@@ -1476,11 +1477,11 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)
* check for timeout, and if we are doing something like this * check for timeout, and if we are doing something like this
* we are pretty desperate anyways. * we are pretty desperate anyways.
*/ */
spin_unlock_irq(SCpnt->host->host_lock); spin_unlock_irq(SCpnt->device->host->host_lock);
scsi_sleep(4 * HZ); scsi_sleep(4 * HZ);
spin_lock_irq(SCpnt->host->host_lock); spin_lock_irq(SCpnt->device->host->host_lock);
WAIT(STATUS(SCpnt->host->io_port), WAIT(STATUS(SCpnt->device->host->io_port),
STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF); STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF);
/* /*
...@@ -1489,12 +1490,12 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) ...@@ -1489,12 +1490,12 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)
* out. We do not try and restart any commands or anything - * out. We do not try and restart any commands or anything -
* the strategy handler takes care of that crap. * the strategy handler takes care of that crap.
*/ */
printk(KERN_WARNING "Sent BUS RESET to scsi host %d\n", SCpnt->host->host_no); printk(KERN_WARNING "Sent BUS RESET to scsi host %d\n", SCpnt->device->host->host_no);
for (i = 0; i < AHA1542_MAILBOXES; i++) { for (i = 0; i < AHA1542_MAILBOXES; i++) {
if (HOSTDATA(SCpnt->host)->SCint[i] != NULL) { if (HOSTDATA(SCpnt->device->host)->SCint[i] != NULL) {
Scsi_Cmnd *SCtmp; Scsi_Cmnd *SCtmp;
SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; SCtmp = HOSTDATA(SCpnt->device->host)->SCint[i];
if (SCtmp->device->soft_reset) { if (SCtmp->device->soft_reset) {
...@@ -1510,8 +1511,8 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) ...@@ -1510,8 +1511,8 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)
kfree(SCtmp->host_scribble); kfree(SCtmp->host_scribble);
SCtmp->host_scribble = NULL; SCtmp->host_scribble = NULL;
} }
HOSTDATA(SCpnt->host)->SCint[i] = NULL; HOSTDATA(SCpnt->device->host)->SCint[i] = NULL;
HOSTDATA(SCpnt->host)->mb[i].status = 0; HOSTDATA(SCpnt->device->host)->mb[i].status = 0;
} }
} }
...@@ -1531,7 +1532,7 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt) ...@@ -1531,7 +1532,7 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
* we do this? Try this first, and we can add that later * we do this? Try this first, and we can add that later
* if it turns out to be useful. * if it turns out to be useful.
*/ */
outb(HRST | SCRST, CONTROL(SCpnt->host->io_port)); outb(HRST | SCRST, CONTROL(SCpnt->device->host->io_port));
/* /*
* Wait for the thing to settle down a bit. Unfortunately * Wait for the thing to settle down a bit. Unfortunately
...@@ -1540,18 +1541,18 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt) ...@@ -1540,18 +1541,18 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
* check for timeout, and if we are doing something like this * check for timeout, and if we are doing something like this
* we are pretty desperate anyways. * we are pretty desperate anyways.
*/ */
spin_unlock_irq(SCpnt->host->host_lock); spin_unlock_irq(SCpnt->device->host->host_lock);
scsi_sleep(4 * HZ); scsi_sleep(4 * HZ);
spin_lock_irq(SCpnt->host->host_lock); spin_lock_irq(SCpnt->device->host->host_lock);
WAIT(STATUS(SCpnt->host->io_port), WAIT(STATUS(SCpnt->device->host->io_port),
STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF); STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF);
/* /*
* We need to do this too before the 1542 can interact with * We need to do this too before the 1542 can interact with
* us again. * us again.
*/ */
setup_mailboxes(SCpnt->host->io_port, SCpnt->host); setup_mailboxes(SCpnt->device->host->io_port, SCpnt->device->host);
/* /*
* Now try to pick up the pieces. For all pending commands, * Now try to pick up the pieces. For all pending commands,
...@@ -1559,12 +1560,12 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt) ...@@ -1559,12 +1560,12 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
* out. We do not try and restart any commands or anything - * out. We do not try and restart any commands or anything -
* the strategy handler takes care of that crap. * the strategy handler takes care of that crap.
*/ */
printk(KERN_WARNING "Sent BUS RESET to scsi host %d\n", SCpnt->host->host_no); printk(KERN_WARNING "Sent BUS RESET to scsi host %d\n", SCpnt->device->host->host_no);
for (i = 0; i < AHA1542_MAILBOXES; i++) { for (i = 0; i < AHA1542_MAILBOXES; i++) {
if (HOSTDATA(SCpnt->host)->SCint[i] != NULL) { if (HOSTDATA(SCpnt->device->host)->SCint[i] != NULL) {
Scsi_Cmnd *SCtmp; Scsi_Cmnd *SCtmp;
SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; SCtmp = HOSTDATA(SCpnt->device->host)->SCint[i];
if (SCtmp->device->soft_reset) { if (SCtmp->device->soft_reset) {
/* /*
...@@ -1579,8 +1580,8 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt) ...@@ -1579,8 +1580,8 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
kfree(SCtmp->host_scribble); kfree(SCtmp->host_scribble);
SCtmp->host_scribble = NULL; SCtmp->host_scribble = NULL;
} }
HOSTDATA(SCpnt->host)->SCint[i] = NULL; HOSTDATA(SCpnt->device->host)->SCint[i] = NULL;
HOSTDATA(SCpnt->host)->mb[i].status = 0; HOSTDATA(SCpnt->device->host)->mb[i].status = 0;
} }
} }
......
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