Commit 0b13c1f5 authored by Doug Ledford's avatar Doug Ledford Committed by Linus Torvalds

[PATCH] Updates for the scsi.h removal of device specific data from struct scsi_device

parent 30f7395a
...@@ -869,7 +869,7 @@ static int esp_host_info(struct NCR_ESP *esp, char *ptr, off_t offset, int len) ...@@ -869,7 +869,7 @@ static int esp_host_info(struct NCR_ESP *esp, char *ptr, off_t offset, int len)
for(i = 0; i < 15; i++) { for(i = 0; i < 15; i++) {
if(esp->targets_present & (1 << i)) { if(esp->targets_present & (1 << i)) {
Scsi_Device *SDptr = esp->ehost->host_queue; Scsi_Device *SDptr = esp->ehost->host_queue;
struct ESP_device *esp_dev; struct esp_device *esp_dev;
while((SDptr->host != esp->ehost) && while((SDptr->host != esp->ehost) &&
(SDptr->id != i) && (SDptr->id != i) &&
...@@ -1014,7 +1014,7 @@ static inline void build_sync_nego_msg(struct NCR_ESP *esp, int period, int offs ...@@ -1014,7 +1014,7 @@ static inline void build_sync_nego_msg(struct NCR_ESP *esp, int period, int offs
static void esp_exec_cmd(struct NCR_ESP *esp) static void esp_exec_cmd(struct NCR_ESP *esp)
{ {
struct ESP_regs *eregs = esp->eregs; struct ESP_regs *eregs = esp->eregs;
struct ESP_device *esp_dev; struct esp_device *esp_dev;
Scsi_Cmnd *SCptr; Scsi_Cmnd *SCptr;
Scsi_Device *SDptr; Scsi_Device *SDptr;
volatile unchar *cmdp = esp->esp_command; volatile unchar *cmdp = esp->esp_command;
...@@ -1043,18 +1043,18 @@ static void esp_exec_cmd(struct NCR_ESP *esp) ...@@ -1043,18 +1043,18 @@ static void esp_exec_cmd(struct NCR_ESP *esp)
/* /*
* If esp_dev == NULL then we need to allocate a struct for our data * If esp_dev == NULL then we need to allocate a struct for our data
*/ */
if(esp_dev == NULL) { if (!esp_dev) {
esp_dev = kmalloc(sizeof(struct ESP_device), GFP_ATOMIC); esp_dev = kmalloc(sizeof(struct esp_device), GFP_ATOMIC);
if(esp_dev == NULL) { if (!esp_dev) {
/* We're SOL. Print a message and bail */ /* We're SOL. Print a message and bail */
printk(KERN_WARNING "esp: no mem for ESP_device %d/%d\n", printk(KERN_WARNING "esp: no mem for esp_device %d/%d\n",
target, lun); target, lun);
esp->current_SC = NULL; esp->current_SC = NULL;
SCptr->result = DID_ERROR << 16; SCptr->result = DID_ERROR << 16;
SCptr->done(SCptr); SCptr->done(SCptr);
return; return;
} }
memset(esp_dev, 0, sizeof(struct ESP_device)); memset(esp_dev, 0, sizeof(struct esp_device));
SDptr->hostdata = esp_dev; SDptr->hostdata = esp_dev;
} }
...@@ -1720,7 +1720,7 @@ static inline void esp_connect(struct NCR_ESP *esp, struct ESP_regs *eregs, ...@@ -1720,7 +1720,7 @@ static inline void esp_connect(struct NCR_ESP *esp, struct ESP_regs *eregs,
Scsi_Cmnd *sp) Scsi_Cmnd *sp)
{ {
Scsi_Device *dp = sp->device; Scsi_Device *dp = sp->device;
struct ESP_device *esp_dev = dp->hostdata; struct esp_device *esp_dev = dp->hostdata;
if(esp->prev_soff != esp_dev->sync_max_offset || if(esp->prev_soff != esp_dev->sync_max_offset ||
esp->prev_stp != esp_dev->sync_min_period || esp->prev_stp != esp_dev->sync_min_period ||
...@@ -2007,7 +2007,7 @@ static int esp_do_data_finale(struct NCR_ESP *esp, ...@@ -2007,7 +2007,7 @@ static int esp_do_data_finale(struct NCR_ESP *esp,
struct ESP_regs *eregs) struct ESP_regs *eregs)
{ {
Scsi_Cmnd *SCptr = esp->current_SC; Scsi_Cmnd *SCptr = esp->current_SC;
struct ESP_device *esp_dev = SCptr->device->hostdata; struct esp_device *esp_dev = SCptr->device->hostdata;
int bogus_data = 0, bytes_sent = 0, fifocnt, ecount = 0; int bogus_data = 0, bytes_sent = 0, fifocnt, ecount = 0;
if(esp->dma_led_off) if(esp->dma_led_off)
...@@ -2228,7 +2228,7 @@ static int esp_do_freebus(struct NCR_ESP *esp, struct ESP_regs *eregs) ...@@ -2228,7 +2228,7 @@ static int esp_do_freebus(struct NCR_ESP *esp, struct ESP_regs *eregs)
esp->msgout_len = 0; esp->msgout_len = 0;
esp->prevmsgout = NOP; esp->prevmsgout = NOP;
if(esp->prevmsgin == COMMAND_COMPLETE) { if(esp->prevmsgin == COMMAND_COMPLETE) {
struct ESP_device *esp_dev = SCptr->device->hostdata; struct esp_device *esp_dev = SCptr->device->hostdata;
/* Normal end of nexus. */ /* Normal end of nexus. */
if(esp->disconnected_SC) if(esp->disconnected_SC)
esp_cmd(esp, eregs, ESP_CMD_ESEL); esp_cmd(esp, eregs, ESP_CMD_ESEL);
...@@ -2503,7 +2503,7 @@ static int esp_disconnect_amidst_phases(struct NCR_ESP *esp, ...@@ -2503,7 +2503,7 @@ static int esp_disconnect_amidst_phases(struct NCR_ESP *esp,
struct ESP_regs *eregs) struct ESP_regs *eregs)
{ {
Scsi_Cmnd *sp = esp->current_SC; Scsi_Cmnd *sp = esp->current_SC;
struct ESP_device *esp_dev = sp->device->hostdata; struct esp_device *esp_dev = sp->device->hostdata;
/* This means real problems if we see this /* This means real problems if we see this
* here. Unless we were actually trying * here. Unless we were actually trying
...@@ -2602,7 +2602,7 @@ static int esp_do_phase_determine(struct NCR_ESP *esp, ...@@ -2602,7 +2602,7 @@ static int esp_do_phase_determine(struct NCR_ESP *esp,
static int esp_select_complete(struct NCR_ESP *esp, struct ESP_regs *eregs) static int esp_select_complete(struct NCR_ESP *esp, struct ESP_regs *eregs)
{ {
Scsi_Cmnd *SCptr = esp->current_SC; Scsi_Cmnd *SCptr = esp->current_SC;
struct ESP_device *esp_dev = SCptr->device->hostdata; struct esp_device *esp_dev = SCptr->device->hostdata;
int cmd_bytes_sent, fcnt; int cmd_bytes_sent, fcnt;
fcnt = (esp_read(eregs->esp_fflags) & ESP_FF_FBYTES); fcnt = (esp_read(eregs->esp_fflags) & ESP_FF_FBYTES);
...@@ -2931,7 +2931,7 @@ static int check_singlebyte_msg(struct NCR_ESP *esp, ...@@ -2931,7 +2931,7 @@ static int check_singlebyte_msg(struct NCR_ESP *esp,
case MESSAGE_REJECT: case MESSAGE_REJECT:
ESPMISC(("msg reject, ")); ESPMISC(("msg reject, "));
if(esp->prevmsgout == EXTENDED_MESSAGE) { if(esp->prevmsgout == EXTENDED_MESSAGE) {
struct ESP_device *esp_dev = esp->current_SC->device->hostdata; struct esp_device *esp_dev = esp->current_SC->device->hostdata;
/* Doesn't look like this target can /* Doesn't look like this target can
* do synchronous or WIDE transfers. * do synchronous or WIDE transfers.
...@@ -2956,7 +2956,7 @@ static int check_singlebyte_msg(struct NCR_ESP *esp, ...@@ -2956,7 +2956,7 @@ static int check_singlebyte_msg(struct NCR_ESP *esp,
*/ */
static int target_with_ants_in_pants(struct NCR_ESP *esp, static int target_with_ants_in_pants(struct NCR_ESP *esp,
Scsi_Cmnd *SCptr, Scsi_Cmnd *SCptr,
struct ESP_device *esp_dev) struct esp_device *esp_dev)
{ {
if(esp_dev->sync || SCptr->device->borken) { if(esp_dev->sync || SCptr->device->borken) {
/* sorry, no can do */ /* sorry, no can do */
...@@ -3011,7 +3011,7 @@ static int check_multibyte_msg(struct NCR_ESP *esp, ...@@ -3011,7 +3011,7 @@ static int check_multibyte_msg(struct NCR_ESP *esp,
struct ESP_regs *eregs) struct ESP_regs *eregs)
{ {
Scsi_Cmnd *SCptr = esp->current_SC; Scsi_Cmnd *SCptr = esp->current_SC;
struct ESP_device *esp_dev = SCptr->device->hostdata; struct esp_device *esp_dev = SCptr->device->hostdata;
unchar regval = 0; unchar regval = 0;
int message_out = 0; int message_out = 0;
...@@ -3345,7 +3345,7 @@ static int esp_do_msgoutdone(struct NCR_ESP *esp, ...@@ -3345,7 +3345,7 @@ static int esp_do_msgoutdone(struct NCR_ESP *esp,
default: default:
if(!fcount(esp, eregs) && if(!fcount(esp, eregs) &&
!(((struct ESP_device *)esp->current_SC->device->hostdata)->sync_max_offset)) !(((struct esp_device *)esp->current_SC->device->hostdata)->sync_max_offset))
esp_cmd(esp, eregs, ESP_CMD_FLUSH); esp_cmd(esp, eregs, ESP_CMD_FLUSH);
break; break;
......
...@@ -286,7 +286,7 @@ enum esp_rev { ...@@ -286,7 +286,7 @@ enum esp_rev {
/* We allocate one of these for each scsi device and attach it to /* We allocate one of these for each scsi device and attach it to
* SDptr->hostdata for use in the driver * SDptr->hostdata for use in the driver
*/ */
struct ESP_device { struct esp_device {
unsigned char sync_min_period; unsigned char sync_min_period;
unsigned char sync_max_offset; unsigned char sync_max_offset;
unsigned sync:1; unsigned sync:1;
......
...@@ -1362,17 +1362,19 @@ static int esp_host_info(struct esp *esp, char *ptr, off_t offset, int len) ...@@ -1362,17 +1362,19 @@ static int esp_host_info(struct esp *esp, char *ptr, off_t offset, int len)
for (i = 0; i < 15; i++) { for (i = 0; i < 15; i++) {
if (esp->targets_present & (1 << i)) { if (esp->targets_present & (1 << i)) {
Scsi_Device *SDptr = esp->ehost->host_queue; Scsi_Device *SDptr = esp->ehost->host_queue;
struct esp_device *esp_dev;
while ((SDptr->host != esp->ehost) && while ((SDptr->host != esp->ehost) &&
(SDptr->id != i) && (SDptr->id != i) &&
(SDptr->next)) (SDptr->next))
SDptr = SDptr->next; SDptr = SDptr->next;
esp_dev = SDptr->hostdata;
copy_info(&info, "%d\t\t", i); copy_info(&info, "%d\t\t", i);
copy_info(&info, "%08lx\t", esp->config3[i]); copy_info(&info, "%08lx\t", esp->config3[i]);
copy_info(&info, "[%02lx,%02lx]\t\t\t", SDptr->sync_max_offset, copy_info(&info, "[%02lx,%02lx]\t\t\t", esp_dev->sync_max_offset,
SDptr->sync_min_period); esp_dev->sync_min_period);
copy_info(&info, "%s\t\t", SDptr->disconnect ? "yes" : "no"); copy_info(&info, "%s\t\t", esp_dev->disconnect ? "yes" : "no");
copy_info(&info, "%s\n", copy_info(&info, "%s\n",
(esp->config3[i] & ESP_CONFIG3_EWIDE) ? "yes" : "no"); (esp->config3[i] & ESP_CONFIG3_EWIDE) ? "yes" : "no");
} }
...@@ -1533,6 +1535,7 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1533,6 +1535,7 @@ static void esp_exec_cmd(struct esp *esp)
{ {
Scsi_Cmnd *SCptr; Scsi_Cmnd *SCptr;
Scsi_Device *SDptr; Scsi_Device *SDptr;
struct esp_device *esp_dev;
volatile u8 *cmdp = esp->esp_command; volatile u8 *cmdp = esp->esp_command;
u8 the_esp_command; u8 the_esp_command;
int lun, target; int lun, target;
...@@ -1552,9 +1555,29 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1552,9 +1555,29 @@ static void esp_exec_cmd(struct esp *esp)
panic("esp: esp_exec_cmd and issue queue is NULL"); panic("esp: esp_exec_cmd and issue queue is NULL");
SDptr = SCptr->device; SDptr = SCptr->device;
esp_dev = SDptr->hostdata;
lun = SCptr->lun; lun = SCptr->lun;
target = SCptr->target; target = SCptr->target;
/*
* We check that esp_dev != NULL. If it is, we allocate it or bail.
*/
if (!esp_dev) {
esp_dev = kmalloc(sizeof(struct esp_device), GFP_ATOMIC);
if (!esp_dev) {
/* We're SOL. Print a message and bail */
printk(KERN_WARNING "esp: no mem for esp_device %d/%d\n",
target, lun);
esp->current_SC = NULL;
SCptr->result = DID_ERROR << 16;
SCptr->done(SCptr);
return;
}
memset(esp_dev, 0, sizeof(struct esp_device));
SDptr->hostdata = esp_dev;
}
}
esp->snip = 0; esp->snip = 0;
esp->msgout_len = 0; esp->msgout_len = 0;
...@@ -1590,12 +1613,12 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1590,12 +1613,12 @@ static void esp_exec_cmd(struct esp *esp)
* selections should not confuse SCSI-1 we hope. * selections should not confuse SCSI-1 we hope.
*/ */
if (SDptr->sync) { if (esp_dev->sync) {
/* this targets sync is known */ /* this targets sync is known */
#ifndef __sparc_v9__ #ifndef __sparc_v9__
do_sync_known: do_sync_known:
#endif #endif
if (SDptr->disconnect) if (esp_dev->disconnect)
*cmdp++ = IDENTIFY(1, lun); *cmdp++ = IDENTIFY(1, lun);
else else
*cmdp++ = IDENTIFY(0, lun); *cmdp++ = IDENTIFY(0, lun);
...@@ -1607,7 +1630,7 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1607,7 +1630,7 @@ static void esp_exec_cmd(struct esp *esp)
the_esp_command = (ESP_CMD_SELA | ESP_CMD_DMA); the_esp_command = (ESP_CMD_SELA | ESP_CMD_DMA);
esp_advance_phase(SCptr, in_slct_norm); esp_advance_phase(SCptr, in_slct_norm);
} }
} else if (!(esp->targets_present & (1<<target)) || !(SDptr->disconnect)) { } else if (!(esp->targets_present & (1<<target)) || !(esp_dev->disconnect)) {
/* After the bootup SCSI code sends both the /* After the bootup SCSI code sends both the
* TEST_UNIT_READY and INQUIRY commands we want * TEST_UNIT_READY and INQUIRY commands we want
* to at least attempt allowing the device to * to at least attempt allowing the device to
...@@ -1615,8 +1638,8 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1615,8 +1638,8 @@ static void esp_exec_cmd(struct esp *esp)
*/ */
ESPMISC(("esp: Selecting device for first time. target=%d " ESPMISC(("esp: Selecting device for first time. target=%d "
"lun=%d\n", target, SCptr->lun)); "lun=%d\n", target, SCptr->lun));
if (!SDptr->borken && !SDptr->disconnect) if (!SDptr->borken && !esp_dev->disconnect)
SDptr->disconnect = 1; esp_dev->disconnect = 1;
*cmdp++ = IDENTIFY(0, lun); *cmdp++ = IDENTIFY(0, lun);
esp->prevmsgout = NOP; esp->prevmsgout = NOP;
...@@ -1624,8 +1647,8 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1624,8 +1647,8 @@ static void esp_exec_cmd(struct esp *esp)
the_esp_command = (ESP_CMD_SELA | ESP_CMD_DMA); the_esp_command = (ESP_CMD_SELA | ESP_CMD_DMA);
/* Take no chances... */ /* Take no chances... */
SDptr->sync_max_offset = 0; esp_dev->sync_max_offset = 0;
SDptr->sync_min_period = 0; esp_dev->sync_min_period = 0;
} else { } else {
/* Sorry, I have had way too many problems with /* Sorry, I have had way too many problems with
* various CDROM devices on ESP. -DaveM * various CDROM devices on ESP. -DaveM
...@@ -1644,12 +1667,12 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1644,12 +1667,12 @@ static void esp_exec_cmd(struct esp *esp)
*/ */
if(SDptr->type == TYPE_TAPE || if(SDptr->type == TYPE_TAPE ||
(SDptr->type != TYPE_ROM && SDptr->removable)) (SDptr->type != TYPE_ROM && SDptr->removable))
SDptr->disconnect = 1; esp_dev->disconnect = 1;
else else
SDptr->disconnect = 0; esp_dev->disconnect = 0;
SDptr->sync_max_offset = 0; esp_dev->sync_max_offset = 0;
SDptr->sync_min_period = 0; esp_dev->sync_min_period = 0;
SDptr->sync = 1; esp_dev->sync = 1;
esp->snip = 0; esp->snip = 0;
goto do_sync_known; goto do_sync_known;
} }
...@@ -1660,16 +1683,16 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1660,16 +1683,16 @@ static void esp_exec_cmd(struct esp *esp)
* need to attempt WIDE first, before * need to attempt WIDE first, before
* sync nego, as per SCSI 2 standard. * sync nego, as per SCSI 2 standard.
*/ */
if (esp->erev == fashme && !SDptr->wide) { if (esp->erev == fashme && !esp_dev->wide) {
if (!SDptr->borken && if (!SDptr->borken &&
SDptr->type != TYPE_ROM && SDptr->type != TYPE_ROM &&
SDptr->removable == 0) { SDptr->removable == 0) {
build_wide_nego_msg(esp, 16); build_wide_nego_msg(esp, 16);
SDptr->wide = 1; esp_dev->wide = 1;
esp->wnip = 1; esp->wnip = 1;
goto after_nego_msg_built; goto after_nego_msg_built;
} else { } else {
SDptr->wide = 1; esp_dev->wide = 1;
/* Fall through and try sync. */ /* Fall through and try sync. */
} }
} }
...@@ -1692,7 +1715,7 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1692,7 +1715,7 @@ static void esp_exec_cmd(struct esp *esp)
} else { } else {
build_sync_nego_msg(esp, 0, 0); build_sync_nego_msg(esp, 0, 0);
} }
SDptr->sync = 1; esp_dev->sync = 1;
esp->snip = 1; esp->snip = 1;
after_nego_msg_built: after_nego_msg_built:
...@@ -1725,7 +1748,7 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1725,7 +1748,7 @@ static void esp_exec_cmd(struct esp *esp)
cdrom_hwbug_wkaround || SDptr->borken) { cdrom_hwbug_wkaround || SDptr->borken) {
ESPMISC((KERN_INFO "esp%d: Disabling DISCONNECT for target %d " ESPMISC((KERN_INFO "esp%d: Disabling DISCONNECT for target %d "
"lun %d\n", esp->esp_id, SCptr->target, SCptr->lun)); "lun %d\n", esp->esp_id, SCptr->target, SCptr->lun));
SDptr->disconnect = 0; esp_dev->disconnect = 0;
*cmdp++ = IDENTIFY(0, lun); *cmdp++ = IDENTIFY(0, lun);
} else { } else {
*cmdp++ = IDENTIFY(1, lun); *cmdp++ = IDENTIFY(1, lun);
...@@ -1752,12 +1775,12 @@ static void esp_exec_cmd(struct esp *esp) ...@@ -1752,12 +1775,12 @@ static void esp_exec_cmd(struct esp *esp)
esp->eregs + ESP_BUSID); esp->eregs + ESP_BUSID);
else else
sbus_writeb(target & 7, esp->eregs + ESP_BUSID); sbus_writeb(target & 7, esp->eregs + ESP_BUSID);
if (esp->prev_soff != SDptr->sync_max_offset || if (esp->prev_soff != esp_dev->sync_max_offset ||
esp->prev_stp != SDptr->sync_min_period || esp->prev_stp != esp_dev->sync_min_period ||
(esp->erev > esp100a && (esp->erev > esp100a &&
esp->prev_cfg3 != esp->config3[target])) { esp->prev_cfg3 != esp->config3[target])) {
esp->prev_soff = SDptr->sync_max_offset; esp->prev_soff = esp_dev->sync_max_offset;
esp->prev_stp = SDptr->sync_min_period; esp->prev_stp = esp_dev->sync_min_period;
sbus_writeb(esp->prev_soff, esp->eregs + ESP_SOFF); sbus_writeb(esp->prev_soff, esp->eregs + ESP_SOFF);
sbus_writeb(esp->prev_stp, esp->eregs + ESP_STP); sbus_writeb(esp->prev_stp, esp->eregs + ESP_STP);
if (esp->erev > esp100a) { if (esp->erev > esp100a) {
...@@ -2462,14 +2485,14 @@ static inline int reconnect_lun(struct esp *esp) ...@@ -2462,14 +2485,14 @@ static inline int reconnect_lun(struct esp *esp)
*/ */
static inline void esp_connect(struct esp *esp, Scsi_Cmnd *sp) static inline void esp_connect(struct esp *esp, Scsi_Cmnd *sp)
{ {
Scsi_Device *dp = sp->device; struct esp_device *esp_dev = sp->device->hostdata;
if (esp->prev_soff != dp->sync_max_offset || if (esp->prev_soff != esp_dev->sync_max_offset ||
esp->prev_stp != dp->sync_min_period || esp->prev_stp != esp_dev->sync_min_period ||
(esp->erev > esp100a && (esp->erev > esp100a &&
esp->prev_cfg3 != esp->config3[sp->target])) { esp->prev_cfg3 != esp->config3[sp->target])) {
esp->prev_soff = dp->sync_max_offset; esp->prev_soff = esp_dev->sync_max_offset;
esp->prev_stp = dp->sync_min_period; esp->prev_stp = esp_dev->sync_min_period;
sbus_writeb(esp->prev_soff, esp->eregs + ESP_SOFF); sbus_writeb(esp->prev_soff, esp->eregs + ESP_SOFF);
sbus_writeb(esp->prev_stp, esp->eregs + ESP_STP); sbus_writeb(esp->prev_stp, esp->eregs + ESP_STP);
if (esp->erev > esp100a) { if (esp->erev > esp100a) {
...@@ -2601,6 +2624,7 @@ static int esp_do_data(struct esp *esp) ...@@ -2601,6 +2624,7 @@ static int esp_do_data(struct esp *esp)
static int esp_do_data_finale(struct esp *esp) static int esp_do_data_finale(struct esp *esp)
{ {
Scsi_Cmnd *SCptr = esp->current_SC; Scsi_Cmnd *SCptr = esp->current_SC;
struct esp_device *esp_dev = SCptr->device->hostdata;
int bogus_data = 0, bytes_sent = 0, fifocnt, ecount = 0; int bogus_data = 0, bytes_sent = 0, fifocnt, ecount = 0;
ESPDATA(("esp_do_data_finale: ")); ESPDATA(("esp_do_data_finale: "));
...@@ -2694,14 +2718,14 @@ static int esp_do_data_finale(struct esp *esp) ...@@ -2694,14 +2718,14 @@ static int esp_do_data_finale(struct esp *esp)
/* If we were in synchronous mode, check for peculiarities. */ /* If we were in synchronous mode, check for peculiarities. */
if (esp->erev == fashme) { if (esp->erev == fashme) {
if (SCptr->device->sync_max_offset) { if (esp_dev->sync_max_offset) {
if (SCptr->SCp.phase == in_dataout) if (SCptr->SCp.phase == in_dataout)
esp_cmd(esp, ESP_CMD_FLUSH); esp_cmd(esp, ESP_CMD_FLUSH);
} else { } else {
esp_cmd(esp, ESP_CMD_FLUSH); esp_cmd(esp, ESP_CMD_FLUSH);
} }
} else { } else {
if (SCptr->device->sync_max_offset) if (esp_dev->sync_max_offset)
bogus_data = esp100_sync_hwbug(esp, SCptr, fifocnt); bogus_data = esp100_sync_hwbug(esp, SCptr, fifocnt);
else else
esp_cmd(esp, ESP_CMD_FLUSH); esp_cmd(esp, ESP_CMD_FLUSH);
...@@ -2730,7 +2754,7 @@ static int esp_do_data_finale(struct esp *esp) ...@@ -2730,7 +2754,7 @@ static int esp_do_data_finale(struct esp *esp)
ESPLOG(("esp%d: Forcing async for target %d\n", esp->esp_id, ESPLOG(("esp%d: Forcing async for target %d\n", esp->esp_id,
SCptr->target)); SCptr->target));
SCptr->device->borken = 1; SCptr->device->borken = 1;
SCptr->device->sync = 0; esp_dev->sync = 0;
bytes_sent = 0; bytes_sent = 0;
} }
...@@ -2815,6 +2839,7 @@ static int esp_should_clear_sync(Scsi_Cmnd *sp) ...@@ -2815,6 +2839,7 @@ static int esp_should_clear_sync(Scsi_Cmnd *sp)
static int esp_do_freebus(struct esp *esp) static int esp_do_freebus(struct esp *esp)
{ {
Scsi_Cmnd *SCptr = esp->current_SC; Scsi_Cmnd *SCptr = esp->current_SC;
struct esp_device *esp_dev = SCptr->device->hostdata;
int rval; int rval;
rval = skipahead2(esp, SCptr, in_status, in_msgindone, in_freeing); rval = skipahead2(esp, SCptr, in_status, in_msgindone, in_freeing);
...@@ -2834,8 +2859,8 @@ static int esp_do_freebus(struct esp *esp) ...@@ -2834,8 +2859,8 @@ static int esp_do_freebus(struct esp *esp)
if (SCptr->SCp.Status != GOOD && if (SCptr->SCp.Status != GOOD &&
SCptr->SCp.Status != CONDITION_GOOD && SCptr->SCp.Status != CONDITION_GOOD &&
((1<<SCptr->target) & esp->targets_present) && ((1<<SCptr->target) & esp->targets_present) &&
SCptr->device->sync && esp_dev->sync &&
SCptr->device->sync_max_offset) { esp_dev->sync_max_offset) {
/* SCSI standard says that the synchronous capabilities /* SCSI standard says that the synchronous capabilities
* should be renegotiated at this point. Most likely * should be renegotiated at this point. Most likely
* we are about to request sense from this target * we are about to request sense from this target
...@@ -2853,7 +2878,7 @@ static int esp_do_freebus(struct esp *esp) ...@@ -2853,7 +2878,7 @@ static int esp_do_freebus(struct esp *esp)
* loading up a tape. * loading up a tape.
*/ */
if (esp_should_clear_sync(SCptr) != 0) if (esp_should_clear_sync(SCptr) != 0)
SCptr->device->sync = 0; esp_dev->sync = 0;
} }
ESPDISC(("F<%02x,%02x>", SCptr->target, SCptr->lun)); ESPDISC(("F<%02x,%02x>", SCptr->target, SCptr->lun));
esp_done(esp, ((SCptr->SCp.Status & 0xff) | esp_done(esp, ((SCptr->SCp.Status & 0xff) |
...@@ -3113,7 +3138,7 @@ static int esp_enter_status(struct esp *esp) ...@@ -3113,7 +3138,7 @@ static int esp_enter_status(struct esp *esp)
static int esp_disconnect_amidst_phases(struct esp *esp) static int esp_disconnect_amidst_phases(struct esp *esp)
{ {
Scsi_Cmnd *sp = esp->current_SC; Scsi_Cmnd *sp = esp->current_SC;
Scsi_Device *dp = sp->device; struct esp_device *esp_dev = sp->device->hostdata;
/* This means real problems if we see this /* This means real problems if we see this
* here. Unless we were actually trying * here. Unless we were actually trying
...@@ -3137,9 +3162,9 @@ static int esp_disconnect_amidst_phases(struct esp *esp) ...@@ -3137,9 +3162,9 @@ static int esp_disconnect_amidst_phases(struct esp *esp)
case BUS_DEVICE_RESET: case BUS_DEVICE_RESET:
ESPLOG(("device reset successful\n")); ESPLOG(("device reset successful\n"));
dp->sync_max_offset = 0; esp_dev->sync_max_offset = 0;
dp->sync_min_period = 0; esp_dev->sync_min_period = 0;
dp->sync = 0; esp_dev->sync = 0;
esp_advance_phase(sp, in_resetdev); esp_advance_phase(sp, in_resetdev);
esp_done(esp, (DID_RESET << 16)); esp_done(esp, (DID_RESET << 16));
break; break;
...@@ -3206,7 +3231,7 @@ static int esp_do_phase_determine(struct esp *esp) ...@@ -3206,7 +3231,7 @@ static int esp_do_phase_determine(struct esp *esp)
static int esp_select_complete(struct esp *esp) static int esp_select_complete(struct esp *esp)
{ {
Scsi_Cmnd *SCptr = esp->current_SC; Scsi_Cmnd *SCptr = esp->current_SC;
Scsi_Device *SDptr = SCptr->device; struct esp_device *esp_dev = SCptr->device->hostdata;
int cmd_bytes_sent, fcnt; int cmd_bytes_sent, fcnt;
if (esp->erev != fashme) if (esp->erev != fashme)
...@@ -3241,7 +3266,7 @@ static int esp_select_complete(struct esp *esp) ...@@ -3241,7 +3266,7 @@ static int esp_select_complete(struct esp *esp)
/* What if the target ignores the sdtr? */ /* What if the target ignores the sdtr? */
if (esp->snip) if (esp->snip)
SDptr->sync = 1; esp_dev->sync = 1;
/* See how far, if at all, we got in getting /* See how far, if at all, we got in getting
* the information out to the target. * the information out to the target.
...@@ -3333,7 +3358,7 @@ static int esp_select_complete(struct esp *esp) ...@@ -3333,7 +3358,7 @@ static int esp_select_complete(struct esp *esp)
if ((esp->erev != fashme) && /* not a Happy Meal and... */ if ((esp->erev != fashme) && /* not a Happy Meal and... */
!fcnt && /* Fifo is empty and... */ !fcnt && /* Fifo is empty and... */
/* either we are not doing synchronous transfers or... */ /* either we are not doing synchronous transfers or... */
(!SDptr->sync_max_offset || (!esp_dev->sync_max_offset ||
/* We are not going into data in phase. */ /* We are not going into data in phase. */
((esp->sreg & ESP_STAT_PMASK) != ESP_DIP))) ((esp->sreg & ESP_STAT_PMASK) != ESP_DIP)))
esp_cmd(esp, ESP_CMD_FLUSH); /* flush is safe */ esp_cmd(esp, ESP_CMD_FLUSH); /* flush is safe */
...@@ -3395,9 +3420,9 @@ static int esp_select_complete(struct esp *esp) ...@@ -3395,9 +3420,9 @@ static int esp_select_complete(struct esp *esp)
esp->snip = 0; esp->snip = 0;
ESPLOG(("esp%d: Failed synchronous negotiation for target %d " ESPLOG(("esp%d: Failed synchronous negotiation for target %d "
"lun %d\n", esp->esp_id, SCptr->target, SCptr->lun)); "lun %d\n", esp->esp_id, SCptr->target, SCptr->lun));
SDptr->sync_max_offset = 0; esp_dev->sync_max_offset = 0;
SDptr->sync_min_period = 0; esp_dev->sync_min_period = 0;
SDptr->sync = 1; /* so we don't negotiate again */ esp_dev->sync = 1; /* so we don't negotiate again */
/* Run the command again, this time though we /* Run the command again, this time though we
* won't try to negotiate for synchronous transfers. * won't try to negotiate for synchronous transfers.
...@@ -3537,16 +3562,16 @@ static int check_singlebyte_msg(struct esp *esp) ...@@ -3537,16 +3562,16 @@ static int check_singlebyte_msg(struct esp *esp)
case MESSAGE_REJECT: case MESSAGE_REJECT:
ESPMISC(("msg reject, ")); ESPMISC(("msg reject, "));
if (esp->prevmsgout == EXTENDED_MESSAGE) { if (esp->prevmsgout == EXTENDED_MESSAGE) {
Scsi_Device *SDptr = esp->current_SC->device; struct esp_device *esp_dev = esp->current_SC->device->hostdata;
/* Doesn't look like this target can /* Doesn't look like this target can
* do synchronous or WIDE transfers. * do synchronous or WIDE transfers.
*/ */
ESPSDTR(("got reject, was trying nego, clearing sync/WIDE\n")); ESPSDTR(("got reject, was trying nego, clearing sync/WIDE\n"));
SDptr->sync = 1; esp_dev->sync = 1;
SDptr->wide = 1; esp_dev->wide = 1;
SDptr->sync_min_period = 0; esp_dev->sync_min_period = 0;
SDptr->sync_max_offset = 0; esp_dev->sync_max_offset = 0;
return 0; return 0;
} else { } else {
ESPMISC(("not sync nego, sending ABORT\n")); ESPMISC(("not sync nego, sending ABORT\n"));
...@@ -3562,13 +3587,13 @@ static int check_singlebyte_msg(struct esp *esp) ...@@ -3562,13 +3587,13 @@ static int check_singlebyte_msg(struct esp *esp)
*/ */
static int target_with_ants_in_pants(struct esp *esp, static int target_with_ants_in_pants(struct esp *esp,
Scsi_Cmnd *SCptr, Scsi_Cmnd *SCptr,
Scsi_Device *SDptr) struct esp_device *esp_dev)
{ {
if (SDptr->sync || SDptr->borken) { if (esp_dev->sync || SCptr->SDptr->borken) {
/* sorry, no can do */ /* sorry, no can do */
ESPSDTR(("forcing to async, ")); ESPSDTR(("forcing to async, "));
build_sync_nego_msg(esp, 0, 0); build_sync_nego_msg(esp, 0, 0);
SDptr->sync = 1; esp_dev->sync = 1;
esp->snip = 1; esp->snip = 1;
ESPLOG(("esp%d: hoping for msgout\n", esp->esp_id)); ESPLOG(("esp%d: hoping for msgout\n", esp->esp_id));
esp_advance_phase(SCptr, in_the_dark); esp_advance_phase(SCptr, in_the_dark);
...@@ -3621,7 +3646,7 @@ static void sync_report(struct esp *esp) ...@@ -3621,7 +3646,7 @@ static void sync_report(struct esp *esp)
static int check_multibyte_msg(struct esp *esp) static int check_multibyte_msg(struct esp *esp)
{ {
Scsi_Cmnd *SCptr = esp->current_SC; Scsi_Cmnd *SCptr = esp->current_SC;
Scsi_Device *SDptr = SCptr->device; struct esp_device *esp_dev = SCptr->device->hostdata;
u8 regval = 0; u8 regval = 0;
int message_out = 0; int message_out = 0;
...@@ -3637,7 +3662,7 @@ static int check_multibyte_msg(struct esp *esp) ...@@ -3637,7 +3662,7 @@ static int check_multibyte_msg(struct esp *esp)
/* Target negotiates first! */ /* Target negotiates first! */
ESPSDTR(("target jumps the gun, ")); ESPSDTR(("target jumps the gun, "));
message_out = EXTENDED_MESSAGE; /* we must respond */ message_out = EXTENDED_MESSAGE; /* we must respond */
rval = target_with_ants_in_pants(esp, SCptr, SDptr); rval = target_with_ants_in_pants(esp, SCptr, esp_dev);
if (rval) if (rval)
return rval; return rval;
} }
...@@ -3684,8 +3709,8 @@ static int check_multibyte_msg(struct esp *esp) ...@@ -3684,8 +3709,8 @@ static int check_multibyte_msg(struct esp *esp)
if (offset) { if (offset) {
u8 bit; u8 bit;
SDptr->sync_min_period = (regval & 0x1f); esp_dev->sync_min_period = (regval & 0x1f);
SDptr->sync_max_offset = (offset | esp->radelay); esp_dev->sync_max_offset = (offset | esp->radelay);
if (esp->erev == fas100a || esp->erev == fas236 || esp->erev == fashme) { if (esp->erev == fas100a || esp->erev == fas236 || esp->erev == fashme) {
if ((esp->erev == fas100a) || (esp->erev == fashme)) if ((esp->erev == fas100a) || (esp->erev == fashme))
bit = ESP_CONFIG3_FAST; bit = ESP_CONFIG3_FAST;
...@@ -3697,7 +3722,7 @@ static int check_multibyte_msg(struct esp *esp) ...@@ -3697,7 +3722,7 @@ static int check_multibyte_msg(struct esp *esp)
* control bits are clear. * control bits are clear.
*/ */
if (esp->erev == fashme) if (esp->erev == fashme)
SDptr->sync_max_offset &= ~esp->radelay; esp_dev->sync_max_offset &= ~esp->radelay;
esp->config3[SCptr->target] |= bit; esp->config3[SCptr->target] |= bit;
} else { } else {
esp->config3[SCptr->target] &= ~bit; esp->config3[SCptr->target] &= ~bit;
...@@ -3705,23 +3730,23 @@ static int check_multibyte_msg(struct esp *esp) ...@@ -3705,23 +3730,23 @@ static int check_multibyte_msg(struct esp *esp)
esp->prev_cfg3 = esp->config3[SCptr->target]; esp->prev_cfg3 = esp->config3[SCptr->target];
sbus_writeb(esp->prev_cfg3, esp->eregs + ESP_CFG3); sbus_writeb(esp->prev_cfg3, esp->eregs + ESP_CFG3);
} }
esp->prev_soff = SDptr->sync_max_offset; esp->prev_soff = esp_dev->sync_max_offset;
esp->prev_stp = SDptr->sync_min_period; esp->prev_stp = esp_dev->sync_min_period;
sbus_writeb(esp->prev_soff, esp->eregs + ESP_SOFF); sbus_writeb(esp->prev_soff, esp->eregs + ESP_SOFF);
sbus_writeb(esp->prev_stp, esp->eregs + ESP_STP); sbus_writeb(esp->prev_stp, esp->eregs + ESP_STP);
ESPSDTR(("soff=%2x stp=%2x cfg3=%2x\n", ESPSDTR(("soff=%2x stp=%2x cfg3=%2x\n",
SDptr->sync_max_offset, esp_dev->sync_max_offset,
SDptr->sync_min_period, esp_dev->sync_min_period,
esp->config3[SCptr->target])); esp->config3[SCptr->target]));
esp->snip = 0; esp->snip = 0;
} else if (SDptr->sync_max_offset) { } else if (esp_dev->sync_max_offset) {
u8 bit; u8 bit;
/* back to async mode */ /* back to async mode */
ESPSDTR(("unaccaptable sync nego, forcing async\n")); ESPSDTR(("unaccaptable sync nego, forcing async\n"));
SDptr->sync_max_offset = 0; esp_dev->sync_max_offset = 0;
SDptr->sync_min_period = 0; esp_dev->sync_min_period = 0;
esp->prev_soff = 0; esp->prev_soff = 0;
esp->prev_stp = 0; esp->prev_stp = 0;
sbus_writeb(esp->prev_soff, esp->eregs + ESP_SOFF); sbus_writeb(esp->prev_soff, esp->eregs + ESP_SOFF);
...@@ -3740,7 +3765,7 @@ static int check_multibyte_msg(struct esp *esp) ...@@ -3740,7 +3765,7 @@ static int check_multibyte_msg(struct esp *esp)
sync_report(esp); sync_report(esp);
ESPSDTR(("chk multibyte msg: sync is known, ")); ESPSDTR(("chk multibyte msg: sync is known, "));
SDptr->sync = 1; esp_dev->sync = 1;
if (message_out) { if (message_out) {
ESPLOG(("esp%d: sending sdtr back, hoping for msgout\n", ESPLOG(("esp%d: sending sdtr back, hoping for msgout\n",
...@@ -3786,7 +3811,7 @@ static int check_multibyte_msg(struct esp *esp) ...@@ -3786,7 +3811,7 @@ static int check_multibyte_msg(struct esp *esp)
/* Regardless, next try for sync transfers. */ /* Regardless, next try for sync transfers. */
build_sync_nego_msg(esp, esp->sync_defp, 15); build_sync_nego_msg(esp, esp->sync_defp, 15);
SDptr->sync = 1; espo_dev->sync = 1;
esp->snip = 1; esp->snip = 1;
message_out = EXTENDED_MESSAGE; message_out = EXTENDED_MESSAGE;
} }
...@@ -4051,7 +4076,7 @@ static int esp_do_msgoutdone(struct esp *esp) ...@@ -4051,7 +4076,7 @@ static int esp_do_msgoutdone(struct esp *esp)
/* Happy Meal fifo is touchy... */ /* Happy Meal fifo is touchy... */
if ((esp->erev != fashme) && if ((esp->erev != fashme) &&
!fcount(esp) && !fcount(esp) &&
!(esp->current_SC->device->sync_max_offset)) !(((struct esp_device *)esp->current_SC->device->hostdata)->sync_max_offset))
esp_cmd(esp, ESP_CMD_FLUSH); esp_cmd(esp, ESP_CMD_FLUSH);
break; break;
...@@ -4330,11 +4355,13 @@ static void esp_intr(int irq, void *dev_id, struct pt_regs *pregs) ...@@ -4330,11 +4355,13 @@ static void esp_intr(int irq, void *dev_id, struct pt_regs *pregs)
spin_unlock_irqrestore(esp->ehost->host_lock, flags); spin_unlock_irqrestore(esp->ehost->host_lock, flags);
} }
int esp_revoke(Scsi_Device* SDptr) void esp_slave_detach(Scsi_Device* SDptr)
{ {
struct esp *esp = (struct esp *) SDptr->host->hostdata; struct esp *esp = (struct esp *) SDptr->host->hostdata;
esp->targets_present &= ~(1 << SDptr->id); esp->targets_present &= ~(1 << SDptr->id);
return 0; if (SDptr->hostdata)
kfree(SDptr->hostdata);
SDptr->hostdata = NULL;
} }
static Scsi_Host_Template driver_template = SCSI_SPARC_ESP; static Scsi_Host_Template driver_template = SCSI_SPARC_ESP;
......
...@@ -64,6 +64,17 @@ enum esp_rev { ...@@ -64,6 +64,17 @@ enum esp_rev {
espunknown = 0x07 espunknown = 0x07
}; };
/* We allocate one of these for each scsi device and attach it to
* SDptr->hostdata for use in the driver
*/
struct esp_device {
unsigned char sync_min_period;
unsigned char sync_max_offset;
unsigned sync:1;
unsigned wide:1;
unsigned disconnect:1;
};
/* We get one of these for each ESP probed. */ /* We get one of these for each ESP probed. */
struct esp { struct esp {
unsigned long eregs; /* ESP controller registers */ unsigned long eregs; /* ESP controller registers */
...@@ -399,7 +410,7 @@ extern int esp_abort(Scsi_Cmnd *); ...@@ -399,7 +410,7 @@ extern int esp_abort(Scsi_Cmnd *);
extern int esp_reset(Scsi_Cmnd *, unsigned int); extern int esp_reset(Scsi_Cmnd *, unsigned int);
extern int esp_proc_info(char *buffer, char **start, off_t offset, int length, extern int esp_proc_info(char *buffer, char **start, off_t offset, int length,
int hostno, int inout); int hostno, int inout);
extern int esp_revoke(Scsi_Device* SDptr); extern void esp_slave_detach(Scsi_Device* SDptr);
#ifdef CONFIG_SPARC64 #ifdef CONFIG_SPARC64
#define SCSI_SPARC_ESP { \ #define SCSI_SPARC_ESP { \
...@@ -407,7 +418,7 @@ extern int esp_revoke(Scsi_Device* SDptr); ...@@ -407,7 +418,7 @@ extern int esp_revoke(Scsi_Device* SDptr);
proc_info: &esp_proc_info, \ proc_info: &esp_proc_info, \
name: "Sun ESP 100/100a/200", \ name: "Sun ESP 100/100a/200", \
detect: esp_detect, \ detect: esp_detect, \
revoke: esp_revoke, \ slave_detach: esp_slave_detach, \
info: esp_info, \ info: esp_info, \
command: esp_command, \ command: esp_command, \
queuecommand: esp_queue, \ queuecommand: esp_queue, \
...@@ -427,7 +438,7 @@ extern int esp_revoke(Scsi_Device* SDptr); ...@@ -427,7 +438,7 @@ extern int esp_revoke(Scsi_Device* SDptr);
proc_info: &esp_proc_info, \ proc_info: &esp_proc_info, \
name: "Sun ESP 100/100a/200", \ name: "Sun ESP 100/100a/200", \
detect: esp_detect, \ detect: esp_detect, \
revoke: esp_revoke, \ slave_detach: esp_slave_detach, \
info: esp_info, \ info: esp_info, \
command: esp_command, \ command: esp_command, \
queuecommand: esp_queue, \ queuecommand: esp_queue, \
......
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