GIT bb1d1073a10fdc8547e3eb821ee2488260094b39 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6.git commit bb1d1073a10fdc8547e3eb821ee2488260094b39 Author: brking@us.ibm.com Date: Mon Jan 23 15:03:22 2006 -0600 [SCSI] Prevent scsi_execute_async from guessing cdb length When the scsi_execute_async interface was added it ended up reducing the flexibility of userspace to send arbitrary scsi commands through sg using SG_IO. The SG_IO interface allows userspace to specify the CDB length. This is now ignored in scsi_execute_async and it is guessed using the COMMAND_SIZE macro, which is not always correct, particularly for vendor specific commands. This patch adds a cmd_len parameter to the scsi_execute_async interface to allow the caller to specify the length of the CDB. Signed-off-by: Brian King Signed-off-by: James Bottomley commit 15084a4a63bc300c18b28a8a9afac870c552abce Author: Jack Hammer Date: Tue Jan 24 14:43:41 2006 -0500 [SCSI] ips soft lockup during reset/initialization Resetting the adapter causes the ServeRAID driver to exceed the max time allowed by the softlock watchdog. Resetting the hardware can easily require 30 or more seconds. To avoid the "BUG: soft lockup detected on CPU#0!" result, this patch replaces the mdelay() calls in the initialization/reset routines with msleep(). Signed-off-by: Jack Hammer Signed-off-by: James Bottomley commit 77427f514f88143bfef41ba8c1e624bc45f42297 Author: andrew.vasquez@qlogic.com Date: Fri Jan 20 14:53:25 2006 -0800 [SCSI] qla2xxx: Drop legacy 'bypass lun scan for tape device' code. Internal lun discovery has been removed since fc_transport integration. Short-circuiting for tape-devices in qla2x00_update_fcport() could inadvertently result in a blocked rport timing-out and its targets being reaped. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley commit 052c40c83b4ca37be226112049b60097cb9961e1 Author: andrew.vasquez@qlogic.com Date: Fri Jan 20 14:53:19 2006 -0800 [SCSI] qla2xxx: Correct issue where the rport's upcall was not being made after relogin. A target can LOGO an initiator at any time (i.e. during I/O, due to a controller hicup, or as a simple authentication mechanism after an initial CDB command), when this occurs, the driver attempts to relogin (PLOGI) to the device via the DPC thread. Add code to make the appropriate upcall to the FC transport layer (fc_remote_port_add()) upon successful completion of the PLOGI. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley commit d97994dc1fddcbb8212b745d9c9c9ce96262155c Author: andrew.vasquez@qlogic.com Date: Fri Jan 20 14:53:13 2006 -0800 [SCSI] qla2xxx: Correct synchronization issues during rport addition/deletion. The driver can typically detect port-loss during an interrupt context (i.e. via interrogation of a status IOCB's completion status [CS_PORT_LOGGED_OUT]. Due to the calling requirements of the fc_rport APIs, the driver would defer removal of the device to the default workqueue. If the work-item was preceded by an event which caused the port to obtain visibility (relogin successful, target re-logged into the topology), deferred removal could inadvertently drop the rport. The code also no longer defers removal via the default workqueue, instead opting for use of the driver's own DPC thread. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley commit 1d12d98d284665c37b75b9538916b5fbb8fcde37 Author: Guennadi Liakhovetski Date: Fri Jan 20 01:05:00 2006 +0100 [SCSI] dc395x: "fix" virt_addr calculation on AUTO_REQSENSE The patch below "fixes" calculation of the virt_addr for the AUTO_REQSENSE case. I put "fixes" in quotes because the real fix would be to completely remove it, but that's beyond the scope of this patch. Signed-off-by: Guennadi Liakhovetski Signed-off-by: James Bottomley commit 2b541f8f77fd339e4c5c5cbe8549b52445012704 Author: Dave C Boutcher Date: Thu Jan 19 13:34:44 2006 -0600 [SCSI] ibmvscsi: handle re-enable firmware message New versions of the Power5 firmware can send a "re-enable" message to the virtual scsi adapter. This fix makes us handle the message correctly. Without it, the driver goes catatonic and the system crashes unpleasantly. Signed-off-by: Dave Boutcher Signed-off-by: James Bottomley commit 2dbb04c65561122cc53b22dbea9aa59f9609215b Author: Jes Sorensen Date: Mon Jan 16 11:49:29 2006 -0500 [SCSI] qla1280: remove < 2.6.0 support Remove support for kernels older than 2.6.0. Signed-off-by: Jes Sorensen Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index c8a32cf..cbf8252 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -246,6 +246,7 @@ struct ScsiReqBlk { * total_xfer_length in xferred. These values are restored in * pci_unmap_srb_sense. This is the only place xferred is used. */ + unsigned char *virt_addr_req; /* Saved virtual address of the request buffer */ u32 xferred; /* Saved copy of total_xfer_length */ u16 state; @@ -2017,7 +2018,7 @@ static void sg_update_list(struct ScsiRe sg_verify_length(srb); /* we need the corresponding virtual address */ - if (!segment) { + if (!segment || (srb->flag & AUTO_REQSENSE)) { srb->virt_addr += xferred; return; } @@ -3318,6 +3319,7 @@ static void pci_unmap_srb_sense(struct A srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address; srb->segment_x[0].length = srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].length; + srb->virt_addr = srb->virt_addr_req; } @@ -3711,6 +3713,8 @@ static void request_sense(struct Adapter srb->xferred = srb->total_xfer_length; /* srb->segment_x : a one entry of S/G list table */ srb->total_xfer_length = sizeof(cmd->sense_buffer); + srb->virt_addr_req = srb->virt_addr; + srb->virt_addr = cmd->sense_buffer; srb->segment_x[0].length = sizeof(cmd->sense_buffer); /* Map sense buffer */ srb->segment_x[0].address = diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 822b9fa..eaefedd 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -87,7 +87,7 @@ static int max_channel = 3; static int init_timeout = 5; static int max_requests = 50; -#define IBMVSCSI_VERSION "1.5.7" +#define IBMVSCSI_VERSION "1.5.8" MODULE_DESCRIPTION("IBM Virtual SCSI"); MODULE_AUTHOR("Dave Boutcher"); @@ -534,7 +534,6 @@ static int map_data_for_srp_cmd(struct s static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, struct ibmvscsi_host_data *hostdata) { - struct scsi_cmnd *cmnd; u64 *crq_as_u64 = (u64 *) &evt_struct->crq; int rc; @@ -544,19 +543,8 @@ static int ibmvscsi_send_srp_event(struc * can handle more requests (can_queue) when we actually can't */ if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) && - (atomic_dec_if_positive(&hostdata->request_limit) < 0)) { - /* See if the adapter is disabled */ - if (atomic_read(&hostdata->request_limit) < 0) - goto send_error; - - printk(KERN_WARNING - "ibmvscsi: Warning, request_limit exceeded\n"); - unmap_cmd_data(&evt_struct->iu.srp.cmd, - evt_struct, - hostdata->dev); - free_event_struct(&hostdata->pool, evt_struct); - return SCSI_MLQUEUE_HOST_BUSY; - } + (atomic_dec_if_positive(&hostdata->request_limit) < 0)) + goto send_error; /* Copy the IU into the transfer area */ *evt_struct->xfer_iu = evt_struct->iu; @@ -572,7 +560,7 @@ static int ibmvscsi_send_srp_event(struc ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) { list_del(&evt_struct->list); - printk(KERN_ERR "ibmvscsi: failed to send event struct rc %d\n", + printk(KERN_ERR "ibmvscsi: send error %d\n", rc); goto send_error; } @@ -582,14 +570,8 @@ static int ibmvscsi_send_srp_event(struc send_error: unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); - if ((cmnd = evt_struct->cmnd) != NULL) { - cmnd->result = DID_ERROR << 16; - evt_struct->cmnd_done(cmnd); - } else if (evt_struct->done) - evt_struct->done(evt_struct); - free_event_struct(&hostdata->pool, evt_struct); - return 0; + return SCSI_MLQUEUE_HOST_BUSY; } /** @@ -802,7 +784,8 @@ static void login_rsp(struct srp_event_s case SRP_LOGIN_RSP_TYPE: /* it worked! */ break; case SRP_LOGIN_REJ_TYPE: /* refused! */ - printk(KERN_INFO "ibmvscsi: SRP_LOGIN_REQ rejected\n"); + printk(KERN_INFO "ibmvscsi: SRP_LOGIN_REJ reason %u\n", + evt_struct->xfer_iu->srp.login_rej.reason); /* Login failed. */ atomic_set(&hostdata->request_limit, -1); return; @@ -834,6 +817,9 @@ static void login_rsp(struct srp_event_s return; } + /* If we had any pending I/Os, kick them */ + scsi_unblock_requests(hostdata->host); + send_mad_adapter_info(hostdata); return; } @@ -862,6 +848,7 @@ static int send_srp_login(struct ibmvscs init_timeout * HZ); login = &evt_struct->iu.srp.login_req; + memset(login, 0x00, sizeof(struct srp_login_req)); login->type = SRP_LOGIN_REQ_TYPE; login->max_requested_initiator_to_target_iulen = sizeof(union srp_iu); login->required_buffer_formats = 0x0006; @@ -1122,7 +1109,7 @@ static int ibmvscsi_eh_device_reset_hand * purge_requests: Our virtual adapter just shut down. purge any sent requests * @hostdata: the adapter */ -static void purge_requests(struct ibmvscsi_host_data *hostdata) +static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code) { struct srp_event_struct *tmp_evt, *pos; unsigned long flags; @@ -1131,7 +1118,7 @@ static void purge_requests(struct ibmvsc list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) { list_del(&tmp_evt->list); if (tmp_evt->cmnd) { - tmp_evt->cmnd->result = (DID_ERROR << 16); + tmp_evt->cmnd->result = (error_code << 16); unmap_cmd_data(&tmp_evt->iu.srp.cmd, tmp_evt, tmp_evt->hostdata->dev); @@ -1186,12 +1173,30 @@ void ibmvscsi_handle_crq(struct viosrp_c printk(KERN_ERR "ibmvscsi: unknown crq message type\n"); } return; - case 0xFF: /* Hypervisor telling us the connection is closed */ - printk(KERN_INFO "ibmvscsi: Virtual adapter failed!\n"); + case 0xFF: /* Hypervisor telling us the connection is closed */ + scsi_block_requests(hostdata->host); + if (crq->format == 0x06) { + /* We need to re-setup the interpartition connection */ + printk(KERN_INFO + "ibmvscsi: Re-enabling adapter!\n"); + purge_requests(hostdata, DID_REQUEUE); + if (ibmvscsi_reenable_crq_queue(&hostdata->queue, + hostdata) == 0) + if (ibmvscsi_send_crq(hostdata, + 0xC001000000000000LL, 0)) + printk(KERN_ERR + "ibmvscsi: transmit error after" + " enable\n"); + } else { + printk(KERN_INFO + "ibmvscsi: Virtual adapter failed rc %d!\n", + crq->format); - atomic_set(&hostdata->request_limit, -1); - purge_requests(hostdata); - ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata); + atomic_set(&hostdata->request_limit, -1); + purge_requests(hostdata, DID_ERROR); + ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata); + } + scsi_unblock_requests(hostdata->host); return; case 0x80: /* real payload */ break; diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.h b/drivers/scsi/ibmvscsi/ibmvscsi.h index 5b0edd1..4550d71 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.h +++ b/drivers/scsi/ibmvscsi/ibmvscsi.h @@ -103,6 +103,9 @@ void ibmvscsi_release_crq_queue(struct c int ibmvscsi_reset_crq_queue(struct crq_queue *queue, struct ibmvscsi_host_data *hostdata); +int ibmvscsi_reenable_crq_queue(struct crq_queue *queue, + struct ibmvscsi_host_data *hostdata); + void ibmvscsi_handle_crq(struct viosrp_crq *crq, struct ibmvscsi_host_data *hostdata); int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata, diff --git a/drivers/scsi/ibmvscsi/iseries_vscsi.c b/drivers/scsi/ibmvscsi/iseries_vscsi.c index ce15d9e..7eed0b0 100644 --- a/drivers/scsi/ibmvscsi/iseries_vscsi.c +++ b/drivers/scsi/ibmvscsi/iseries_vscsi.c @@ -124,6 +124,19 @@ int ibmvscsi_reset_crq_queue(struct crq_ } /** + * reenable_crq_queue: - reenables a crq after a failure + * @queue: crq_queue to initialize and register + * @hostdata: ibmvscsi_host_data of host + * + * no-op for iSeries + */ +int ibmvscsi_reenable_crq_queue(struct crq_queue *queue, + struct ibmvscsi_host_data *hostdata) +{ + return 0; +} + +/** * ibmvscsi_send_crq: - Send a CRQ * @hostdata: the adapter * @word1: the first 64 bits of the data diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c index 75db2f5..f47dd87 100644 --- a/drivers/scsi/ibmvscsi/rpa_vscsi.c +++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c @@ -281,6 +281,28 @@ int ibmvscsi_init_crq_queue(struct crq_q } /** + * reenable_crq_queue: - reenables a crq after + * @queue: crq_queue to initialize and register + * @hostdata: ibmvscsi_host_data of host + * + */ +int ibmvscsi_reenable_crq_queue(struct crq_queue *queue, + struct ibmvscsi_host_data *hostdata) +{ + int rc; + struct vio_dev *vdev = to_vio_dev(hostdata->dev); + + /* Re-enable the CRQ */ + do { + rc = plpar_hcall_norets(H_ENABLE_CRQ, vdev->unit_address); + } while ((rc == H_InProgress) || (rc == H_Busy) || (H_isLongBusy(rc))); + + if (rc) + printk(KERN_ERR "ibmvscsi: Error %d enabling adapter\n", rc); + return rc; +} + +/** * reset_crq_queue: - resets a crq after a failure * @queue: crq_queue to initialize and register * @hostdata: ibmvscsi_host_data of host diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index e5e1ca4..32d592b 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -5012,7 +5012,7 @@ ips_init_copperhead(ips_ha_t * ha) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (j >= 45) @@ -5038,7 +5038,7 @@ ips_init_copperhead(ips_ha_t * ha) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (j >= 240) @@ -5056,7 +5056,7 @@ ips_init_copperhead(ips_ha_t * ha) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (i >= 240) @@ -5106,7 +5106,7 @@ ips_init_copperhead_memio(ips_ha_t * ha) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (j >= 45) @@ -5132,7 +5132,7 @@ ips_init_copperhead_memio(ips_ha_t * ha) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (j >= 240) @@ -5150,7 +5150,7 @@ ips_init_copperhead_memio(ips_ha_t * ha) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (i >= 240) @@ -5202,7 +5202,7 @@ ips_init_morpheus(ips_ha_t * ha) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (i >= 45) { @@ -5228,7 +5228,7 @@ ips_init_morpheus(ips_ha_t * ha) if (Post != 0x4F00) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (i >= 120) { @@ -5258,7 +5258,7 @@ ips_init_morpheus(ips_ha_t * ha) break; /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); } if (i >= 240) { @@ -5318,12 +5318,12 @@ ips_reset_copperhead(ips_ha_t * ha) outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR); /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); outb(0, ha->io_addr + IPS_REG_SCPR); /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); if ((*ha->func.init) (ha)) break; @@ -5363,12 +5363,12 @@ ips_reset_copperhead_memio(ips_ha_t * ha writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR); /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); writeb(0, ha->mem_ptr + IPS_REG_SCPR); /* Delay for 1 Second */ - MDELAY(IPS_ONE_SEC); + msleep(IPS_ONE_SEC); if ((*ha->func.init) (ha)) break; @@ -5409,7 +5409,7 @@ ips_reset_morpheus(ips_ha_t * ha) writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR); /* Delay for 5 Seconds */ - MDELAY(5 * IPS_ONE_SEC); + msleep(5 * IPS_ONE_SEC); /* Do a PCI config read to wait for adapter */ pci_read_config_byte(ha->pcidev, 4, &junk); diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 0878f95..e023024 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -17,9 +17,11 @@ * General Public License for more details. * ******************************************************************************/ -#define QLA1280_VERSION "3.25" +#define QLA1280_VERSION "3.26" /***************************************************************************** Revision History: + Rev 3.26, January 16, 2006 Jes Sorensen + - Ditch all < 2.6 support Rev 3.25.1, February 10, 2005 Christoph Hellwig - use pci_map_single to map non-S/G requests - remove qla1280_proc_info @@ -356,25 +358,18 @@ #include #include -#if LINUX_VERSION_CODE >= 0x020545 #include #include #include #include #include -#else -#include -#include "scsi.h" -#include -#include "sd.h" -#endif #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) #include #endif -#if LINUX_VERSION_CODE < 0x020407 -#error "Kernels older than 2.4.7 are no longer supported" +#if LINUX_VERSION_CODE < 0x020600 +#error "Kernels older than 2.6.0 are no longer supported" #endif @@ -441,52 +436,6 @@ #define NVRAM_DELAY() udelay(500) /* 2 microseconds */ -#if LINUX_VERSION_CODE < 0x020500 -#define HOST_LOCK &io_request_lock -#define irqreturn_t void -#define IRQ_RETVAL(foo) -#define MSG_ORDERED_TAG 1 - -#define DMA_BIDIRECTIONAL SCSI_DATA_UNKNOWN -#define DMA_TO_DEVICE SCSI_DATA_WRITE -#define DMA_FROM_DEVICE SCSI_DATA_READ -#define DMA_NONE SCSI_DATA_NONE - -#ifndef HAVE_SECTOR_T -typedef unsigned int sector_t; -#endif - -static inline void -scsi_adjust_queue_depth(struct scsi_device *device, int tag, int depth) -{ - if (tag) { - device->tagged_queue = tag; - device->current_tag = 0; - } - device->queue_depth = depth; -} -static inline struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *t, size_t s) -{ - return scsi_register(t, s); -} -static inline void scsi_host_put(struct Scsi_Host *h) -{ - scsi_unregister(h); -} -#else -#define HOST_LOCK ha->host->host_lock -#endif -#if LINUX_VERSION_CODE < 0x020600 -#define DEV_SIMPLE_TAGS(device) device->tagged_queue -/* - * Hack around that qla1280_remove_one is called from - * qla1280_release in 2.4 - */ -#undef __devexit -#define __devexit -#else -#define DEV_SIMPLE_TAGS(device) device->simple_tags -#endif #if defined(__ia64__) && !defined(ia64_platform_is) #define ia64_platform_is(foo) (!strcmp(x, platform_name)) #endif @@ -506,9 +455,6 @@ static void qla1280_remove_one(struct pc * QLogic Driver Support Function Prototypes. */ static void qla1280_done(struct scsi_qla_host *); -#if LINUX_VERSION_CODE < 0x020545 -static void qla1280_get_target_options(struct scsi_cmnd *, struct scsi_qla_host *); -#endif static int qla1280_get_token(char *); static int qla1280_setup(char *s) __init; @@ -610,11 +556,7 @@ __setup("qla1280=", qla1280_setup); #define CMD_SNSLEN(Cmnd) sizeof(Cmnd->sense_buffer) #define CMD_RESULT(Cmnd) Cmnd->result #define CMD_HANDLE(Cmnd) Cmnd->host_scribble -#if LINUX_VERSION_CODE < 0x020545 -#define CMD_REQUEST(Cmnd) Cmnd->request.cmd -#else #define CMD_REQUEST(Cmnd) Cmnd->request->cmd -#endif #define CMD_HOST(Cmnd) Cmnd->device->host #define SCSI_BUS_32(Cmnd) Cmnd->device->channel @@ -1064,10 +1006,10 @@ qla1280_error_action(struct scsi_cmnd *c add_timer(&timer); /* wait for the action to complete (or the timer to expire) */ - spin_unlock_irq(HOST_LOCK); + spin_unlock_irq(ha->host->host_lock); wait_for_completion(&wait); del_timer_sync(&timer); - spin_lock_irq(HOST_LOCK); + spin_lock_irq(ha->host->host_lock); sp->wait = NULL; /* the only action we might get a fail for is abort */ @@ -1173,96 +1115,6 @@ qla1280_biosparam(struct scsi_device *sd return 0; } -#if LINUX_VERSION_CODE < 0x020600 -static int -qla1280_detect(struct scsi_host_template *template) -{ - struct pci_device_id *id = &qla1280_pci_tbl[0]; - struct pci_dev *pdev = NULL; - int num_hosts = 0; - - if (sizeof(struct srb) > sizeof(Scsi_Pointer)) { - printk(KERN_WARNING - "qla1280: struct srb too big, aborting\n"); - return 0; - } - - if ((DMA_BIDIRECTIONAL != PCI_DMA_BIDIRECTIONAL) || - (DMA_TO_DEVICE != PCI_DMA_TODEVICE) || - (DMA_FROM_DEVICE != PCI_DMA_FROMDEVICE) || - (DMA_NONE != PCI_DMA_NONE)) { - printk(KERN_WARNING - "qla1280: dma direction bits don't match\n"); - return 0; - } - -#ifdef MODULE - /* - * If we are called as a module, the qla1280 pointer may not be null - * and it would point to our bootup string, just like on the lilo - * command line. IF not NULL, then process this config string with - * qla1280_setup - * - * Boot time Options - * To add options at boot time add a line to your lilo.conf file like: - * append="qla1280=verbose,max_tags:{{255,255,255,255},{255,255,255,255}}" - * which will result in the first four devices on the first two - * controllers being set to a tagged queue depth of 32. - */ - if (qla1280) - qla1280_setup(qla1280); -#endif - - /* First Initialize QLA12160 on PCI Bus 1 Dev 2 */ - while ((pdev = pci_find_device(id->vendor, id->device, pdev))) { - if (pdev->bus->number == 1 && PCI_SLOT(pdev->devfn) == 2) { - if (!qla1280_probe_one(pdev, id)) - num_hosts++; - } - } - - pdev = NULL; - /* Try and find each different type of adapter we support */ - for (id = &qla1280_pci_tbl[0]; id->device; id++) { - while ((pdev = pci_find_device(id->vendor, id->device, pdev))) { - /* - * skip QLA12160 already initialized on - * PCI Bus 1 Dev 2 since we already initialized - * and presented it - */ - if (id->device == PCI_DEVICE_ID_QLOGIC_ISP12160 && - pdev->bus->number == 1 && - PCI_SLOT(pdev->devfn) == 2) - continue; - - if (!qla1280_probe_one(pdev, id)) - num_hosts++; - } - } - - return num_hosts; -} - -/* - * This looks a bit ugly as we could just pass down host to - * qla1280_remove_one, but I want to keep qla1280_release purely a wrapper - * around pci_driver::remove as used from 2.6 onwards. - */ -static int -qla1280_release(struct Scsi_Host *host) -{ - struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; - - qla1280_remove_one(ha->pdev); - return 0; -} - -static int -qla1280_biosparam_old(Disk * disk, kdev_t dev, int geom[]) -{ - return qla1280_biosparam(disk->device, NULL, disk->capacity, geom); -} -#endif /* disable risc and host interrupts */ static inline void @@ -1295,7 +1147,7 @@ qla1280_intr_handler(int irq, void *dev_ ENTER_INTR ("qla1280_intr_handler"); ha = (struct scsi_qla_host *)dev_id; - spin_lock(HOST_LOCK); + spin_lock(ha->host->host_lock); ha->isr_count++; reg = ha->iobase; @@ -1311,7 +1163,7 @@ qla1280_intr_handler(int irq, void *dev_ if (!list_empty(&ha->done_q)) qla1280_done(ha); - spin_unlock(HOST_LOCK); + spin_unlock(ha->host->host_lock); qla1280_enable_intrs(ha); @@ -1411,11 +1263,9 @@ qla1280_slave_configure(struct scsi_devi scsi_adjust_queue_depth(device, 0, default_depth); } -#if LINUX_VERSION_CODE > 0x020500 nv->bus[bus].target[target].parameter.enable_sync = device->sdtr; nv->bus[bus].target[target].parameter.enable_wide = device->wdtr; nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = device->ppr; -#endif if (driver_setup.no_sync || (driver_setup.sync_mask && @@ -1432,38 +1282,14 @@ qla1280_slave_configure(struct scsi_devi nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0; } - spin_lock_irqsave(HOST_LOCK, flags); + spin_lock_irqsave(ha->host->host_lock, flags); if (nv->bus[bus].target[target].parameter.enable_sync) status = qla1280_set_target_parameters(ha, bus, target); qla1280_get_target_parameters(ha, device); - spin_unlock_irqrestore(HOST_LOCK, flags); + spin_unlock_irqrestore(ha->host->host_lock, flags); return status; } -#if LINUX_VERSION_CODE < 0x020545 -/************************************************************************** - * qla1280_select_queue_depth - * - * Sets the queue depth for each SCSI device hanging off the input - * host adapter. We use a queue depth of 2 for devices that do not - * support tagged queueing. - **************************************************************************/ -static void -qla1280_select_queue_depth(struct Scsi_Host *host, struct scsi_device *sdev_q) -{ - struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; - struct scsi_device *sdev; - - ENTER("qla1280_select_queue_depth"); - for (sdev = sdev_q; sdev; sdev = sdev->next) - if (sdev->host == host) - qla1280_slave_configure(sdev); - - if (sdev_q) - qla1280_check_for_dead_scsi_bus(ha, sdev_q->channel); - LEAVE("qla1280_select_queue_depth"); -} -#endif /* * qla1280_done @@ -1523,10 +1349,6 @@ qla1280_done(struct scsi_qla_host *ha) CMD_HANDLE(sp->cmd) = (unsigned char *)INVALID_HANDLE; ha->actthreads--; -#if LINUX_VERSION_CODE < 0x020500 - if (cmd->cmnd[0] == INQUIRY) - qla1280_get_target_options(cmd, ha); -#endif (*(cmd)->scsi_done)(cmd); if(sp->wait != NULL) @@ -1655,9 +1477,7 @@ qla1280_initialize_adapter(struct scsi_q struct device_reg __iomem *reg; int status; int bus; -#if LINUX_VERSION_CODE > 0x020500 unsigned long flags; -#endif ENTER("qla1280_initialize_adapter"); @@ -1695,15 +1515,12 @@ qla1280_initialize_adapter(struct scsi_q "NVRAM\n"); } -#if LINUX_VERSION_CODE >= 0x020500 /* * It's necessary to grab the spin here as qla1280_mailbox_command * needs to be able to drop the lock unconditionally to wait * for completion. - * In 2.4 ->detect is called with the io_request_lock held. */ - spin_lock_irqsave(HOST_LOCK, flags); -#endif + spin_lock_irqsave(ha->host->host_lock, flags); status = qla1280_load_firmware(ha); if (status) { @@ -1735,9 +1552,8 @@ qla1280_initialize_adapter(struct scsi_q ha->flags.online = 1; out: -#if LINUX_VERSION_CODE >= 0x020500 - spin_unlock_irqrestore(HOST_LOCK, flags); -#endif + spin_unlock_irqrestore(ha->host->host_lock, flags); + if (status) dprintk(2, "qla1280_initialize_adapter: **** FAILED ****\n"); @@ -2650,14 +2466,14 @@ qla1280_mailbox_command(struct scsi_qla_ timer.function = qla1280_mailbox_timeout; add_timer(&timer); - spin_unlock_irq(HOST_LOCK); + spin_unlock_irq(ha->host->host_lock); WRT_REG_WORD(®->host_cmd, HC_SET_HOST_INT); data = qla1280_debounce_register(®->istatus); wait_for_completion(&wait); del_timer_sync(&timer); - spin_lock_irq(HOST_LOCK); + spin_lock_irq(ha->host->host_lock); ha->mailbox_wait = NULL; @@ -2770,9 +2586,9 @@ qla1280_bus_reset(struct scsi_qla_host * ha->bus_settings[bus].scsi_bus_dead = 1; ha->bus_settings[bus].failed_reset_count++; } else { - spin_unlock_irq(HOST_LOCK); + spin_unlock_irq(ha->host->host_lock); ssleep(reset_delay); - spin_lock_irq(HOST_LOCK); + spin_lock_irq(ha->host->host_lock); ha->bus_settings[bus].scsi_bus_dead = 0; ha->bus_settings[bus].failed_reset_count = 0; @@ -3078,7 +2894,7 @@ qla1280_64bit_start_scsi(struct scsi_qla (SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd); /* Enable simple tag queuing if device supports it. */ - if (DEV_SIMPLE_TAGS(cmd->device)) + if (cmd->device->simple_tags) pkt->control_flags |= cpu_to_le16(BIT_3); /* Load SCSI command packet. */ @@ -3377,7 +3193,7 @@ qla1280_32bit_start_scsi(struct scsi_qla (SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd); /* Enable simple tag queuing if device supports it. */ - if (DEV_SIMPLE_TAGS(cmd->device)) + if (cmd->device->simple_tags) pkt->control_flags |= cpu_to_le16(BIT_3); /* Load SCSI command packet. */ @@ -3889,50 +3705,6 @@ qla1280_rst_aen(struct scsi_qla_host *ha } -#if LINUX_VERSION_CODE < 0x020500 -/* - * - */ -static void -qla1280_get_target_options(struct scsi_cmnd *cmd, struct scsi_qla_host *ha) -{ - unsigned char *result; - struct nvram *n; - int bus, target, lun; - - bus = SCSI_BUS_32(cmd); - target = SCSI_TCN_32(cmd); - lun = SCSI_LUN_32(cmd); - - /* - * Make sure to not touch anything if someone is using the - * sg interface. - */ - if (cmd->use_sg || (CMD_RESULT(cmd) >> 16) != DID_OK || lun) - return; - - result = cmd->request_buffer; - n = &ha->nvram; - - n->bus[bus].target[target].parameter.enable_wide = 0; - n->bus[bus].target[target].parameter.enable_sync = 0; - n->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0; - - if (result[7] & 0x60) - n->bus[bus].target[target].parameter.enable_wide = 1; - if (result[7] & 0x10) - n->bus[bus].target[target].parameter.enable_sync = 1; - if ((result[2] >= 3) && (result[4] + 5 > 56) && - (result[56] & 0x4)) - n->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 1; - - dprintk(2, "get_target_options(): wide %i, sync %i, ppr %i\n", - n->bus[bus].target[target].parameter.enable_wide, - n->bus[bus].target[target].parameter.enable_sync, - n->bus[bus].target[target].ppr_1x160.flags.enable_ppr); -} -#endif - /* * qla1280_status_entry * Processes received ISP status entry. @@ -4271,7 +4043,7 @@ qla1280_get_target_parameters(struct scs } else printk(" Async"); - if (DEV_SIMPLE_TAGS(device)) + if (device->simple_tags) printk(", Tagged queuing: depth %d", device->queue_depth); printk("\n"); } @@ -4485,7 +4257,7 @@ qla1280_get_token(char *str) return ret; } -#if LINUX_VERSION_CODE >= 0x020600 + static struct scsi_host_template qla1280_driver_template = { .module = THIS_MODULE, .proc_name = "qla1280", @@ -4504,27 +4276,7 @@ static struct scsi_host_template qla1280 .cmd_per_lun = 1, .use_clustering = ENABLE_CLUSTERING, }; -#else -static struct scsi_host_template qla1280_driver_template = { - .proc_name = "qla1280", - .name = "Qlogic ISP 1280/12160", - .detect = qla1280_detect, - .release = qla1280_release, - .info = qla1280_info, - .queuecommand = qla1280_queuecommand, - .eh_abort_handler = qla1280_eh_abort, - .eh_device_reset_handler= qla1280_eh_device_reset, - .eh_bus_reset_handler = qla1280_eh_bus_reset, - .eh_host_reset_handler = qla1280_eh_adapter_reset, - .bios_param = qla1280_biosparam_old, - .can_queue = 0xfffff, - .this_id = -1, - .sg_tablesize = SG_ALL, - .cmd_per_lun = 1, - .use_clustering = ENABLE_CLUSTERING, - .use_new_eh_code = 1, -}; -#endif + static int __devinit qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) @@ -4615,10 +4367,6 @@ qla1280_probe_one(struct pci_dev *pdev, host->max_sectors = 1024; host->unique_id = host->host_no; -#if LINUX_VERSION_CODE < 0x020545 - host->select_queue_depths = qla1280_select_queue_depth; -#endif - error = -ENODEV; #if MEMORY_MAPPED_IO @@ -4666,21 +4414,15 @@ qla1280_probe_one(struct pci_dev *pdev, pci_set_drvdata(pdev, host); -#if LINUX_VERSION_CODE >= 0x020600 error = scsi_add_host(host, &pdev->dev); if (error) goto error_disable_adapter; scsi_scan_host(host); -#else - scsi_set_pci_device(host, pdev); -#endif return 0; -#if LINUX_VERSION_CODE >= 0x020600 error_disable_adapter: qla1280_disable_intrs(ha); -#endif error_free_irq: free_irq(pdev->irq, ha); error_release_region: @@ -4712,9 +4454,7 @@ qla1280_remove_one(struct pci_dev *pdev) struct Scsi_Host *host = pci_get_drvdata(pdev); struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; -#if LINUX_VERSION_CODE >= 0x020600 scsi_remove_host(host); -#endif qla1280_disable_intrs(ha); @@ -4738,7 +4478,6 @@ qla1280_remove_one(struct pci_dev *pdev) scsi_host_put(host); } -#if LINUX_VERSION_CODE >= 0x020600 static struct pci_driver qla1280_pci_driver = { .name = "qla1280", .id_table = qla1280_pci_tbl, @@ -4784,10 +4523,6 @@ qla1280_exit(void) module_init(qla1280_init); module_exit(qla1280_exit); -#else -# define driver_template qla1280_driver_template -# include "scsi_module.c" -#endif MODULE_AUTHOR("Qlogic & Jes Sorensen"); MODULE_DESCRIPTION("Qlogic ISP SCSI (qla1x80/qla1x160) driver"); diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 79d8a91..bad066e 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -1680,7 +1680,8 @@ typedef struct fc_port { uint8_t mp_byte; /* multi-path byte (not used) */ uint8_t cur_path; /* current path id */ - struct fc_rport *rport; + spinlock_t rport_lock; + struct fc_rport *rport, *drport; u32 supported_classes; struct work_struct rport_add_work; struct work_struct rport_del_work; @@ -2270,6 +2271,7 @@ typedef struct scsi_qla_host { #define LOOP_RESET_NEEDED 24 #define BEACON_BLINK_NEEDED 25 #define REGISTER_FDMI_NEEDED 26 +#define FCPORT_UPDATE_NEEDED 27 uint32_t device_flags; #define DFLG_LOCAL_DEVICES BIT_0 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 32be4c1..35266bd 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -47,9 +47,11 @@ extern int qla2x00_local_device_login(sc extern void qla2x00_restart_queues(scsi_qla_host_t *, uint8_t); extern void qla2x00_rescan_fcports(scsi_qla_host_t *); +extern void qla2x00_update_fcports(scsi_qla_host_t *); extern int qla2x00_abort_isp(scsi_qla_host_t *); +extern void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *); extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *); /* @@ -70,8 +72,8 @@ extern char *qla2x00_get_fw_version_str( extern void qla2x00_cmd_timeout(srb_t *); -extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int); -extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *); +extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int, int); +extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *, int); extern void qla2x00_blink_led(scsi_qla_host_t *); diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index a91fea6..e67bb09 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -32,7 +32,6 @@ static int qla2x00_fw_ready(scsi_qla_hos static int qla2x00_configure_hba(scsi_qla_host_t *); static int qla2x00_configure_loop(scsi_qla_host_t *); static int qla2x00_configure_local_loop(scsi_qla_host_t *); -static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *); static int qla2x00_configure_fabric(scsi_qla_host_t *); static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *); static int qla2x00_device_resync(scsi_qla_host_t *); @@ -1688,10 +1687,16 @@ static void qla2x00_rport_del(void *data) { fc_port_t *fcport = data; + struct fc_rport *rport; + unsigned long flags; + + spin_lock_irqsave(&fcport->rport_lock, flags); + rport = fcport->drport; + fcport->drport = NULL; + spin_unlock_irqrestore(&fcport->rport_lock, flags); + if (rport) + fc_remote_port_delete(rport); - if (fcport->rport) - fc_remote_port_delete(fcport->rport); - fcport->rport = NULL; } /** @@ -1719,6 +1724,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha atomic_set(&fcport->state, FCS_UNCONFIGURED); fcport->flags = FCF_RLC_SUPPORT; fcport->supported_classes = FC_COS_UNSPECIFIED; + spin_lock_init(&fcport->rport_lock); INIT_WORK(&fcport->rport_add_work, qla2x00_rport_add, fcport); INIT_WORK(&fcport->rport_del_work, qla2x00_rport_del, fcport); @@ -2008,7 +2014,7 @@ qla2x00_probe_for_all_luns(scsi_qla_host { fc_port_t *fcport; - qla2x00_mark_all_devices_lost(ha); + qla2x00_mark_all_devices_lost(ha, 0); list_for_each_entry(fcport, &ha->fcports, list) { if (fcport->port_type != FCT_TARGET) continue; @@ -2032,13 +2038,9 @@ qla2x00_probe_for_all_luns(scsi_qla_host * Context: * Kernel context. */ -static void +void qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) { - uint16_t index; - unsigned long flags; - srb_t *sp; - fcport->ha = ha; fcport->login_retry = 0; fcport->port_login_retry_count = ha->port_down_retry_count * @@ -2047,28 +2049,6 @@ qla2x00_update_fcport(scsi_qla_host_t *h PORT_RETRY_TIME); fcport->flags &= ~FCF_LOGIN_NEEDED; - /* - * Check for outstanding cmd on tape Bypass LUN discovery if active - * command on tape. - */ - if (fcport->flags & FCF_TAPE_PRESENT) { - spin_lock_irqsave(&ha->hardware_lock, flags); - for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { - fc_port_t *sfcp; - - if ((sp = ha->outstanding_cmds[index]) != 0) { - sfcp = sp->fcport; - if (sfcp == fcport) { - atomic_set(&fcport->state, FCS_ONLINE); - spin_unlock_irqrestore( - &ha->hardware_lock, flags); - return; - } - } - } - spin_unlock_irqrestore(&ha->hardware_lock, flags); - } - if (fcport->port_type == FCT_INITIATOR || fcport->port_type == FCT_BROADCAST) fcport->device_type = TYPE_PROCESSOR; @@ -2084,24 +2064,29 @@ qla2x00_reg_remote_port(scsi_qla_host_t { struct fc_rport_identifiers rport_ids; struct fc_rport *rport; + unsigned long flags; - if (fcport->rport) { - fc_remote_port_delete(fcport->rport); - fcport->rport = NULL; - } + if (fcport->drport) + qla2x00_rport_del(fcport); + if (fcport->rport) + return; rport_ids.node_name = wwn_to_u64(fcport->node_name); rport_ids.port_name = wwn_to_u64(fcport->port_name); rport_ids.port_id = fcport->d_id.b.domain << 16 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; - fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids); + rport = fc_remote_port_add(ha->host, 0, &rport_ids); if (!rport) { qla_printk(KERN_WARNING, ha, "Unable to allocate fc remote port!\n"); return; } + spin_lock_irqsave(&fcport->rport_lock, flags); + fcport->rport = rport; *((fc_port_t **)rport->dd_data) = fcport; + spin_unlock_irqrestore(&fcport->rport_lock, flags); + rport->supported_classes = fcport->supported_classes; rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; @@ -2217,12 +2202,11 @@ qla2x00_configure_fabric(scsi_qla_host_t if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { qla2x00_mark_device_lost(ha, fcport, - ql2xplogiabsentdevice); + ql2xplogiabsentdevice, 0); if (fcport->loop_id != FC_NO_LOOP_ID && (fcport->flags & FCF_TAPE_PRESENT) == 0 && fcport->port_type != FCT_INITIATOR && fcport->port_type != FCT_BROADCAST) { - ha->isp_ops.fabric_logout(ha, fcport->loop_id, fcport->d_id.b.domain, @@ -2694,7 +2678,8 @@ qla2x00_device_resync(scsi_qla_host_t *h if (atomic_read(&fcport->state) == FCS_ONLINE) { if (format != 3 || fcport->port_type != FCT_INITIATOR) { - qla2x00_mark_device_lost(ha, fcport, 0); + qla2x00_mark_device_lost(ha, fcport, + 0, 0); } } fcport->flags &= ~FCF_FARP_DONE; @@ -2741,8 +2726,7 @@ qla2x00_fabric_dev_login(scsi_qla_host_t ha->isp_ops.fabric_logout(ha, fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa); - qla2x00_mark_device_lost(ha, fcport, 1); - + qla2x00_mark_device_lost(ha, fcport, 1, 0); } else { qla2x00_update_fcport(ha, fcport); } @@ -2855,7 +2839,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha ha->isp_ops.fabric_logout(ha, fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa); - qla2x00_mark_device_lost(ha, fcport, 1); + qla2x00_mark_device_lost(ha, fcport, 1, 0); rval = 1; break; @@ -2990,6 +2974,17 @@ qla2x00_rescan_fcports(scsi_qla_host_t * qla2x00_probe_for_all_luns(ha); } +void +qla2x00_update_fcports(scsi_qla_host_t *ha) +{ + fc_port_t *fcport; + + /* Go with deferred removal of rport references. */ + list_for_each_entry(fcport, &ha->fcports, list) + if (fcport->drport) + qla2x00_rport_del(fcport); +} + /* * qla2x00_abort_isp * Resets ISP and aborts all outstanding commands. @@ -3019,7 +3014,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); if (atomic_read(&ha->loop_state) != LOOP_DOWN) { atomic_set(&ha->loop_state, LOOP_DOWN); - qla2x00_mark_all_devices_lost(ha); + qla2x00_mark_all_devices_lost(ha, 0); } else { if (!atomic_read(&ha->loop_down_timer)) atomic_set(&ha->loop_down_timer, diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index f63af08..71a46fc 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -389,7 +389,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, if (atomic_read(&ha->loop_state) != LOOP_DOWN) { atomic_set(&ha->loop_state, LOOP_DOWN); atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); - qla2x00_mark_all_devices_lost(ha); + qla2x00_mark_all_devices_lost(ha, 1); } set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); @@ -432,7 +432,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, atomic_set(&ha->loop_state, LOOP_DOWN); atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); ha->device_flags |= DFLG_NO_CABLE; - qla2x00_mark_all_devices_lost(ha); + qla2x00_mark_all_devices_lost(ha, 1); } ha->flags.management_server_logged_in = 0; @@ -453,7 +453,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, if (atomic_read(&ha->loop_state) != LOOP_DOWN) { atomic_set(&ha->loop_state, LOOP_DOWN); atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); - qla2x00_mark_all_devices_lost(ha); + qla2x00_mark_all_devices_lost(ha, 1); } set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); @@ -482,7 +482,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, if (!atomic_read(&ha->loop_down_timer)) atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); - qla2x00_mark_all_devices_lost(ha); + qla2x00_mark_all_devices_lost(ha, 1); } if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) { @@ -506,7 +506,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, if (!atomic_read(&ha->loop_down_timer)) atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); - qla2x00_mark_all_devices_lost(ha); + qla2x00_mark_all_devices_lost(ha, 1); } set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); @@ -580,7 +580,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, */ atomic_set(&ha->loop_state, LOOP_UP); - qla2x00_mark_all_devices_lost(ha); + qla2x00_mark_all_devices_lost(ha, 1); ha->flags.rscn_queue_overflow = 1; @@ -1091,7 +1091,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha cp->result = DID_BUS_BUSY << 16; if (atomic_read(&fcport->state) == FCS_ONLINE) { - qla2x00_mark_device_lost(ha, fcport, 1); + qla2x00_mark_device_lost(ha, fcport, 1, 1); } break; @@ -1135,7 +1135,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha /* Check to see if logout occurred. */ if ((le16_to_cpu(sts->status_flags) & SF_LOGOUT_SENT)) - qla2x00_mark_device_lost(ha, fcport, 1); + qla2x00_mark_device_lost(ha, fcport, 1, 1); break; case CS_QUEUE_FULL: diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 4916847..5866a7c 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -756,7 +756,7 @@ qla2xxx_eh_device_reset(struct scsi_cmnd if (ret == SUCCESS) { if (fcport->flags & FC_FABRIC_DEVICE) { ha->isp_ops.fabric_logout(ha, fcport->loop_id); - qla2x00_mark_device_lost(ha, fcport); + qla2x00_mark_device_lost(ha, fcport, 0, 0); } } #endif @@ -1642,6 +1642,31 @@ qla2x00_free_device(scsi_qla_host_t *ha) pci_disable_device(ha->pdev); } +static inline void +qla2x00_schedule_rport_del(struct scsi_qla_host *ha, fc_port_t *fcport, + int defer) +{ + unsigned long flags; + struct fc_rport *rport; + + if (!fcport->rport) + return; + + rport = fcport->rport; + if (defer) { + spin_lock_irqsave(&fcport->rport_lock, flags); + fcport->drport = rport; + fcport->rport = NULL; + spin_unlock_irqrestore(&fcport->rport_lock, flags); + set_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags); + } else { + spin_lock_irqsave(&fcport->rport_lock, flags); + fcport->rport = NULL; + spin_unlock_irqrestore(&fcport->rport_lock, flags); + fc_remote_port_delete(rport); + } +} + /* * qla2x00_mark_device_lost Updates fcport state when device goes offline. * @@ -1652,10 +1677,10 @@ qla2x00_free_device(scsi_qla_host_t *ha) * Context: */ void qla2x00_mark_device_lost(scsi_qla_host_t *ha, fc_port_t *fcport, - int do_login) + int do_login, int defer) { - if (atomic_read(&fcport->state) == FCS_ONLINE && fcport->rport) - schedule_work(&fcport->rport_del_work); + if (atomic_read(&fcport->state) == FCS_ONLINE) + qla2x00_schedule_rport_del(ha, fcport, defer); /* * We may need to retry the login, so don't change the state of the @@ -1702,7 +1727,7 @@ void qla2x00_mark_device_lost(scsi_qla_h * Context: */ void -qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha) +qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer) { fc_port_t *fcport; @@ -1716,10 +1741,13 @@ qla2x00_mark_all_devices_lost(scsi_qla_h */ if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) continue; - if (atomic_read(&fcport->state) == FCS_ONLINE && fcport->rport) - schedule_work(&fcport->rport_del_work); + if (atomic_read(&fcport->state) == FCS_ONLINE) + qla2x00_schedule_rport_del(ha, fcport, defer); atomic_set(&fcport->state, FCS_DEVICE_LOST); } + + if (defer && ha->dpc_wait && !ha->dpc_active) + up(ha->dpc_wait); } /* @@ -2161,6 +2189,9 @@ qla2x00_do_dpc(void *data) ha->host_no)); } + if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags)) + qla2x00_update_fcports(ha); + if (test_and_clear_bit(LOOP_RESET_NEEDED, &ha->dpc_flags)) { DEBUG(printk("scsi(%ld): dpc: sched loop_reset()\n", ha->host_no)); @@ -2219,13 +2250,8 @@ qla2x00_do_dpc(void *data) DEBUG(printk("scsi(%ld): port login OK: logged in ID 0x%x\n", ha->host_no, fcport->loop_id)); - fcport->port_login_retry_count = - ha->port_down_retry_count * PORT_RETRY_TIME; - atomic_set(&fcport->state, FCS_ONLINE); - atomic_set(&fcport->port_down_timer, - ha->port_down_retry_count * PORT_RETRY_TIME); - - fcport->login_retry = 0; + qla2x00_update_fcport(ha, + fcport); } else if (status == 1) { set_bit(RELOGIN_NEEDED, &ha->dpc_flags); /* retry the login again */ @@ -2469,6 +2495,7 @@ qla2x00_timer(scsi_qla_host_t *ha) if ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || test_bit(LOOP_RESET_NEEDED, &ha->dpc_flags) || + test_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags) || start_dpc || test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags) || test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) || diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index a2333d2..5cc97b7 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1350,7 +1350,7 @@ static void scsi_eh_lock_door(struct scs cmnd[4] = SCSI_REMOVAL_PREVENT; cmnd[5] = 0; - scsi_execute_async(sdev, cmnd, DMA_NONE, NULL, 0, 0, 10 * HZ, + scsi_execute_async(sdev, cmnd, 6, DMA_NONE, NULL, 0, 0, 10 * HZ, 5, NULL, NULL, GFP_KERNEL); } diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3574ba9..4a60285 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -436,6 +436,7 @@ free_bios: * scsi_execute_async - insert request * @sdev: scsi device * @cmd: scsi command + * @cmd_len: length of scsi cdb * @data_direction: data direction * @buffer: data buffer (this can be a kernel buffer or scatterlist) * @bufflen: len of buffer @@ -445,7 +446,7 @@ free_bios: * @flags: or into request flags **/ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, - int data_direction, void *buffer, unsigned bufflen, + int cmd_len, int data_direction, void *buffer, unsigned bufflen, int use_sg, int timeout, int retries, void *privdata, void (*done)(void *, char *, int, int), gfp_t gfp) { @@ -472,7 +473,7 @@ int scsi_execute_async(struct scsi_devic if (err) goto free_req; - req->cmd_len = COMMAND_SIZE(cmd[0]); + req->cmd_len = cmd_len; memcpy(req->cmd, cmd, req->cmd_len); req->sense = sioc->sense; req->sense_len = 0; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 78aad95..7d07000 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -741,7 +741,7 @@ sg_common_write(Sg_fd * sfp, Sg_request hp->duration = jiffies_to_msecs(jiffies); /* Now send everything of to mid-level. The next time we hear about this packet is when sg_cmd_done() is called (i.e. a callback). */ - if (scsi_execute_async(sdp->device, cmnd, data_dir, srp->data.buffer, + if (scsi_execute_async(sdp->device, cmnd, hp->cmd_len, data_dir, srp->data.buffer, hp->dxfer_len, srp->data.k_use_sg, timeout, SG_DEFAULT_RETRIES, srp, sg_cmd_done, GFP_ATOMIC)) { diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 13b1d3a..7f96f33 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -508,7 +508,7 @@ st_do_scsi(struct st_request * SRpnt, st STp->buffer->cmdstat.have_sense = 0; STp->buffer->syscall_result = 0; - if (scsi_execute_async(STp->device, cmd, direction, + if (scsi_execute_async(STp->device, cmd, COMMAND_SIZE(cmd[0]), direction, &((STp->buffer)->sg[0]), bytes, (STp->buffer)->sg_segs, timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) { /* could not allocate the buffer or request was too large */ diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index e94ca4d..290e3b4 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -275,7 +275,7 @@ extern int scsi_execute_req(struct scsi_ int data_direction, void *buffer, unsigned bufflen, struct scsi_sense_hdr *, int timeout, int retries); extern int scsi_execute_async(struct scsi_device *sdev, - const unsigned char *cmd, int data_direction, + const unsigned char *cmd, int cmd_len, int data_direction, void *buffer, unsigned bufflen, int use_sg, int timeout, int retries, void *privdata, void (*done)(void *, char *, int, int),