Commit 1fbcea01 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] first pass at seagate st-02 for 2.5

parent 147f09f5
...@@ -265,16 +265,14 @@ MODULE_LICENSE("GPL"); ...@@ -265,16 +265,14 @@ MODULE_LICENSE("GPL");
#define WRITE_CONTROL(d) { isa_writeb((d), st0x_cr_sr); } #define WRITE_CONTROL(d) { isa_writeb((d), st0x_cr_sr); }
#define WRITE_DATA(d) { isa_writeb((d), st0x_dr); } #define WRITE_DATA(d) { isa_writeb((d), st0x_dr); }
void static void st0x_setup (char *str, int *ints)
st0x_setup (char *str, int *ints)
{ {
controller_type = SEAGATE; controller_type = SEAGATE;
base_address = ints[1]; base_address = ints[1];
irq = ints[2]; irq = ints[2];
} }
void static void tmc8xx_setup (char *str, int *ints)
tmc8xx_setup (char *str, int *ints)
{ {
controller_type = FD; controller_type = FD;
base_address = ints[1]; base_address = ints[1];
...@@ -389,8 +387,14 @@ static void __init borken_init (void) ...@@ -389,8 +387,14 @@ static void __init borken_init (void)
{ {
register int count = 0, start = jiffies + 1, stop = start + 25; register int count = 0, start = jiffies + 1, stop = start + 25;
while (time_before (jiffies, start)) ; /* FIXME: There may be a better approach, this is a straight port for
for (; time_before (jiffies, stop); ++count) ; now */
preempt_disable();
while (time_before (jiffies, start))
cpu_relax();
for (; time_before (jiffies, stop); ++count)
cpu_relax();
preempt_enable();
/* /*
* Ok, we now have a count for .25 seconds. Convert to a * Ok, we now have a count for .25 seconds. Convert to a
...@@ -406,8 +410,9 @@ static inline void borken_wait (void) ...@@ -406,8 +410,9 @@ static inline void borken_wait (void)
{ {
register int count; register int count;
for (count = borken_calibration; count && (STATUS & STAT_REQ); for (count = borken_calibration; count && (STATUS & STAT_REQ); --count)
--count) ; cpu_relax();
#if (DEBUG & DEBUG_BORKEN) #if (DEBUG & DEBUG_BORKEN)
if (count) if (count)
printk ("scsi%d : borken timeout\n", hostno); printk ("scsi%d : borken timeout\n", hostno);
...@@ -462,14 +467,9 @@ int __init seagate_st0x_detect (Scsi_Host_Template * tpnt) ...@@ -462,14 +467,9 @@ int __init seagate_st0x_detect (Scsi_Host_Template * tpnt)
* space for the on-board RAM instead. * space for the on-board RAM instead.
*/ */
for (i = 0; for (i = 0; i < (sizeof (seagate_bases) / sizeof (unsigned int)); ++i)
i < (sizeof (seagate_bases) / sizeof (unsigned int)); ++i)
for (j = 0; !base_address && j < NUM_SIGNATURES; ++j) for (j = 0; !base_address && j < NUM_SIGNATURES; ++j)
if (isa_check_signature if (isa_check_signature(seagate_bases[i] + signatures[j].offset, signatures[j].signature, signatures[j].length)) {
(seagate_bases[i] + signatures[j].offset,
signatures[j].signature,
signatures[j].length)) {
base_address = seagate_bases[i]; base_address = seagate_bases[i];
controller_type = signatures[j].type; controller_type = signatures[j].type;
} }
...@@ -480,40 +480,36 @@ int __init seagate_st0x_detect (Scsi_Host_Template * tpnt) ...@@ -480,40 +480,36 @@ int __init seagate_st0x_detect (Scsi_Host_Template * tpnt)
tpnt->name = (controller_type == SEAGATE) ? ST0X_ID_STR : FD_ID_STR; tpnt->name = (controller_type == SEAGATE) ? ST0X_ID_STR : FD_ID_STR;
if (!base_address) { if (!base_address) {
DANY ("ST0x / TMC-8xx not detected.\n"); printk(KERN_INFO "seagate: ST0x/TMC-8xx not detected.\n");
return 0; return 0;
} }
st0x_cr_sr = st0x_cr_sr = base_address + (controller_type == SEAGATE ? 0x1a00 : 0x1c00);
base_address + (controller_type == SEAGATE ? 0x1a00 : 0x1c00);
st0x_dr = st0x_cr_sr + 0x200; st0x_dr = st0x_cr_sr + 0x200;
DANY ("%s detected. Base address = %x, cr = %x, dr = %x\n", DANY("%s detected. Base address = %x, cr = %x, dr = %x\n",
tpnt->name, base_address, st0x_cr_sr, st0x_dr); tpnt->name, base_address, st0x_cr_sr, st0x_dr);
/* /*
* At all times, we will use IRQ 5. Should also check for IRQ3 if we * At all times, we will use IRQ 5. Should also check for IRQ3
* loose our first interrupt. * if we loose our first interrupt.
*/ */
instance = scsi_register (tpnt, 0); instance = scsi_register (tpnt, 0);
if (instance == NULL) if (instance == NULL)
return 0; return 0;
hostno = instance->host_no; hostno = instance->host_no;
if (request_irq (irq, do_seagate_reconnect_intr, SA_INTERRUPT, if (request_irq (irq, do_seagate_reconnect_intr, SA_INTERRUPT, (controller_type == SEAGATE) ? "seagate" : "tmc-8xx", instance)) {
(controller_type == SEAGATE) ? "seagate" : "tmc-8xx", printk(KERN_ERR "scsi%d : unable to allocate IRQ%d\n", hostno, irq);
instance)) {
printk ("scsi%d : unable to allocate IRQ%d\n", hostno, irq);
return 0; return 0;
} }
instance->irq = irq; instance->irq = irq;
instance->io_port = base_address; instance->io_port = base_address;
#ifdef SLOW_RATE #ifdef SLOW_RATE
printk (KERN_INFO "Calibrating borken timer... "); printk(KERN_INFO "Calibrating borken timer... ");
borken_init (); borken_init();
printk (" %d cycles per transfer\n", borken_calibration); printk(" %d cycles per transfer\n", borken_calibration);
#endif #endif
printk (KERN_INFO "This is one second... "); printk (KERN_INFO "This is one second... ");
{ {
int clock; int clock;
...@@ -559,12 +555,11 @@ int __init seagate_st0x_detect (Scsi_Host_Template * tpnt) ...@@ -559,12 +555,11 @@ int __init seagate_st0x_detect (Scsi_Host_Template * tpnt)
return 1; return 1;
} }
const char * static const char *seagate_st0x_info (struct Scsi_Host *shpnt)
seagate_st0x_info (struct Scsi_Host *shpnt)
{ {
static char buffer[64]; static char buffer[64];
sprintf (buffer, "%s at irq %d, address 0x%05X", snprintf(buffer, 64, "%s at irq %d, address 0x%05X",
(controller_type == SEAGATE) ? ST0X_ID_STR : FD_ID_STR, (controller_type == SEAGATE) ? ST0X_ID_STR : FD_ID_STR,
irq, base_address); irq, base_address);
return buffer; return buffer;
...@@ -640,36 +635,29 @@ static void seagate_reconnect_intr (int irq, void *dev_id, struct pt_regs *regs) ...@@ -640,36 +635,29 @@ static void seagate_reconnect_intr (int irq, void *dev_id, struct pt_regs *regs)
int temp; int temp;
Scsi_Cmnd *SCtmp; Scsi_Cmnd *SCtmp;
DPRINTK (PHASE_RESELECT, "scsi%d : seagate_reconnect_intr() called\n", DPRINTK (PHASE_RESELECT, "scsi%d : seagate_reconnect_intr() called\n", hostno);
hostno);
if (!should_reconnect) if (!should_reconnect)
printk ("scsi%d: unexpected interrupt.\n", hostno); printk(KERN_WARNING "scsi%d: unexpected interrupt.\n", hostno);
else { else {
should_reconnect = 0; should_reconnect = 0;
DPRINTK (PHASE_RESELECT, "scsi%d : internal_command(" DPRINTK (PHASE_RESELECT, "scsi%d : internal_command(%d, %08x, %08x, RECONNECT_NOW\n",
"%d, %08x, %08x, RECONNECT_NOW\n", hostno, hostno, current_target, current_data, current_bufflen);
current_target, current_data, current_bufflen);
temp = temp = internal_command (current_target, current_lun, current_cmnd, current_data, current_bufflen, RECONNECT_NOW);
internal_command (current_target, current_lun, current_cmnd,
current_data, current_bufflen,
RECONNECT_NOW);
if (msg_byte (temp) != DISCONNECT) { if (msg_byte(temp) != DISCONNECT) {
if (done_fn) { if (done_fn) {
DPRINTK (PHASE_RESELECT, DPRINTK(PHASE_RESELECT, "scsi%d : done_fn(%d,%08x)", hostno, hostno, temp);
"scsi%d : done_fn(%d,%08x)", hostno,
hostno, temp);
if (!SCint) if (!SCint)
panic ("SCint == NULL in seagate"); panic ("SCint == NULL in seagate");
SCtmp = SCint; SCtmp = SCint;
SCint = NULL; SCint = NULL;
SCtmp->result = temp; SCtmp->result = temp;
done_fn (SCtmp); done_fn(SCtmp);
} else } else
printk ("done_fn() not defined.\n"); printk(KERN_ERR "done_fn() not defined.\n");
} }
} }
} }
...@@ -687,7 +675,7 @@ static void seagate_reconnect_intr (int irq, void *dev_id, struct pt_regs *regs) ...@@ -687,7 +675,7 @@ static void seagate_reconnect_intr (int irq, void *dev_id, struct pt_regs *regs)
static int recursion_depth = 0; static int recursion_depth = 0;
int seagate_st0x_queue_command (Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) static int seagate_st0x_queue_command (Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
{ {
int result, reconnect; int result, reconnect;
Scsi_Cmnd *SCtmp; Scsi_Cmnd *SCtmp;
...@@ -696,53 +684,49 @@ int seagate_st0x_queue_command (Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) ...@@ -696,53 +684,49 @@ int seagate_st0x_queue_command (Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
done_fn = done; done_fn = done;
current_target = SCpnt->target; current_target = SCpnt->target;
current_lun = SCpnt->lun; current_lun = SCpnt->lun;
(const void *) current_cmnd = SCpnt->cmnd; current_cmnd = SCpnt->cmnd;
current_data = (unsigned char *) SCpnt->request_buffer; current_data = (unsigned char *) SCpnt->request_buffer;
current_bufflen = SCpnt->request_bufflen; current_bufflen = SCpnt->request_bufflen;
SCint = SCpnt; SCint = SCpnt;
if (recursion_depth) if (recursion_depth)
return 0; return 1;
recursion_depth++; recursion_depth++;
do { do {
#ifdef LINKED #ifdef LINKED
/* /*
* Set linked command bit in control field of SCSI command. * Set linked command bit in control field of SCSI command.
*/ */
current_cmnd[SCpnt->cmd_len] |= 0x01; current_cmnd[SCpnt->cmd_len] |= 0x01;
if (linked_connected) { if (linked_connected) {
DPRINTK (DEBUG_LINKED, DPRINTK (DEBUG_LINKED, "scsi%d : using linked commands, current I_T_L nexus is ", hostno);
"scsi%d : using linked commands, current I_T_L nexus is ", if (linked_target == current_target && linked_lun == current_lun)
hostno); {
if ((linked_target == current_target) DPRINTK(DEBUG_LINKED, "correct\n");
&& (linked_lun == current_lun)) {
DPRINTK (DEBUG_LINKED, "correct\n");
reconnect = LINKED_RIGHT; reconnect = LINKED_RIGHT;
} else { } else {
DPRINTK (DEBUG_LINKED, "incorrect\n"); DPRINTK(DEBUG_LINKED, "incorrect\n");
reconnect = LINKED_WRONG; reconnect = LINKED_WRONG;
} }
} else } else
#endif /* LINKED */ #endif /* LINKED */
reconnect = CAN_RECONNECT; reconnect = CAN_RECONNECT;
result = result = internal_command(SCint->target, SCint->lun, SCint->cmnd,
internal_command (SCint->target, SCint->lun, SCint->cmnd, SCint->request_buffer, SCint->request_bufflen, reconnect);
SCint->request_buffer, if (msg_byte(result) == DISCONNECT)
SCint->request_bufflen, reconnect);
if (msg_byte (result) == DISCONNECT)
break; break;
SCtmp = SCint; SCtmp = SCint;
SCint = NULL; SCint = NULL;
SCtmp->result = result; SCtmp->result = result;
done_fn (SCtmp); done_fn(SCtmp);
} }
while (SCint); while (SCint);
recursion_depth--; recursion_depth--;
return 0; return 0;
} }
int seagate_st0x_command (Scsi_Cmnd * SCpnt) static int seagate_st0x_command(Scsi_Cmnd * SCpnt)
{ {
return internal_command (SCpnt->target, SCpnt->lun, SCpnt->cmnd, return internal_command (SCpnt->target, SCpnt->lun, SCpnt->cmnd,
SCpnt->request_buffer, SCpnt->request_bufflen, SCpnt->request_buffer, SCpnt->request_bufflen,
...@@ -755,17 +739,12 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -755,17 +739,12 @@ static int internal_command (unsigned char target, unsigned char lun,
unsigned char *data = NULL; unsigned char *data = NULL;
struct scatterlist *buffer = NULL; struct scatterlist *buffer = NULL;
int clock, temp, nobuffs = 0, done = 0, len = 0; int clock, temp, nobuffs = 0, done = 0, len = 0;
unsigned long flags;
#ifdef DEBUG #ifdef DEBUG
int transfered = 0, phase = 0, newphase; int transfered = 0, phase = 0, newphase;
#endif #endif
register unsigned char status_read; register unsigned char status_read;
unsigned char tmp_data, tmp_control, status = 0, message = 0; unsigned char tmp_data, tmp_control, status = 0, message = 0;
unsigned transfersize = 0, underflow = 0; unsigned transfersize = 0, underflow = 0;
#ifdef SLOW_RATE #ifdef SLOW_RATE
int borken = (int) SCint->device->borken; /* Does the current target require int borken = (int) SCint->device->borken; /* Does the current target require
Very Slow I/O ? */ Very Slow I/O ? */
...@@ -775,36 +754,36 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -775,36 +754,36 @@ static int internal_command (unsigned char target, unsigned char lun,
st0x_aborted = 0; st0x_aborted = 0;
#if (DEBUG & PRINT_COMMAND) #if (DEBUG & PRINT_COMMAND)
printk ("scsi%d : target = %d, command = ", hostno, target); printk("scsi%d : target = %d, command = ", hostno, target);
print_command ((unsigned char *) cmnd); print_command((unsigned char *) cmnd);
#endif #endif
#if (DEBUG & PHASE_RESELECT) #if (DEBUG & PHASE_RESELECT)
switch (reselect) { switch (reselect) {
case RECONNECT_NOW: case RECONNECT_NOW:
printk ("scsi%d : reconnecting\n", hostno); printk("scsi%d : reconnecting\n", hostno);
break; break;
#ifdef LINKED #ifdef LINKED
case LINKED_RIGHT: case LINKED_RIGHT:
printk ("scsi%d : connected, can reconnect\n", hostno); printk("scsi%d : connected, can reconnect\n", hostno);
break; break;
case LINKED_WRONG: case LINKED_WRONG:
printk ("scsi%d : connected to wrong target, can reconnect\n", printk("scsi%d : connected to wrong target, can reconnect\n",
hostno); hostno);
break; break;
#endif #endif
case CAN_RECONNECT: case CAN_RECONNECT:
printk ("scsi%d : allowed to reconnect\n", hostno); printk("scsi%d : allowed to reconnect\n", hostno);
break; break;
default: default:
printk ("scsi%d : not allowed to reconnect\n", hostno); printk("scsi%d : not allowed to reconnect\n", hostno);
} }
#endif #endif
if (target == (controller_type == SEAGATE ? 7 : 6)) if (target == (controller_type == SEAGATE ? 7 : 6))
return DID_BAD_TARGET; return DID_BAD_TARGET;
/* /*
* We work it differently depending on if this is is "the first time," * We work it differently depending on if this is is "the first time,"
* or a reconnect. If this is a reselect phase, then SEL will * or a reconnect. If this is a reselect phase, then SEL will
* be asserted, and we must skip selection / arbitration phases. * be asserted, and we must skip selection / arbitration phases.
...@@ -813,46 +792,38 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -813,46 +792,38 @@ static int internal_command (unsigned char target, unsigned char lun,
switch (reselect) { switch (reselect) {
case RECONNECT_NOW: case RECONNECT_NOW:
DPRINTK (PHASE_RESELECT, "scsi%d : phase RESELECT \n", hostno); DPRINTK (PHASE_RESELECT, "scsi%d : phase RESELECT \n", hostno);
/*
/* * At this point, we should find the logical or of our ID
* At this point, we should find the logical or of our ID and the original * and the original target's ID on the BUS, with BSY, SEL,
* target's ID on the BUS, with BSY, SEL, and I/O signals asserted. * and I/O signals asserted.
* *
* After ARBITRATION phase is completed, only SEL, BSY, and the * After ARBITRATION phase is completed, only SEL, BSY,
* target ID are asserted. A valid initiator ID is not on the bus * and the target ID are asserted. A valid initiator ID
* until IO is asserted, so we must wait for that. * is not on the bus until IO is asserted, so we must wait
* for that.
*/ */
ULOOP (100 * 1000) { ULOOP (100 * 1000) {
temp = STATUS; temp = STATUS;
if ((temp & STAT_IO) && !(temp & STAT_BSY)) if ((temp & STAT_IO) && !(temp & STAT_BSY))
break; break;
if (TIMEOUT) { if (TIMEOUT) {
DPRINTK (PHASE_RESELECT, DPRINTK (PHASE_RESELECT, "scsi%d : RESELECT timed out while waiting for IO .\n", hostno);
"scsi%d : RESELECT timed out while waiting for IO .\n",
hostno);
return (DID_BAD_INTR << 16); return (DID_BAD_INTR << 16);
} }
} }
/* /*
* After I/O is asserted by the target, we can read our ID and its * After I/O is asserted by the target, we can read our ID
* ID off of the BUS. * and its ID off of the BUS.
*/ */
if (! if (!((temp = DATA) & (controller_type == SEAGATE ? 0x80 : 0x40))) {
((temp = DPRINTK (PHASE_RESELECT, "scsi%d : detected reconnect request to different target.\n\tData bus = %d\n", hostno, temp);
DATA) & (controller_type == SEAGATE ? 0x80 : 0x40))) {
DPRINTK (PHASE_RESELECT,
"scsi%d : detected reconnect request to different target.\n"
"\tData bus = %d\n", hostno, temp);
return (DID_BAD_INTR << 16); return (DID_BAD_INTR << 16);
} }
if (!(temp & (1 << current_target))) { if (!(temp & (1 << current_target))) {
printk printk(KERN_WARNING "scsi%d : Unexpected reselect interrupt. Data bus = %d\n", hostno, temp);
("scsi%d : Unexpected reselect interrupt. Data bus = %d\n",
hostno, temp);
return (DID_BAD_INTR << 16); return (DID_BAD_INTR << 16);
} }
...@@ -862,9 +833,10 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -862,9 +833,10 @@ static int internal_command (unsigned char target, unsigned char lun,
len = current_bufflen; /* WDE add */ len = current_bufflen; /* WDE add */
nobuffs = current_nobuffs; nobuffs = current_nobuffs;
/* /*
* We have determined that we have been selected. At this point, * We have determined that we have been selected. At this
* we must respond to the reselection by asserting BSY ourselves * point, we must respond to the reselection by asserting
* BSY ourselves
*/ */
#if 1 #if 1
...@@ -873,9 +845,9 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -873,9 +845,9 @@ static int internal_command (unsigned char target, unsigned char lun,
WRITE_CONTROL (BASE_CMD | CMD_BSY); WRITE_CONTROL (BASE_CMD | CMD_BSY);
#endif #endif
/* /*
* The target will drop SEL, and raise BSY, at which time we must drop * The target will drop SEL, and raise BSY, at which time
* BSY. * we must drop BSY.
*/ */
ULOOP (100 * 1000) { ULOOP (100 * 1000) {
...@@ -883,38 +855,30 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -883,38 +855,30 @@ static int internal_command (unsigned char target, unsigned char lun,
break; break;
if (TIMEOUT) { if (TIMEOUT) {
WRITE_CONTROL (BASE_CMD | CMD_INTR); WRITE_CONTROL (BASE_CMD | CMD_INTR);
DPRINTK (PHASE_RESELECT, DPRINTK (PHASE_RESELECT, "scsi%d : RESELECT timed out while waiting for SEL.\n", hostno);
"scsi%d : RESELECT timed out while waiting for SEL.\n",
hostno);
return (DID_BAD_INTR << 16); return (DID_BAD_INTR << 16);
} }
} }
WRITE_CONTROL (BASE_CMD); WRITE_CONTROL (BASE_CMD);
/*
/* * At this point, we have connected with the target
* At this point, we have connected with the target and can get * and can get on with our lives.
* on with our lives.
*/ */
break; break;
case CAN_RECONNECT: case CAN_RECONNECT:
#ifdef LINKED #ifdef LINKED
/* /*
* This is a bletcherous hack, just as bad as the Unix #! interpreter stuff. * This is a bletcherous hack, just as bad as the Unix #!
* If it turns out we are using the wrong I_T_L nexus, the easiest way to deal * interpreter stuff. If it turns out we are using the wrong
* with it is to go into our INFORMATION TRANSFER PHASE code, send a ABORT * I_T_L nexus, the easiest way to deal with it is to go into
* our INFORMATION TRANSFER PHASE code, send a ABORT
* message on MESSAGE OUT phase, and then loop back to here. * message on MESSAGE OUT phase, and then loop back to here.
*/ */
connect_loop:
connect_loop:
#endif #endif
DPRINTK (PHASE_BUS_FREE, "scsi%d : phase = BUS FREE \n", hostno);
DPRINTK (PHASE_BUS_FREE, "scsi%d : phase = BUS FREE \n", /*
hostno);
/*
* BUS FREE PHASE * BUS FREE PHASE
* *
* On entry, we make sure that the BUS is in a BUS FREE * On entry, we make sure that the BUS is in a BUS FREE
...@@ -927,22 +891,19 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -927,22 +891,19 @@ static int internal_command (unsigned char target, unsigned char lun,
#error FIXME: this is broken: we may not use jiffies here - we are under cli(). It will hardlock. #error FIXME: this is broken: we may not use jiffies here - we are under cli(). It will hardlock.
clock = jiffies + ST0X_BUS_FREE_DELAY; clock = jiffies + ST0X_BUS_FREE_DELAY;
while (((STATUS | STATUS | STATUS) & while (((STATUS | STATUS | STATUS) & (STAT_BSY | STAT_SEL)) && (!st0x_aborted) && time_before (jiffies, clock))
(STAT_BSY | STAT_SEL)) && cpu_relax();
(!st0x_aborted) && time_before (jiffies, clock)) ;
if (time_after (jiffies, clock)) if (time_after (jiffies, clock))
return retcode (DID_BUS_BUSY); return retcode (DID_BUS_BUSY);
else if (st0x_aborted) else if (st0x_aborted)
return retcode (st0x_aborted); return retcode (st0x_aborted);
#endif #endif
DPRINTK (PHASE_SELECTION, "scsi%d : phase = SELECTION\n", hostno);
DPRINTK (PHASE_SELECTION, "scsi%d : phase = SELECTION\n",
hostno);
clock = jiffies + ST0X_SELECTION_DELAY; clock = jiffies + ST0X_SELECTION_DELAY;
/* /*
* Arbitration/selection procedure : * Arbitration/selection procedure :
* 1. Disable drivers * 1. Disable drivers
* 2. Write HOST adapter address bit * 2. Write HOST adapter address bit
...@@ -954,12 +915,10 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -954,12 +915,10 @@ static int internal_command (unsigned char target, unsigned char lun,
*/ */
#ifdef ARBITRATE #ifdef ARBITRATE
save_flags (flags); /* FIXME: verify host lock is always held here */
cli (); WRITE_CONTROL(0);
WRITE_CONTROL (0); WRITE_DATA((controller_type == SEAGATE) ? 0x80 : 0x40);
WRITE_DATA ((controller_type == SEAGATE) ? 0x80 : 0x40); WRITE_CONTROL(CMD_START_ARB);
WRITE_CONTROL (CMD_START_ARB);
restore_flags (flags);
ULOOP (ST0X_SELECTION_DELAY * 10000) { ULOOP (ST0X_SELECTION_DELAY * 10000) {
status_read = STATUS; status_read = STATUS;
...@@ -968,40 +927,31 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -968,40 +927,31 @@ static int internal_command (unsigned char target, unsigned char lun,
if (st0x_aborted) /* FIXME: What? We are going to do something even after abort? */ if (st0x_aborted) /* FIXME: What? We are going to do something even after abort? */
break; break;
if (TIMEOUT || (status_read & STAT_SEL)) { if (TIMEOUT || (status_read & STAT_SEL)) {
printk printk(KERN_WARNING "scsi%d : arbitration lost or timeout.\n", hostno);
("scsi%d : arbitration lost or timeout.\n",
hostno);
WRITE_CONTROL (BASE_CMD); WRITE_CONTROL (BASE_CMD);
return retcode (DID_NO_CONNECT); return retcode (DID_NO_CONNECT);
} }
} }
DPRINTK (PHASE_SELECTION, "scsi%d : arbitration complete\n", hostno);
DPRINTK (PHASE_SELECTION, "scsi%d : arbitration complete\n",
hostno);
#endif #endif
/* /*
* When the SCSI device decides that we're gawking at it, it will * When the SCSI device decides that we're gawking at it,
* respond by asserting BUSY on the bus. * it will respond by asserting BUSY on the bus.
* *
* Note : the Seagate ST-01/02 product manual says that we should * Note : the Seagate ST-01/02 product manual says that we
* twiddle the DATA register before the control register. However, * should twiddle the DATA register before the control
* this does not work reliably so we do it the other way around. * register. However, this does not work reliably so we do
* it the other way around.
* *
* Probably could be a problem with arbitration too, we really should * Probably could be a problem with arbitration too, we
* try this with a SCSI protocol or logic analyzer to see what is * really should try this with a SCSI protocol or logic
* going on. * analyzer to see what is going on.
*/ */
tmp_data = tmp_data = (unsigned char) ((1 << target) | (controller_type == SEAGATE ? 0x80 : 0x40));
(unsigned char) ((1 << target) | tmp_control = BASE_CMD | CMD_DRVR_ENABLE | CMD_SEL | (reselect ? CMD_ATTN : 0);
(controller_type ==
SEAGATE ? 0x80 : 0x40)); /* FIXME: verify host lock is always held here */
tmp_control =
BASE_CMD | CMD_DRVR_ENABLE | CMD_SEL | (reselect ? CMD_ATTN
: 0);
save_flags (flags);
cli ();
#ifdef OLDCNTDATASCEME #ifdef OLDCNTDATASCEME
#ifdef SWAPCNTDATA #ifdef SWAPCNTDATA
WRITE_CONTROL (tmp_control); WRITE_CONTROL (tmp_control);
...@@ -1018,22 +968,20 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1018,22 +968,20 @@ static int internal_command (unsigned char target, unsigned char lun,
WRITE_CONTROL (tmp_control); /* -- pavel@ucw.cz */ WRITE_CONTROL (tmp_control); /* -- pavel@ucw.cz */
#endif #endif
restore_flags (flags);
ULOOP (250 * 1000) { ULOOP (250 * 1000) {
if (st0x_aborted) { if (st0x_aborted) {
/* /*
* If we have been aborted, and we have a command in progress, IE the * If we have been aborted, and we have a
* target still has BSY asserted, then we will reset the bus, and * command in progress, IE the target
* notify the midlevel driver to expect sense. * still has BSY asserted, then we will
* reset the bus, and notify the midlevel
* driver to expect sense.
*/ */
WRITE_CONTROL (BASE_CMD); WRITE_CONTROL (BASE_CMD);
if (STATUS & STAT_BSY) { if (STATUS & STAT_BSY) {
printk printk(KERN_WARNING "scsi%d : BST asserted after we've been aborted.\n", hostno);
("scsi%d : BST asserted after we've been aborted.\n", seagate_st0x_bus_reset(NULL);
hostno);
seagate_st0x_reset (NULL, 0);
return retcode (DID_RESET); return retcode (DID_RESET);
} }
return retcode (st0x_aborted); return retcode (st0x_aborted);
...@@ -1041,26 +989,20 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1041,26 +989,20 @@ static int internal_command (unsigned char target, unsigned char lun,
if (STATUS & STAT_BSY) if (STATUS & STAT_BSY)
break; break;
if (TIMEOUT) { if (TIMEOUT) {
DPRINTK (PHASE_SELECTION, DPRINTK (PHASE_SELECTION, "scsi%d : NO CONNECT with target %d, stat = %x \n", hostno, target, STATUS);
"scsi%d : NO CONNECT with target %d, stat = %x \n",
hostno, target, STATUS);
return retcode (DID_NO_CONNECT); return retcode (DID_NO_CONNECT);
} }
} }
/* Establish current pointers. Take into account scatter / gather */ /* Establish current pointers. Take into account scatter / gather */
if ((nobuffs = SCint->use_sg)) { if ((nobuffs = SCint->use_sg)) {
#if (DEBUG & DEBUG_SG) #if (DEBUG & DEBUG_SG)
{ {
int i; int i;
printk("scsi%d : scatter gather requested, using %d buffers.\n", hostno, nobuffs);
printk
("scsi%d : scatter gather requested, using %d buffers.\n",
hostno, nobuffs);
for (i = 0; i < nobuffs; ++i) for (i = 0; i < nobuffs; ++i)
printk printk("scsi%d : buffer %d address = %p length = %d\n",
("scsi%d : buffer %d address = %p length = %d\n",
hostno, i, hostno, i,
page_address(buffer[i].page) + buffer[i].offset, page_address(buffer[i].page) + buffer[i].offset,
buffer[i].length); buffer[i].length);
...@@ -1069,11 +1011,9 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1069,11 +1011,9 @@ static int internal_command (unsigned char target, unsigned char lun,
buffer = (struct scatterlist *) SCint->buffer; buffer = (struct scatterlist *) SCint->buffer;
len = buffer->length; len = buffer->length;
data = (unsigned char *) buffer->address; data = page_address(buffer->page) + buffer->offset;
} else { } else {
DPRINTK (DEBUG_SG, DPRINTK (DEBUG_SG, "scsi%d : scatter gather not requested.\n", hostno);
"scsi%d : scatter gather not requested.\n",
hostno);
buffer = NULL; buffer = NULL;
len = SCint->request_bufflen; len = SCint->request_bufflen;
data = (unsigned char *) SCint->request_buffer; data = (unsigned char *) SCint->request_buffer;
...@@ -1091,28 +1031,24 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1091,28 +1031,24 @@ static int internal_command (unsigned char target, unsigned char lun,
#endif #endif
} /* end of switch(reselect) */ } /* end of switch(reselect) */
/* /*
* There are several conditions under which we wish to send a message : * There are several conditions under which we wish to send a message :
* 1. When we are allowing disconnect / reconnect, and need to establish * 1. When we are allowing disconnect / reconnect, and need to
* the I_T_L nexus via an IDENTIFY with the DiscPriv bit set. * establish the I_T_L nexus via an IDENTIFY with the DiscPriv bit
* set.
* *
* 2. When we are doing linked commands, are have the wrong I_T_L nexus * 2. When we are doing linked commands, are have the wrong I_T_L
* established and want to send an ABORT message. * nexus established and want to send an ABORT message.
*/ */
/* GCC does not like an ifdef inside a macro, so do it the hard way. */ /* GCC does not like an ifdef inside a macro, so do it the hard way. */
#ifdef LINKED #ifdef LINKED
WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE | WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE | (((reselect == CAN_RECONNECT)|| (reselect == LINKED_WRONG))? CMD_ATTN : 0));
(((reselect == CAN_RECONNECT)
|| (reselect == LINKED_WRONG)
)? CMD_ATTN : 0));
#else #else
WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE | WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE | (((reselect == CAN_RECONNECT))? CMD_ATTN : 0));
(((reselect == CAN_RECONNECT)
)? CMD_ATTN : 0));
#endif #endif
/* /*
* INFORMATION TRANSFER PHASE * INFORMATION TRANSFER PHASE
* *
* The nasty looking read / write inline assembler loops we use for * The nasty looking read / write inline assembler loops we use for
...@@ -1130,72 +1066,63 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1130,72 +1066,63 @@ static int internal_command (unsigned char target, unsigned char lun,
transfersize = SCint->transfersize; transfersize = SCint->transfersize;
underflow = SCint->underflow; underflow = SCint->underflow;
/* /*
* Now, we poll the device for status information, * Now, we poll the device for status information,
* and handle any requests it makes. Note that since we are unsure of * and handle any requests it makes. Note that since we are unsure
* how much data will be flowing across the system, etc and cannot * of how much data will be flowing across the system, etc and
* make reasonable timeouts, that we will instead have the midlevel * cannot make reasonable timeouts, that we will instead have the
* driver handle any timeouts that occur in this phase. * midlevel driver handle any timeouts that occur in this phase.
*/ */
while (((status_read = STATUS) & STAT_BSY) && !st0x_aborted && !done) { while (((status_read = STATUS) & STAT_BSY) && !st0x_aborted && !done) {
#ifdef PARITY #ifdef PARITY
if (status_read & STAT_PARITY) { if (status_read & STAT_PARITY) {
printk ("scsi%d : got parity error\n", hostno); printk(KERN_ERR "scsi%d : got parity error\n", hostno);
st0x_aborted = DID_PARITY; st0x_aborted = DID_PARITY;
} }
#endif #endif
if (status_read & STAT_REQ) { if (status_read & STAT_REQ) {
#if ((DEBUG & PHASE_ETC) == PHASE_ETC) #if ((DEBUG & PHASE_ETC) == PHASE_ETC)
if ((newphase = (status_read & REQ_MASK)) != phase) { if ((newphase = (status_read & REQ_MASK)) != phase) {
phase = newphase; phase = newphase;
switch (phase) { switch (phase) {
case REQ_DATAOUT: case REQ_DATAOUT:
printk ("scsi%d : phase = DATA OUT\n", printk ("scsi%d : phase = DATA OUT\n", hostno);
hostno);
break; break;
case REQ_DATAIN: case REQ_DATAIN:
printk ("scsi%d : phase = DATA IN\n", printk ("scsi%d : phase = DATA IN\n", hostno);
hostno);
break; break;
case REQ_CMDOUT: case REQ_CMDOUT:
printk printk
("scsi%d : phase = COMMAND OUT\n", ("scsi%d : phase = COMMAND OUT\n", hostno);
hostno);
break; break;
case REQ_STATIN: case REQ_STATIN:
printk ("scsi%d : phase = STATUS IN\n", printk ("scsi%d : phase = STATUS IN\n", hostno);
hostno);
break; break;
case REQ_MSGOUT: case REQ_MSGOUT:
printk printk
("scsi%d : phase = MESSAGE OUT\n", ("scsi%d : phase = MESSAGE OUT\n", hostno);
hostno);
break; break;
case REQ_MSGIN: case REQ_MSGIN:
printk ("scsi%d : phase = MESSAGE IN\n", printk ("scsi%d : phase = MESSAGE IN\n", hostno);
hostno);
break; break;
default: default:
printk ("scsi%d : phase = UNKNOWN\n", printk ("scsi%d : phase = UNKNOWN\n", hostno);
hostno);
st0x_aborted = DID_ERROR; st0x_aborted = DID_ERROR;
} }
} }
#endif #endif
switch (status_read & REQ_MASK) { switch (status_read & REQ_MASK) {
case REQ_DATAOUT: case REQ_DATAOUT:
/* /*
* If we are in fast mode, then we simply splat the data out * If we are in fast mode, then we simply splat
* in word-sized chunks as fast as we can. * the data out in word-sized chunks as fast as
* we can.
*/ */
if (!len) { if (!len) {
#if 0 #if 0
printk printk("scsi%d: underflow to target %d lun %d \n", hostno, target, lun);
("scsi%d: underflow to target %d lun %d \n",
hostno, target, lun);
st0x_aborted = DID_ERROR; st0x_aborted = DID_ERROR;
fast = 0; fast = 0;
#endif #endif
...@@ -1216,7 +1143,7 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1216,7 +1143,7 @@ static int internal_command (unsigned char target, unsigned char lun,
SCint->transfersize, len, SCint->transfersize, len,
data); data);
/* SJT: Start. Fast Write */ /* SJT: Start. Fast Write */
#ifdef SEAGATE_USE_ASM #ifdef SEAGATE_USE_ASM
__asm__ ("cld\n\t" __asm__ ("cld\n\t"
#ifdef FAST32 #ifdef FAST32
...@@ -1241,14 +1168,11 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1241,14 +1168,11 @@ static int internal_command (unsigned char target, unsigned char lun,
#else /* SEAGATE_USE_ASM */ #else /* SEAGATE_USE_ASM */
{ {
#ifdef FAST32 #ifdef FAST32
unsigned int *iop = unsigned int *iop = phys_to_virt (st0x_dr);
phys_to_virt (st0x_dr); const unsigned int *dp =(unsigned int *) data;
const unsigned int *dp =
(unsigned int *) data;
int xferlen = transfersize >> 2; int xferlen = transfersize >> 2;
#else #else
unsigned char *iop = unsigned char *iop = phys_to_virt (st0x_dr);
phys_to_virt (st0x_dr);
const unsigned char *dp = data; const unsigned char *dp = data;
int xferlen = transfersize; int xferlen = transfersize;
#endif #endif
...@@ -1259,13 +1183,12 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1259,13 +1183,12 @@ static int internal_command (unsigned char target, unsigned char lun,
/* SJT: End */ /* SJT: End */
len -= transfersize; len -= transfersize;
data += transfersize; data += transfersize;
DPRINTK (DEBUG_FAST, DPRINTK (DEBUG_FAST, "scsi%d : FAST transfer complete len = %d data = %08x\n", hostno, len, data);
"scsi%d : FAST transfer complete len = %d data = %08x\n",
hostno, len, data);
} else { } else {
/* /*
* We loop as long as we are in a data out phase, there is data to send, * We loop as long as we are in a
* and BSY is still active. * data out phase, there is data to
* send, and BSY is still active.
*/ */
/* SJT: Start. Slow Write. */ /* SJT: Start. Slow Write. */
...@@ -1335,8 +1258,7 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1335,8 +1258,7 @@ static int internal_command (unsigned char target, unsigned char lun,
--nobuffs; --nobuffs;
++buffer; ++buffer;
len = buffer->length; len = buffer->length;
data = data = page_address(buffer->page) + buffer->offset;
(unsigned char *) buffer->address;
DPRINTK (DEBUG_SG, DPRINTK (DEBUG_SG,
"scsi%d : next scatter-gather buffer len = %d address = %08x\n", "scsi%d : next scatter-gather buffer len = %d address = %08x\n",
hostno, len, data); hostno, len, data);
...@@ -1349,13 +1271,9 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1349,13 +1271,9 @@ static int internal_command (unsigned char target, unsigned char lun,
#if (DEBUG & (PHASE_DATAIN)) #if (DEBUG & (PHASE_DATAIN))
transfered += len; transfered += len;
#endif #endif
for (; for (; len && (STATUS & (REQ_MASK | STAT_REQ)) == (REQ_DATAIN | STAT_REQ); --len) {
len
&& (STATUS & (REQ_MASK | STAT_REQ))
== (REQ_DATAIN | STAT_REQ);
--len) {
*data++ = DATA; *data++ = DATA;
borken_wait (); borken_wait();
} }
#if (DEBUG & (PHASE_DATAIN)) #if (DEBUG & (PHASE_DATAIN))
transfered -= len; transfered -= len;
...@@ -1421,19 +1339,15 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1421,19 +1339,15 @@ static int internal_command (unsigned char target, unsigned char lun,
len -= transfersize; len -= transfersize;
data += transfersize; data += transfersize;
#if (DEBUG & PHASE_DATAIN) #if (DEBUG & PHASE_DATAIN)
printk ("scsi%d: transfered += %d\n", printk ("scsi%d: transfered += %d\n", hostno, transfersize);
hostno, transfersize);
transfered += transfersize; transfered += transfersize;
#endif #endif
DPRINTK (DEBUG_FAST, DPRINTK (DEBUG_FAST, "scsi%d : FAST transfer complete len = %d data = %08x\n", hostno, len, data);
"scsi%d : FAST transfer complete len = %d data = %08x\n",
hostno, len, data);
} else { } else {
#if (DEBUG & PHASE_DATAIN) #if (DEBUG & PHASE_DATAIN)
printk ("scsi%d: transfered += %d\n", printk ("scsi%d: transfered += %d\n", hostno, len);
hostno, len);
transfered += len; /* Assume we'll transfer it all, then transfered += len; /* Assume we'll transfer it all, then
subtract what we *didn't* transfer */ subtract what we *didn't* transfer */
#endif #endif
...@@ -1508,8 +1422,7 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1508,8 +1422,7 @@ static int internal_command (unsigned char target, unsigned char lun,
#endif /* SEAGATE_USE_ASM */ #endif /* SEAGATE_USE_ASM */
/* SJT: End. */ /* SJT: End. */
#if (DEBUG & PHASE_DATAIN) #if (DEBUG & PHASE_DATAIN)
printk ("scsi%d: transfered -= %d\n", printk ("scsi%d: transfered -= %d\n", hostno, len);
hostno, len);
transfered -= len; /* Since we assumed all of Len got * transfered -= len; /* Since we assumed all of Len got *
transfered, correct our mistake */ transfered, correct our mistake */
#endif #endif
...@@ -1519,26 +1432,17 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1519,26 +1432,17 @@ static int internal_command (unsigned char target, unsigned char lun,
--nobuffs; --nobuffs;
++buffer; ++buffer;
len = buffer->length; len = buffer->length;
data = data = page_address(buffer->page) + buffer->offset;
(unsigned char *) buffer->address; DPRINTK (DEBUG_SG, "scsi%d : next scatter-gather buffer len = %d address = %08x\n", hostno, len, data);
DPRINTK (DEBUG_SG,
"scsi%d : next scatter-gather buffer len = %d address = %08x\n",
hostno, len, data);
} }
break; break;
case REQ_CMDOUT: case REQ_CMDOUT:
while (((status_read = STATUS) & STAT_BSY) && while (((status_read = STATUS) & STAT_BSY) &&
((status_read & REQ_MASK) == REQ_CMDOUT)) ((status_read & REQ_MASK) == REQ_CMDOUT))
if (status_read & STAT_REQ) { if (status_read & STAT_REQ) {
WRITE_DATA (* WRITE_DATA (*(const unsigned char *) cmnd);
(const unsigned char cmnd = 1 + (const unsigned char *)cmnd;
*) cmnd);
cmnd =
1 +
(const unsigned char *)
cmnd;
#ifdef SLOW_RATE #ifdef SLOW_RATE
if (borken) if (borken)
borken_wait (); borken_wait ();
...@@ -1551,23 +1455,21 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1551,23 +1455,21 @@ static int internal_command (unsigned char target, unsigned char lun,
break; break;
case REQ_MSGOUT: case REQ_MSGOUT:
/* /*
* We can only have sent a MSG OUT if we requested to do this * We can only have sent a MSG OUT if we
* by raising ATTN. So, we must drop ATTN. * requested to do this by raising ATTN.
* So, we must drop ATTN.
*/ */
WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE); WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE);
/* /*
* If we are reconnecting, then we must send an IDENTIFY message in * If we are reconnecting, then we must
* response to MSGOUT. * send an IDENTIFY message in response
* to MSGOUT.
*/ */
switch (reselect) { switch (reselect) {
case CAN_RECONNECT: case CAN_RECONNECT:
WRITE_DATA (IDENTIFY (1, lun)); WRITE_DATA (IDENTIFY (1, lun));
DPRINTK (PHASE_RESELECT | PHASE_MSGOUT, "scsi%d : sent IDENTIFY message.\n", hostno);
DPRINTK (PHASE_RESELECT | PHASE_MSGOUT,
"scsi%d : sent IDENTIFY message.\n",
hostno);
break; break;
#ifdef LINKED #ifdef LINKED
case LINKED_WRONG: case LINKED_WRONG:
...@@ -1575,23 +1477,19 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1575,23 +1477,19 @@ static int internal_command (unsigned char target, unsigned char lun,
linked_connected = 0; linked_connected = 0;
reselect = CAN_RECONNECT; reselect = CAN_RECONNECT;
goto connect_loop; goto connect_loop;
DPRINTK (PHASE_MSGOUT | DEBUG_LINKED, DPRINTK (PHASE_MSGOUT | DEBUG_LINKED, "scsi%d : sent ABORT message to cancel incorrect I_T_L nexus.\n", hostno);
"scsi%d : sent ABORT message to cancel incorrect I_T_L nexus.\n",
hostno);
#endif /* LINKED */ #endif /* LINKED */
DPRINTK (DEBUG_LINKED, "correct\n"); DPRINTK (DEBUG_LINKED, "correct\n");
default: default:
WRITE_DATA (NOP); WRITE_DATA (NOP);
printk printk("scsi%d : target %d requested MSGOUT, sent NOP message.\n", hostno, target);
("scsi%d : target %d requested MSGOUT, sent NOP message.\n",
hostno, target);
} }
break; break;
case REQ_MSGIN: case REQ_MSGIN:
switch (message = DATA) { switch (message = DATA) {
case DISCONNECT: case DISCONNECT:
DANY ("seagate: deciding to disconnect\n"); DANY("seagate: deciding to disconnect\n");
should_reconnect = 1; should_reconnect = 1;
current_data = data; /* WDE add */ current_data = data; /* WDE add */
current_buffer = buffer; current_buffer = buffer;
...@@ -1601,9 +1499,7 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1601,9 +1499,7 @@ static int internal_command (unsigned char target, unsigned char lun,
linked_connected = 0; linked_connected = 0;
#endif #endif
done = 1; done = 1;
DPRINTK ((PHASE_RESELECT | PHASE_MSGIN), DPRINTK ((PHASE_RESELECT | PHASE_MSGIN), "scsi%d : disconnected.\n", hostno);
"scsi%d : disconnected.\n",
hostno);
break; break;
#ifdef LINKED #ifdef LINKED
...@@ -1611,18 +1507,14 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1611,18 +1507,14 @@ static int internal_command (unsigned char target, unsigned char lun,
case LINKED_FLG_CMD_COMPLETE: case LINKED_FLG_CMD_COMPLETE:
#endif #endif
case COMMAND_COMPLETE: case COMMAND_COMPLETE:
/* /*
* Note : we should check for underflow here. * Note : we should check for underflow here.
*/ */
DPRINTK (PHASE_MSGIN, DPRINTK(PHASE_MSGIN, "scsi%d : command complete.\n", hostno);
"scsi%d : command complete.\n",
hostno);
done = 1; done = 1;
break; break;
case ABORT: case ABORT:
DPRINTK (PHASE_MSGIN, DPRINTK(PHASE_MSGIN, "scsi%d : abort message.\n", hostno);
"scsi%d : abort message.\n",
hostno);
done = 1; done = 1;
break; break;
case SAVE_POINTERS: case SAVE_POINTERS:
...@@ -1630,9 +1522,7 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1630,9 +1522,7 @@ static int internal_command (unsigned char target, unsigned char lun,
current_bufflen = len; /* WDE add */ current_bufflen = len; /* WDE add */
current_data = data; /* WDE mod */ current_data = data; /* WDE mod */
current_nobuffs = nobuffs; current_nobuffs = nobuffs;
DPRINTK (PHASE_MSGIN, DPRINTK (PHASE_MSGIN, "scsi%d : pointers saved.\n", hostno);
"scsi%d : pointers saved.\n",
hostno);
break; break;
case RESTORE_POINTERS: case RESTORE_POINTERS:
buffer = current_buffer; buffer = current_buffer;
...@@ -1640,90 +1530,86 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1640,90 +1530,86 @@ static int internal_command (unsigned char target, unsigned char lun,
data = current_data; /* WDE mod */ data = current_data; /* WDE mod */
len = current_bufflen; len = current_bufflen;
nobuffs = current_nobuffs; nobuffs = current_nobuffs;
DPRINTK (PHASE_MSGIN, DPRINTK(PHASE_MSGIN, "scsi%d : pointers restored.\n", hostno);
"scsi%d : pointers restored.\n",
hostno);
break; break;
default: default:
/* /*
* IDENTIFY distinguishes itself from the other messages by setting the * IDENTIFY distinguishes itself
* high byte. [FIXME: should not this read "the high bit"? - pavel@ucw.cz] * from the other messages by
* setting the high bit.
* *
* Note : we need to handle at least one outstanding command per LUN, * Note : we need to handle at
* and need to hash the SCSI command for that I_T_L nexus based on the * least one outstanding command
* known ID (at this point) and LUN. * per LUN, and need to hash the
* SCSI command for that I_T_L
* nexus based on the known ID
* (at this point) and LUN.
*/ */
if (message & 0x80) { if (message & 0x80) {
DPRINTK (PHASE_MSGIN, DPRINTK (PHASE_MSGIN, "scsi%d : IDENTIFY message received from id %d, lun %d.\n", hostno, target, message & 7);
"scsi%d : IDENTIFY message received from id %d, lun %d.\n",
hostno, target,
message & 7);
} else { } else {
/*
/* * We should go into a
* We should go into a MESSAGE OUT phase, and send a MESSAGE_REJECT * MESSAGE OUT phase, and
* if we run into a message that we don't like. The seagate driver * send a MESSAGE_REJECT
* needs some serious restructuring first though. * if we run into a message
* that we don't like. The
* seagate driver needs
* some serious
* restructuring first
* though.
*/ */
DPRINTK (PHASE_MSGIN, "scsi%d : unknown message %d from target %d.\n", hostno, message, target);
DPRINTK (PHASE_MSGIN,
"scsi%d : unknown message %d from target %d.\n",
hostno, message,
target);
} }
} }
break; break;
default: default:
printk ("scsi%d : unknown phase.\n", hostno); printk(KERN_ERR "scsi%d : unknown phase.\n", hostno);
st0x_aborted = DID_ERROR; st0x_aborted = DID_ERROR;
} /* end of switch (status_read & } /* end of switch (status_read & REQ_MASK) */
REQ_MASK) */
#ifdef SLOW_RATE #ifdef SLOW_RATE
/* /*
* I really don't care to deal with borken devices in each single * I really don't care to deal with borken devices in
* byte transfer case (ie, message in, message out, status), so * each single byte transfer case (ie, message in,
* I'll do the wait here if necessary. * message out, status), so I'll do the wait here if
* necessary.
*/ */
if (borken) if(borken)
borken_wait (); borken_wait();
#endif #endif
} /* if(status_read & STAT_REQ) ends */ } /* if(status_read & STAT_REQ) ends */
} /* while(((status_read = STATUS)...) } /* while(((status_read = STATUS)...) ends */
ends */
DPRINTK (PHASE_DATAIN | PHASE_DATAOUT | PHASE_EXIT, DPRINTK(PHASE_DATAIN | PHASE_DATAOUT | PHASE_EXIT, "scsi%d : Transfered %d bytes\n", hostno, transfered);
"scsi%d : Transfered %d bytes\n", hostno, transfered);
#if (DEBUG & PHASE_EXIT) #if (DEBUG & PHASE_EXIT)
#if 0 /* Doesn't work for scatter/gather */ #if 0 /* Doesn't work for scatter/gather */
printk ("Buffer : \n"); printk("Buffer : \n");
for (i = 0; i < 20; ++i) for(i = 0; i < 20; ++i)
printk ("%02x ", ((unsigned char *) data)[i]); /* WDE mod */ printk("%02x ", ((unsigned char *) data)[i]); /* WDE mod */
printk ("\n"); printk("\n");
#endif #endif
printk ("scsi%d : status = ", hostno); printk("scsi%d : status = ", hostno);
print_status (status); print_status(status);
printk (" message = %02x\n", message); printk(" message = %02x\n", message);
#endif #endif
/* We shouldn't reach this until *after* BSY has been deasserted */ /* We shouldn't reach this until *after* BSY has been deasserted */
#ifdef LINKED #ifdef LINKED
else else
{ {
/* /*
* Fix the message byte so that unsuspecting high level drivers don't * Fix the message byte so that unsuspecting high level drivers
* puke when they see a LINKED COMMAND message in place of the COMMAND * don't puke when they see a LINKED COMMAND message in place of
* COMPLETE they may be expecting. Shouldn't be necessary, but it's * the COMMAND COMPLETE they may be expecting. Shouldn't be
* better to be on the safe side. * necessary, but it's better to be on the safe side.
* *
* A non LINKED* message byte will indicate that the command completed, * A non LINKED* message byte will indicate that the command
* and we are now disconnected. * completed, and we are now disconnected.
*/ */
switch (message) { switch (message) {
...@@ -1733,33 +1619,27 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1733,33 +1619,27 @@ static int internal_command (unsigned char target, unsigned char lun,
linked_target = current_target; linked_target = current_target;
linked_lun = current_lun; linked_lun = current_lun;
linked_connected = 1; linked_connected = 1;
DPRINTK (DEBUG_LINKED, DPRINTK (DEBUG_LINKED, "scsi%d : keeping I_T_L nexus established for linked command.\n", hostno);
"scsi%d : keeping I_T_L nexus established"
"for linked command.\n", hostno);
/* We also will need to adjust status to accommodate intermediate /* We also will need to adjust status to accommodate intermediate
conditions. */ conditions. */
if ((status == INTERMEDIATE_GOOD) || if ((status == INTERMEDIATE_GOOD) || (status == INTERMEDIATE_C_GOOD))
(status == INTERMEDIATE_C_GOOD))
status = GOOD; status = GOOD;
break; break;
/* /*
* We should also handle what are "normal" termination messages * We should also handle what are "normal" termination
* here (ABORT, BUS_DEVICE_RESET?, and COMMAND_COMPLETE individually, * messages here (ABORT, BUS_DEVICE_RESET?, and
* and flake if things aren't right. * COMMAND_COMPLETE individually, and flake if things
* aren't right.
*/ */
default: default:
DPRINTK (DEBUG_LINKED, DPRINTK (DEBUG_LINKED, "scsi%d : closing I_T_L nexus.\n", hostno);
"scsi%d : closing I_T_L nexus.\n", hostno);
linked_connected = 0; linked_connected = 0;
} }
} }
#endif /* LINKED */ #endif /* LINKED */
if (should_reconnect) { if (should_reconnect) {
DPRINTK (PHASE_RESELECT, DPRINTK (PHASE_RESELECT, "scsi%d : exiting seagate_st0x_queue_command() with reconnect enabled.\n", hostno);
"scsi%d : exiting seagate_st0x_queue_command()"
"with reconnect enabled.\n", hostno);
WRITE_CONTROL (BASE_CMD | CMD_INTR); WRITE_CONTROL (BASE_CMD | CMD_INTR);
} else } else
WRITE_CONTROL (BASE_CMD); WRITE_CONTROL (BASE_CMD);
...@@ -1770,7 +1650,7 @@ static int internal_command (unsigned char target, unsigned char lun, ...@@ -1770,7 +1650,7 @@ static int internal_command (unsigned char target, unsigned char lun,
static int seagate_st0x_abort (Scsi_Cmnd * SCpnt) static int seagate_st0x_abort (Scsi_Cmnd * SCpnt)
{ {
st0x_aborted = DID_ABORT; st0x_aborted = DID_ABORT;
return SCSI_ABORT_PENDING; return SUCCESS;
} }
#undef ULOOP #undef ULOOP
...@@ -1778,14 +1658,16 @@ static int seagate_st0x_abort (Scsi_Cmnd * SCpnt) ...@@ -1778,14 +1658,16 @@ static int seagate_st0x_abort (Scsi_Cmnd * SCpnt)
/* /*
* the seagate_st0x_reset function resets the SCSI bus * the seagate_st0x_reset function resets the SCSI bus
*
* May be called with SCpnt = NULL
*/ */
static int seagate_st0x_reset (Scsi_Cmnd * SCpnt, unsigned int reset_flags) static int seagate_st0x_bus_reset(Scsi_Cmnd * SCpnt)
{ {
/* No timeouts - this command is going to fail because it was reset. */ /* No timeouts - this command is going to fail because it was reset. */
DANY ("scsi%d: Reseting bus... ", hostno); DANY ("scsi%d: Reseting bus... ", hostno);
/* assert RESET signal on SCSI bus. */ /* assert RESET signal on SCSI bus. */
WRITE_CONTROL (BASE_CMD | CMD_RST); WRITE_CONTROL (BASE_CMD | CMD_RST);
udelay (20 * 1000); udelay (20 * 1000);
...@@ -1794,7 +1676,17 @@ static int seagate_st0x_reset (Scsi_Cmnd * SCpnt, unsigned int reset_flags) ...@@ -1794,7 +1676,17 @@ static int seagate_st0x_reset (Scsi_Cmnd * SCpnt, unsigned int reset_flags)
st0x_aborted = DID_RESET; st0x_aborted = DID_RESET;
DANY ("done.\n"); DANY ("done.\n");
return SCSI_RESET_WAKEUP; return SUCCESS;
}
static int seagate_st0x_host_reset(Scsi_Cmnd *SCpnt)
{
return FAILED;
}
static int seagate_st0x_device_reset(Scsi_Cmnd *SCpnt)
{
return FAILED;
} }
/* Eventually this will go into an include file, but this will be later */ /* Eventually this will go into an include file, but this will be later */
......
...@@ -7,30 +7,30 @@ ...@@ -7,30 +7,30 @@
*/ */
#ifndef _SEAGATE_H #ifndef _SEAGATE_H
#define SEAGATE_H #define SEAGATE_H
/*
$Header static int seagate_st0x_detect(Scsi_Host_Template *);
*/ static int seagate_st0x_command(Scsi_Cmnd *);
#ifndef ASM static int seagate_st0x_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
int seagate_st0x_detect(Scsi_Host_Template *);
int seagate_st0x_command(Scsi_Cmnd *);
int seagate_st0x_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
static int seagate_st0x_abort(Scsi_Cmnd *); static int seagate_st0x_abort(Scsi_Cmnd *);
const char *seagate_st0x_info(struct Scsi_Host *); static const char *seagate_st0x_info(struct Scsi_Host *);
static int seagate_st0x_reset(Scsi_Cmnd *, unsigned int); static int seagate_st0x_bus_reset(Scsi_Cmnd *);
static int seagate_st0x_device_reset(Scsi_Cmnd *);
static int seagate_st0x_host_reset(Scsi_Cmnd *);
#define SEAGATE_ST0X { detect: seagate_st0x_detect, \ #define SEAGATE_ST0X { detect: seagate_st0x_detect, \
info: seagate_st0x_info, \ info: seagate_st0x_info, \
command: seagate_st0x_command, \ command: seagate_st0x_command, \
queuecommand: seagate_st0x_queue_command, \ queuecommand: seagate_st0x_queue_command, \
abort: seagate_st0x_abort, \ eh_abort_handler: seagate_st0x_abort, \
reset: seagate_st0x_reset, \ eh_bus_reset_handler: seagate_st0x_bus_reset, \
eh_host_reset_handler: seagate_st0x_host_reset, \
eh_device_reset_handler:seagate_st0x_device_reset, \
can_queue: 1, \ can_queue: 1, \
this_id: 7, \ this_id: 7, \
sg_tablesize: SG_ALL, \ sg_tablesize: SG_ALL, \
cmd_per_lun: 1, \ cmd_per_lun: 1, \
use_clustering: DISABLE_CLUSTERING} use_clustering: DISABLE_CLUSTERING}
#endif /* ASM */
#endif /* _SEAGATE_H */ #endif /* _SEAGATE_H */
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