From 1ecd3902c6e16c2445165b872c49e73770b72da7 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Mon, 15 Oct 2007 23:05:07 -0600 Subject: [SCSI] fc4: remove this and all associated drivers This code has been slowly rotting for about eight years. It's currently impeding a few SCSI cleanups, and nobody seems to have hardware to test it any more. I talked to Dave Miller about it, and he agrees we can delete it. If anyone wants a software FC stack in future, they can retrieve this driver from git. Signed-off-by: Matthew Wilcox Acked-by: David S. Miller Signed-off-by: James Bottomley --- drivers/scsi/Makefile | 2 - drivers/scsi/fcal.c | 317 --------------------------------------------- drivers/scsi/fcal.h | 27 ---- drivers/scsi/pluto.c | 349 -------------------------------------------------- drivers/scsi/pluto.h | 47 ------- 5 files changed, 742 deletions(-) delete mode 100644 drivers/scsi/fcal.c delete mode 100644 drivers/scsi/fcal.h delete mode 100644 drivers/scsi/pluto.c delete mode 100644 drivers/scsi/pluto.h (limited to 'drivers/scsi') diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 6141389dcdb2..2e6129f13d38 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -115,7 +115,6 @@ obj-$(CONFIG_SCSI_QLOGICPTI) += qlogicpti.o obj-$(CONFIG_BLK_DEV_IDESCSI) += ide-scsi.o obj-$(CONFIG_SCSI_MESH) += mesh.o obj-$(CONFIG_SCSI_MAC53C94) += mac53c94.o -obj-$(CONFIG_SCSI_PLUTO) += pluto.o obj-$(CONFIG_SCSI_DECNCR) += NCR53C9x.o dec_esp.o obj-$(CONFIG_BLK_DEV_3W_XXXX_RAID) += 3w-xxxx.o obj-$(CONFIG_SCSI_3W_9XXX) += 3w-9xxx.o @@ -123,7 +122,6 @@ obj-$(CONFIG_SCSI_PPA) += ppa.o obj-$(CONFIG_SCSI_IMM) += imm.o obj-$(CONFIG_JAZZ_ESP) += esp_scsi.o jazz_esp.o obj-$(CONFIG_SUN3X_ESP) += NCR53C9x.o sun3x_esp.o -obj-$(CONFIG_SCSI_FCAL) += fcal.o obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o obj-$(CONFIG_SCSI_SNI_53C710) += 53c700.o sni_53c710.o obj-$(CONFIG_SCSI_NSP32) += nsp32.o diff --git a/drivers/scsi/fcal.c b/drivers/scsi/fcal.c deleted file mode 100644 index c4e16c0775de..000000000000 --- a/drivers/scsi/fcal.c +++ /dev/null @@ -1,317 +0,0 @@ -/* fcal.c: Fibre Channel Arbitrated Loop SCSI host adapter driver. - * - * Copyright (C) 1998,1999 Jakub Jelinek (jj@ultra.linux.cz) - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_KMOD -#include -#endif - -#include - -#include "scsi.h" -#include -#include "../fc4/fcp_impl.h" -#include "fcal.h" - -#include - -/* #define FCAL_DEBUG */ - -#define fcal_printk printk ("FCAL %s: ", fc->name); printk - -#ifdef FCAL_DEBUG -#define FCALD(x) fcal_printk x; -#define FCALND(x) printk ("FCAL: "); printk x; -#else -#define FCALD(x) -#define FCALND(x) -#endif - -static unsigned char alpa2target[] = { -0x7e, 0x7d, 0x7c, 0xff, 0x7b, 0xff, 0xff, 0xff, 0x7a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x79, -0x78, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x77, 0x76, 0xff, 0xff, 0x75, 0xff, 0x74, 0x73, 0x72, -0xff, 0xff, 0xff, 0x71, 0xff, 0x70, 0x6f, 0x6e, 0xff, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0xff, -0xff, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0xff, 0xff, 0x61, 0x60, 0xff, 0x5f, 0xff, 0xff, 0xff, -0xff, 0xff, 0xff, 0x5e, 0xff, 0x5d, 0x5c, 0x5b, 0xff, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0xff, -0xff, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0xff, 0xff, 0x4e, 0x4d, 0xff, 0x4c, 0xff, 0xff, 0xff, -0xff, 0xff, 0xff, 0x4b, 0xff, 0x4a, 0x49, 0x48, 0xff, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0xff, -0xff, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0xff, 0xff, 0x3b, 0x3a, 0xff, 0x39, 0xff, 0xff, 0xff, -0x38, 0x37, 0x36, 0xff, 0x35, 0xff, 0xff, 0xff, 0x34, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, -0x32, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x31, 0x30, 0xff, 0xff, 0x2f, 0xff, 0x2e, 0x2d, 0x2c, -0xff, 0xff, 0xff, 0x2b, 0xff, 0x2a, 0x29, 0x28, 0xff, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0xff, -0xff, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0xff, 0xff, 0x1b, 0x1a, 0xff, 0x19, 0xff, 0xff, 0xff, -0xff, 0xff, 0xff, 0x18, 0xff, 0x17, 0x16, 0x15, 0xff, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0xff, -0xff, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0xff, 0xff, 0x08, 0x07, 0xff, 0x06, 0xff, 0xff, 0xff, -0x05, 0x04, 0x03, 0xff, 0x02, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 -}; - -static unsigned char target2alpa[] = { -0xef, 0xe8, 0xe4, 0xe2, 0xe1, 0xe0, 0xdc, 0xda, 0xd9, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xce, -0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7, 0xc6, 0xc5, 0xc3, 0xbc, 0xba, 0xb9, 0xb6, 0xb5, 0xb4, 0xb3, -0xb2, 0xb1, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa7, 0xa6, 0xa5, 0xa3, 0x9f, 0x9e, 0x9d, 0x9b, -0x98, 0x97, 0x90, 0x8f, 0x88, 0x84, 0x82, 0x81, 0x80, 0x7c, 0x7a, 0x79, 0x76, 0x75, 0x74, 0x73, -0x72, 0x71, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x67, 0x66, 0x65, 0x63, 0x5c, 0x5a, 0x59, 0x56, -0x55, 0x54, 0x53, 0x52, 0x51, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x47, 0x46, 0x45, 0x43, 0x3c, -0x3a, 0x39, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x27, 0x26, -0x25, 0x23, 0x1f, 0x1e, 0x1d, 0x1b, 0x18, 0x17, 0x10, 0x0f, 0x08, 0x04, 0x02, 0x01, 0x00 -}; - -static int fcal_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd); - -int fcal_slave_configure(struct scsi_device *device) -{ - int depth_to_use; - - if (device->tagged_supported) - depth_to_use = /* 254 */ 8; - else - depth_to_use = 2; - - scsi_adjust_queue_depth(device, - (device->tagged_supported ? - MSG_SIMPLE_TAG : 0), - depth_to_use); - - return 0; -} - -/* Detect all FC Arbitrated Loops attached to the machine. - fc4 module has done all the work for us... */ -int __init fcal_detect(struct scsi_host_template *tpnt) -{ - int nfcals = 0; - fc_channel *fc; - int fcalcount; - int i; - - tpnt->proc_name = "fcal"; - fcalcount = 0; - for_each_online_fc_channel(fc) - if (fc->posmap) - fcalcount++; - FCALND(("%d channels online\n", fcalcount)) - if (!fcalcount) { -#if defined(MODULE) && defined(CONFIG_FC4_SOCAL_MODULE) && defined(CONFIG_KMOD) - request_module("socal"); - - for_each_online_fc_channel(fc) - if (fc->posmap) - fcalcount++; - if (!fcalcount) -#endif - return 0; - } - for_each_online_fc_channel(fc) { - struct Scsi_Host *host; - long *ages; - struct fcal *fcal; - - if (!fc->posmap) continue; - - /* Strange, this is already registered to some other SCSI host, then it cannot be fcal */ - if (fc->scsi_name[0]) continue; - memcpy (fc->scsi_name, "FCAL", 4); - - fc->can_queue = FCAL_CAN_QUEUE; - fc->rsp_size = 64; - fc->encode_addr = fcal_encode_addr; - - ages = kmalloc (128 * sizeof(long), GFP_KERNEL); - if (!ages) continue; - - host = scsi_register (tpnt, sizeof (struct fcal)); - if (!host) - { - kfree(ages); - continue; - } - - if (!try_module_get(fc->module)) { - kfree(ages); - scsi_unregister(host); - continue; - } - - nfcals++; - - fcal = (struct fcal *)host->hostdata; - - fc->fcp_register(fc, TYPE_SCSI_FCP, 0); - - for (i = 0; i < fc->posmap->len; i++) { - int status, target, alpa; - - alpa = fc->posmap->list[i]; - FCALD(("Sending PLOGI to %02x\n", alpa)) - target = alpa2target[alpa]; - status = fc_do_plogi(fc, alpa, fcal->node_wwn + target, - fcal->nport_wwn + target); - FCALD(("PLOGI returned with status %d\n", status)) - if (status != FC_STATUS_OK) - continue; - FCALD(("Sending PRLI to %02x\n", alpa)) - status = fc_do_prli(fc, alpa); - FCALD(("PRLI returned with status %d\n", status)) - if (status == FC_STATUS_OK) - fcal->map[target] = 1; - } - - host->max_id = 127; - host->irq = fc->irq; -#ifdef __sparc_v9__ - host->unchecked_isa_dma = 1; -#endif - - fc->channels = 1; - fc->targets = 127; - fc->ages = ages; - memset (ages, 0, 128 * sizeof(long)); - - fcal->fc = fc; - - FCALD(("Found FCAL\n")) - } - if (nfcals) -#ifdef __sparc__ - printk ("FCAL: Total of %d Sun Enterprise Network Array (A5000 or EX500) channels found\n", nfcals); -#else - printk ("FCAL: Total of %d Fibre Channel Arbitrated Loops found\n", nfcals); -#endif - return nfcals; -} - -int fcal_release(struct Scsi_Host *host) -{ - struct fcal *fcal = (struct fcal *)host->hostdata; - fc_channel *fc = fcal->fc; - - module_put(fc->module); - - fc->fcp_register(fc, TYPE_SCSI_FCP, 1); - FCALND((" releasing fcal.\n")); - kfree (fc->ages); - FCALND(("released fcal!\n")); - return 0; -} - -#undef SPRINTF -#define SPRINTF(args...) { if (pos < (buffer + length)) pos += sprintf (pos, ## args); } - -int fcal_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout) -{ - struct fcal *fcal; - fc_channel *fc; - char *pos = buffer; - int i, j; - - if (inout) return length; - - fcal = (struct fcal *)host->hostdata; - fc = fcal->fc; - -#ifdef __sparc__ - SPRINTF ("Sun Enterprise Network Array (A5000 or E?500) on %s PROM node %x\n", fc->name, fc->dev->prom_node); -#else - SPRINTF ("Fibre Channel Arbitrated Loop on %s\n", fc->name); -#endif - SPRINTF ("Initiator AL-PA: %02x\n", fc->sid); - - SPRINTF ("\nAttached devices:\n"); - - for (i = 0; i < fc->posmap->len; i++) { - unsigned char alpa = fc->posmap->list[i]; - unsigned char target; - u32 *u1, *u2; - - target = alpa2target[alpa]; - u1 = (u32 *)&fcal->nport_wwn[target]; - u2 = (u32 *)&fcal->node_wwn[target]; - if (!u1[0] && !u1[1]) { - SPRINTF (" [AL-PA: %02x] Not responded to PLOGI\n", alpa); - } else if (!fcal->map[target]) { - SPRINTF (" [AL-PA: %02x, Port WWN: %08x%08x, Node WWN: %08x%08x] Not responded to PRLI\n", - alpa, u1[0], u1[1], u2[0], u2[1]); - } else { - struct scsi_device *scd; - shost_for_each_device(scd, host) - if (scd->id == target) { - SPRINTF (" [AL-PA: %02x, Id: %02d, Port WWN: %08x%08x, Node WWN: %08x%08x] ", - alpa, target, u1[0], u1[1], u2[0], u2[1]); - SPRINTF ("%s ", scsi_device_type(scd->type)); - - for (j = 0; (j < 8) && (scd->vendor[j] >= 0x20); j++) - SPRINTF ("%c", scd->vendor[j]); - SPRINTF (" "); - - for (j = 0; (j < 16) && (scd->model[j] >= 0x20); j++) - SPRINTF ("%c", scd->model[j]); - - SPRINTF ("\n"); - } - } - } - SPRINTF ("\n"); - - *start = buffer + offset; - - if ((pos - buffer) < offset) - return 0; - else if (pos - buffer - offset < length) - return pos - buffer - offset; - else - return length; -} - -/* - For FC-AL, we use a simple addressing: we have just one channel 0, - and all AL-PAs are mapped to targets 0..0x7e - */ -static int fcal_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd) -{ - struct fcal *f; - - /* We don't support LUNs yet - I'm not sure if LUN should be in SCSI fcp_cdb, or in second byte of addr[0] */ - if (SCpnt->cmnd[1] & 0xe0) return -EINVAL; - /* FC-PLDA tells us... */ - memset(addr, 0, 8); - f = (struct fcal *)SCpnt->device->host->hostdata; - if (!f->map[SCpnt->device->id]) - return -EINVAL; - /* Now, determine DID: It will be Native Identifier, so we zero upper - 2 bytes of the 3 byte DID, lowest byte will be AL-PA */ - fcmd->did = target2alpa[SCpnt->device->id]; - FCALD(("trying DID %06x\n", fcmd->did)) - return 0; -} - -static struct scsi_host_template driver_template = { - .name = "Fibre Channel Arbitrated Loop", - .detect = fcal_detect, - .release = fcal_release, - .proc_info = fcal_proc_info, - .queuecommand = fcp_scsi_queuecommand, - .slave_configure = fcal_slave_configure, - .can_queue = FCAL_CAN_QUEUE, - .this_id = -1, - .sg_tablesize = 1, - .cmd_per_lun = 1, - .use_clustering = ENABLE_CLUSTERING, - .eh_abort_handler = fcp_scsi_abort, - .eh_device_reset_handler = fcp_scsi_dev_reset, - .eh_host_reset_handler = fcp_scsi_host_reset, -}; -#include "scsi_module.c" - -MODULE_LICENSE("GPL"); - diff --git a/drivers/scsi/fcal.h b/drivers/scsi/fcal.h deleted file mode 100644 index 7ff2c3494f9e..000000000000 --- a/drivers/scsi/fcal.h +++ /dev/null @@ -1,27 +0,0 @@ -/* fcal.h: Generic Fibre Channel Arbitrated Loop SCSI host adapter driver definitions. - * - * Copyright (C) 1998,1999 Jakub Jelinek (jj@ultra.linux.cz) - */ - -#ifndef _FCAL_H -#define _FCAL_H - -#include "../fc4/fcp_impl.h" - -struct fcal { - /* fc must be first */ - fc_channel *fc; - unsigned char map[128]; - fc_wwn nport_wwn[128]; - fc_wwn node_wwn[128]; -}; - -/* Arbitrary constant. Cannot be too large, as fc4 layer has limitations - for a particular channel */ -#define FCAL_CAN_QUEUE 512 - -int fcal_detect(struct scsi_host_template *); -int fcal_release(struct Scsi_Host *); -int fcal_slave_configure(struct scsi_device *); - -#endif /* !(_FCAL_H) */ diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c deleted file mode 100644 index 0363c1cd68c1..000000000000 --- a/drivers/scsi/pluto.c +++ /dev/null @@ -1,349 +0,0 @@ -/* pluto.c: SparcSTORAGE Array SCSI host adapter driver. - * - * Copyright (C) 1997,1998,1999 Jakub Jelinek (jj@sunsite.mff.cuni.cz) - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_KMOD -#include -#endif - -#include - -#include "scsi.h" -#include -#include "../fc4/fcp_impl.h" -#include "pluto.h" - -#include - -#define RQ_SCSI_BUSY 0xffff -#define RQ_SCSI_DONE 0xfffe - -/* #define PLUTO_DEBUG */ - -#define pluto_printk printk ("PLUTO %s: ", fc->name); printk - -#ifdef PLUTO_DEBUG -#define PLD(x) pluto_printk x; -#define PLND(x) printk ("PLUTO: "); printk x; -#else -#define PLD(x) -#define PLND(x) -#endif - -static struct ctrl_inquiry { - struct Scsi_Host host; - struct pluto pluto; - Scsi_Cmnd cmd; - char inquiry[256]; - fc_channel *fc; -} *fcs __initdata; -static int fcscount __initdata = 0; -static atomic_t fcss __initdata = ATOMIC_INIT(0); -static DECLARE_COMPLETION(fc_detect_complete); - -static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd); - -static void __init pluto_detect_done(Scsi_Cmnd *SCpnt) -{ - /* Do nothing */ -} - -static void __init pluto_detect_scsi_done(Scsi_Cmnd *SCpnt) -{ - PLND(("Detect done %08lx\n", (long)SCpnt)) - if (atomic_dec_and_test (&fcss)) - complete(&fc_detect_complete); -} - -int pluto_slave_configure(struct scsi_device *device) -{ - int depth_to_use; - - if (device->tagged_supported) - depth_to_use = /* 254 */ 8; - else - depth_to_use = 2; - - scsi_adjust_queue_depth(device, - (device->tagged_supported ? - MSG_SIMPLE_TAG : 0), - depth_to_use); - - return 0; -} - -/* Detect all SSAs attached to the machine. - To be fast, do it on all online FC channels at the same time. */ -int __init pluto_detect(struct scsi_host_template *tpnt) -{ - int i, retry, nplutos; - fc_channel *fc; - struct scsi_device dev; - - tpnt->proc_name = "pluto"; - fcscount = 0; - for_each_online_fc_channel(fc) { - if (!fc->posmap) - fcscount++; - } - PLND(("%d channels online\n", fcscount)) - if (!fcscount) { -#if defined(MODULE) && defined(CONFIG_FC4_SOC_MODULE) && defined(CONFIG_KMOD) - request_module("soc"); - - for_each_online_fc_channel(fc) { - if (!fc->posmap) - fcscount++; - } - if (!fcscount) -#endif - return 0; - } - fcs = kcalloc(fcscount, sizeof (struct ctrl_inquiry), GFP_DMA); - if (!fcs) { - printk ("PLUTO: Not enough memory to probe\n"); - return 0; - } - - memset (&dev, 0, sizeof(dev)); - atomic_set (&fcss, fcscount); - - i = 0; - for_each_online_fc_channel(fc) { - Scsi_Cmnd *SCpnt; - struct Scsi_Host *host; - struct pluto *pluto; - - if (i == fcscount) break; - if (fc->posmap) continue; - - PLD(("trying to find SSA\n")) - - /* If this is already registered to some other SCSI host, then it cannot be pluto */ - if (fc->scsi_name[0]) continue; - memcpy (fc->scsi_name, "SSA", 4); - - fcs[i].fc = fc; - - fc->can_queue = PLUTO_CAN_QUEUE; - fc->rsp_size = 64; - fc->encode_addr = pluto_encode_addr; - - fc->fcp_register(fc, TYPE_SCSI_FCP, 0); - - SCpnt = &(fcs[i].cmd); - host = &(fcs[i].host); - pluto = (struct pluto *)host->hostdata; - - pluto->fc = fc; - - SCpnt->cmnd[0] = INQUIRY; - SCpnt->cmnd[4] = 255; - - /* FC layer requires this, so that SCpnt->device->tagged_supported is initially 0 */ - SCpnt->device = &dev; - dev.host = host; - - SCpnt->cmd_len = COMMAND_SIZE(INQUIRY); - - SCpnt->request->cmd_flags &= ~REQ_STARTED; - - SCpnt->request_bufflen = 256; - SCpnt->request_buffer = fcs[i].inquiry; - PLD(("set up %d %08lx\n", i, (long)SCpnt)) - i++; - } - - for (retry = 0; retry < 5; retry++) { - for (i = 0; i < fcscount; i++) { - if (!fcs[i].fc) break; - if (!(fcs[i].cmd.request->cmd_flags & REQ_STARTED)) { - fcs[i].cmd.request->cmd_flags |= REQ_STARTED; - disable_irq(fcs[i].fc->irq); - PLND(("queuecommand %d %d\n", retry, i)) - fcp_scsi_queuecommand (&(fcs[i].cmd), - pluto_detect_scsi_done); - enable_irq(fcs[i].fc->irq); - } - } - - wait_for_completion_timeout(&fc_detect_complete, 10 * HZ); - PLND(("Woken up\n")) - if (!atomic_read(&fcss)) - break; /* All fc channels have answered us */ - } - - PLND(("Finished search\n")) - for (i = 0, nplutos = 0; i < fcscount; i++) { - Scsi_Cmnd *SCpnt; - - if (!(fc = fcs[i].fc)) break; - - SCpnt = &(fcs[i].cmd); - - /* Let FC mid-level free allocated resources */ - pluto_detect_scsi_done(SCpnt); - - if (!SCpnt->result) { - struct pluto_inquiry *inq; - struct pluto *pluto; - struct Scsi_Host *host; - - inq = (struct pluto_inquiry *)fcs[i].inquiry; - - if ((inq->dtype & 0x1f) == TYPE_PROCESSOR && - !strncmp (inq->vendor_id, "SUN", 3) && - !strncmp (inq->product_id, "SSA", 3)) { - char *p; - long *ages; - - ages = kcalloc((inq->channels + 1) * inq->targets, sizeof(long), GFP_KERNEL); - if (!ages) continue; - - host = scsi_register (tpnt, sizeof (struct pluto)); - if(!host) - { - kfree(ages); - continue; - } - - if (!try_module_get(fc->module)) { - kfree(ages); - scsi_unregister(host); - continue; - } - - nplutos++; - - pluto = (struct pluto *)host->hostdata; - - host->max_id = inq->targets; - host->max_channel = inq->channels; - host->irq = fc->irq; - - fc->channels = inq->channels + 1; - fc->targets = inq->targets; - fc->ages = ages; - - pluto->fc = fc; - memcpy (pluto->rev_str, inq->revision, 4); - pluto->rev_str[4] = 0; - p = strchr (pluto->rev_str, ' '); - if (p) *p = 0; - memcpy (pluto->fw_rev_str, inq->fw_revision, 4); - pluto->fw_rev_str[4] = 0; - p = strchr (pluto->fw_rev_str, ' '); - if (p) *p = 0; - memcpy (pluto->serial_str, inq->serial, 12); - pluto->serial_str[12] = 0; - p = strchr (pluto->serial_str, ' '); - if (p) *p = 0; - - PLD(("Found SSA rev %s fw rev %s serial %s %dx%d\n", pluto->rev_str, pluto->fw_rev_str, pluto->serial_str, host->max_channel, host->max_id)) - } else - fc->fcp_register(fc, TYPE_SCSI_FCP, 1); - } else - fc->fcp_register(fc, TYPE_SCSI_FCP, 1); - } - kfree(fcs); - if (nplutos) - printk ("PLUTO: Total of %d SparcSTORAGE Arrays found\n", nplutos); - return nplutos; -} - -int pluto_release(struct Scsi_Host *host) -{ - struct pluto *pluto = (struct pluto *)host->hostdata; - fc_channel *fc = pluto->fc; - - module_put(fc->module); - - fc->fcp_register(fc, TYPE_SCSI_FCP, 1); - PLND((" releasing pluto.\n")); - kfree (fc->ages); - PLND(("released pluto!\n")); - return 0; -} - -const char *pluto_info(struct Scsi_Host *host) -{ - static char buf[128], *p; - struct pluto *pluto = (struct pluto *) host->hostdata; - - sprintf(buf, "SUN SparcSTORAGE Array %s fw %s serial %s %dx%d on %s", - pluto->rev_str, pluto->fw_rev_str, pluto->serial_str, - host->max_channel, host->max_id, pluto->fc->name); -#ifdef __sparc__ - p = strchr(buf, 0); - sprintf(p, " PROM node %x", pluto->fc->dev->prom_node); -#endif - return buf; -} - -/* SSA uses this FC4S addressing: - switch (addr[0]) - { - case 0: CONTROLLER - All of addr[1]..addr[3] has to be 0 - case 1: SINGLE DISK - addr[1] channel, addr[2] id, addr[3] 0 - case 2: DISK GROUP - ??? - } - - So that SCSI mid-layer can access to these, we reserve - channel 0 id 0 lun 0 for CONTROLLER - and channels 1 .. max_channel are normal single disks. - */ -static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd) -{ - PLND(("encode addr %d %d %d\n", SCpnt->device->channel, SCpnt->device->id, SCpnt->cmnd[1] & 0xe0)) - /* We don't support LUNs - neither does SSA :) */ - if (SCpnt->cmnd[1] & 0xe0) - return -EINVAL; - if (!SCpnt->device->channel) { - if (SCpnt->device->id) - return -EINVAL; - memset (addr, 0, 4 * sizeof(u16)); - } else { - addr[0] = 1; - addr[1] = SCpnt->device->channel - 1; - addr[2] = SCpnt->device->id; - addr[3] = 0; - } - /* We're Point-to-Point, so target it to the default DID */ - fcmd->did = fc->did; - PLND(("trying %04x%04x%04x%04x\n", addr[0], addr[1], addr[2], addr[3])) - return 0; -} - -static struct scsi_host_template driver_template = { - .name = "Sparc Storage Array 100/200", - .detect = pluto_detect, - .release = pluto_release, - .info = pluto_info, - .queuecommand = fcp_scsi_queuecommand, - .slave_configure = pluto_slave_configure, - .can_queue = PLUTO_CAN_QUEUE, - .this_id = -1, - .sg_tablesize = 1, - .cmd_per_lun = 1, - .use_clustering = ENABLE_CLUSTERING, - .eh_abort_handler = fcp_scsi_abort, - .eh_device_reset_handler = fcp_scsi_dev_reset, - .eh_host_reset_handler = fcp_scsi_host_reset, -}; - -#include "scsi_module.c" - -MODULE_LICENSE("GPL"); - diff --git a/drivers/scsi/pluto.h b/drivers/scsi/pluto.h deleted file mode 100644 index 5da20616ac36..000000000000 --- a/drivers/scsi/pluto.h +++ /dev/null @@ -1,47 +0,0 @@ -/* pluto.h: SparcSTORAGE Array SCSI host adapter driver definitions. - * - * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) - */ - -#ifndef _PLUTO_H -#define _PLUTO_H - -#include "../fc4/fcp_impl.h" - -struct pluto { - /* This must be first */ - fc_channel *fc; - char rev_str[5]; - char fw_rev_str[5]; - char serial_str[13]; -}; - -struct pluto_inquiry { - u8 dtype; - u8 removable:1, qualifier:7; - u8 iso:2, ecma:3, ansi:3; - u8 aenc:1, trmiop:1, :2, rdf:4; - u8 len; - u8 xxx1; - u8 xxx2; - u8 reladdr:1, wbus32:1, wbus16:1, sync:1, linked:1, :1, cmdque:1, softreset:1; - u8 vendor_id[8]; - u8 product_id[16]; - u8 revision[4]; - u8 fw_revision[4]; - u8 serial[12]; - u8 xxx3[2]; - u8 channels; - u8 targets; -}; - -/* This is the max number of outstanding SCSI commands per pluto */ -#define PLUTO_CAN_QUEUE 254 - -int pluto_detect(struct scsi_host_template *); -int pluto_release(struct Scsi_Host *); -const char * pluto_info(struct Scsi_Host *); -int pluto_slave_configure(struct scsi_device *); - -#endif /* !(_PLUTO_H) */ - -- cgit v1.2.3 From 645a0c6c48e0122f4212e3957e73bddc18788d99 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 15 Oct 2007 21:07:17 -0400 Subject: [SCSI] include linux/scatterlist.h in scsi_eh.h Spotted by Paul Jackson The error handler rework moved the scatterlist into a globally exposed structure in scsi_eh.h; unfortunately, the scatterlist include needs to move from scsi_error.c to scsi_eh.h to allow this to compile universally. Acked-by: Paul Jackson Signed-off-by: James Bottomley --- drivers/scsi/scsi_error.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index d29f8464b74f..ebaca4ca4a13 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 7a39ac3f25bef018862a991d754aff681c019127 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 25 Sep 2007 22:45:53 -0500 Subject: [SCSI] make supported_mode default to initiator. if shost->supported mode is zero (i.e. MODE_UNKNOWN) show it as initiator (it's obviously an unconverted driver that won't do target). Acked-by: FUJITA Tomonori Signed-off-by: James Bottomley --- drivers/scsi/hosts.c | 6 ++++++ drivers/scsi/scsi_sysfs.c | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 112ab6abe62b..24271a871b8c 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -345,6 +345,12 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->active_mode = sht->supported_mode; shost->use_sg_chaining = sht->use_sg_chaining; + if (sht->supported_mode == MODE_UNKNOWN) + /* means we didn't set it ... default to INITIATOR */ + shost->active_mode = MODE_INITIATOR; + else + shost->active_mode = sht->supported_mode; + if (sht->max_host_blocked) shost->max_host_blocked = sht->max_host_blocked; else diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index daed37df00b1..d531ceeb0d8c 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -209,11 +209,13 @@ show_shost_mode(unsigned int mode, char *buf) static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *buf) { struct Scsi_Host *shost = class_to_shost(class_dev); + unsigned int supported_mode = shost->hostt->supported_mode; - if (shost->hostt->supported_mode == MODE_UNKNOWN) - return snprintf(buf, 20, "unknown\n"); - else - return show_shost_mode(shost->hostt->supported_mode, buf); + if (supported_mode == MODE_UNKNOWN) + /* by default this should be initiator */ + supported_mode = MODE_INITIATOR; + + return show_shost_mode(supported_mode, buf); } static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); -- cgit v1.2.3 From 0fec02c93f60fb44ba3a24a0d3e4a52521d34d3f Mon Sep 17 00:00:00 2001 From: HighPoint Linux Team Date: Mon, 15 Oct 2007 14:42:52 +0800 Subject: [SCSI] hptiop: avoid buffer overflow when returning sense data The newer firmware may return more than 96 bytes of sense data when it does autosense. Truncate this to the size of the SCSI layer sense buffer to avoid an overrun. Signed-off-by: HighPoint Linux Team Signed-off-by: James Bottomley --- drivers/scsi/hptiop.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index 8515054cdf70..0844331abb87 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c @@ -375,8 +375,9 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag) scp->result = SAM_STAT_CHECK_CONDITION; memset(&scp->sense_buffer, 0, sizeof(scp->sense_buffer)); - memcpy(&scp->sense_buffer, - &req->sg_list, le32_to_cpu(req->dataxfer_length)); + memcpy(&scp->sense_buffer, &req->sg_list, + min(sizeof(scp->sense_buffer), + le32_to_cpu(req->dataxfer_length))); break; default: -- cgit v1.2.3 From e9e42faf47255274a1ed0b9bf1c46118023ec5fa Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 15 Oct 2007 20:51:32 +0100 Subject: [SCSI] initio: Fix merge fallout Fix IRQ reporting - just assign the ->pci_dev pointer earlier and use the pci_dev irq field rather than keeping a private one Init the spinlock as it works better on SMP that way Signed-off-by: Alan Cox Signed-off-by: James Bottomley --- drivers/scsi/initio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index 22d40fd5845b..4c4465d39a1d 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c @@ -665,7 +665,7 @@ static void initio_init(struct initio_host * host, u8 *bios_addr) host->max_tags[i] = 0xFF; } /* for */ printk("i91u: PCI Base=0x%04X, IRQ=%d, BIOS=0x%04X0, SCSI ID=%d\n", - host->addr, host->irq, + host->addr, host->pci_dev->irq, host->bios_addr, host->scsi_id); /* Reset SCSI Bus */ if (host->config & HCC_SCSI_RESET) { @@ -2891,6 +2891,8 @@ static int initio_probe_one(struct pci_dev *pdev, goto out_release_region; } + host->pci_dev = pdev; + host->num_scbs = num_scb; host->scb = scb; host->next_pending = scb; @@ -2905,6 +2907,7 @@ static int initio_probe_one(struct pci_dev *pdev, host->scb_end = tmp; host->first_avail = scb; host->last_avail = prev; + spin_lock_init(&host->avail_lock); initio_init(host, phys_to_virt(bios_seg << 4)); @@ -2928,7 +2931,6 @@ static int initio_probe_one(struct pci_dev *pdev, } pci_set_drvdata(pdev, shost); - host->pci_dev = pdev; error = scsi_add_host(shost, &pdev->dev); if (error) -- cgit v1.2.3 From ff86ba59fbf6f0fd56b367b99b66dc8fb8ad61e7 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 18 Oct 2007 12:52:37 +0200 Subject: [SCSI] lpfc: lpfc_debugfs.c: fix typo This patch fixes a typo introduced by commit bbfbbbc1182f8b44c8cc4c99f4a3f3a512149022. It wasn't a compile error since CONFIG_LPFC_DEBUG_FS is not (yet?) available as an option. Signed-off-by: Adrian Bunk Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index 149fdd25f8e8..d6a98bc970ff 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c @@ -901,7 +901,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) } } - vport->disc_trc = kmzlloc( + vport->disc_trc = kzalloc( (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc), GFP_KERNEL); -- cgit v1.2.3 From 875baf3cbc0f11009ef5ca33c78210d265c8d779 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 16 Oct 2007 14:28:20 -0700 Subject: [SCSI] qla2xxx: printk fixes drivers/scsi/qla2xxx/qla_sup.c: In function 'qla24xx_write_flash_data': drivers/scsi/qla2xxx/qla_sup.c:655: warning: format '%llx' expects type 'long long unsigned int', but argument 6 has type 'dma_addr_t' drivers/scsi/qla2xxx/qla_sup.c: In function 'qla25xx_read_optrom_data': drivers/scsi/qla2xxx/qla_sup.c:1853: warning: format '%llx' expects type 'long long unsigned int', but argument 6 has type 'dma_addr_t' Signed-off-by: Andrew Morton Acked-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_sup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index 40b059fc1981..6670ad585f28 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -656,7 +656,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, "Unable to burst-write optrom segment " "(%x/%x/%llx).\n", ret, flash_data_to_access_addr(faddr), - optrom_dma); + (unsigned long long)optrom_dma); qla_printk(KERN_WARNING, ha, "Reverting to slow-write.\n"); @@ -1853,7 +1853,8 @@ qla25xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, qla_printk(KERN_WARNING, ha, "Unable to burst-read optrom segment " "(%x/%x/%llx).\n", rval, - flash_data_to_access_addr(faddr), optrom_dma); + flash_data_to_access_addr(faddr), + (unsigned long long)optrom_dma); qla_printk(KERN_WARNING, ha, "Reverting to slow-read.\n"); -- cgit v1.2.3 From 4135f9d28af912d541c0c32f1bc2ee6da23306eb Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 18 Oct 2007 12:52:07 +0200 Subject: [SCSI] aic7xxx_old: fix accidental logic reversal Commit bbfbbbc1182f8b44c8cc4c99f4a3f3a512149022 accidentally reversed the logic of this NULL check. Spotted by the Coverity checker. Signed-off-by: Adrian Bunk Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx_old.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c index 4025608d6964..8f8db5f0aef7 100644 --- a/drivers/scsi/aic7xxx_old.c +++ b/drivers/scsi/aic7xxx_old.c @@ -8417,7 +8417,7 @@ aic7xxx_alloc(struct scsi_host_template *sht, struct aic7xxx_host *temp) p->host = host; p->scb_data = kzalloc(sizeof(scb_data_type), GFP_ATOMIC); - if (!p->scb_data) + if (p->scb_data) { scbq_init (&p->scb_data->free_scbs); } -- cgit v1.2.3 From 05dd7ed2c7e22d0fc3027fc27a072664bbdf8274 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 18 Oct 2007 12:51:05 +0200 Subject: [SCSI] gdth: __init fixes This patch fixes the following build warnings: WARNING: vmlinux.o(.text+0xbcffdb): Section mismatch: reference to .init.text.20:gdth_search_drives (between 'gdth_pci_probe_one' and 'gdth_start_timeout') WARNING: vmlinux.o(.text+0xbd0102): Section mismatch: reference to .init.text.20:gdth_enable_int (between 'gdth_pci_probe_one' and 'gdth_start_timeout') Signed-off-by: Adrian Bunk Signed-off-by: James Bottomley --- drivers/scsi/gdth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 3ac080ee6e2f..56de5a6f2817 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -4734,7 +4734,7 @@ static struct scsi_host_template gdth_template = { }; #ifdef CONFIG_ISA -static int gdth_isa_probe_one(ulong32 isa_bios) +static int __init gdth_isa_probe_one(ulong32 isa_bios) { struct Scsi_Host *shp; gdth_ha_str *ha; @@ -4862,7 +4862,7 @@ static int gdth_isa_probe_one(ulong32 isa_bios) #endif /* CONFIG_ISA */ #ifdef CONFIG_EISA -static int gdth_eisa_probe_one(ushort eisa_slot) +static int __init gdth_eisa_probe_one(ushort eisa_slot) { struct Scsi_Host *shp; gdth_ha_str *ha; @@ -4991,7 +4991,7 @@ static int gdth_eisa_probe_one(ushort eisa_slot) #endif /* CONFIG_EISA */ #ifdef CONFIG_PCI -static int gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) +static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) { struct Scsi_Host *shp; gdth_ha_str *ha; -- cgit v1.2.3 From eb7a1698d24783dd215cb86a12cadebe9b4e7046 Mon Sep 17 00:00:00 2001 From: Johannes Dickgreber Date: Wed, 3 Oct 2007 13:22:19 +0200 Subject: [SCSI] qla1280: uses wrong failure path after failed pci_set_dma_mask A failure here wouldn't currently free the irq; go to the irq free path instead. Signed-off-by: Johannes Dickgreber Acked-by: Jes Sorensen Signed-off-by: James Bottomley --- drivers/scsi/qla1280.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 76089cf55f4e..3aeb68bcb7ac 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -4310,7 +4310,7 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) printk(KERN_WARNING "scsi(%li): Unable to set a " "suitable DMA mask - aborting\n", ha->host_no); error = -ENODEV; - goto error_free_irq; + goto error_put_host; } } else dprintk(2, "scsi(%li): 64 Bit PCI Addressing Enabled\n", @@ -4320,7 +4320,7 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) printk(KERN_WARNING "scsi(%li): Unable to set a " "suitable DMA mask - aborting\n", ha->host_no); error = -ENODEV; - goto error_free_irq; + goto error_put_host; } #endif -- cgit v1.2.3 From b5720729f58a4a05b0e2c8c61ac3ed3a3e9f94e5 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 19 Oct 2007 10:32:21 +0200 Subject: [SCSI] aic7xxx: Add suspend/resume support The aic7xxx driver already contains fragments for suspend/resume support. So we only need to update them to the current interface and have full PCI suspend/resume. Signed-off-by: Hannes Reinecke Tested-by: Jens Axboe Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic7770.c | 16 ----------- drivers/scsi/aic7xxx/aic79xx.h | 11 ++++++++ drivers/scsi/aic7xxx/aic79xx_core.c | 7 +---- drivers/scsi/aic7xxx/aic79xx_osm_pci.c | 50 ++++++++++++++++++++++++++++++++++ drivers/scsi/aic7xxx/aic79xx_pci.c | 27 ++++++++++++++++++ drivers/scsi/aic7xxx/aic7xxx.h | 11 +------- drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | 46 +++++++++++++++++++++++++++++++ drivers/scsi/aic7xxx/aic7xxx_pci.c | 16 +---------- 8 files changed, 137 insertions(+), 47 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/aic7xxx/aic7770.c b/drivers/scsi/aic7xxx/aic7770.c index c4d17231c828..6d86a9be538f 100644 --- a/drivers/scsi/aic7xxx/aic7770.c +++ b/drivers/scsi/aic7xxx/aic7770.c @@ -60,8 +60,6 @@ #define ID_OLV_274xD 0x04907783 /* Olivetti OEM (Differential) */ static int aic7770_chip_init(struct ahc_softc *ahc); -static int aic7770_suspend(struct ahc_softc *ahc); -static int aic7770_resume(struct ahc_softc *ahc); static int aha2840_load_seeprom(struct ahc_softc *ahc); static ahc_device_setup_t ahc_aic7770_VL_setup; static ahc_device_setup_t ahc_aic7770_EISA_setup; @@ -155,8 +153,6 @@ aic7770_config(struct ahc_softc *ahc, struct aic7770_identity *entry, u_int io) return (error); ahc->bus_chip_init = aic7770_chip_init; - ahc->bus_suspend = aic7770_suspend; - ahc->bus_resume = aic7770_resume; error = ahc_reset(ahc, /*reinit*/FALSE); if (error != 0) @@ -272,18 +268,6 @@ aic7770_chip_init(struct ahc_softc *ahc) return (ahc_chip_init(ahc)); } -static int -aic7770_suspend(struct ahc_softc *ahc) -{ - return (ahc_suspend(ahc)); -} - -static int -aic7770_resume(struct ahc_softc *ahc) -{ - return (ahc_resume(ahc)); -} - /* * Read the 284x SEEPROM. */ diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h index 27adbb294ac1..ce638aa6005a 100644 --- a/drivers/scsi/aic7xxx/aic79xx.h +++ b/drivers/scsi/aic7xxx/aic79xx.h @@ -1003,8 +1003,15 @@ struct ahd_suspend_channel_state { uint8_t seqctl; }; +struct ahd_suspend_pci_state { + uint32_t devconfig; + uint8_t command; + uint8_t csize_lattime; +}; + struct ahd_suspend_state { struct ahd_suspend_channel_state channel[2]; + struct ahd_suspend_pci_state pci_state; uint8_t optionmode; uint8_t dscommand0; uint8_t dspcistatus; @@ -1333,6 +1340,8 @@ struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t); int ahd_pci_config(struct ahd_softc *, struct ahd_pci_identity *); int ahd_pci_test_register_access(struct ahd_softc *); +void ahd_pci_suspend(struct ahd_softc *); +void ahd_pci_resume(struct ahd_softc *); /************************** SCB and SCB queue management **********************/ void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, @@ -1343,6 +1352,8 @@ struct ahd_softc *ahd_alloc(void *platform_arg, char *name); int ahd_softc_init(struct ahd_softc *); void ahd_controller_info(struct ahd_softc *ahd, char *buf); int ahd_init(struct ahd_softc *ahd); +int ahd_suspend(struct ahd_softc *ahd); +void ahd_resume(struct ahd_softc *ahd); int ahd_default_config(struct ahd_softc *ahd); int ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd); diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index 05f692bd0adc..a7dd8cdda472 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -7175,7 +7175,6 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd) ahd->flags &= ~AHD_ALL_INTERRUPTS; } -#if 0 int ahd_suspend(struct ahd_softc *ahd) { @@ -7189,19 +7188,15 @@ ahd_suspend(struct ahd_softc *ahd) ahd_shutdown(ahd); return (0); } -#endif /* 0 */ -#if 0 -int +void ahd_resume(struct ahd_softc *ahd) { ahd_reset(ahd, /*reinit*/TRUE); ahd_intr_enable(ahd, TRUE); ahd_restart(ahd); - return (0); } -#endif /* 0 */ /************************** Busy Target Table *********************************/ /* diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c index c62ce41f2793..66f0259edb69 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c @@ -50,6 +50,8 @@ static int ahd_linux_pci_reserve_io_regions(struct ahd_softc *ahd, static int ahd_linux_pci_reserve_mem_region(struct ahd_softc *ahd, u_long *bus_addr, uint8_t __iomem **maddr); +static int ahd_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg); +static int ahd_linux_pci_dev_resume(struct pci_dev *pdev); static void ahd_linux_pci_dev_remove(struct pci_dev *pdev); /* Define the macro locally since it's different for different class of chips. @@ -86,10 +88,58 @@ MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table); static struct pci_driver aic79xx_pci_driver = { .name = "aic79xx", .probe = ahd_linux_pci_dev_probe, +#ifdef CONFIG_PM + .suspend = ahd_linux_pci_dev_suspend, + .resume = ahd_linux_pci_dev_resume, +#endif .remove = ahd_linux_pci_dev_remove, .id_table = ahd_linux_pci_id_table }; +static int +ahd_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) +{ + struct ahd_softc *ahd = pci_get_drvdata(pdev); + int rc; + + if ((rc = ahd_suspend(ahd))) + return rc; + + ahd_pci_suspend(ahd); + + pci_save_state(pdev); + pci_disable_device(pdev); + + if (mesg.event == PM_EVENT_SUSPEND) + pci_set_power_state(pdev, PCI_D3hot); + + return rc; +} + +static int +ahd_linux_pci_dev_resume(struct pci_dev *pdev) +{ + struct ahd_softc *ahd = pci_get_drvdata(pdev); + int rc; + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + + if ((rc = pci_enable_device(pdev))) { + dev_printk(KERN_ERR, &pdev->dev, + "failed to enable device after resume (%d)\n", rc); + return rc; + } + + pci_set_master(pdev); + + ahd_pci_resume(ahd); + + ahd_resume(ahd); + + return rc; +} + static void ahd_linux_pci_dev_remove(struct pci_dev *pdev) { diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c index 0bada0028aa0..7a203a90601a 100644 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c @@ -389,6 +389,33 @@ ahd_pci_config(struct ahd_softc *ahd, struct ahd_pci_identity *entry) return error; } +void +ahd_pci_suspend(struct ahd_softc *ahd) +{ + /* + * Save chip register configuration data for chip resets + * that occur during runtime and resume events. + */ + ahd->suspend_state.pci_state.devconfig = + ahd_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4); + ahd->suspend_state.pci_state.command = + ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/1); + ahd->suspend_state.pci_state.csize_lattime = + ahd_pci_read_config(ahd->dev_softc, CSIZE_LATTIME, /*bytes*/1); + +} + +void +ahd_pci_resume(struct ahd_softc *ahd) +{ + ahd_pci_write_config(ahd->dev_softc, DEVCONFIG, + ahd->suspend_state.pci_state.devconfig, /*bytes*/4); + ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, + ahd->suspend_state.pci_state.command, /*bytes*/1); + ahd_pci_write_config(ahd->dev_softc, CSIZE_LATTIME, + ahd->suspend_state.pci_state.csize_lattime, /*bytes*/1); +} + /* * Perform some simple tests that should catch situations where * our registers are invalidly mapped. diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h index e1bd57b9f23d..3d4e42d90452 100644 --- a/drivers/scsi/aic7xxx/aic7xxx.h +++ b/drivers/scsi/aic7xxx/aic7xxx.h @@ -961,16 +961,6 @@ struct ahc_softc { */ ahc_bus_chip_init_t bus_chip_init; - /* - * Bus specific suspend routine. - */ - ahc_bus_suspend_t bus_suspend; - - /* - * Bus specific resume routine. - */ - ahc_bus_resume_t bus_resume; - /* * Target mode related state kept on a per enabled lun basis. * Targets that are not enabled will have null entries. @@ -1153,6 +1143,7 @@ struct ahc_pci_identity *ahc_find_pci_device(ahc_dev_softc_t); int ahc_pci_config(struct ahc_softc *, struct ahc_pci_identity *); int ahc_pci_test_register_access(struct ahc_softc *); +void ahc_pci_resume(struct ahc_softc *ahc); /*************************** EISA/VL Front End ********************************/ struct aic7770_identity *aic7770_find_device(uint32_t); diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index ea5687df732d..4488946cff2e 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c @@ -49,6 +49,8 @@ static int ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, static int ahc_linux_pci_reserve_mem_region(struct ahc_softc *ahc, u_long *bus_addr, uint8_t __iomem **maddr); +static int ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg); +static int ahc_linux_pci_dev_resume(struct pci_dev *pdev); static void ahc_linux_pci_dev_remove(struct pci_dev *pdev); /* Define the macro locally since it's different for different class of chips. @@ -133,10 +135,54 @@ MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table); static struct pci_driver aic7xxx_pci_driver = { .name = "aic7xxx", .probe = ahc_linux_pci_dev_probe, +#ifdef CONFIG_PM + .suspend = ahc_linux_pci_dev_suspend, + .resume = ahc_linux_pci_dev_resume, +#endif .remove = ahc_linux_pci_dev_remove, .id_table = ahc_linux_pci_id_table }; +static int +ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) +{ + struct ahc_softc *ahc = pci_get_drvdata(pdev); + int rc; + + if ((rc = ahc_suspend(ahc))) + return rc; + + pci_save_state(pdev); + pci_disable_device(pdev); + + if (mesg.event == PM_EVENT_SUSPEND) + pci_set_power_state(pdev, PCI_D3hot); + + return rc; +} + +static int +ahc_linux_pci_dev_resume(struct pci_dev *pdev) +{ + struct ahc_softc *ahc = pci_get_drvdata(pdev); + int rc; + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + + if ((rc = pci_enable_device(pdev))) { + dev_printk(KERN_ERR, &pdev->dev, + "failed to enable device after resume (%d)\n", rc); + return rc; + } + + pci_set_master(pdev); + + ahc_pci_resume(ahc); + + return (ahc_resume(ahc)); +} + static void ahc_linux_pci_dev_remove(struct pci_dev *pdev) { diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c index 09c8172c9e5e..ae35937b8055 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c @@ -633,8 +633,6 @@ static void write_brdctl(struct ahc_softc *ahc, uint8_t value); static uint8_t read_brdctl(struct ahc_softc *ahc); static void ahc_pci_intr(struct ahc_softc *ahc); static int ahc_pci_chip_init(struct ahc_softc *ahc); -static int ahc_pci_suspend(struct ahc_softc *ahc); -static int ahc_pci_resume(struct ahc_softc *ahc); static int ahc_9005_subdevinfo_valid(uint16_t device, uint16_t vendor, @@ -791,8 +789,6 @@ ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry) ahc->bus_intr = ahc_pci_intr; ahc->bus_chip_init = ahc_pci_chip_init; - ahc->bus_suspend = ahc_pci_suspend; - ahc->bus_resume = ahc_pci_resume; /* Remeber how the card was setup in case there is no SEEPROM */ if ((ahc_inb(ahc, HCNTRL) & POWRDN) == 0) { @@ -2024,18 +2020,9 @@ ahc_pci_chip_init(struct ahc_softc *ahc) return (ahc_chip_init(ahc)); } -static int -ahc_pci_suspend(struct ahc_softc *ahc) -{ - return (ahc_suspend(ahc)); -} - -static int +void ahc_pci_resume(struct ahc_softc *ahc) { - - pci_set_power_state(ahc->dev_softc, AHC_POWER_STATE_D0); - /* * We assume that the OS has restored our register * mappings, etc. Just update the config space registers @@ -2063,7 +2050,6 @@ ahc_pci_resume(struct ahc_softc *ahc) &sxfrctl1); ahc_release_seeprom(&sd); } - return (ahc_resume(ahc)); } static int -- cgit v1.2.3 From 64624d4f46d5e439906bcd3a99a688c833506124 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 19 Oct 2007 10:32:29 +0200 Subject: [SCSI] aic7xxx: Update Maintainer information Might as well take the blame officially. Signed-off-by: Hannes Reinecke Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 4 ++-- drivers/scsi/aic7xxx/aic7xxx_osm.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 42c0f14a262c..2d020405480c 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -315,8 +315,8 @@ uint32_t aic79xx_slowcrc; */ static char *aic79xx = NULL; -MODULE_AUTHOR("Maintainer: Justin T. Gibbs "); -MODULE_DESCRIPTION("Adaptec Aic790X U320 SCSI Host Bus Adapter driver"); +MODULE_AUTHOR("Maintainer: Hannes Reinecke "); +MODULE_DESCRIPTION("Adaptec AIC790X U320 SCSI Host Bus Adapter driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_VERSION(AIC79XX_DRIVER_VERSION); module_param(aic79xx, charp, 0444); diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 7770befbf50c..390b0fc991c5 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -335,8 +335,8 @@ static uint32_t aic7xxx_periodic_otag; */ static char *aic7xxx = NULL; -MODULE_AUTHOR("Maintainer: Justin T. Gibbs "); -MODULE_DESCRIPTION("Adaptec Aic77XX/78XX SCSI Host Bus Adapter driver"); +MODULE_AUTHOR("Maintainer: Hannes Reinecke "); +MODULE_DESCRIPTION("Adaptec AIC77XX/78XX SCSI Host Bus Adapter driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_VERSION(AIC7XXX_DRIVER_VERSION); module_param(aic7xxx, charp, 0444); -- cgit v1.2.3 From fc2adcfd37f6f1c32d246b5b43f83e38233358ae Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 19 Oct 2007 10:32:34 +0200 Subject: [SCSI] aic7xxx: Fix firmware build If a prefix is selected for flex, we should be using it everywhere. Signed-off-by: Hannes Reinecke Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l b/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l index f06e7035cb35..c0457b8c3b77 100644 --- a/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l +++ b/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l @@ -66,6 +66,7 @@ static char string_buf[MAX_STR_CONST]; static char *string_buf_ptr; static int parren_count; static char buf[255]; +int mmlineno; %} WORD [A-Za-z_][-A-Za-z_0-9]* @@ -76,7 +77,7 @@ MCARG [^(), \t]+ %% \n { - ++yylineno; + ++mmlineno; } \r ; {SPACE} ; -- cgit v1.2.3 From 20d2d3afa87781fe2674ce17bfb16af08a436e81 Mon Sep 17 00:00:00 2001 From: Johannes Dickgreber Date: Thu, 20 Sep 2007 01:07:50 +0200 Subject: [SCSI] qla1280: eliminate wasted space in request and response ring i think there is wasted space in allocated pages for request and response rings. The allocations are made with REQUEST_ENTRY_CNT + 1 and RESPONSE_ENTRY_CNT + 1, but they are set with 256 and 16. So we got more pages, which we dont use very much so eliminate them. Signed-off-by: Johannes Dickgreber Acked-by: Jes Sorensen Signed-off-by: James Bottomley --- drivers/scsi/qla1280.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h index 59915fb70301..ff2c363ead26 100644 --- a/drivers/scsi/qla1280.h +++ b/drivers/scsi/qla1280.h @@ -91,8 +91,8 @@ #define INVALID_HANDLE (MAX_OUTSTANDING_COMMANDS + 2) /* ISP request and response entry counts (37-65535) */ -#define REQUEST_ENTRY_CNT 256 /* Number of request entries. */ -#define RESPONSE_ENTRY_CNT 16 /* Number of response entries. */ +#define REQUEST_ENTRY_CNT 255 /* Number of request entries. */ +#define RESPONSE_ENTRY_CNT 63 /* Number of response entries. */ /* * SCSI Request Block structure (sp) that is placed -- cgit v1.2.3 From 34996acc5571e64be7f3dba3adced1f7221a8d07 Mon Sep 17 00:00:00 2001 From: Kai Makisara Date: Fri, 5 Oct 2007 15:54:58 -0400 Subject: [SCSI] sym53c8xx: Work around 53c896 erratum Prevent DMA transfers from crossing the 16MB limit for early 53c896 chips. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index db03c4c8ec1e..44169390c467 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1531,6 +1531,10 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, BUG_ON(sym2_transport_template == NULL); instance->transportt = sym2_transport_template; + /* 53c896 rev 1 errata: DMA may not cross 16MB boundary */ + if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && np->revision_id < 2) + instance->dma_boundary = 0xFFFFFF; + spin_unlock_irqrestore(instance->host_lock, flags); return instance; -- cgit v1.2.3 From f363abff55cad0e9c6e73c4eedae13d9ee794880 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:54:59 -0400 Subject: [SCSI] sym53c8xx: Use pci_dev irq number Don't cache a private copy of the interrupt number Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 7 +++---- drivers/scsi/sym53c8xx_2/sym_glue.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 44169390c467..e053222a10a3 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1288,7 +1288,7 @@ static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) "revision id 0x%x\n", np->s.chip_name, np->device_id, np->revision_id); copy_info(&info, "At PCI address %s, IRQ " IRQ_FMT "\n", - pci_name(np->s.device), IRQ_PRM(np->s.irq)); + pci_name(np->s.device), IRQ_PRM(np->s.device->irq)); copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", (int) (np->minsync_dt ? np->minsync_dt : np->minsync), np->maxwide ? "Wide" : "Narrow", @@ -1341,8 +1341,8 @@ static void sym_free_resources(struct sym_hcb *np, struct pci_dev *pdev) /* * Free O/S specific resources. */ - if (np->s.irq) - free_irq(np->s.irq, np); + if (pdev->irq) + free_irq(pdev->irq, np); if (np->s.ioaddr) pci_iounmap(pdev, np->s.ioaddr); if (np->s.ramaddr) @@ -1491,7 +1491,6 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, sym_name(np), pdev->irq); goto attach_failed; } - np->s.irq = pdev->irq; /* * After SCSI devices have been opened, we cannot diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index 0f097ba4f712..bea7bcc69ebd 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -184,7 +184,6 @@ struct sym_shcb { void __iomem * ioaddr; /* MMIO kernel io address */ void __iomem * ramaddr; /* RAM kernel io address */ u_short io_ws; /* IO window size */ - int irq; /* IRQ number */ struct timer_list timer; /* Timer handler link header */ u_long lasttime; -- cgit v1.2.3 From 39c05d1e3c85c725e140ded1281bbb2303dfe5d3 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:00 -0400 Subject: [SCSI] sym53c8xx: Remove data_mapping and data_mapped Before all commands used sg, data_mapping and data_mapped were used to distinguish whether the command had used map_single or map_sg. Now all commands are sg, so we can delete data_mapping, data_mapped and the wrapper functions __unmap_scsi_data, __map_scsi_sg_data, unmap_scsi_data and map_scsi_sg_data. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index e053222a10a3..cfce00ba2b6e 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -134,8 +134,6 @@ static struct scsi_transport_template *sym2_transport_template = NULL; * Driver private area in the SCSI command structure. */ struct sym_ucmd { /* Override the SCSI pointer structure */ - dma_addr_t data_mapping; - unsigned char data_mapped; unsigned char to_do; /* For error handling */ void (*old_done)(struct scsi_cmnd *); /* For error handling */ struct completion *eh_done; /* For error handling */ @@ -144,37 +142,12 @@ struct sym_ucmd { /* Override the SCSI pointer structure */ #define SYM_UCMD_PTR(cmd) ((struct sym_ucmd *)(&(cmd)->SCp)) #define SYM_SOFTC_PTR(cmd) sym_get_hcb(cmd->device->host) -static void __unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd) -{ - if (SYM_UCMD_PTR(cmd)->data_mapped) - scsi_dma_unmap(cmd); - - SYM_UCMD_PTR(cmd)->data_mapped = 0; -} - -static int __map_scsi_sg_data(struct pci_dev *pdev, struct scsi_cmnd *cmd) -{ - int use_sg; - - use_sg = scsi_dma_map(cmd); - if (use_sg > 0) { - SYM_UCMD_PTR(cmd)->data_mapped = 2; - SYM_UCMD_PTR(cmd)->data_mapping = use_sg; - } - - return use_sg; -} - -#define unmap_scsi_data(np, cmd) \ - __unmap_scsi_data(np->s.device, cmd) -#define map_scsi_sg_data(np, cmd) \ - __map_scsi_sg_data(np->s.device, cmd) /* * Complete a pending CAM CCB. */ void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *cmd) { - unmap_scsi_data(np, cmd); + scsi_dma_unmap(cmd); cmd->scsi_done(cmd); } @@ -307,14 +280,14 @@ static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd cp->data_len = 0; - use_sg = map_scsi_sg_data(np, cmd); + use_sg = scsi_dma_map(cmd); if (use_sg > 0) { struct scatterlist *sg; struct sym_tcb *tp = &np->target[cp->target]; struct sym_tblmove *data; if (use_sg > SYM_CONF_MAX_SG) { - unmap_scsi_data(np, cmd); + scsi_dma_unmap(cmd); return -1; } -- cgit v1.2.3 From 71c222dc45ddf01b0dabb8a4d3e232e13e1452b5 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:01 -0400 Subject: [SCSI] sym53c8xx: Remove unnecessary check in queuecommand The midlayer won't scan the host ID, so we don't need to check. This is the only caller of sym_xpt_done2, so remove that too. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index cfce00ba2b6e..9fc2ae836257 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -151,13 +151,6 @@ void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *cmd) cmd->scsi_done(cmd); } -static void sym_xpt_done2(struct sym_hcb *np, struct scsi_cmnd *cmd, int cam_status) -{ - sym_set_cam_status(cmd, cam_status); - sym_xpt_done(np, cmd); -} - - /* * Tell the SCSI layer about a BUS RESET. */ @@ -323,15 +316,6 @@ static int sym_queue_command(struct sym_hcb *np, struct scsi_cmnd *cmd) struct sym_ccb *cp; int order; - /* - * Minimal checkings, so that we will not - * go outside our tables. - */ - if (sdev->id == np->myaddr) { - sym_xpt_done2(np, cmd, DID_NO_CONNECT); - return 0; - } - /* * Retrieve the target descriptor. */ @@ -537,7 +521,7 @@ static int sym53c8xx_queue_command(struct scsi_cmnd *cmd, struct sym_ucmd *ucp = SYM_UCMD_PTR(cmd); int sts = 0; - cmd->scsi_done = done; + cmd->scsi_done = done; memset(ucp, 0, sizeof(*ucp)); /* -- cgit v1.2.3 From 6c9746b363b8191587191518a65d5de93df80a92 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:02 -0400 Subject: [SCSI] sym53c8xx: Don't disable interrupts in the interrupt handler Interrupts can't be re-entered, so it's sufficient to call spin_lock, not spin_lock_irqsave(). Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 9fc2ae836257..b5e7c6478653 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -550,14 +550,13 @@ static int sym53c8xx_queue_command(struct scsi_cmnd *cmd, */ static irqreturn_t sym53c8xx_intr(int irq, void *dev_id) { - unsigned long flags; - struct sym_hcb *np = (struct sym_hcb *)dev_id; + struct sym_hcb *np = dev_id; if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("["); - spin_lock_irqsave(np->s.host->host_lock, flags); + spin_lock(np->s.host->host_lock); sym_interrupt(np); - spin_unlock_irqrestore(np->s.host->host_lock, flags); + spin_unlock(np->s.host->host_lock); if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("]\n"); -- cgit v1.2.3 From 2ba65367720d871f9d955ca3ef96358999182765 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:03 -0400 Subject: [SCSI] sym53c8xx: Stop overriding scsi_done Instead of telling the reset routine that the command completed from sym_eh_done, do it from sym_xpt_done. The 'to_do' element of the ucmd is redundant -- it serves only to tell whether eh_done is valid or not, and we can tell this by checking to see if it's NULL. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 60 +++++++++++-------------------------- 1 file changed, 18 insertions(+), 42 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index b5e7c6478653..4de0692f5c4f 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -134,8 +134,6 @@ static struct scsi_transport_template *sym2_transport_template = NULL; * Driver private area in the SCSI command structure. */ struct sym_ucmd { /* Override the SCSI pointer structure */ - unsigned char to_do; /* For error handling */ - void (*old_done)(struct scsi_cmnd *); /* For error handling */ struct completion *eh_done; /* For error handling */ }; @@ -147,6 +145,12 @@ struct sym_ucmd { /* Override the SCSI pointer structure */ */ void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *cmd) { + struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); + BUILD_BUG_ON(sizeof(struct scsi_pointer) < sizeof(struct sym_ucmd)); + + if (ucmd->eh_done) + complete(ucmd->eh_done); + scsi_dma_unmap(cmd); cmd->scsi_done(cmd); } @@ -585,26 +589,6 @@ static void sym53c8xx_timer(unsigned long npref) #define SYM_EH_BUS_RESET 2 #define SYM_EH_HOST_RESET 3 -/* - * What we will do regarding the involved SCSI command. - */ -#define SYM_EH_DO_IGNORE 0 -#define SYM_EH_DO_WAIT 2 - -/* - * scsi_done() alias when error recovery is in progress. - */ -static void sym_eh_done(struct scsi_cmnd *cmd) -{ - struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); - BUILD_BUG_ON(sizeof(struct scsi_pointer) < sizeof(struct sym_ucmd)); - - cmd->scsi_done = ucmd->old_done; - - if (ucmd->to_do == SYM_EH_DO_WAIT) - complete(ucmd->eh_done); -} - /* * Generic method for our eh processing. * The 'op' argument tells what we have to do. @@ -615,7 +599,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); struct Scsi_Host *host = cmd->device->host; SYM_QUEHEAD *qp; - int to_do = SYM_EH_DO_IGNORE; + int cmd_queued = 0; int sts = -1; struct completion eh_done; @@ -626,19 +610,11 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); if (cp->cmd == cmd) { - to_do = SYM_EH_DO_WAIT; + cmd_queued = 1; break; } } - if (to_do == SYM_EH_DO_WAIT) { - init_completion(&eh_done); - ucmd->old_done = cmd->scsi_done; - ucmd->eh_done = &eh_done; - wmb(); - cmd->scsi_done = sym_eh_done; - } - /* Try to proceed the operation we have been asked for */ sts = -1; switch(op) { @@ -662,21 +638,21 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) } /* On error, restore everything and cross fingers :) */ - if (sts) { - cmd->scsi_done = ucmd->old_done; - to_do = SYM_EH_DO_IGNORE; - } - - ucmd->to_do = to_do; - spin_unlock_irq(host->host_lock); + if (sts) + cmd_queued = 0; - if (to_do == SYM_EH_DO_WAIT) { + if (cmd_queued) { + init_completion(&eh_done); + ucmd->eh_done = &eh_done; + spin_unlock_irq(host->host_lock); if (!wait_for_completion_timeout(&eh_done, 5*HZ)) { - ucmd->to_do = SYM_EH_DO_IGNORE; - wmb(); + ucmd->eh_done = NULL; sts = -2; } + } else { + spin_unlock_irq(host->host_lock); } + dev_warn(&cmd->device->sdev_gendev, "%s operation %s.\n", opname, sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed"); return sts ? SCSI_FAILED : SCSI_SUCCESS; -- cgit v1.2.3 From d68cd75992f95d6977956fb227f02e6d532f3d26 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Fri, 5 Oct 2007 15:55:04 -0400 Subject: [SCSI] sym53c8xx: PCI Error Recovery support This patch adds the PCI error recovery callbacks to the Symbios SCSI device driver. It includes support for First Failure Data Capture. Signed-off-by: Linas Vepstas Assorted changes to initial patches, including returning IRQ_NONE from the interrupt handler if the device is offline and re-using the eh_done completion in the scsi error handler. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 179 +++++++++++++++++++++++++++++++++++- drivers/scsi/sym53c8xx_2/sym_glue.h | 3 + drivers/scsi/sym53c8xx_2/sym_hipd.c | 25 ++++- 3 files changed, 200 insertions(+), 7 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 4de0692f5c4f..67a577db5d18 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -134,7 +134,7 @@ static struct scsi_transport_template *sym2_transport_template = NULL; * Driver private area in the SCSI command structure. */ struct sym_ucmd { /* Override the SCSI pointer structure */ - struct completion *eh_done; /* For error handling */ + struct completion *eh_done; /* SCSI error handling */ }; #define SYM_UCMD_PTR(cmd) ((struct sym_ucmd *)(&(cmd)->SCp)) @@ -556,6 +556,10 @@ static irqreturn_t sym53c8xx_intr(int irq, void *dev_id) { struct sym_hcb *np = dev_id; + /* Avoid spinloop trying to handle interrupts on frozen device */ + if (pci_channel_offline(np->s.device)) + return IRQ_NONE; + if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("["); spin_lock(np->s.host->host_lock); @@ -598,6 +602,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) struct sym_hcb *np = SYM_SOFTC_PTR(cmd); struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); struct Scsi_Host *host = cmd->device->host; + struct pci_dev *pdev = np->s.device; SYM_QUEHEAD *qp; int cmd_queued = 0; int sts = -1; @@ -605,6 +610,38 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) dev_warn(&cmd->device->sdev_gendev, "%s operation started.\n", opname); + /* We may be in an error condition because the PCI bus + * went down. In this case, we need to wait until the + * PCI bus is reset, the card is reset, and only then + * proceed with the scsi error recovery. There's no + * point in hurrying; take a leisurely wait. + */ +#define WAIT_FOR_PCI_RECOVERY 35 + if (pci_channel_offline(pdev)) { + struct host_data *hostdata = shost_priv(host); + struct completion *io_reset; + int finished_reset = 0; + init_completion(&eh_done); + spin_lock_irq(host->host_lock); + /* Make sure we didn't race */ + if (pci_channel_offline(pdev)) { + if (!hostdata->io_reset) + hostdata->io_reset = &eh_done; + io_reset = hostdata->io_reset; + } else { + io_reset = NULL; + } + + if (!pci_channel_offline(pdev)) + finished_reset = 1; + spin_unlock_irq(host->host_lock); + if (!finished_reset) + finished_reset = wait_for_completion_timeout(io_reset, + WAIT_FOR_PCI_RECOVERY*HZ); + if (!finished_reset) + return SCSI_FAILED; + } + spin_lock_irq(host->host_lock); /* This one is queued in some place -> to wait for completion */ FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { @@ -630,7 +667,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) break; case SYM_EH_HOST_RESET: sym_reset_scsi_bus(np, 0); - sym_start_up (np, 1); + sym_start_up(np, 1); sts = 0; break; default: @@ -1435,7 +1472,7 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, /* * Start the SCRIPTS. */ - sym_start_up (np, 1); + sym_start_up(np, 1); /* * Start the timer daemon @@ -1823,6 +1860,134 @@ static void __devexit sym2_remove(struct pci_dev *pdev) attach_count--; } +/** + * sym2_io_error_detected() - called when PCI error is detected + * @pdev: pointer to PCI device + * @state: current state of the PCI slot + */ +static pci_ers_result_t sym2_io_error_detected(struct pci_dev *pdev, + enum pci_channel_state state) +{ + /* If slot is permanently frozen, turn everything off */ + if (state == pci_channel_io_perm_failure) { + sym2_remove(pdev); + return PCI_ERS_RESULT_DISCONNECT; + } + + disable_irq(pdev->irq); + pci_disable_device(pdev); + + /* Request that MMIO be enabled, so register dump can be taken. */ + return PCI_ERS_RESULT_CAN_RECOVER; +} + +/** + * sym2_io_slot_dump - Enable MMIO and dump debug registers + * @pdev: pointer to PCI device + */ +static pci_ers_result_t sym2_io_slot_dump(struct pci_dev *pdev) +{ + struct sym_hcb *np = pci_get_drvdata(pdev); + + sym_dump_registers(np); + + /* Request a slot reset. */ + return PCI_ERS_RESULT_NEED_RESET; +} + +/** + * sym2_reset_workarounds - hardware-specific work-arounds + * + * This routine is similar to sym_set_workarounds(), except + * that, at this point, we already know that the device was + * succesfully intialized at least once before, and so most + * of the steps taken there are un-needed here. + */ +static void sym2_reset_workarounds(struct pci_dev *pdev) +{ + u_char revision; + u_short status_reg; + struct sym_chip *chip; + + pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); + chip = sym_lookup_chip_table(pdev->device, revision); + + /* Work around for errant bit in 895A, in a fashion + * similar to what is done in sym_set_workarounds(). + */ + pci_read_config_word(pdev, PCI_STATUS, &status_reg); + if (!(chip->features & FE_66MHZ) && (status_reg & PCI_STATUS_66MHZ)) { + status_reg = PCI_STATUS_66MHZ; + pci_write_config_word(pdev, PCI_STATUS, status_reg); + pci_read_config_word(pdev, PCI_STATUS, &status_reg); + } +} + +/** + * sym2_io_slot_reset() - called when the pci bus has been reset. + * @pdev: pointer to PCI device + * + * Restart the card from scratch. + */ +static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev) +{ + struct sym_hcb *np = pci_get_drvdata(pdev); + + printk(KERN_INFO "%s: recovering from a PCI slot reset\n", + sym_name(np)); + + if (pci_enable_device(pdev)) { + printk(KERN_ERR "%s: Unable to enable after PCI reset\n", + sym_name(np)); + return PCI_ERS_RESULT_DISCONNECT; + } + + pci_set_master(pdev); + enable_irq(pdev->irq); + + /* If the chip can do Memory Write Invalidate, enable it */ + if (np->features & FE_WRIE) { + if (pci_set_mwi(pdev)) + return PCI_ERS_RESULT_DISCONNECT; + } + + /* Perform work-arounds, analogous to sym_set_workarounds() */ + sym2_reset_workarounds(pdev); + + /* Perform host reset only on one instance of the card */ + if (PCI_FUNC(pdev->devfn) == 0) { + if (sym_reset_scsi_bus(np, 0)) { + printk(KERN_ERR "%s: Unable to reset scsi host\n", + sym_name(np)); + return PCI_ERS_RESULT_DISCONNECT; + } + sym_start_up(np, 1); + } + + return PCI_ERS_RESULT_RECOVERED; +} + +/** + * sym2_io_resume() - resume normal ops after PCI reset + * @pdev: pointer to PCI device + * + * Called when the error recovery driver tells us that its + * OK to resume normal operation. Use completion to allow + * halted scsi ops to resume. + */ +static void sym2_io_resume(struct pci_dev *pdev) +{ + struct sym_hcb *np = pci_get_drvdata(pdev); + struct Scsi_Host *shost = np->s.host; + struct host_data *hostdata = shost_priv(shost); + + spin_lock_irq(shost->host_lock); + if (hostdata->io_reset) + complete_all(hostdata->io_reset); + hostdata->io_reset = NULL; + spin_unlock_irq(shost->host_lock); +} + static void sym2_get_signalling(struct Scsi_Host *shost) { struct sym_hcb *np = sym_get_hcb(shost); @@ -1985,11 +2150,19 @@ static struct pci_device_id sym2_id_table[] __devinitdata = { MODULE_DEVICE_TABLE(pci, sym2_id_table); +static struct pci_error_handlers sym2_err_handler = { + .error_detected = sym2_io_error_detected, + .mmio_enabled = sym2_io_slot_dump, + .slot_reset = sym2_io_slot_reset, + .resume = sym2_io_resume, +}; + static struct pci_driver sym2_driver = { .name = NAME53C8XX, .id_table = sym2_id_table, .probe = sym2_probe, .remove = __devexit_p(sym2_remove), + .err_handler = &sym2_err_handler, }; static int __init sym2_init(void) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index bea7bcc69ebd..d5ba5aae6c5a 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -40,6 +40,7 @@ #ifndef SYM_GLUE_H #define SYM_GLUE_H +#include #include #include #include @@ -220,6 +221,7 @@ struct sym_device { */ struct host_data { struct sym_hcb *ncb; + struct completion *io_reset; /* PCI error handling */ }; static inline struct sym_hcb * sym_get_hcb(struct Scsi_Host *host) @@ -265,5 +267,6 @@ void sym_xpt_async_bus_reset(struct sym_hcb *np); void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target); int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp); void sym_log_bus_error(struct sym_hcb *np); +void sym_dump_registers(struct sym_hcb *np); #endif /* SYM_GLUE_H */ diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 21cd4c7f5289..af24c447b195 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -1180,10 +1180,10 @@ static void sym_log_hard_error(struct sym_hcb *np, u_short sist, u_char dstat) scr_to_cpu((int) *(u32 *)(script_base + script_ofs))); } - printf ("%s: regdump:", sym_name(np)); - for (i=0; i<24;i++) - printf (" %02x", (unsigned)INB_OFF(np, i)); - printf (".\n"); + printf("%s: regdump:", sym_name(np)); + for (i = 0; i < 24; i++) + printf(" %02x", (unsigned)INB_OFF(np, i)); + printf(".\n"); /* * PCI BUS error. @@ -1192,6 +1192,16 @@ static void sym_log_hard_error(struct sym_hcb *np, u_short sist, u_char dstat) sym_log_bus_error(np); } +void sym_dump_registers(struct sym_hcb *np) +{ + u_short sist; + u_char dstat; + + sist = INW(np, nc_sist); + dstat = INB(np, nc_dstat); + sym_log_hard_error(np, sist, dstat); +} + static struct sym_chip sym_dev_table[] = { {PCI_DEVICE_ID_NCR_53C810, 0x0f, "810", 4, 8, 4, 64, FE_ERL} @@ -2809,6 +2819,13 @@ void sym_interrupt (struct sym_hcb *np) dstat |= INB(np, nc_dstat); istatc = INB(np, nc_istat); istat |= istatc; + + /* Prevent deadlock waiting on a condition that may + * never clear. */ + if (unlikely(sist == 0xffff && dstat == 0xff)) { + if (pci_channel_offline(np->s.device)) + return; + } } while (istatc & (SIP|DIP)); if (DEBUG_FLAGS & DEBUG_TINY) -- cgit v1.2.3 From bd678450bfbd4bb6543a7138d9ee3418c2a11e7c Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:05 -0400 Subject: [SCSI] sym53c8xx: Use pdev->revision Auke missed the sym2 driver in his initial sweep. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_fw.c | 6 +++--- drivers/scsi/sym53c8xx_2/sym_glue.c | 25 +++++++++---------------- drivers/scsi/sym53c8xx_2/sym_hipd.c | 8 ++++---- drivers/scsi/sym53c8xx_2/sym_hipd.h | 1 - 4 files changed, 16 insertions(+), 24 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c index 9916a2a22558..2be0ae17e06c 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw.c +++ b/drivers/scsi/sym53c8xx_2/sym_fw.c @@ -206,13 +206,13 @@ sym_fw2_patch(struct sym_hcb *np) * they are not desirable. See `sym_fw2.h' for more details. */ if (!(np->device_id == PCI_DEVICE_ID_LSI_53C1010_66 && - np->revision_id < 0x1 && + np->s.device->revision < 0x1 && np->pciclk_khz < 60000)) { scripta0->datao_phase[0] = cpu_to_scr(SCR_NO_OP); scripta0->datao_phase[1] = cpu_to_scr(0); } - if (!(np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 && - /* np->revision_id < 0xff */ 1)) { + if (!(np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 /* && + np->s.device->revision < 0xff */)) { scripta0->sel_done[0] = cpu_to_scr(SCR_NO_OP); scripta0->sel_done[1] = cpu_to_scr(0); } diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 67a577db5d18..3ed3ed86d350 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1254,8 +1254,8 @@ static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) info.pos = 0; copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " - "revision id 0x%x\n", - np->s.chip_name, np->device_id, np->revision_id); + "revision id 0x%x\n", np->s.chip_name, + np->device_id, np->s.device->revision); copy_info(&info, "At PCI address %s, IRQ " IRQ_FMT "\n", pci_name(np->s.device), IRQ_PRM(np->s.device->irq)); copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", @@ -1368,10 +1368,9 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, unsigned long flags; struct sym_fw *fw; - printk(KERN_INFO - "sym%d: <%s> rev 0x%x at pci %s irq " IRQ_FMT "\n", - unit, dev->chip.name, dev->chip.revision_id, - pci_name(pdev), IRQ_PRM(pdev->irq)); + printk(KERN_INFO "sym%d: <%s> rev 0x%x at pci %s irq " IRQ_FMT "\n", + unit, dev->chip.name, pdev->revision, pci_name(pdev), + IRQ_PRM(pdev->irq)); /* * Get the firmware for this chip. @@ -1412,7 +1411,6 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, np->s.device = pdev; np->s.unit = unit; np->device_id = dev->chip.device_id; - np->revision_id = dev->chip.revision_id; np->features = dev->chip.features; np->clock_divn = dev->chip.nr_divisor; np->maxoffs = dev->chip.offset_max; @@ -1500,7 +1498,7 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, instance->transportt = sym2_transport_template; /* 53c896 rev 1 errata: DMA may not cross 16MB boundary */ - if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && np->revision_id < 2) + if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 2) instance->dma_boundary = 0xFFFFFF; spin_unlock_irqrestore(instance->host_lock, flags); @@ -1545,7 +1543,6 @@ static int __devinit sym_check_supported(struct sym_device *device) { struct sym_chip *chip; struct pci_dev *pdev = device->pdev; - u_char revision; unsigned long io_port = pci_resource_start(pdev, 0); int i; @@ -1565,14 +1562,12 @@ static int __devinit sym_check_supported(struct sym_device *device) * to our device structure so we can make it match the actual device * and options. */ - pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); - chip = sym_lookup_chip_table(pdev->device, revision); + chip = sym_lookup_chip_table(pdev->device, pdev->revision); if (!chip) { dev_info(&pdev->dev, "device not supported\n"); return -ENODEV; } memcpy(&device->chip, chip, sizeof(device->chip)); - device->chip.revision_id = revision; return 0; } @@ -1613,7 +1608,7 @@ static int __devinit sym_set_workarounds(struct sym_device *device) * We must ensure the chip will use WRITE AND INVALIDATE. * The revision number limit is for now arbitrary. */ - if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && chip->revision_id < 0x4) { + if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 0x4) { chip->features |= (FE_WRIE | FE_CLSE); } @@ -1905,12 +1900,10 @@ static pci_ers_result_t sym2_io_slot_dump(struct pci_dev *pdev) */ static void sym2_reset_workarounds(struct pci_dev *pdev) { - u_char revision; u_short status_reg; struct sym_chip *chip; - pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); - chip = sym_lookup_chip_table(pdev->device, revision); + chip = sym_lookup_chip_table(pdev->device, pdev->revision); /* Work around for errant bit in 895A, in a fashion * similar to what is done in sym_set_workarounds(). diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index af24c447b195..9f4198ce845e 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -805,7 +805,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * are used. Disable internal cycles. */ if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 && - np->revision_id < 0x1) + np->s.device->revision < 0x1) np->rv_ccntl0 |= DILS; /* @@ -829,9 +829,9 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * LOAD/STORE instructions does not need this work-around. */ if ((np->device_id == PCI_DEVICE_ID_NCR_53C810 && - np->revision_id >= 0x10 && np->revision_id <= 0x11) || + np->s.device->revision >= 0x10 && np->s.device->revision <= 0x11) || (np->device_id == PCI_DEVICE_ID_NCR_53C860 && - np->revision_id <= 0x1)) + np->s.device->revision <= 0x1)) np->features &= ~(FE_WRIE|FE_ERL|FE_ERMP); /* @@ -1809,7 +1809,7 @@ void sym_start_up (struct sym_hcb *np, int reason) * I just don't want. :) */ if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 && - np->revision_id < 1) + np->s.device->revision < 1) OUTB(np, nc_stest1, INB(np, nc_stest1) | 0x30); /* diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index 79ab6a177039..3aa8060a4d2a 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -919,7 +919,6 @@ struct sym_hcb { * General controller parameters and configuration. */ u_short device_id; /* PCI device id */ - u_char revision_id; /* PCI device revision id */ u_int features; /* Chip features map */ u_char myaddr; /* SCSI id of the adapter */ u_char maxburst; /* log base 2 of dwords burst */ -- cgit v1.2.3 From e58bc06ed071e43bef4e2f94340853761a4bf034 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:06 -0400 Subject: [SCSI] sym53c8xx: Remove ->device_id Following the same path as ->revision_id, remove ->device_id Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_fw.c | 4 ++-- drivers/scsi/sym53c8xx_2/sym_glue.c | 4 +--- drivers/scsi/sym53c8xx_2/sym_glue.h | 1 - drivers/scsi/sym53c8xx_2/sym_hipd.c | 16 ++++++++-------- drivers/scsi/sym53c8xx_2/sym_hipd.h | 1 - drivers/scsi/sym53c8xx_2/sym_nvram.c | 2 +- 6 files changed, 12 insertions(+), 16 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c index 2be0ae17e06c..3d4db802c06f 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw.c +++ b/drivers/scsi/sym53c8xx_2/sym_fw.c @@ -205,13 +205,13 @@ sym_fw2_patch(struct sym_hcb *np) * Remove a couple of work-arounds specific to C1010 if * they are not desirable. See `sym_fw2.h' for more details. */ - if (!(np->device_id == PCI_DEVICE_ID_LSI_53C1010_66 && + if (!(np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_66 && np->s.device->revision < 0x1 && np->pciclk_khz < 60000)) { scripta0->datao_phase[0] = cpu_to_scr(SCR_NO_OP); scripta0->datao_phase[1] = cpu_to_scr(0); } - if (!(np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 /* && + if (!(np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 /* && np->s.device->revision < 0xff */)) { scripta0->sel_done[0] = cpu_to_scr(SCR_NO_OP); scripta0->sel_done[1] = cpu_to_scr(0); diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 3ed3ed86d350..cbe31f2923bc 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1255,7 +1255,7 @@ static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " "revision id 0x%x\n", np->s.chip_name, - np->device_id, np->s.device->revision); + np->s.device->device, np->s.device->revision); copy_info(&info, "At PCI address %s, IRQ " IRQ_FMT "\n", pci_name(np->s.device), IRQ_PRM(np->s.device->irq)); copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", @@ -1410,7 +1410,6 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, np->verbose = sym_driver_setup.verbose; np->s.device = pdev; np->s.unit = unit; - np->device_id = dev->chip.device_id; np->features = dev->chip.features; np->clock_divn = dev->chip.nr_divisor; np->maxoffs = dev->chip.offset_max; @@ -1528,7 +1527,6 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, static void __devinit sym_get_nvram(struct sym_device *devp, struct sym_nvram *nvp) { devp->nvram = nvp; - devp->device_id = devp->chip.device_id; nvp->type = 0; sym_read_nvram(devp, nvp); diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index d5ba5aae6c5a..b961f704ccb1 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -212,7 +212,6 @@ struct sym_device { } s; struct sym_chip chip; struct sym_nvram *nvram; - u_short device_id; u_char host_id; }; diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 9f4198ce845e..5443394a60e5 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -804,7 +804,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * In dual channel mode, contention occurs if internal cycles * are used. Disable internal cycles. */ - if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 && + if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 && np->s.device->revision < 0x1) np->rv_ccntl0 |= DILS; @@ -828,9 +828,9 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * this driver. The generic ncr driver that does not use * LOAD/STORE instructions does not need this work-around. */ - if ((np->device_id == PCI_DEVICE_ID_NCR_53C810 && + if ((np->s.device->device == PCI_DEVICE_ID_NCR_53C810 && np->s.device->revision >= 0x10 && np->s.device->revision <= 0x11) || - (np->device_id == PCI_DEVICE_ID_NCR_53C860 && + (np->s.device->device == PCI_DEVICE_ID_NCR_53C860 && np->s.device->revision <= 0x1)) np->features &= ~(FE_WRIE|FE_ERL|FE_ERMP); @@ -897,7 +897,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru if ((SYM_SETUP_SCSI_LED || (nvram->type == SYM_SYMBIOS_NVRAM || (nvram->type == SYM_TEKRAM_NVRAM && - np->device_id == PCI_DEVICE_ID_NCR_53C895))) && + np->s.device->device == PCI_DEVICE_ID_NCR_53C895))) && !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01)) np->features |= FE_LED0; @@ -1798,7 +1798,7 @@ void sym_start_up (struct sym_hcb *np, int reason) /* * For now, disable AIP generation on C1010-66. */ - if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_66) + if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_66) OUTB(np, nc_aipcntl1, DISAIP); /* @@ -1808,7 +1808,7 @@ void sym_start_up (struct sym_hcb *np, int reason) * that from SCRIPTS for each selection/reselection, but * I just don't want. :) */ - if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 && + if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 && np->s.device->revision < 1) OUTB(np, nc_stest1, INB(np, nc_stest1) | 0x30); @@ -1817,9 +1817,9 @@ void sym_start_up (struct sym_hcb *np, int reason) * Disable overlapped arbitration for some dual function devices, * regardless revision id (kind of post-chip-design feature. ;-)) */ - if (np->device_id == PCI_DEVICE_ID_NCR_53C875) + if (np->s.device->device == PCI_DEVICE_ID_NCR_53C875) OUTB(np, nc_ctest0, (1<<5)); - else if (np->device_id == PCI_DEVICE_ID_NCR_53C896) + else if (np->s.device->device == PCI_DEVICE_ID_NCR_53C896) np->rv_ccntl0 |= DPR; /* diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index 3aa8060a4d2a..b8908e10162a 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -918,7 +918,6 @@ struct sym_hcb { /* * General controller parameters and configuration. */ - u_short device_id; /* PCI device id */ u_int features; /* Chip features map */ u_char myaddr; /* SCSI id of the adapter */ u_char maxburst; /* log base 2 of dwords burst */ diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.c b/drivers/scsi/sym53c8xx_2/sym_nvram.c index 15d69298ab6e..5662fbb3ff60 100644 --- a/drivers/scsi/sym53c8xx_2/sym_nvram.c +++ b/drivers/scsi/sym53c8xx_2/sym_nvram.c @@ -696,7 +696,7 @@ static int sym_read_Tekram_nvram (struct sym_device *np, Tekram_nvram *nvram) u_short csum; int x; - switch (np->device_id) { + switch (np->pdev->device) { case PCI_DEVICE_ID_NCR_53C885: case PCI_DEVICE_ID_NCR_53C895: case PCI_DEVICE_ID_NCR_53C896: -- cgit v1.2.3 From 8637baa3609afff9fe4c65ad4c64d72484c699fc Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:07 -0400 Subject: [SCSI] sym53c8xx: Remove io_ws, mmio_ws and ram_ws elements These struct elements record info that is never needed Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 5 +---- drivers/scsi/sym53c8xx_2/sym_glue.h | 1 - drivers/scsi/sym53c8xx_2/sym_hipd.c | 7 ++----- drivers/scsi/sym53c8xx_2/sym_hipd.h | 3 --- 4 files changed, 3 insertions(+), 13 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index cbe31f2923bc..6e768c542225 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1432,17 +1432,14 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, np->mmio_ba = (u32)dev->mmio_base; np->s.ioaddr = dev->s.ioaddr; np->s.ramaddr = dev->s.ramaddr; - np->s.io_ws = (np->features & FE_IO256) ? 256 : 128; /* * Map on-chip RAM if present and supported. */ if (!(np->features & FE_RAM)) dev->ram_base = 0; - if (dev->ram_base) { + if (dev->ram_base) np->ram_ba = (u32)dev->ram_base; - np->ram_ws = (np->features & FE_RAM8K) ? 8192 : 4096; - } if (sym_hcb_attach(instance, fw, dev->nvram)) goto attach_failed; diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index b961f704ccb1..ab2de1ca9438 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -184,7 +184,6 @@ struct sym_shcb { void __iomem * ioaddr; /* MMIO kernel io address */ void __iomem * ramaddr; /* RAM kernel io address */ - u_short io_ws; /* IO window size */ struct timer_list timer; /* Timer handler link header */ u_long lasttime; diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 5443394a60e5..39f84bbe6856 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -1910,7 +1910,7 @@ void sym_start_up (struct sym_hcb *np, int reason) if (sym_verbose >= 2) printf("%s: Downloading SCSI SCRIPTS.\n", sym_name(np)); memcpy_toio(np->s.ramaddr, np->scripta0, np->scripta_sz); - if (np->ram_ws == 8192) { + if (np->features & FE_RAM8K) { memcpy_toio(np->s.ramaddr + 4096, np->scriptb0, np->scriptb_sz); phys = scr_to_cpu(np->scr_ram_seg); OUTL(np, nc_mmws, phys); @@ -5595,16 +5595,13 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram np->scriptz_ba = vtobus(np->scriptz0); if (np->ram_ba) { - np->scripta_ba = np->ram_ba; + np->scripta_ba = np->ram_ba; if (np->features & FE_RAM8K) { - np->ram_ws = 8192; np->scriptb_ba = np->scripta_ba + 4096; #if 0 /* May get useful for 64 BIT PCI addressing */ np->scr_ram_seg = cpu_to_scr(np->scripta_ba >> 32); #endif } - else - np->ram_ws = 4096; } /* diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index b8908e10162a..f76b27f0aa2c 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -883,10 +883,7 @@ struct sym_hcb { * Physical bus addresses of the chip. */ u32 mmio_ba; /* MMIO 32 bit BUS address */ - int mmio_ws; /* MMIO Window size */ - u32 ram_ba; /* RAM 32 bit BUS address */ - int ram_ws; /* RAM window size */ /* * SCRIPTS virtual and physical bus addresses. -- cgit v1.2.3 From a44131b35ec1a46ed75014d818cb9d5706117b49 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:08 -0400 Subject: [SCSI] sym53c8xx: Remove tag_ctrl module parameter With sysfs making these options tunable at runtime, there's no justification for keeping this horrendously complex specification string around. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym53c8xx.h | 1 - drivers/scsi/sym53c8xx_2/sym_glue.c | 66 ++---------------------------------- 2 files changed, 3 insertions(+), 64 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym53c8xx.h b/drivers/scsi/sym53c8xx_2/sym53c8xx.h index 7519728dfc38..62d29cfac9e4 100644 --- a/drivers/scsi/sym53c8xx_2/sym53c8xx.h +++ b/drivers/scsi/sym53c8xx_2/sym53c8xx.h @@ -127,7 +127,6 @@ struct sym_driver_setup { u_char settle_delay; u_char use_nvram; u_long excludes[8]; - char tag_ctrl[100]; }; #define SYM_SETUP_MAX_TAG sym_driver_setup.max_tag diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 6e768c542225..c1d9f6989664 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -63,7 +63,6 @@ unsigned int sym_debug_flags = 0; static char *excl_string; static char *safe_string; module_param_named(cmd_per_lun, sym_driver_setup.max_tag, ushort, 0); -module_param_string(tag_ctrl, sym_driver_setup.tag_ctrl, 100, 0); module_param_named(burst, sym_driver_setup.burst_order, byte, 0); module_param_named(led, sym_driver_setup.scsi_led, byte, 0); module_param_named(diff, sym_driver_setup.scsi_diff, byte, 0); @@ -78,7 +77,6 @@ module_param_named(excl, excl_string, charp, 0); module_param_named(safe, safe_string, charp, 0); MODULE_PARM_DESC(cmd_per_lun, "The maximum number of tags to use by default"); -MODULE_PARM_DESC(tag_ctrl, "More detailed control over tags per LUN"); MODULE_PARM_DESC(burst, "Maximum burst. 0 to disable, 255 to read from registers"); MODULE_PARM_DESC(led, "Set to 1 to enable LED support"); MODULE_PARM_DESC(diff, "0 for no differential mode, 1 for BIOS, 2 for always, 3 for not GPIO3"); @@ -744,59 +742,6 @@ static void sym_tune_dev_queuing(struct sym_tcb *tp, int lun, u_short reqtags) } } -/* - * Linux select queue depths function - */ -#define DEF_DEPTH (sym_driver_setup.max_tag) -#define ALL_TARGETS -2 -#define NO_TARGET -1 -#define ALL_LUNS -2 -#define NO_LUN -1 - -static int device_queue_depth(struct sym_hcb *np, int target, int lun) -{ - int c, h, t, u, v; - char *p = sym_driver_setup.tag_ctrl; - char *ep; - - h = -1; - t = NO_TARGET; - u = NO_LUN; - while ((c = *p++) != 0) { - v = simple_strtoul(p, &ep, 0); - switch(c) { - case '/': - ++h; - t = ALL_TARGETS; - u = ALL_LUNS; - break; - case 't': - if (t != target) - t = (target == v) ? v : NO_TARGET; - u = ALL_LUNS; - break; - case 'u': - if (u != lun) - u = (lun == v) ? v : NO_LUN; - break; - case 'q': - if (h == np->s.unit && - (t == ALL_TARGETS || t == target) && - (u == ALL_LUNS || u == lun)) - return v; - break; - case '-': - t = ALL_TARGETS; - u = ALL_LUNS; - break; - default: - break; - } - p = ep; - } - return DEF_DEPTH; -} - static int sym53c8xx_slave_alloc(struct scsi_device *sdev) { struct sym_hcb *np = sym_get_hcb(sdev->host); @@ -861,21 +806,16 @@ static int sym53c8xx_slave_configure(struct scsi_device *sdev) * Use at least 2. * Donnot use more than our maximum. */ - reqtags = device_queue_depth(np, sdev->id, sdev->lun); + reqtags = sym_driver_setup.max_tag; if (reqtags > tp->usrtags) reqtags = tp->usrtags; if (!sdev->tagged_supported) reqtags = 0; -#if 1 /* Avoid to locally queue commands for no good reasons */ if (reqtags > SYM_CONF_MAX_TAG) reqtags = SYM_CONF_MAX_TAG; - depth_to_use = (reqtags ? reqtags : 2); -#else - depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2); -#endif + depth_to_use = reqtags ? reqtags : 2; scsi_adjust_queue_depth(sdev, - (sdev->tagged_supported ? - MSG_SIMPLE_TAG : 0), + sdev->tagged_supported ? MSG_SIMPLE_TAG : 0, depth_to_use); lp->s.scdev_depth = depth_to_use; sym_tune_dev_queuing(tp, sdev->lun, reqtags); -- cgit v1.2.3 From 4d85b471593d03e141f9160a58574b9204363267 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:09 -0400 Subject: [SCSI] sym53c8xx: Simplify DAC DMA handling By introducing the use_dac(), set_dac() and DMA_DAC_MASK macros, we can eliminate a lot of ifdefs from the code. We now rely on the compiler to optimise away a few things that we'd formerly relied on the preprocessor to do. This makes sym_setup_bus_dma_mask() small enough to inline into its only caller. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_fw.c | 2 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 32 ++++++-------------------------- drivers/scsi/sym53c8xx_2/sym_hipd.c | 23 ++++++++--------------- drivers/scsi/sym53c8xx_2/sym_hipd.h | 11 +++++++++++ 4 files changed, 26 insertions(+), 42 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c index 3d4db802c06f..aa230d23eda4 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw.c +++ b/drivers/scsi/sym53c8xx_2/sym_fw.c @@ -167,7 +167,7 @@ sym_fw2_patch(struct sym_hcb *np) * Remove useless 64 bit DMA specific SCRIPTS, * when this feature is not available. */ - if (!np->use_dac) { + if (!use_dac(np)) { scripta0->is_dmap_dirty[0] = cpu_to_scr(SCR_NO_OP); scripta0->is_dmap_dirty[1] = 0; scripta0->is_dmap_dirty[2] = cpu_to_scr(SCR_NO_OP); diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index c1d9f6989664..55012970912b 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1264,31 +1264,6 @@ static void sym_free_resources(struct sym_hcb *np, struct pci_dev *pdev) sym_mfree_dma(np, sizeof(*np), "HCB"); } -/* - * Ask/tell the system about DMA addressing. - */ -static int sym_setup_bus_dma_mask(struct sym_hcb *np) -{ -#if SYM_CONF_DMA_ADDRESSING_MODE > 0 -#if SYM_CONF_DMA_ADDRESSING_MODE == 1 -#define DMA_DAC_MASK DMA_40BIT_MASK -#elif SYM_CONF_DMA_ADDRESSING_MODE == 2 -#define DMA_DAC_MASK DMA_64BIT_MASK -#endif - if ((np->features & FE_DAC) && - !pci_set_dma_mask(np->s.device, DMA_DAC_MASK)) { - np->use_dac = 1; - return 0; - } -#endif - - if (!pci_set_dma_mask(np->s.device, DMA_32BIT_MASK)) - return 0; - - printf_warning("%s: No suitable DMA available\n", sym_name(np)); - return -1; -} - /* * Host attach and initialisations. * @@ -1362,8 +1337,13 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, strlcpy(np->s.chip_name, dev->chip.name, sizeof(np->s.chip_name)); sprintf(np->s.inst_name, "sym%d", np->s.unit); - if (sym_setup_bus_dma_mask(np)) + if ((SYM_CONF_DMA_ADDRESSING_MODE > 0) && (np->features & FE_DAC) && + !pci_set_dma_mask(np->s.device, DMA_DAC_MASK)) { + set_dac(np); + } else if (pci_set_dma_mask(np->s.device, DMA_32BIT_MASK)) { + printf_warning("%s: No suitable DMA available\n", sym_name(np)); goto attach_failed; + } /* * Try to map the controller chip to diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 39f84bbe6856..5d0d356e1e74 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -778,19 +778,12 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * 64 bit addressing (895A/896/1010) ? */ if (np->features & FE_DAC) { -#if SYM_CONF_DMA_ADDRESSING_MODE == 0 - np->rv_ccntl1 |= (DDAC); -#elif SYM_CONF_DMA_ADDRESSING_MODE == 1 - if (!np->use_dac) - np->rv_ccntl1 |= (DDAC); - else - np->rv_ccntl1 |= (XTIMOD | EXTIBMV); -#elif SYM_CONF_DMA_ADDRESSING_MODE == 2 - if (!np->use_dac) - np->rv_ccntl1 |= (DDAC); - else - np->rv_ccntl1 |= (0 | EXTIBMV); -#endif + if (!use_dac(np)) + np->rv_ccntl1 |= (DDAC); + else if (SYM_CONF_DMA_ADDRESSING_MODE == 1) + np->rv_ccntl1 |= (XTIMOD | EXTIBMV); + else if (SYM_CONF_DMA_ADDRESSING_MODE == 2) + np->rv_ccntl1 |= (0 | EXTIBMV); } /* @@ -1322,7 +1315,7 @@ int sym_lookup_dmap(struct sym_hcb *np, u32 h, int s) { int i; - if (!np->use_dac) + if (!use_dac(np)) goto weird; /* Look up existing mappings */ @@ -1837,7 +1830,7 @@ void sym_start_up (struct sym_hcb *np, int reason) * Set up scratch C and DRS IO registers to map the 32 bit * DMA address range our data structures are located in. */ - if (np->use_dac) { + if (use_dac(np)) { np->dmap_bah[0] = 0; /* ??? */ OUTL(np, nc_scrx[0], np->dmap_bah[0]); OUTL(np, nc_drs, np->dmap_bah[0]); diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index f76b27f0aa2c..4354571a63ef 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -1026,6 +1026,14 @@ struct sym_hcb { #endif }; +#if SYM_CONF_DMA_ADDRESSING_MODE == 0 +#define use_dac(np) 0 +#define set_dac(np) do { } while (0) +#else +#define use_dac(np) (np)->use_dac +#define set_dac(np) (np)->use_dac = 1 +#endif + #define HCB_BA(np, lbl) (np->hcb_ba + offsetof(struct sym_hcb, lbl)) @@ -1068,18 +1076,21 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram */ #if SYM_CONF_DMA_ADDRESSING_MODE == 0 +#define DMA_DAC_MASK DMA_32BIT_MASK #define sym_build_sge(np, data, badd, len) \ do { \ (data)->addr = cpu_to_scr(badd); \ (data)->size = cpu_to_scr(len); \ } while (0) #elif SYM_CONF_DMA_ADDRESSING_MODE == 1 +#define DMA_DAC_MASK DMA_40BIT_MASK #define sym_build_sge(np, data, badd, len) \ do { \ (data)->addr = cpu_to_scr(badd); \ (data)->size = cpu_to_scr((((badd) >> 8) & 0xff000000) + len); \ } while (0) #elif SYM_CONF_DMA_ADDRESSING_MODE == 2 +#define DMA_DAC_MASK DMA_64BIT_MASK int sym_lookup_dmap(struct sym_hcb *np, u32 h, int s); static __inline void sym_build_sge(struct sym_hcb *np, struct sym_tblmove *data, u64 badd, int len) -- cgit v1.2.3 From 3fb364e089e05c35ead55a08d56d3004193681f6 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:10 -0400 Subject: [SCSI] sym53c8xx: Use scmd_printk where appropriate If we have a scsi_cmnd, it gives the user more information than the sym_name, and maybe the target. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 4 ++-- drivers/scsi/sym53c8xx_2/sym_hipd.c | 35 +++++++++++++++++------------------ 2 files changed, 19 insertions(+), 20 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 55012970912b..84a0fc571ceb 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -392,7 +392,7 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s */ switch (dir) { case DMA_BIDIRECTIONAL: - printk("%s: got DMA_BIDIRECTIONAL command", sym_name(np)); + scmd_printk(KERN_INFO, cmd, "got DMA_BIDIRECTIONAL command"); sym_set_cam_status(cmd, DID_ERROR); goto out_abort; case DMA_TO_DEVICE: @@ -606,7 +606,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) int sts = -1; struct completion eh_done; - dev_warn(&cmd->device->sdev_gendev, "%s operation started.\n", opname); + scmd_printk(KERN_WARNING, cmd, "%s operation started.\n", opname); /* We may be in an error condition because the PCI bus * went down. In this case, we need to wait until the diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 5d0d356e1e74..13fd5b2c56fc 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -52,7 +52,7 @@ * Needed function prototypes. */ static void sym_int_ma (struct sym_hcb *np); -static void sym_int_sir (struct sym_hcb *np); +static void sym_int_sir(struct sym_hcb *); static struct sym_ccb *sym_alloc_ccb(struct sym_hcb *np); static struct sym_ccb *sym_ccb_from_dsa(struct sym_hcb *np, u32 dsa); static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln); @@ -1522,7 +1522,8 @@ void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) np->squeueput = qidx; if (DEBUG_FLAGS & DEBUG_QUEUE) - printf ("%s: queuepos=%d.\n", sym_name (np), np->squeueput); + scmd_printk(KERN_DEBUG, cp->cmd, "queuepos=%d\n", + np->squeueput); /* * Script processor may be waiting for reselect. @@ -2852,7 +2853,7 @@ void sym_interrupt (struct sym_hcb *np) !(dstat & (MDPE|BF|ABRT|IID))) { if (sist & PAR) sym_int_par (np, sist); else if (sist & MA) sym_int_ma (np); - else if (dstat & SIR) sym_int_sir (np); + else if (dstat & SIR) sym_int_sir(np); else if (dstat & SSI) OUTONB_STD(); else goto unknown_int; return; @@ -4314,7 +4315,7 @@ static void sym_nego_rejected(struct sym_hcb *np, struct sym_tcb *tp, struct sym /* * chip exception handler for programmed interrupts. */ -static void sym_int_sir (struct sym_hcb *np) +static void sym_int_sir(struct sym_hcb *np) { u_char num = INB(np, nc_dsps); u32 dsa = INL(np, nc_dsa); @@ -4353,31 +4354,30 @@ static void sym_int_sir (struct sym_hcb *np) return; /* * The device didn't go to MSG OUT phase after having - * been selected with ATN. We donnot want to handle - * that. + * been selected with ATN. We do not want to handle that. */ case SIR_SEL_ATN_NO_MSG_OUT: - printf ("%s:%d: No MSG OUT phase after selection with ATN.\n", - sym_name (np), target); + scmd_printk(KERN_WARNING, cp->cmd, + "No MSG OUT phase after selection with ATN\n"); goto out_stuck; /* * The device didn't switch to MSG IN phase after - * having reseleted the initiator. + * having reselected the initiator. */ case SIR_RESEL_NO_MSG_IN: - printf ("%s:%d: No MSG IN phase after reselection.\n", - sym_name (np), target); + scmd_printk(KERN_WARNING, cp->cmd, + "No MSG IN phase after reselection\n"); goto out_stuck; /* * After reselection, the device sent a message that wasn't * an IDENTIFY. */ case SIR_RESEL_NO_IDENTIFY: - printf ("%s:%d: No IDENTIFY after reselection.\n", - sym_name (np), target); + scmd_printk(KERN_WARNING, cp->cmd, + "No IDENTIFY after reselection\n"); goto out_stuck; /* - * The device reselected a LUN we donnot know about. + * The device reselected a LUN we do not know about. */ case SIR_RESEL_BAD_LUN: np->msgout[0] = M_RESET; @@ -4390,8 +4390,7 @@ static void sym_int_sir (struct sym_hcb *np) np->msgout[0] = M_ABORT; goto out; /* - * The device reselected for a tagged nexus that we donnot - * have. + * The device reselected for a tagged nexus that we do not have. */ case SIR_RESEL_BAD_I_T_L_Q: np->msgout[0] = M_ABORT_TAG; @@ -4403,8 +4402,8 @@ static void sym_int_sir (struct sym_hcb *np) case SIR_RESEL_ABORTED: np->lastmsg = np->msgout[0]; np->msgout[0] = M_NOOP; - printf ("%s:%d: message %x sent on bad reselection.\n", - sym_name (np), target, np->lastmsg); + scmd_printk(KERN_WARNING, cp->cmd, + "message %x sent on bad reselection\n", np->lastmsg); goto out; /* * The SCRIPTS let us know that a message has been -- cgit v1.2.3 From 8022fbdacb0e9193a5dfb666479d1fc2ca63ecf1 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:11 -0400 Subject: [SCSI] sym53c8xx: Get rid of IRQ_FMT and IRQ_PRM These macros aren't needed any more. They used to be used for SPARC. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 84a0fc571ceb..9521f0ea4129 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -54,9 +54,6 @@ #define NAME53C "sym53c" #define NAME53C8XX "sym53c8xx" -#define IRQ_FMT "%d" -#define IRQ_PRM(x) (x) - struct sym_driver_setup sym_driver_setup = SYM_LINUX_DRIVER_SETUP; unsigned int sym_debug_flags = 0; @@ -1196,8 +1193,8 @@ static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " "revision id 0x%x\n", np->s.chip_name, np->s.device->device, np->s.device->revision); - copy_info(&info, "At PCI address %s, IRQ " IRQ_FMT "\n", - pci_name(np->s.device), IRQ_PRM(np->s.device->irq)); + copy_info(&info, "At PCI address %s, IRQ %u\n", + pci_name(np->s.device), np->s.device->irq); copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", (int) (np->minsync_dt ? np->minsync_dt : np->minsync), np->maxwide ? "Wide" : "Narrow", @@ -1283,9 +1280,9 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, unsigned long flags; struct sym_fw *fw; - printk(KERN_INFO "sym%d: <%s> rev 0x%x at pci %s irq " IRQ_FMT "\n", + printk(KERN_INFO "sym%d: <%s> rev 0x%x at pci %s irq %u\n", unit, dev->chip.name, pdev->revision, pci_name(pdev), - IRQ_PRM(pdev->irq)); + pdev->irq); /* * Get the firmware for this chip. @@ -1370,7 +1367,7 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, * we do not want to share the INTR line at all. */ if (request_irq(pdev->irq, sym53c8xx_intr, IRQF_SHARED, NAME53C8XX, np)) { - printf_err("%s: request irq %d failure\n", + printf_err("%s: request irq %u failure\n", sym_name(np), pdev->irq); goto attach_failed; } -- cgit v1.2.3 From 99c9e0a1d6cfe1ba1169a7a81435ee85bc00e4a1 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:12 -0400 Subject: [SCSI] sym53c8xx: Make interrupt handler capable of returning IRQ_NONE Make sym_interrupt return an irqreturn_t instead of void, and take a Scsi_Host instead of a sym_hcb. Pass the Scsi_Host to the interrupt handler instead of the sym_hcb. Rename the host_data to sym_data. Keep a pci_dev pointer in the sym_data. Rename the Scsi_Host from instance to shost. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 107 ++++++++++++++++++------------------ drivers/scsi/sym53c8xx_2/sym_glue.h | 6 +- drivers/scsi/sym53c8xx_2/sym_hipd.c | 16 +++--- drivers/scsi/sym53c8xx_2/sym_hipd.h | 2 +- 4 files changed, 66 insertions(+), 65 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 9521f0ea4129..1c18b3b9aa15 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -39,7 +39,6 @@ */ #include #include -#include #include #include #include @@ -549,21 +548,23 @@ static int sym53c8xx_queue_command(struct scsi_cmnd *cmd, */ static irqreturn_t sym53c8xx_intr(int irq, void *dev_id) { - struct sym_hcb *np = dev_id; + struct Scsi_Host *shost = dev_id; + struct sym_data *sym_data = shost_priv(shost); + irqreturn_t result; /* Avoid spinloop trying to handle interrupts on frozen device */ - if (pci_channel_offline(np->s.device)) + if (pci_channel_offline(sym_data->pdev)) return IRQ_NONE; if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("["); - spin_lock(np->s.host->host_lock); - sym_interrupt(np); - spin_unlock(np->s.host->host_lock); + spin_lock(shost->host_lock); + result = sym_interrupt(shost); + spin_unlock(shost->host_lock); if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("]\n"); - return IRQ_HANDLED; + return result; } /* @@ -613,22 +614,19 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) */ #define WAIT_FOR_PCI_RECOVERY 35 if (pci_channel_offline(pdev)) { - struct host_data *hostdata = shost_priv(host); + struct sym_data *sym_data = shost_priv(host); struct completion *io_reset; int finished_reset = 0; init_completion(&eh_done); spin_lock_irq(host->host_lock); /* Make sure we didn't race */ if (pci_channel_offline(pdev)) { - if (!hostdata->io_reset) - hostdata->io_reset = &eh_done; - io_reset = hostdata->io_reset; + if (!sym_data->io_reset) + sym_data->io_reset = &eh_done; + io_reset = sym_data->io_reset; } else { - io_reset = NULL; - } - - if (!pci_channel_offline(pdev)) finished_reset = 1; + } spin_unlock_irq(host->host_lock); if (!finished_reset) finished_reset = wait_for_completion_timeout(io_reset, @@ -1273,9 +1271,9 @@ static void sym_free_resources(struct sym_hcb *np, struct pci_dev *pdev) static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, int unit, struct sym_device *dev) { - struct host_data *host_data; + struct sym_data *sym_data; struct sym_hcb *np = NULL; - struct Scsi_Host *instance = NULL; + struct Scsi_Host *shost; struct pci_dev *pdev = dev->pdev; unsigned long flags; struct sym_fw *fw; @@ -1289,15 +1287,12 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, */ fw = sym_find_firmware(&dev->chip); if (!fw) - goto attach_failed; + return NULL; - /* - * Allocate host_data structure - */ - instance = scsi_host_alloc(tpnt, sizeof(*host_data)); - if (!instance) - goto attach_failed; - host_data = (struct host_data *) instance->hostdata; + shost = scsi_host_alloc(tpnt, sizeof(*sym_data)); + if (!shost) + return NULL; + sym_data = shost_priv(shost); /* * Allocate immediately the host control block, @@ -1310,8 +1305,9 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, goto attach_failed; np->s.device = pdev; np->bus_dmat = &pdev->dev; /* Result in 1 DMA pool per HBA */ - host_data->ncb = np; - np->s.host = instance; + sym_data->ncb = np; + sym_data->pdev = pdev; + np->s.host = shost; pci_set_drvdata(pdev, np); @@ -1358,7 +1354,7 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, if (dev->ram_base) np->ram_ba = (u32)dev->ram_base; - if (sym_hcb_attach(instance, fw, dev->nvram)) + if (sym_hcb_attach(shost, fw, dev->nvram)) goto attach_failed; /* @@ -1366,7 +1362,8 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, * If we synchonize the C code with SCRIPTS on interrupt, * we do not want to share the INTR line at all. */ - if (request_irq(pdev->irq, sym53c8xx_intr, IRQF_SHARED, NAME53C8XX, np)) { + if (request_irq(pdev->irq, sym53c8xx_intr, IRQF_SHARED, NAME53C8XX, + shost)) { printf_err("%s: request irq %u failure\n", sym_name(np), pdev->irq); goto attach_failed; @@ -1376,7 +1373,7 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, * After SCSI devices have been opened, we cannot * reset the bus safely, so we do it here. */ - spin_lock_irqsave(instance->host_lock, flags); + spin_lock_irqsave(shost->host_lock, flags); if (sym_reset_scsi_bus(np, 0)) goto reset_failed; @@ -1398,37 +1395,37 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, * Fill Linux host instance structure * and return success. */ - instance->max_channel = 0; - instance->this_id = np->myaddr; - instance->max_id = np->maxwide ? 16 : 8; - instance->max_lun = SYM_CONF_MAX_LUN; - instance->unique_id = pci_resource_start(pdev, 0); - instance->cmd_per_lun = SYM_CONF_MAX_TAG; - instance->can_queue = (SYM_CONF_MAX_START-2); - instance->sg_tablesize = SYM_CONF_MAX_SG; - instance->max_cmd_len = 16; + shost->max_channel = 0; + shost->this_id = np->myaddr; + shost->max_id = np->maxwide ? 16 : 8; + shost->max_lun = SYM_CONF_MAX_LUN; + shost->unique_id = pci_resource_start(pdev, 0); + shost->cmd_per_lun = SYM_CONF_MAX_TAG; + shost->can_queue = (SYM_CONF_MAX_START-2); + shost->sg_tablesize = SYM_CONF_MAX_SG; + shost->max_cmd_len = 16; BUG_ON(sym2_transport_template == NULL); - instance->transportt = sym2_transport_template; + shost->transportt = sym2_transport_template; /* 53c896 rev 1 errata: DMA may not cross 16MB boundary */ if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 2) - instance->dma_boundary = 0xFFFFFF; + shost->dma_boundary = 0xFFFFFF; - spin_unlock_irqrestore(instance->host_lock, flags); + spin_unlock_irqrestore(shost->host_lock, flags); - return instance; + return shost; reset_failed: printf_err("%s: FATAL ERROR: CHECK SCSI BUS - CABLES, " "TERMINATION, DEVICE POWER etc.!\n", sym_name(np)); - spin_unlock_irqrestore(instance->host_lock, flags); + spin_unlock_irqrestore(shost->host_lock, flags); attach_failed: - if (!instance) + if (!shost) return NULL; printf_info("%s: giving up ...\n", sym_name(np)); if (np) sym_free_resources(np, pdev); - scsi_host_put(instance); + scsi_host_put(shost); return NULL; } @@ -1702,7 +1699,7 @@ static int __devinit sym2_probe(struct pci_dev *pdev, { struct sym_device sym_dev; struct sym_nvram nvram; - struct Scsi_Host *instance; + struct Scsi_Host *shost; memset(&sym_dev, 0, sizeof(sym_dev)); memset(&nvram, 0, sizeof(nvram)); @@ -1729,13 +1726,13 @@ static int __devinit sym2_probe(struct pci_dev *pdev, sym_get_nvram(&sym_dev, &nvram); - instance = sym_attach(&sym2_template, attach_count, &sym_dev); - if (!instance) + shost = sym_attach(&sym2_template, attach_count, &sym_dev); + if (!shost) goto free; - if (scsi_add_host(instance, &pdev->dev)) + if (scsi_add_host(shost, &pdev->dev)) goto detach; - scsi_scan_host(instance); + scsi_scan_host(shost); attach_count++; @@ -1884,12 +1881,12 @@ static void sym2_io_resume(struct pci_dev *pdev) { struct sym_hcb *np = pci_get_drvdata(pdev); struct Scsi_Host *shost = np->s.host; - struct host_data *hostdata = shost_priv(shost); + struct sym_data *sym_data = shost_priv(shost); spin_lock_irq(shost->host_lock); - if (hostdata->io_reset) - complete_all(hostdata->io_reset); - hostdata->io_reset = NULL; + if (sym_data->io_reset) + complete_all(sym_data->io_reset); + sym_data->io_reset = NULL; spin_unlock_irq(shost->host_lock); } diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index ab2de1ca9438..98261a5af87d 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -217,14 +218,15 @@ struct sym_device { /* * Driver host data structure. */ -struct host_data { +struct sym_data { struct sym_hcb *ncb; struct completion *io_reset; /* PCI error handling */ + struct pci_dev *pdev; }; static inline struct sym_hcb * sym_get_hcb(struct Scsi_Host *host) { - return ((struct host_data *)host->hostdata)->ncb; + return ((struct sym_data *)host->hostdata)->ncb; } #include "sym_fw.h" diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 13fd5b2c56fc..5d2079f9e596 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -2760,8 +2760,9 @@ reset_all: * Use at your own decision and risk. */ -void sym_interrupt (struct sym_hcb *np) +irqreturn_t sym_interrupt(struct Scsi_Host *shost) { + struct sym_hcb *np = sym_get_hcb(shost); u_char istat, istatc; u_char dstat; u_short sist; @@ -2786,7 +2787,7 @@ void sym_interrupt (struct sym_hcb *np) } if (!(istat & (SIP|DIP))) - return; + return (istat & INTF) ? IRQ_HANDLED : IRQ_NONE; #if 0 /* We should never get this one */ if (istat & CABRT) @@ -2818,7 +2819,7 @@ void sym_interrupt (struct sym_hcb *np) * never clear. */ if (unlikely(sist == 0xffff && dstat == 0xff)) { if (pci_channel_offline(np->s.device)) - return; + return IRQ_NONE; } } while (istatc & (SIP|DIP)); @@ -2856,7 +2857,7 @@ void sym_interrupt (struct sym_hcb *np) else if (dstat & SIR) sym_int_sir(np); else if (dstat & SSI) OUTONB_STD(); else goto unknown_int; - return; + return IRQ_HANDLED; } /* @@ -2873,7 +2874,7 @@ void sym_interrupt (struct sym_hcb *np) if (sist & RST) { printf("%s: SCSI BUS reset detected.\n", sym_name(np)); sym_start_up (np, 1); - return; + return IRQ_HANDLED; } OUTB(np, nc_ctest3, np->rv_ctest3 | CLF); /* clear dma fifo */ @@ -2885,7 +2886,7 @@ void sym_interrupt (struct sym_hcb *np) else if (sist & STO) sym_int_sto (np); else if (sist & UDC) sym_int_udc (np); else goto unknown_int; - return; + return IRQ_HANDLED; } /* @@ -2900,7 +2901,7 @@ void sym_interrupt (struct sym_hcb *np) if ((sist & (GEN|HTH|SGE)) || (dstat & (MDPE|BF|ABRT|IID))) { sym_start_reset(np); - return; + return IRQ_HANDLED; } unknown_int: @@ -2911,6 +2912,7 @@ unknown_int: printf( "%s: unknown interrupt(s) ignored, " "ISTAT=0x%x DSTAT=0x%x SIST=0x%x\n", sym_name(np), istat, dstat, sist); + return IRQ_NONE; } /* diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index 4354571a63ef..a9c08668b98c 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -1056,7 +1056,7 @@ void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn); void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp); #endif void sym_start_up(struct sym_hcb *np, int reason); -void sym_interrupt(struct sym_hcb *np); +irqreturn_t sym_interrupt(struct Scsi_Host *); int sym_clear_tasks(struct sym_hcb *np, int cam_status, int target, int lun, int task); struct sym_ccb *sym_get_ccb(struct sym_hcb *np, struct scsi_cmnd *cmd, u_char tag_order); void sym_free_ccb(struct sym_hcb *np, struct sym_ccb *cp); -- cgit v1.2.3 From 5111eefa17615bdf17ca00ec2cdca16302c7697e Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:13 -0400 Subject: [SCSI] sym53c8xx: Remove pci_dev pointer from sym_shcb This structure is accessed by the device; the fewer Linux things in it, the better. Using the pci_dev pointer from the hostdata requires a lot of changes: - Pass Scsi_Host to a lot of routines which currently take a sym_hcb. - Set the Scsi_Host as the pci drvdata (instead of the sym_hcb) Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_fw.c | 16 +++--- drivers/scsi/sym53c8xx_2/sym_fw.h | 2 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 97 +++++++++++++++++++------------------ drivers/scsi/sym53c8xx_2/sym_glue.h | 5 +- drivers/scsi/sym53c8xx_2/sym_hipd.c | 60 +++++++++++++---------- drivers/scsi/sym53c8xx_2/sym_hipd.h | 4 +- 6 files changed, 99 insertions(+), 85 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c index aa230d23eda4..190770bdc194 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw.c +++ b/drivers/scsi/sym53c8xx_2/sym_fw.c @@ -104,8 +104,9 @@ static struct sym_fwz_ofs sym_fw2z_ofs = { * Patch routine for firmware #1. */ static void -sym_fw1_patch(struct sym_hcb *np) +sym_fw1_patch(struct Scsi_Host *shost) { + struct sym_hcb *np = sym_get_hcb(shost); struct sym_fw1a_scr *scripta0; struct sym_fw1b_scr *scriptb0; @@ -145,8 +146,11 @@ sym_fw1_patch(struct sym_hcb *np) * Patch routine for firmware #2. */ static void -sym_fw2_patch(struct sym_hcb *np) +sym_fw2_patch(struct Scsi_Host *shost) { + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; + struct sym_hcb *np = sym_data->ncb; struct sym_fw2a_scr *scripta0; struct sym_fw2b_scr *scriptb0; @@ -205,14 +209,14 @@ sym_fw2_patch(struct sym_hcb *np) * Remove a couple of work-arounds specific to C1010 if * they are not desirable. See `sym_fw2.h' for more details. */ - if (!(np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_66 && - np->s.device->revision < 0x1 && + if (!(pdev->device == PCI_DEVICE_ID_LSI_53C1010_66 && + pdev->revision < 0x1 && np->pciclk_khz < 60000)) { scripta0->datao_phase[0] = cpu_to_scr(SCR_NO_OP); scripta0->datao_phase[1] = cpu_to_scr(0); } - if (!(np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 /* && - np->s.device->revision < 0xff */)) { + if (!(pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 /* && + pdev->revision < 0xff */)) { scripta0->sel_done[0] = cpu_to_scr(SCR_NO_OP); scripta0->sel_done[1] = cpu_to_scr(0); } diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.h b/drivers/scsi/sym53c8xx_2/sym_fw.h index 66ec35beab5b..ae7e0f9e93fc 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw.h +++ b/drivers/scsi/sym53c8xx_2/sym_fw.h @@ -143,7 +143,7 @@ struct sym_fw { *z_ofs; /* Useful offsets in script Z */ /* Setup and patch methods for this firmware */ void (*setup)(struct sym_hcb *, struct sym_fw *); - void (*patch)(struct sym_hcb *); + void (*patch)(struct Scsi_Host *); }; /* diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 1c18b3b9aa15..df0547afe526 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -497,14 +497,16 @@ static void sym_timer(struct sym_hcb *np) /* * PCI BUS error handler. */ -void sym_log_bus_error(struct sym_hcb *np) +void sym_log_bus_error(struct Scsi_Host *shost) { - u_short pci_sts; - pci_read_config_word(np->s.device, PCI_STATUS, &pci_sts); + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; + unsigned short pci_sts; + pci_read_config_word(pdev, PCI_STATUS, &pci_sts); if (pci_sts & 0xf900) { - pci_write_config_word(np->s.device, PCI_STATUS, pci_sts); - printf("%s: PCI STATUS = 0x%04x\n", - sym_name(np), pci_sts & 0xf900); + pci_write_config_word(pdev, PCI_STATUS, pci_sts); + shost_printk(KERN_WARNING, shost, + "PCI bus error: status = 0x%04x\n", pci_sts & 0xf900); } } @@ -595,16 +597,17 @@ static void sym53c8xx_timer(unsigned long npref) */ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) { - struct sym_hcb *np = SYM_SOFTC_PTR(cmd); struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); - struct Scsi_Host *host = cmd->device->host; - struct pci_dev *pdev = np->s.device; + struct Scsi_Host *shost = cmd->device->host; + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; + struct sym_hcb *np = sym_data->ncb; SYM_QUEHEAD *qp; int cmd_queued = 0; int sts = -1; struct completion eh_done; - scmd_printk(KERN_WARNING, cmd, "%s operation started.\n", opname); + scmd_printk(KERN_WARNING, cmd, "%s operation started\n", opname); /* We may be in an error condition because the PCI bus * went down. In this case, we need to wait until the @@ -614,11 +617,10 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) */ #define WAIT_FOR_PCI_RECOVERY 35 if (pci_channel_offline(pdev)) { - struct sym_data *sym_data = shost_priv(host); struct completion *io_reset; int finished_reset = 0; init_completion(&eh_done); - spin_lock_irq(host->host_lock); + spin_lock_irq(shost->host_lock); /* Make sure we didn't race */ if (pci_channel_offline(pdev)) { if (!sym_data->io_reset) @@ -627,7 +629,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) } else { finished_reset = 1; } - spin_unlock_irq(host->host_lock); + spin_unlock_irq(shost->host_lock); if (!finished_reset) finished_reset = wait_for_completion_timeout(io_reset, WAIT_FOR_PCI_RECOVERY*HZ); @@ -635,7 +637,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) return SCSI_FAILED; } - spin_lock_irq(host->host_lock); + spin_lock_irq(shost->host_lock); /* This one is queued in some place -> to wait for completion */ FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); @@ -660,7 +662,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) break; case SYM_EH_HOST_RESET: sym_reset_scsi_bus(np, 0); - sym_start_up(np, 1); + sym_start_up(shost, 1); sts = 0; break; default: @@ -674,13 +676,13 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) if (cmd_queued) { init_completion(&eh_done); ucmd->eh_done = &eh_done; - spin_unlock_irq(host->host_lock); + spin_unlock_irq(shost->host_lock); if (!wait_for_completion_timeout(&eh_done, 5*HZ)) { ucmd->eh_done = NULL; sts = -2; } } else { - spin_unlock_irq(host->host_lock); + spin_unlock_irq(shost->host_lock); } dev_warn(&cmd->device->sdev_gendev, "%s operation %s.\n", opname, @@ -993,8 +995,9 @@ static int is_keyword(char *ptr, int len, char *verb) * Parse a control command */ -static int sym_user_command(struct sym_hcb *np, char *buffer, int length) +static int sym_user_command(struct Scsi_Host *shost, char *buffer, int length) { + struct sym_hcb *np = sym_get_hcb(shost); char *ptr = buffer; int len = length; struct sym_usrcmd cmd, *uc = &cmd; @@ -1121,9 +1124,9 @@ printk("sym_user_command: data=%ld\n", uc->data); else { unsigned long flags; - spin_lock_irqsave(np->s.host->host_lock, flags); - sym_exec_user_command (np, uc); - spin_unlock_irqrestore(np->s.host->host_lock, flags); + spin_lock_irqsave(shost->host_lock, flags); + sym_exec_user_command(np, uc); + spin_unlock_irqrestore(shost->host_lock, flags); } return length; } @@ -1179,8 +1182,11 @@ static int copy_info(struct info_str *info, char *fmt, ...) /* * Copy formatted information into the input buffer. */ -static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) +static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int len) { + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; + struct sym_hcb *np = sym_data->ncb; struct info_str info; info.buffer = ptr; @@ -1190,9 +1196,9 @@ static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " "revision id 0x%x\n", np->s.chip_name, - np->s.device->device, np->s.device->revision); + pdev->device, pdev->revision); copy_info(&info, "At PCI address %s, IRQ %u\n", - pci_name(np->s.device), np->s.device->irq); + pci_name(pdev), pdev->irq); copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", (int) (np->minsync_dt ? np->minsync_dt : np->minsync), np->maxwide ? "Wide" : "Narrow", @@ -1211,15 +1217,14 @@ static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) * - func = 0 means read (returns adapter infos) * - func = 1 means write (not yet merget from sym53c8xx) */ -static int sym53c8xx_proc_info(struct Scsi_Host *host, char *buffer, +static int sym53c8xx_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, int length, int func) { - struct sym_hcb *np = sym_get_hcb(host); int retv; if (func) { #ifdef SYM_LINUX_USER_COMMAND_SUPPORT - retv = sym_user_command(np, buffer, length); + retv = sym_user_command(shost, buffer, length); #else retv = -EINVAL; #endif @@ -1227,7 +1232,7 @@ static int sym53c8xx_proc_info(struct Scsi_Host *host, char *buffer, if (start) *start = buffer; #ifdef SYM_LINUX_USER_INFO_SUPPORT - retv = sym_host_info(np, buffer, offset, length); + retv = sym_host_info(shost, buffer, offset, length); #else retv = -EINVAL; #endif @@ -1303,20 +1308,18 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, np = __sym_calloc_dma(&pdev->dev, sizeof(*np), "HCB"); if (!np) goto attach_failed; - np->s.device = pdev; np->bus_dmat = &pdev->dev; /* Result in 1 DMA pool per HBA */ sym_data->ncb = np; sym_data->pdev = pdev; np->s.host = shost; - pci_set_drvdata(pdev, np); + pci_set_drvdata(pdev, shost); /* * Copy some useful infos to the HCB. */ np->hcb_ba = vtobus(np); np->verbose = sym_driver_setup.verbose; - np->s.device = pdev; np->s.unit = unit; np->features = dev->chip.features; np->clock_divn = dev->chip.nr_divisor; @@ -1331,9 +1334,9 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, sprintf(np->s.inst_name, "sym%d", np->s.unit); if ((SYM_CONF_DMA_ADDRESSING_MODE > 0) && (np->features & FE_DAC) && - !pci_set_dma_mask(np->s.device, DMA_DAC_MASK)) { + !pci_set_dma_mask(pdev, DMA_DAC_MASK)) { set_dac(np); - } else if (pci_set_dma_mask(np->s.device, DMA_32BIT_MASK)) { + } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { printf_warning("%s: No suitable DMA available\n", sym_name(np)); goto attach_failed; } @@ -1380,7 +1383,7 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, /* * Start the SCRIPTS. */ - sym_start_up(np, 1); + sym_start_up(shost, 1); /* * Start the timer daemon @@ -1645,8 +1648,9 @@ static void sym_config_pqs(struct pci_dev *pdev, struct sym_device *sym_dev) * Detach the host. * We have to free resources and halt the NCR chip. */ -static int sym_detach(struct sym_hcb *np, struct pci_dev *pdev) +static int sym_detach(struct Scsi_Host *shost, struct pci_dev *pdev) { + struct sym_hcb *np = sym_get_hcb(shost); printk("%s: detaching ...\n", sym_name(np)); del_timer_sync(&np->s.timer); @@ -1750,14 +1754,11 @@ static int __devinit sym2_probe(struct pci_dev *pdev, static void __devexit sym2_remove(struct pci_dev *pdev) { - struct sym_hcb *np = pci_get_drvdata(pdev); - struct Scsi_Host *host = np->s.host; - - scsi_remove_host(host); - scsi_host_put(host); - - sym_detach(np, pdev); + struct Scsi_Host *shost = pci_get_drvdata(pdev); + scsi_remove_host(shost); + scsi_host_put(shost); + sym_detach(shost, pdev); pci_release_regions(pdev); pci_disable_device(pdev); @@ -1791,9 +1792,9 @@ static pci_ers_result_t sym2_io_error_detected(struct pci_dev *pdev, */ static pci_ers_result_t sym2_io_slot_dump(struct pci_dev *pdev) { - struct sym_hcb *np = pci_get_drvdata(pdev); + struct Scsi_Host *shost = pci_get_drvdata(pdev); - sym_dump_registers(np); + sym_dump_registers(shost); /* Request a slot reset. */ return PCI_ERS_RESULT_NEED_RESET; @@ -1833,7 +1834,8 @@ static void sym2_reset_workarounds(struct pci_dev *pdev) */ static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev) { - struct sym_hcb *np = pci_get_drvdata(pdev); + struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct sym_hcb *np = sym_get_hcb(shost); printk(KERN_INFO "%s: recovering from a PCI slot reset\n", sym_name(np)); @@ -1863,7 +1865,7 @@ static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev) sym_name(np)); return PCI_ERS_RESULT_DISCONNECT; } - sym_start_up(np, 1); + sym_start_up(shost, 1); } return PCI_ERS_RESULT_RECOVERED; @@ -1879,8 +1881,7 @@ static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev) */ static void sym2_io_resume(struct pci_dev *pdev) { - struct sym_hcb *np = pci_get_drvdata(pdev); - struct Scsi_Host *shost = np->s.host; + struct Scsi_Host *shost = pci_get_drvdata(pdev); struct sym_data *sym_data = shost_priv(shost); spin_lock_irq(shost->host_lock); diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index 98261a5af87d..e5bd0afcb4d8 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -179,7 +179,6 @@ struct sym_shcb { int unit; char inst_name[16]; char chip_name[8]; - struct pci_dev *device; struct Scsi_Host *host; @@ -266,7 +265,7 @@ void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *ccb); void sym_xpt_async_bus_reset(struct sym_hcb *np); void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target); int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp); -void sym_log_bus_error(struct sym_hcb *np); -void sym_dump_registers(struct sym_hcb *np); +void sym_log_bus_error(struct Scsi_Host *); +void sym_dump_registers(struct Scsi_Host *); #endif /* SYM_GLUE_H */ diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 5d2079f9e596..3cf1209301a4 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -684,6 +684,8 @@ static void sym_set_bus_mode(struct sym_hcb *np, struct sym_nvram *nvram) */ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; u_char burst_max; u32 period; int i; @@ -797,8 +799,8 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * In dual channel mode, contention occurs if internal cycles * are used. Disable internal cycles. */ - if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 && - np->s.device->revision < 0x1) + if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 && + pdev->revision < 0x1) np->rv_ccntl0 |= DILS; /* @@ -821,10 +823,10 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * this driver. The generic ncr driver that does not use * LOAD/STORE instructions does not need this work-around. */ - if ((np->s.device->device == PCI_DEVICE_ID_NCR_53C810 && - np->s.device->revision >= 0x10 && np->s.device->revision <= 0x11) || - (np->s.device->device == PCI_DEVICE_ID_NCR_53C860 && - np->s.device->revision <= 0x1)) + if ((pdev->device == PCI_DEVICE_ID_NCR_53C810 && + pdev->revision >= 0x10 && pdev->revision <= 0x11) || + (pdev->device == PCI_DEVICE_ID_NCR_53C860 && + pdev->revision <= 0x1)) np->features &= ~(FE_WRIE|FE_ERL|FE_ERMP); /* @@ -890,7 +892,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru if ((SYM_SETUP_SCSI_LED || (nvram->type == SYM_SYMBIOS_NVRAM || (nvram->type == SYM_TEKRAM_NVRAM && - np->s.device->device == PCI_DEVICE_ID_NCR_53C895))) && + pdev->device == PCI_DEVICE_ID_NCR_53C895))) && !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01)) np->features |= FE_LED0; @@ -1128,8 +1130,9 @@ restart_test: * First 24 register of the chip: * r0..rf */ -static void sym_log_hard_error(struct sym_hcb *np, u_short sist, u_char dstat) +static void sym_log_hard_error(struct Scsi_Host *shost, u_short sist, u_char dstat) { + struct sym_hcb *np = sym_get_hcb(shost); u32 dsp; int script_ofs; int script_size; @@ -1182,17 +1185,18 @@ static void sym_log_hard_error(struct sym_hcb *np, u_short sist, u_char dstat) * PCI BUS error. */ if (dstat & (MDPE|BF)) - sym_log_bus_error(np); + sym_log_bus_error(shost); } -void sym_dump_registers(struct sym_hcb *np) +void sym_dump_registers(struct Scsi_Host *shost) { + struct sym_hcb *np = sym_get_hcb(shost); u_short sist; u_char dstat; sist = INW(np, nc_sist); dstat = INB(np, nc_dstat); - sym_log_hard_error(np, sist, dstat); + sym_log_hard_error(shost, sist, dstat); } static struct sym_chip sym_dev_table[] = { @@ -1700,8 +1704,11 @@ static void sym_flush_busy_queue (struct sym_hcb *np, int cam_status) * 1: SCSI BUS RESET delivered or received. * 2: SCSI BUS MODE changed. */ -void sym_start_up (struct sym_hcb *np, int reason) +void sym_start_up(struct Scsi_Host *shost, int reason) { + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; + struct sym_hcb *np = sym_data->ncb; int i; u32 phys; @@ -1750,7 +1757,7 @@ void sym_start_up (struct sym_hcb *np, int reason) * This also let point to first position the start * and done queue pointers used from SCRIPTS. */ - np->fw_patch(np); + np->fw_patch(shost); /* * Wakeup all pending jobs. @@ -1792,7 +1799,7 @@ void sym_start_up (struct sym_hcb *np, int reason) /* * For now, disable AIP generation on C1010-66. */ - if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_66) + if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_66) OUTB(np, nc_aipcntl1, DISAIP); /* @@ -1802,8 +1809,8 @@ void sym_start_up (struct sym_hcb *np, int reason) * that from SCRIPTS for each selection/reselection, but * I just don't want. :) */ - if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 && - np->s.device->revision < 1) + if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 && + pdev->revision < 1) OUTB(np, nc_stest1, INB(np, nc_stest1) | 0x30); /* @@ -1811,9 +1818,9 @@ void sym_start_up (struct sym_hcb *np, int reason) * Disable overlapped arbitration for some dual function devices, * regardless revision id (kind of post-chip-design feature. ;-)) */ - if (np->s.device->device == PCI_DEVICE_ID_NCR_53C875) + if (pdev->device == PCI_DEVICE_ID_NCR_53C875) OUTB(np, nc_ctest0, (1<<5)); - else if (np->s.device->device == PCI_DEVICE_ID_NCR_53C896) + else if (pdev->device == PCI_DEVICE_ID_NCR_53C896) np->rv_ccntl0 |= DPR; /* @@ -2218,8 +2225,9 @@ static void sym_int_udc (struct sym_hcb *np) * mode to eight bit asynchronous, etc... * So, just reinitializing all except chip should be enough. */ -static void sym_int_sbmc (struct sym_hcb *np) +static void sym_int_sbmc(struct Scsi_Host *shost) { + struct sym_hcb *np = sym_get_hcb(shost); u_char scsi_mode = INB(np, nc_stest4) & SMODE; /* @@ -2232,7 +2240,7 @@ static void sym_int_sbmc (struct sym_hcb *np) * Should suspend command processing for a few seconds and * reinitialize all except the chip. */ - sym_start_up (np, 2); + sym_start_up(shost, 2); } /* @@ -2762,7 +2770,9 @@ reset_all: irqreturn_t sym_interrupt(struct Scsi_Host *shost) { - struct sym_hcb *np = sym_get_hcb(shost); + struct sym_data *sym_data = shost_priv(shost); + struct sym_hcb *np = sym_data->ncb; + struct pci_dev *pdev = sym_data->pdev; u_char istat, istatc; u_char dstat; u_short sist; @@ -2818,7 +2828,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) /* Prevent deadlock waiting on a condition that may * never clear. */ if (unlikely(sist == 0xffff && dstat == 0xff)) { - if (pci_channel_offline(np->s.device)) + if (pci_channel_offline(pdev)) return IRQ_NONE; } } while (istatc & (SIP|DIP)); @@ -2873,7 +2883,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) */ if (sist & RST) { printf("%s: SCSI BUS reset detected.\n", sym_name(np)); - sym_start_up (np, 1); + sym_start_up(shost, 1); return IRQ_HANDLED; } @@ -2882,7 +2892,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) if (!(sist & (GEN|HTH|SGE)) && !(dstat & (MDPE|BF|ABRT|IID))) { - if (sist & SBMC) sym_int_sbmc (np); + if (sist & SBMC) sym_int_sbmc(shost); else if (sist & STO) sym_int_sto (np); else if (sist & UDC) sym_int_udc (np); else goto unknown_int; @@ -2896,7 +2906,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) * Reset everything. */ - sym_log_hard_error(np, sist, dstat); + sym_log_hard_error(shost, sist, dstat); if ((sist & (GEN|HTH|SGE)) || (dstat & (MDPE|BF|ABRT|IID))) { diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index a9c08668b98c..ad078805e62b 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -909,7 +909,7 @@ struct sym_hcb { struct sym_fwb_ba fwb_bas; /* Useful SCRIPTB bus addresses */ struct sym_fwz_ba fwz_bas; /* Useful SCRIPTZ bus addresses */ void (*fw_setup)(struct sym_hcb *np, struct sym_fw *fw); - void (*fw_patch)(struct sym_hcb *np); + void (*fw_patch)(struct Scsi_Host *); char *fw_name; /* @@ -1055,7 +1055,7 @@ void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn); #else void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp); #endif -void sym_start_up(struct sym_hcb *np, int reason); +void sym_start_up(struct Scsi_Host *, int reason); irqreturn_t sym_interrupt(struct Scsi_Host *); int sym_clear_tasks(struct sym_hcb *np, int cam_status, int target, int lun, int task); struct sym_ccb *sym_get_ccb(struct sym_hcb *np, struct scsi_cmnd *cmd, u_char tag_order); -- cgit v1.2.3 From aac6a5a34050a97016290f341e8de0a09f3a8f8c Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 5 Oct 2007 15:55:14 -0400 Subject: [SCSI] sym53c8xx: Remove sym_xpt_async_sent_bdr This function just printed a message to the user; move the print to its only caller, and turn it into an starget_printk. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 8 -------- drivers/scsi/sym53c8xx_2/sym_glue.h | 1 - drivers/scsi/sym53c8xx_2/sym_hipd.c | 3 ++- 3 files changed, 2 insertions(+), 10 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index df0547afe526..0f74aba5b237 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -162,14 +162,6 @@ void sym_xpt_async_bus_reset(struct sym_hcb *np) sym_name(np), sym_driver_setup.settle_delay); } -/* - * Tell the SCSI layer about a BUS DEVICE RESET message sent. - */ -void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target) -{ - printf_notice("%s: TARGET %d has been reset.\n", sym_name(np), target); -} - /* * Choose the more appropriate CAM status if * the IO encountered an extended error. diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index e5bd0afcb4d8..567fbe0b4f09 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -263,7 +263,6 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *ccb); #define sym_print_addr(cmd, arg...) dev_info(&cmd->device->sdev_gendev , ## arg) void sym_xpt_async_bus_reset(struct sym_hcb *np); -void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target); int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp); void sym_log_bus_error(struct Scsi_Host *); void sym_dump_registers(struct Scsi_Host *); diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 3cf1209301a4..463f119f20e9 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -3543,7 +3543,8 @@ static void sym_sir_task_recovery(struct sym_hcb *np, int num) * If we sent a BDR, make upper layer aware of that. */ if (np->abrt_msg[0] == M_RESET) - sym_xpt_async_sent_bdr(np, target); + starget_printk(KERN_NOTICE, starget, + "has been reset\n"); break; } -- cgit v1.2.3 From 6557f3a06a5eb73b34d01b23523a513f2c52cadb Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 19 Oct 2007 15:59:13 -0700 Subject: [SCSI] qla2xxx: Resync with latest HBA SSID specification -- 2.2u. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_devtbl.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_devtbl.h b/drivers/scsi/qla2xxx/qla_devtbl.h index dd435410dfa2..d78d35e681ab 100644 --- a/drivers/scsi/qla2xxx/qla_devtbl.h +++ b/drivers/scsi/qla2xxx/qla_devtbl.h @@ -1,4 +1,4 @@ -#define QLA_MODEL_NAMES 0x57 +#define QLA_MODEL_NAMES 0x5C /* * Adapter model names and descriptions. @@ -91,4 +91,9 @@ static char *qla2x00_model_name[QLA_MODEL_NAMES*2] = { " ", " ", /* 0x154 */ "QLE220", "PCI-Express to 4Gb FC, Single Channel", /* 0x155 */ "QLE220", "PCI-Express to 4Gb FC, Single Channel", /* 0x156 */ + " ", " ", /* 0x157 */ + " ", " ", /* 0x158 */ + " ", " ", /* 0x159 */ + " ", " ", /* 0x15a */ + "QME2472", "Dell BS PCI-Express to 4Gb FC, Dual Channel", /* 0x15b */ }; -- cgit v1.2.3 From a3a63d55a4eec418d845a91222ac53443f62717b Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 19 Oct 2007 15:59:14 -0700 Subject: [SCSI] qla2xxx: Defer explicit interrupt-polling processing to init-time scenarios. As the intermixing may cause issues where HCCR bits could be cleared inappropriately during MSI/MSI-X interrupt handling. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_iocb.c | 2 +- drivers/scsi/qla2xxx/qla_mbx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 7f6a89bd94f3..024c662ec34d 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -525,7 +525,7 @@ qla2x00_req_pkt(scsi_qla_host_t *ha) /* Check for pending interrupts. */ /* During init we issue marker directly */ - if (!ha->marker_needed) + if (!ha->marker_needed && !ha->flags.init_done) qla2x00_poll(ha); spin_lock_irq(&ha->hardware_lock); diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index c53ec67c47f4..ccd662a6f5dc 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -252,7 +252,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp) /* Clean up */ ha->mcp = NULL; - if (!abort_active) { + if (abort_active || !io_lock_on) { DEBUG11(printk("%s(%ld): checking for additional resp " "interrupt.\n", __func__, ha->host_no)); -- cgit v1.2.3 From 2c96d8d0c17978bbf5eb82314d488f46d4a51280 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 19 Oct 2007 15:59:15 -0700 Subject: [SCSI] qla2xxx: Handle unaligned sector writes during NVRAM/VPD updates. Since both NVRAM and VPD regions of the flash reside on unaligned sector boundaries, during update, the driver must perform a read-modify-write operation to the composite NVRAM/VPD region. This affects ISP25xx type boards only. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_attr.c | 6 ------ drivers/scsi/qla2xxx/qla_sup.c | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 05fa7796a559..2f0bd5abb9ac 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -114,7 +114,6 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, { struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, struct device, kobj))); - unsigned long flags; uint16_t cnt; if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) @@ -144,11 +143,9 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, } /* Write NVRAM. */ - spin_lock_irqsave(&ha->hardware_lock, flags); ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); ha->isp_ops->read_nvram(ha, (uint8_t *)ha->nvram, ha->nvram_base, count); - spin_unlock_irqrestore(&ha->hardware_lock, flags); set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); @@ -397,16 +394,13 @@ qla2x00_sysfs_write_vpd(struct kobject *kobj, { struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, struct device, kobj))); - unsigned long flags; if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size) return 0; /* Write NVRAM. */ - spin_lock_irqsave(&ha->hardware_lock, flags); ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count); ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd, ha->vpd_base, count); - spin_unlock_irqrestore(&ha->hardware_lock, flags); return count; } diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index 6670ad585f28..c24f3d9dea76 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -7,6 +7,7 @@ #include "qla_def.h" #include +#include #include static uint16_t qla2x00_nvram_request(scsi_qla_host_t *, uint32_t); @@ -745,9 +746,11 @@ qla2x00_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, int ret, stat; uint32_t i; uint16_t *wptr; + unsigned long flags; ret = QLA_SUCCESS; + spin_lock_irqsave(&ha->hardware_lock, flags); qla2x00_lock_nvram_access(ha); /* Disable NVRAM write-protection. */ @@ -764,6 +767,7 @@ qla2x00_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, qla2x00_set_nvram_protection(ha, stat); qla2x00_unlock_nvram_access(ha); + spin_unlock_irqrestore(&ha->hardware_lock, flags); return ret; } @@ -776,9 +780,11 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, uint32_t i; uint32_t *dwptr; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; + unsigned long flags; ret = QLA_SUCCESS; + spin_lock_irqsave(&ha->hardware_lock, flags); /* Enable flash write. */ WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) | CSRX_FLASH_ENABLE); @@ -812,6 +818,7 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) & ~CSRX_FLASH_ENABLE); RD_REG_DWORD(®->ctrl_status); /* PCI Posting. */ + spin_unlock_irqrestore(&ha->hardware_lock, flags); return ret; } @@ -836,8 +843,20 @@ int qla25xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, uint32_t bytes) { - return qla24xx_write_flash_data(ha, (uint32_t *)buf, - FA_VPD_NVRAM_ADDR | naddr, bytes >> 2); +#define RMW_BUFFER_SIZE (64 * 1024) + uint8_t *dbuf; + + dbuf = vmalloc(RMW_BUFFER_SIZE); + if (!dbuf) + return QLA_MEMORY_ALLOC_FAILED; + ha->isp_ops->read_optrom(ha, dbuf, FA_VPD_NVRAM_ADDR << 2, + RMW_BUFFER_SIZE); + memcpy(dbuf + (naddr << 2), buf, bytes); + ha->isp_ops->write_optrom(ha, dbuf, FA_VPD_NVRAM_ADDR << 2, + RMW_BUFFER_SIZE); + vfree(dbuf); + + return QLA_SUCCESS; } static inline void -- cgit v1.2.3 From 94d6a2b32864421467d48f9a3a1c7b1da1e1dadf Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 19 Oct 2007 15:59:16 -0700 Subject: [SCSI] qla2xxx: Fix issue where final flash-segment updates were falling into the slow-path write handler. Original implementation would not use the burst-write mechanisms for requests equal to OPTROM_BURST_DWORDS transfer dwords. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_sup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index c24f3d9dea76..ad2fa01bd233 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -643,7 +643,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, } /* Go with burst-write. */ - if (optrom && (liter + OPTROM_BURST_DWORDS) < dwords) { + if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { /* Copy data to DMA'ble buffer. */ for (miter = 0, s = optrom, d = dwptr; miter < OPTROM_BURST_DWORDS; miter++, s++, d++) -- cgit v1.2.3 From 285d0321d15cf3130b3347a207ceae652ccc95b5 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 19 Oct 2007 15:59:17 -0700 Subject: [SCSI] qla2xxx: Make driver (mostly) legacy I/O port free. Recent ISPs need only the single MMIO BAR to manipulate HW registers. Unfortunately, ISP21xx, ISP22xx, ISP23xx, and ISP63xx type cards still require the I/O mapped region to manipulate the FLASH via the two HW flash-registers (flash_address and flash_data). Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_def.h | 1 + drivers/scsi/qla2xxx/qla_os.c | 50 +++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 20 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 1900fbf6cd74..04e8cbca4c0d 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -2271,6 +2271,7 @@ typedef struct scsi_qla_host { spinlock_t hardware_lock ____cacheline_aligned; + int bars; device_reg_t __iomem *iobase; /* Base I/O address */ unsigned long pio_address; unsigned long pio_length; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 0351d380c2d7..a5bcf1f390b3 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1482,6 +1482,17 @@ qla2x00_iospace_config(scsi_qla_host_t *ha) unsigned long pio, pio_len, pio_flags; unsigned long mmio, mmio_len, mmio_flags; + if (pci_request_selected_regions(ha->pdev, ha->bars, + QLA2XXX_DRIVER_NAME)) { + qla_printk(KERN_WARNING, ha, + "Failed to reserve PIO/MMIO regions (%s)\n", + pci_name(ha->pdev)); + + goto iospace_error_exit; + } + if (!(ha->bars & 1)) + goto skip_pio; + /* We only need PIO for Flash operations on ISP2312 v2 chips. */ pio = pci_resource_start(ha->pdev, 0); pio_len = pci_resource_len(ha->pdev, 0); @@ -1499,7 +1510,10 @@ qla2x00_iospace_config(scsi_qla_host_t *ha) pci_name(ha->pdev)); pio = 0; } + ha->pio_address = pio; + ha->pio_length = pio_len; +skip_pio: /* Use MMIO operations for all accesses. */ mmio = pci_resource_start(ha->pdev, 1); mmio_len = pci_resource_len(ha->pdev, 1); @@ -1518,16 +1532,6 @@ qla2x00_iospace_config(scsi_qla_host_t *ha) goto iospace_error_exit; } - if (pci_request_regions(ha->pdev, QLA2XXX_DRIVER_NAME)) { - qla_printk(KERN_WARNING, ha, - "Failed to reserve PIO/MMIO regions (%s)\n", - pci_name(ha->pdev)); - - goto iospace_error_exit; - } - - ha->pio_address = pio; - ha->pio_length = pio_len; ha->iobase = ioremap(mmio, MIN_IOBASE_LEN); if (!ha->iobase) { qla_printk(KERN_ERR, ha, @@ -1579,21 +1583,26 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) char pci_info[30]; char fw_str[30]; struct scsi_host_template *sht; + int bars; - if (pci_enable_device(pdev)) - goto probe_out; - - if (pci_find_aer_capability(pdev)) - if (pci_enable_pcie_error_reporting(pdev)) - goto probe_out; - + bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); sht = &qla2x00_driver_template; if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || - pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532) + pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532) { + bars = pci_select_bars(pdev, IORESOURCE_MEM); sht = &qla24xx_driver_template; + } + + if (pci_enable_device_bars(pdev, bars)) + goto probe_out; + + if (pci_find_aer_capability(pdev)) + if (pci_enable_pcie_error_reporting(pdev)) + goto probe_out; + host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); if (host == NULL) { printk(KERN_WARNING @@ -1610,6 +1619,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->host_no = host->host_no; sprintf(ha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, ha->host_no); ha->parent = NULL; + ha->bars = bars; /* Set ISP-type information. */ qla2x00_set_isp_flags(ha); @@ -1880,7 +1890,7 @@ qla2x00_free_device(scsi_qla_host_t *ha) /* release io space registers */ if (ha->iobase) iounmap(ha->iobase); - pci_release_regions(ha->pdev); + pci_release_selected_regions(ha->pdev, ha->bars); } static inline void @@ -2890,7 +2900,7 @@ qla2xxx_pci_slot_reset(struct pci_dev *pdev) pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; scsi_qla_host_t *ha = pci_get_drvdata(pdev); - if (pci_enable_device(pdev)) { + if (pci_enable_device_bars(pdev, ha->bars)) { qla_printk(KERN_WARNING, ha, "Can't re-enable PCI device after reset.\n"); -- cgit v1.2.3 From 6acf8190025e9c4ea513d4084ff089d476112816 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 19 Oct 2007 15:59:18 -0700 Subject: [SCSI] qla2xxx: Correct residual-count handling discrepancies during UNDERRUN handling. For recent ISPs, software during CS_UNDERRUN handling must determine if the two residuals, firmware-calculated and FCP_RSP, are different to recognize if a frame has been dropped. Update the driver to catch this condition, and clear the SS_RESIDUAL_UNDER and lscsi_status bits. This logic is consistent with what earlier firmwares did by explicitly cracking open the FCP_RSP statuses and clearing SS_RESIDUAL_UNDER. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_isr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index c4768c4f3990..1104bd2eed40 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -1012,8 +1012,14 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt) case CS_DATA_UNDERRUN: resid = resid_len; /* Use F/W calculated residual length. */ - if (IS_FWI2_CAPABLE(ha)) + if (IS_FWI2_CAPABLE(ha)) { + if (scsi_status & SS_RESIDUAL_UNDER && + resid != fw_resid_len) { + scsi_status &= ~SS_RESIDUAL_UNDER; + lscsi_status = 0; + } resid = fw_resid_len; + } if (scsi_status & SS_RESIDUAL_UNDER) { scsi_set_resid(cp, resid); -- cgit v1.2.3 From 8b7afc2a90d93d87d53732a9281c22facebe8d62 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 19 Oct 2007 15:59:19 -0700 Subject: [SCSI] qla2xxx: Correct display of ISP serial-number. The original serial-number calculations based on WWPN no longer apply to newer ISPs (ISP24xx and ISP25xx). These newer board's serial number reside in the VPD. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_attr.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 2f0bd5abb9ac..fb388b8c07cf 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -538,6 +538,9 @@ qla2x00_serial_num_show(struct class_device *cdev, char *buf) scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); uint32_t sn; + if (IS_FWI2_CAPABLE(ha)) + return snprintf(buf, PAGE_SIZE, "\n"); + sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000, sn % 100000); -- cgit v1.2.3 From af2709fd0d127cd590e7a77ab50b23cdb9f6f48f Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Fri, 19 Oct 2007 15:59:20 -0700 Subject: [SCSI] qla2xxx: Update version number to 8.02.00-k5. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h index 2d551a3006f6..ae6f7a2fb19f 100644 --- a/drivers/scsi/qla2xxx/qla_version.h +++ b/drivers/scsi/qla2xxx/qla_version.h @@ -7,7 +7,7 @@ /* * Driver version */ -#define QLA2XXX_VERSION "8.02.00-k4" +#define QLA2XXX_VERSION "8.02.00-k5" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 2 -- cgit v1.2.3