X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fscsi%2Fu14-34f.c;h=33cd90fc657b839d0659768e4f013ccb88b9e4f7;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=b2f69d7a82edf7deeea07aef0cbfd49de605ac56;hpb=9bf4aaab3e101692164d49b7ca357651eb691cb6;p=linux-2.6.git diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c index b2f69d7a8..33cd90fc6 100644 --- a/drivers/scsi/u14-34f.c +++ b/drivers/scsi/u14-34f.c @@ -282,7 +282,7 @@ * clustering is enabled. ENABLE_CLUSTERING provides a performance increase * up to 50% on sequential access. * - * Since the Scsi_Host_Template structure is shared among all 14F and 34F, + * Since the struct scsi_host_template structure is shared among all 14F and 34F, * the last setting of use_clustering is in effect for all of these boards. * * Here a sample configuration using two U14F boards: @@ -421,29 +421,31 @@ #include #include #include -#include -#include "scsi.h" -#include #include #include -static int u14_34f_detect(Scsi_Host_Template *); +#include +#include +#include +#include +#include +#include + +static int u14_34f_detect(struct scsi_host_template *); static int u14_34f_release(struct Scsi_Host *); -static int u14_34f_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); -static int u14_34f_eh_abort(Scsi_Cmnd *); -static int u14_34f_eh_host_reset(Scsi_Cmnd *); +static int u14_34f_queuecommand(struct scsi_cmnd *, void (*done)(struct scsi_cmnd *)); +static int u14_34f_eh_abort(struct scsi_cmnd *); +static int u14_34f_eh_host_reset(struct scsi_cmnd *); static int u14_34f_bios_param(struct scsi_device *, struct block_device *, sector_t, int *); -static int u14_34f_slave_configure(Scsi_Device *); +static int u14_34f_slave_configure(struct scsi_device *); -static Scsi_Host_Template driver_template = { +static struct scsi_host_template driver_template = { .name = "UltraStor 14F/34F rev. 8.10.00 ", .detect = u14_34f_detect, .release = u14_34f_release, .queuecommand = u14_34f_queuecommand, .eh_abort_handler = u14_34f_eh_abort, - .eh_device_reset_handler = NULL, - .eh_bus_reset_handler = NULL, .eh_host_reset_handler = u14_34f_eh_host_reset, .bios_param = u14_34f_bios_param, .slave_configure = u14_34f_slave_configure, @@ -575,7 +577,7 @@ struct mscp { unsigned int sense_addr PACKED; /* Additional fields begin here. */ - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; unsigned int cpp_index; /* cp index */ /* All the cp structure is zero filled by queuecommand except the @@ -608,7 +610,7 @@ struct hostdata { static struct Scsi_Host *sh[MAX_BOARDS + 1]; static const char *driver_name = "Ux4F"; static char sha[MAX_BOARDS]; -static spinlock_t driver_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(driver_lock); /* Initialize num_boards so that ihdlr can work while detect is in progress */ static unsigned int num_boards = MAX_BOARDS; @@ -634,7 +636,7 @@ static unsigned long io_port[] = { #define DEV2H(x) le32_to_cpu(x) static irqreturn_t do_interrupt_handler(int, void *, struct pt_regs *); -static void flush_dev(Scsi_Device *, unsigned long, unsigned int, unsigned int); +static void flush_dev(struct scsi_device *, unsigned long, unsigned int, unsigned int); static int do_trace = FALSE; static int setup_done = FALSE; static int link_statistics; @@ -682,7 +684,7 @@ MODULE_DESCRIPTION("UltraStor 14F/34F SCSI Driver"); #endif -static int u14_34f_slave_configure(Scsi_Device *dev) { +static int u14_34f_slave_configure(struct scsi_device *dev) { int j, tqd, utqd; char *tag_suffix, *link_suffix; struct Scsi_Host *host = dev->host; @@ -724,8 +726,7 @@ static int u14_34f_slave_configure(Scsi_Device *dev) { else link_suffix = ""; - printk("%s: scsi%d, channel %d, id %d, lun %d, cmds/lun %d%s%s.\n", - BN(j), host->host_no, dev->channel, dev->id, dev->lun, + sdev_printk(KERN_INFO, dev, "cmds/lun %d%s%s.\n", dev->queue_depth, link_suffix, tag_suffix); return FALSE; @@ -794,7 +795,7 @@ static int board_inquiry(unsigned int j) { } static int port_detect \ - (unsigned long port_base, unsigned int j, Scsi_Host_Template *tpnt) { + (unsigned long port_base, unsigned int j, struct scsi_host_template *tpnt) { unsigned char irq, dma_channel, subversion, i; unsigned char in_byte; char *bus_type, dma_name[16]; @@ -1080,7 +1081,7 @@ static int option_setup(char *str) { return 1; } -static int u14_34f_detect(Scsi_Host_Template *tpnt) { +static int u14_34f_detect(struct scsi_host_template *tpnt) { unsigned int j = 0, k; tpnt->proc_name = "u14-34f"; @@ -1113,10 +1114,10 @@ static void map_dma(unsigned int i, unsigned int j) { unsigned int k, count, pci_dir; struct scatterlist *sgpnt; struct mscp *cpp; - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt; - pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction); + pci_dir = SCpnt->sc_data_direction; if (SCpnt->sense_buffer) cpp->sense_addr = H2DEV(pci_map_single(HD(j)->pdev, SCpnt->sense_buffer, @@ -1156,10 +1157,10 @@ static void map_dma(unsigned int i, unsigned int j) { static void unmap_dma(unsigned int i, unsigned int j) { unsigned int pci_dir; struct mscp *cpp; - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt; - pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction); + pci_dir = SCpnt->sc_data_direction; if (DEV2H(cpp->sense_addr)) pci_unmap_single(HD(j)->pdev, DEV2H(cpp->sense_addr), @@ -1178,10 +1179,10 @@ static void unmap_dma(unsigned int i, unsigned int j) { static void sync_dma(unsigned int i, unsigned int j) { unsigned int pci_dir; struct mscp *cpp; - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt; - pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction); + pci_dir = SCpnt->sc_data_direction; if (DEV2H(cpp->sense_addr)) pci_dma_sync_single_for_cpu(HD(j)->pdev, DEV2H(cpp->sense_addr), @@ -1214,24 +1215,24 @@ static void scsi_to_dev_dir(unsigned int i, unsigned int j) { }; struct mscp *cpp; - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt; - if (SCpnt->sc_data_direction == SCSI_DATA_READ) { + if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) { cpp->xdir = DTD_IN; return; } - else if (SCpnt->sc_data_direction == SCSI_DATA_WRITE) { + else if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) { cpp->xdir = DTD_OUT; return; } - else if (SCpnt->sc_data_direction == SCSI_DATA_NONE) { + else if (SCpnt->sc_data_direction == DMA_NONE) { cpp->xdir = DTD_NONE; return; } - if (SCpnt->sc_data_direction != SCSI_DATA_UNKNOWN) + if (SCpnt->sc_data_direction != DMA_BIDIRECTIONAL) panic("%s: qcomm, invalid SCpnt->sc_data_direction.\n", BN(j)); cpp->xdir = DTD_IN; @@ -1251,7 +1252,7 @@ static void scsi_to_dev_dir(unsigned int i, unsigned int j) { } -static int u14_34f_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { +static int u14_34f_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) { unsigned int i, j, k; struct mscp *cpp; @@ -1317,8 +1318,8 @@ static int u14_34f_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { if (wait_on_busy(sh[j]->io_port, MAXLOOP)) { unmap_dma(i, j); SCpnt->host_scribble = NULL; - printk("%s: qcomm, target %d.%d:%d, pid %ld, adapter busy.\n", - BN(j), SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, SCpnt->pid); + scmd_printk(KERN_INFO, SCpnt, + "qcomm, pid %ld, adapter busy.\n", SCpnt->pid); return 1; } @@ -1332,20 +1333,20 @@ static int u14_34f_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { return 0; } -static int u14_34f_eh_abort(Scsi_Cmnd *SCarg) { +static int u14_34f_eh_abort(struct scsi_cmnd *SCarg) { unsigned int i, j; j = ((struct hostdata *) SCarg->device->host->hostdata)->board_number; if (SCarg->host_scribble == NULL) { - printk("%s: abort, target %d.%d:%d, pid %ld inactive.\n", - BN(j), SCarg->device->channel, SCarg->device->id, SCarg->device->lun, SCarg->pid); + scmd_printk(KERN_INFO, SCarg, "abort, pid %ld inactive.\n", + SCarg->pid); return SUCCESS; } i = *(unsigned int *)SCarg->host_scribble; - printk("%s: abort, mbox %d, target %d.%d:%d, pid %ld.\n", - BN(j), i, SCarg->device->channel, SCarg->device->id, SCarg->device->lun, SCarg->pid); + scmd_printk(KERN_INFO, SCarg, "abort, mbox %d, pid %ld.\n", + i, SCarg->pid); if (i >= sh[j]->can_queue) panic("%s: abort, invalid SCarg->host_scribble.\n", BN(j)); @@ -1370,15 +1371,6 @@ static int u14_34f_eh_abort(Scsi_Cmnd *SCarg) { if (inb(sh[j]->io_port + REG_SYS_INTR) & IRQ_ASSERTED) printk("%s: abort, mbox %d, interrupt pending.\n", BN(j), i); - if (SCarg->eh_state == SCSI_STATE_TIMEOUT) { - unmap_dma(i, j); - SCarg->host_scribble = NULL; - HD(j)->cp_stat[i] = FREE; - printk("%s, abort, mbox %d, eh_state timeout, pid %ld.\n", - BN(j), i, SCarg->pid); - return SUCCESS; - } - return FAILED; } @@ -1406,25 +1398,28 @@ static int u14_34f_eh_abort(Scsi_Cmnd *SCarg) { panic("%s: abort, mbox %d, invalid cp_stat.\n", BN(j), i); } -static int u14_34f_eh_host_reset(Scsi_Cmnd *SCarg) { +static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) { unsigned int i, j, time, k, c, limit = 0; int arg_done = FALSE; - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; j = ((struct hostdata *) SCarg->device->host->hostdata)->board_number; - printk("%s: reset, enter, target %d.%d:%d, pid %ld.\n", - BN(j), SCarg->device->channel, SCarg->device->id, SCarg->device->lun, SCarg->pid); + scmd_printk(KERN_INFO, SCarg, "reset, enter, pid %ld.\n", SCarg->pid); + + spin_lock_irq(sh[j]->host_lock); if (SCarg->host_scribble == NULL) printk("%s: reset, pid %ld inactive.\n", BN(j), SCarg->pid); if (HD(j)->in_reset) { printk("%s: reset, exit, already in reset.\n", BN(j)); + spin_unlock_irq(sh[j]->host_lock); return FAILED; } if (wait_on_busy(sh[j]->io_port, MAXLOOP)) { printk("%s: reset, exit, timeout error.\n", BN(j)); + spin_unlock_irq(sh[j]->host_lock); return FAILED; } @@ -1475,6 +1470,7 @@ static int u14_34f_eh_host_reset(Scsi_Cmnd *SCarg) { if (wait_on_busy(sh[j]->io_port, MAXLOOP)) { printk("%s: reset, cannot reset, timeout error.\n", BN(j)); + spin_unlock_irq(sh[j]->host_lock); return FAILED; } @@ -1536,6 +1532,7 @@ static int u14_34f_eh_host_reset(Scsi_Cmnd *SCarg) { if (arg_done) printk("%s: reset, exit, pid %ld done.\n", BN(j), SCarg->pid); else printk("%s: reset, exit.\n", BN(j)); + spin_unlock_irq(sh[j]->host_lock); return SUCCESS; } @@ -1589,7 +1586,7 @@ static void sort(unsigned long sk[], unsigned int da[], unsigned int n, static int reorder(unsigned int j, unsigned long cursec, unsigned int ihdlr, unsigned int il[], unsigned int n_ready) { - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; struct mscp *cpp; unsigned int k, n; unsigned int rev = FALSE, s = TRUE, r = TRUE; @@ -1685,9 +1682,9 @@ static int reorder(unsigned int j, unsigned long cursec, return overlap; } -static void flush_dev(Scsi_Device *dev, unsigned long cursec, unsigned int j, +static void flush_dev(struct scsi_device *dev, unsigned long cursec, unsigned int j, unsigned int ihdlr) { - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; struct mscp *cpp; unsigned int k, n, n_ready = 0, il[MAX_MAILBOXES]; @@ -1710,9 +1707,10 @@ static void flush_dev(Scsi_Device *dev, unsigned long cursec, unsigned int j, k = il[n]; cpp = &HD(j)->cp[k]; SCpnt = cpp->SCpnt; if (wait_on_busy(sh[j]->io_port, MAXLOOP)) { - printk("%s: %s, target %d.%d:%d, pid %ld, mbox %d, adapter"\ - " busy, will abort.\n", BN(j), (ihdlr ? "ihdlr" : "qcomm"), - SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, SCpnt->pid, k); + scmd_printk(KERN_INFO, SCpnt, + "%s, pid %ld, mbox %d, adapter" + " busy, will abort.\n", (ihdlr ? "ihdlr" : "qcomm"), + SCpnt->pid, k); HD(j)->cp_stat[k] = ABORTING; continue; } @@ -1725,7 +1723,7 @@ static void flush_dev(Scsi_Device *dev, unsigned long cursec, unsigned int j, } static irqreturn_t ihdlr(int irq, unsigned int j) { - Scsi_Cmnd *SCpnt; + struct scsi_cmnd *SCpnt; unsigned int i, k, c, status, tstatus, reg, ret; struct mscp *spp, *cpp; @@ -1824,7 +1822,7 @@ static irqreturn_t ihdlr(int irq, unsigned int j) { /* If there was a bus reset, redo operation on each target */ else if (tstatus != GOOD && SCpnt->device->type == TYPE_DISK - && HD(j)->target_redo[SCpnt->device->id][SCpnt->device->channel]) + && HD(j)->target_redo[scmd_id(SCpnt)][scmd_channel(SCpnt)]) status = DID_BUS_BUSY << 16; /* Works around a flaw in scsi.c */ @@ -1837,29 +1835,28 @@ static irqreturn_t ihdlr(int irq, unsigned int j) { status = DID_OK << 16; if (tstatus == GOOD) - HD(j)->target_redo[SCpnt->device->id][SCpnt->device->channel] = FALSE; + HD(j)->target_redo[scmd_id(SCpnt)][scmd_channel(SCpnt)] = FALSE; if (spp->target_status && SCpnt->device->type == TYPE_DISK && (!(tstatus == CHECK_CONDITION && HD(j)->iocount <= 1000 && (SCpnt->sense_buffer[2] & 0xf) == NOT_READY))) - printk("%s: ihdlr, target %d.%d:%d, pid %ld, "\ - "target_status 0x%x, sense key 0x%x.\n", BN(j), - SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, + scmd_printk(KERN_INFO, SCpnt, + "ihdlr, pid %ld, target_status 0x%x, sense key 0x%x.\n", SCpnt->pid, spp->target_status, SCpnt->sense_buffer[2]); - HD(j)->target_to[SCpnt->device->id][SCpnt->device->channel] = 0; + HD(j)->target_to[scmd_id(SCpnt)][scmd_channel(SCpnt)] = 0; if (HD(j)->last_retried_pid == SCpnt->pid) HD(j)->retries = 0; break; case ASST: /* Selection Time Out */ - if (HD(j)->target_to[SCpnt->device->id][SCpnt->device->channel] > 1) + if (HD(j)->target_to[scmd_id(SCpnt)][scmd_channel(SCpnt)] > 1) status = DID_ERROR << 16; else { status = DID_TIME_OUT << 16; - HD(j)->target_to[SCpnt->device->id][SCpnt->device->channel]++; + HD(j)->target_to[scmd_id(SCpnt)][scmd_channel(SCpnt)]++; } break; @@ -1915,10 +1912,9 @@ static irqreturn_t ihdlr(int irq, unsigned int j) { spp->adapter_status != ASST && HD(j)->iocount <= 1000) || do_trace || msg_byte(spp->target_status)) #endif - printk("%s: ihdlr, mbox %2d, err 0x%x:%x,"\ - " target %d.%d:%d, pid %ld, reg 0x%x, count %d.\n", - BN(j), i, spp->adapter_status, spp->target_status, - SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, SCpnt->pid, + scmd_printk(KERN_INFO, SCpnt, "ihdlr, mbox %2d, err 0x%x:%x,"\ + " pid %ld, reg 0x%x, count %d.\n", + i, spp->adapter_status, spp->target_status, SCpnt->pid, reg, HD(j)->iocount); unmap_dma(i, j); @@ -1957,11 +1953,11 @@ static int u14_34f_release(struct Scsi_Host *shpnt) { for (j = 0; sh[j] != NULL && sh[j] != shpnt; j++); - if (sh[j] == NULL) panic("%s: release, invalid Scsi_Host pointer.\n", - driver_name); + if (sh[j] == NULL) + panic("%s: release, invalid Scsi_Host pointer.\n", driver_name); for (i = 0; i < sh[j]->can_queue; i++) - if ((&HD(j)->cp[i])->sglist) kfree((&HD(j)->cp[i])->sglist); + kfree((&HD(j)->cp[i])->sglist); for (i = 0; i < sh[j]->can_queue; i++) pci_unmap_single(HD(j)->pdev, HD(j)->cp[i].cp_dma_addr, @@ -1969,7 +1965,8 @@ static int u14_34f_release(struct Scsi_Host *shpnt) { free_irq(sh[j]->irq, &sha[j]); - if (sh[j]->dma_channel != NO_DMA) free_dma(sh[j]->dma_channel); + if (sh[j]->dma_channel != NO_DMA) + free_dma(sh[j]->dma_channel); release_region(sh[j]->io_port, sh[j]->n_io_port); scsi_unregister(sh[j]);