merge by hand (fix up qla_os.c merge error)
authorJames Bottomley <jejb@titanic.(none)>
Fri, 17 Jun 2005 23:42:23 +0000 (18:42 -0500)
committerJames Bottomley <jejb@titanic.(none)>
Fri, 17 Jun 2005 23:42:23 +0000 (18:42 -0500)
1  2 
drivers/block/elevator.c
drivers/ieee1394/sbp2.c
drivers/scsi/Kconfig
drivers/scsi/aic7xxx/aic79xx_osm.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/scsi_scan.c

diff --combined drivers/block/elevator.c
index 89982925f9e2230d404c78349efe2b415133d5f7,8c51d1ccebbd6c14c20b160e126363f4f06476ab..f831f08f839c14d145cb19d322b361c47a08a2e6
@@@ -220,6 -220,11 +220,6 @@@ void elevator_exit(elevator_t *e
        kfree(e);
  }
  
 -static int elevator_global_init(void)
 -{
 -      return 0;
 -}
 -
  int elv_merge(request_queue_t *q, struct request **req, struct bio *bio)
  {
        elevator_t *e = q->elevator;
@@@ -285,6 -290,13 +285,13 @@@ void elv_requeue_request(request_queue_
                rq = rq->end_io_data;
        }
  
+       /*
+        * the request is prepped and may have some resources allocated.
+        * allowing unprepped requests to pass this one may cause resource
+        * deadlock.  turn on softbarrier.
+        */
+       rq->flags |= REQ_SOFTBARRIER;
        /*
         * if iosched has an explicit requeue hook, then use that. otherwise
         * just put the request at the front of the queue
@@@ -317,7 -329,7 +324,7 @@@ void __elv_add_request(request_queue_t 
                        int nrq = q->rq.count[READ] + q->rq.count[WRITE]
                                  - q->in_flight;
  
 -                      if (nrq == q->unplug_thresh)
 +                      if (nrq >= q->unplug_thresh)
                                __generic_unplug_device(q);
                }
        } else
@@@ -381,6 -393,12 +388,12 @@@ struct request *elv_next_request(reques
                if (ret == BLKPREP_OK) {
                        break;
                } else if (ret == BLKPREP_DEFER) {
+                       /*
+                        * the request may have been (partially) prepped.
+                        * we need to keep this request in the front to
+                        * avoid resource deadlock.  turn on softbarrier.
+                        */
+                       rq->flags |= REQ_SOFTBARRIER;
                        rq = NULL;
                        break;
                } else if (ret == BLKPREP_KILL) {
@@@ -687,6 -705,8 +700,6 @@@ ssize_t elv_iosched_show(request_queue_
        return len;
  }
  
 -module_init(elevator_global_init);
 -
  EXPORT_SYMBOL(elv_add_request);
  EXPORT_SYMBOL(__elv_add_request);
  EXPORT_SYMBOL(elv_requeue_request);
diff --combined drivers/ieee1394/sbp2.c
index ab82d6addd7fb78bca4cf0d83da3e14a09aa88d6,fcfddcc8e7ba1ca6f95b29289004ff66dbc5836f..2bae300aad4629623ffc6c6d61b5a4f0cd727766
@@@ -745,8 -745,7 +745,8 @@@ static struct scsi_id_instance_data *sb
        list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids);
  
        /* Register our host with the SCSI stack. */
 -      scsi_host = scsi_host_alloc(&scsi_driver_template, 0);
 +      scsi_host = scsi_host_alloc(&scsi_driver_template,
 +                                  sizeof (unsigned long));
        if (!scsi_host) {
                SBP2_ERR("failed to register scsi host");
                goto failed_alloc;
@@@ -1071,7 -1070,7 +1071,7 @@@ static int sbp2_handle_physdma_read(str
  static __inline__ int sbp2_command_conversion_device_type(u8 device_type)
  {
        return (((device_type == TYPE_DISK) ||
-                (device_type == TYPE_SDAD) ||
+                (device_type == TYPE_RBC) ||
                 (device_type == TYPE_ROM)) ? 1:0);
  }
  
@@@ -2112,102 -2111,6 +2112,6 @@@ static int sbp2_send_command(struct scs
   */
  static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd)
  {
-       unchar new_cmd[16];
-       u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun);
-       SBP2_DEBUG("sbp2_check_sbp2_command");
-       switch (*cmd) {
-               case READ_6:
-                       if (sbp2_command_conversion_device_type(device_type)) {
-                               SBP2_DEBUG("Convert READ_6 to READ_10");
-                               /*
-                                * Need to turn read_6 into read_10
-                                */
-                               new_cmd[0] = 0x28;
-                               new_cmd[1] = (cmd[1] & 0xe0);
-                               new_cmd[2] = 0x0;
-                               new_cmd[3] = (cmd[1] & 0x1f);
-                               new_cmd[4] = cmd[2];
-                               new_cmd[5] = cmd[3];
-                               new_cmd[6] = 0x0;
-                               new_cmd[7] = 0x0;
-                               new_cmd[8] = cmd[4];
-                               new_cmd[9] = cmd[5];
-                               memcpy(cmd, new_cmd, 10);
-                       }
-                       break;
-               case WRITE_6:
-                       if (sbp2_command_conversion_device_type(device_type)) {
-                               SBP2_DEBUG("Convert WRITE_6 to WRITE_10");
-                               /*
-                                * Need to turn write_6 into write_10
-                                */
-                               new_cmd[0] = 0x2a;
-                               new_cmd[1] = (cmd[1] & 0xe0);
-                               new_cmd[2] = 0x0;
-                               new_cmd[3] = (cmd[1] & 0x1f);
-                               new_cmd[4] = cmd[2];
-                               new_cmd[5] = cmd[3];
-                               new_cmd[6] = 0x0;
-                               new_cmd[7] = 0x0;
-                               new_cmd[8] = cmd[4];
-                               new_cmd[9] = cmd[5];
-                               memcpy(cmd, new_cmd, 10);
-                       }
-                       break;
-               case MODE_SENSE:
-                       if (sbp2_command_conversion_device_type(device_type)) {
-                               SBP2_DEBUG("Convert MODE_SENSE_6 to MODE_SENSE_10");
-                               /*
-                                * Need to turn mode_sense_6 into mode_sense_10
-                                */
-                               new_cmd[0] = 0x5a;
-                               new_cmd[1] = cmd[1];
-                               new_cmd[2] = cmd[2];
-                               new_cmd[3] = 0x0;
-                               new_cmd[4] = 0x0;
-                               new_cmd[5] = 0x0;
-                               new_cmd[6] = 0x0;
-                               new_cmd[7] = 0x0;
-                               new_cmd[8] = cmd[4];
-                               new_cmd[9] = cmd[5];
-                               memcpy(cmd, new_cmd, 10);
-                       }
-                       break;
-               case MODE_SELECT:
-                       /*
-                        * TODO. Probably need to change mode select to 10 byte version
-                        */
-               default:
-                       break;
-       }
-       return;
  }
  
  /*
@@@ -2248,7 -2151,6 +2152,6 @@@ static void sbp2_check_sbp2_response(st
                                     struct scsi_cmnd *SCpnt)
  {
        u8 *scsi_buf = SCpnt->request_buffer;
-       u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun);
  
        SBP2_DEBUG("sbp2_check_sbp2_response");
  
                                scsi_buf[4] = 36 - 5;
                        }
  
-                       /*
-                        * Check for Simple Direct Access Device and change it to TYPE_DISK
-                        */
-                       if ((scsi_buf[0] & 0x1f) == TYPE_SDAD) {
-                               SBP2_DEBUG("Changing TYPE_SDAD to TYPE_DISK");
-                               scsi_buf[0] &= 0xe0;
-                       }
                        /*
                         * Fix ansi revision and response data format
                         */
  
                        break;
  
-               case MODE_SENSE:
-                       if (sbp2_command_conversion_device_type(device_type)) {
-                               SBP2_DEBUG("Modify mode sense response (10 byte version)");
-                               scsi_buf[0] = scsi_buf[1];      /* Mode data length */
-                               scsi_buf[1] = scsi_buf[2];      /* Medium type */
-                               scsi_buf[2] = scsi_buf[3];      /* Device specific parameter */
-                               scsi_buf[3] = scsi_buf[7];      /* Block descriptor length */
-                               memcpy(scsi_buf + 4, scsi_buf + 8, scsi_buf[0]);
-                       }
-                       break;
-               case MODE_SELECT:
-                       /*
-                        * TODO. Probably need to change mode select to 10 byte version
-                        */
                default:
                        break;
        }
@@@ -2580,8 -2453,6 +2454,6 @@@ static void sbp2scsi_complete_command(s
                                      u32 scsi_status, struct scsi_cmnd *SCpnt,
                                      void (*done)(struct scsi_cmnd *))
  {
-       unsigned long flags;
        SBP2_DEBUG("sbp2scsi_complete_command");
  
        /*
        /*
         * Tell scsi stack that we're done with this command
         */
-       spin_lock_irqsave(scsi_id->scsi_host->host_lock,flags);
        done (SCpnt);
-       spin_unlock_irqrestore(scsi_id->scsi_host->host_lock,flags);
-       return;
  }
  
  
  static int sbp2scsi_slave_configure (struct scsi_device *sdev)
  {
        blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
+       sdev->use_10_for_rw = 1;
+       sdev->use_10_for_ms = 1;
        return 0;
  }
  
@@@ -2747,7 -2615,7 +2616,7 @@@ static int sbp2scsi_abort(struct scsi_c
  /*
   * Called by scsi stack when something has really gone wrong.
   */
- static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
+ static int __sbp2scsi_reset(struct scsi_cmnd *SCpnt)
  {
        struct scsi_id_instance_data *scsi_id =
                (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
        return(SUCCESS);
  }
  
+ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
+ {
+       unsigned long flags;
+       int rc;
+       spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
+       rc = __sbp2scsi_reset(SCpnt);
+       spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags);
+       return rc;
+ }
  static const char *sbp2scsi_info (struct Scsi_Host *host)
  {
          return "SCSI emulation for IEEE-1394 SBP-2 Devices";
diff --combined drivers/scsi/Kconfig
index 27fec8a5eb5bff4642c28160fb4d0ad6941dcd15,88e34095ca4e11a1a106b0a5d1fb6d11ba0194c7..96df148ed96967f06e544893ae415ba2bb18699d
@@@ -137,6 -137,24 +137,24 @@@ config CHR_DEV_S
  
          If unsure, say N.
  
+ config CHR_DEV_SCH
+       tristate "SCSI media changer support"
+       depends on SCSI
+       ---help---
+         This is a driver for SCSI media changers.  Most common devices are
+         tape libraries and MOD/CDROM jukeboxes.  *Real* jukeboxes, you
+         don't need this for those tiny 6-slot cdrom changers.  Media
+         changers are listed as "Type: Medium Changer" in /proc/scsi/scsi.
+         If you have such hardware and want to use it with linux, say Y
+         here.  Check <file:Documentation/scsi-changer.txt> for details.
+       
+         If you want to compile this as a module ( = code which can be
+         inserted in and removed from the running kernel whenever you want),
+         say M here and read <file:Documentation/modules.txt> and
+         <file:Documentation/scsi.txt>. The module will be called ch.o.
+         If unsure, say N.
+       
  comment "Some SCSI devices (e.g. CD jukebox) support multiple LUNs"
        depends on SCSI
  
@@@ -1192,28 -1210,6 +1210,6 @@@ config SCSI_PAS1
          To compile this driver as a module, choose M here: the
          module will be called pas16.
  
- config SCSI_PCI2000
-       tristate "PCI2000 support"
-       depends on PCI && SCSI && BROKEN
-       help
-         This is support for the PCI2000I EIDE interface card which acts as a
-         SCSI host adapter.  Please read the SCSI-HOWTO, available from
-         <http://www.tldp.org/docs.html#howto>.
-         To compile this driver as a module, choose M here: the
-         module will be called pci2000.
- config SCSI_PCI2220I
-       tristate "PCI2220i support"
-       depends on PCI && SCSI && BROKEN
-       help
-         This is support for the PCI2220i EIDE interface card which acts as a
-         SCSI host adapter.  Please read the SCSI-HOWTO, available from
-         <http://www.tldp.org/docs.html#howto>.
-         To compile this driver as a module, choose M here: the
-         module will be called pci2220i.
  config SCSI_PSI240I
        tristate "PSI240i support"
        depends on ISA && SCSI
@@@ -1752,7 -1748,7 +1748,7 @@@ config SCSI_NCR53C7xx_FAS
  
  config SUN3_SCSI
        tristate "Sun3 NCR5380 SCSI"
 -      depends on SUN3 && SCSI
 +      depends on SUN3 && SCSI && BROKEN
        help
          This option will enable support for the OBIO (onboard io) NCR5380
          SCSI controller found in the Sun 3/50 and 3/60, as well as for
index 7c02b7dc7098869d0eba696477c1c35fef3f0693,53b7b2c15f86b344456132b3e2c64a0705bc3ade..c4eaaad2c69bedd3f67004aae7960802709739f6
@@@ -941,7 -941,7 +941,7 @@@ ahd_linux_queue(Scsi_Cmnd * cmd, void (
         */
        cmd->scsi_done = scsi_done;
  
-       ahd_midlayer_entrypoint_lock(ahd, &flags);
+       ahd_lock(ahd, &flags);
  
        /*
         * Close the race of a command that was in the process of
                ahd_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ);
                ahd_linux_queue_cmd_complete(ahd, cmd);
                ahd_schedule_completeq(ahd);
-               ahd_midlayer_entrypoint_unlock(ahd, &flags);
+               ahd_unlock(ahd, &flags);
                return (0);
        }
        dev = ahd_linux_get_device(ahd, cmd->device->channel,
                ahd_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL);
                ahd_linux_queue_cmd_complete(ahd, cmd);
                ahd_schedule_completeq(ahd);
-               ahd_midlayer_entrypoint_unlock(ahd, &flags);
+               ahd_unlock(ahd, &flags);
                printf("%s: aic79xx_linux_queue - Unable to allocate device!\n",
                       ahd_name(ahd));
                return (0);
                dev->flags |= AHD_DEV_ON_RUN_LIST;
                ahd_linux_run_device_queues(ahd);
        }
-       ahd_midlayer_entrypoint_unlock(ahd, &flags);
+       ahd_unlock(ahd, &flags);
        return (0);
  }
  
@@@ -1511,17 -1511,17 +1511,17 @@@ ahd_linux_dev_reset(Scsi_Cmnd *cmd
                       ahd_name(ahd), cmd->device->channel, cmd->device->id,
                       cmd->device->lun, cmd);
  #endif
-       ahd_midlayer_entrypoint_lock(ahd, &s);
+       ahd_lock(ahd, &s);
  
        dev = ahd_linux_get_device(ahd, cmd->device->channel, cmd->device->id,
                                   cmd->device->lun, /*alloc*/FALSE);
        if (dev == NULL) {
-               ahd_midlayer_entrypoint_unlock(ahd, &s);
+               ahd_unlock(ahd, &s);
                kfree(recovery_cmd);
                return (FAILED);
        }
        if ((scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX)) == NULL) {
-               ahd_midlayer_entrypoint_unlock(ahd, &s);
+               ahd_unlock(ahd, &s);
                kfree(recovery_cmd);
                return (FAILED);
        }
        spin_lock_irq(&ahd->platform_data->spin_lock);
        ahd_schedule_runq(ahd);
        ahd_linux_run_complete_queue(ahd);
-       ahd_midlayer_entrypoint_unlock(ahd, &s);
+       ahd_unlock(ahd, &s);
        printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval);
        return (retval);
  }
@@@ -1591,11 -1591,11 +1591,11 @@@ ahd_linux_bus_reset(Scsi_Cmnd *cmd
                printf("%s: Bus reset called for cmd %p\n",
                       ahd_name(ahd), cmd);
  #endif
-       ahd_midlayer_entrypoint_lock(ahd, &s);
+       ahd_lock(ahd, &s);
        found = ahd_reset_channel(ahd, cmd->device->channel + 'A',
                                  /*initiate reset*/TRUE);
        ahd_linux_run_complete_queue(ahd);
-       ahd_midlayer_entrypoint_unlock(ahd, &s);
+       ahd_unlock(ahd, &s);
  
        if (bootverbose)
                printf("%s: SCSI bus reset delivered. "
@@@ -2488,7 -2488,7 +2488,7 @@@ ahd_linux_dv_thread(void *data
        sprintf(current->comm, "ahd_dv_%d", ahd->unit);
  #else
        daemonize("ahd_dv_%d", ahd->unit);
 -      current->flags |= PF_FREEZE;
 +      current->flags |= PF_NOFREEZE;
  #endif
        unlock_kernel();
  
index 3c97aa45772dc4aea2b7c4dbd759e76fa46c1745,f12a2b6fa7a06995de0a2a1dbeac71495981ed6d..e6831264f67ca87002b1b96151795035cebf1af6
@@@ -36,27 -36,12 +36,12 @@@ char qla2x00_version_str[40]
  /*
   * SRB allocation cache
   */
- char srb_cachep_name[16];
- kmem_cache_t *srb_cachep;
- /*
-  * Stats for all adpaters.
-  */
- struct _qla2x00stats qla2x00_stats;
+ static kmem_cache_t *srb_cachep;
  
  /*
   * Ioctl related information.
   */
- int num_hosts;
- int apiHBAInstance;
- /*
-  * Module parameter information and variables
-  */
- int ql2xmaxqdepth;
- module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
- MODULE_PARM_DESC(ql2xmaxqdepth,
-               "Maximum queue depth to report for target devices.");
+ static int num_hosts;
  
  int ql2xlogintimeout = 20;
  module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR);
@@@ -69,12 -54,6 +54,6 @@@ MODULE_PARM_DESC(qlport_down_retry
                "Maximum number of command retries to a port that returns"
                "a PORT-DOWN status.");
  
- int ql2xretrycount = 20;
- module_param(ql2xretrycount, int, S_IRUGO|S_IWUSR);
- MODULE_PARM_DESC(ql2xretrycount,
-               "Maximum number of mid-layer retries allowed for a command.  "
-               "Default value is 20, ");
  int ql2xplogiabsentdevice;
  module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
  MODULE_PARM_DESC(ql2xplogiabsentdevice,
@@@ -95,25 -74,6 +74,6 @@@ MODULE_PARM_DESC(ql2xintrdelaytimer
                "ZIO: Waiting time for Firmware before it generates an "
                "interrupt to the host to notify completion of request.");
  
- int ConfigRequired;
- module_param(ConfigRequired, int, S_IRUGO|S_IRUSR);
- MODULE_PARM_DESC(ConfigRequired,
-               "If 1, then only configured devices passed in through the"
-               "ql2xopts parameter will be presented to the OS");
- int Bind = BIND_BY_PORT_NAME;
- module_param(Bind, int, S_IRUGO|S_IRUSR);
- MODULE_PARM_DESC(Bind,
-               "Target persistent binding method: "
-               "0 by Portname (default); 1 by PortID; 2 by Nodename. ");
- int ql2xsuspendcount = SUSPEND_COUNT;
- module_param(ql2xsuspendcount, int, S_IRUGO|S_IWUSR);
- MODULE_PARM_DESC(ql2xsuspendcount,
-               "Number of 6-second suspend iterations to perform while a "
-               "target returns a <NOT READY> status.  Default is 10 "
-               "iterations.");
  int ql2xloginretrycount = 0;
  module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
  MODULE_PARM_DESC(ql2xloginretrycount,
@@@ -330,7 -290,6 +290,6 @@@ qla2x00_queuecommand(struct scsi_cmnd *
        sp->fcport = fcport;
        sp->cmd = cmd;
        sp->flags = 0;
-       sp->err_id = 0;
  
        CMD_SP(cmd) = (void *)sp;
        cmd->scsi_done = done;
@@@ -474,7 -433,6 +433,6 @@@ qla2x00_wait_for_loop_ready(scsi_qla_ho
  
        while ((!atomic_read(&ha->loop_down_timer) &&
            atomic_read(&ha->loop_state) == LOOP_DOWN) ||
-           test_bit(CFG_ACTIVE, &ha->cfg_flags) ||
            atomic_read(&ha->loop_state) != LOOP_READY) {
                msleep(1000);
                if (time_after_eq(jiffies, loop_timeout)) {
@@@ -507,7 -465,6 +465,7 @@@ qla2xxx_eh_abort(struct scsi_cmnd *cmd
        int ret, i;
        unsigned int id, lun;
        unsigned long serial;
 +      unsigned long flags;
  
        if (!CMD_SP(cmd))
                return FAILED;
        serial = cmd->serial_number;
  
        /* Check active list for command command. */
-       spin_unlock_irq(ha->host->host_lock);
 -      spin_lock(&ha->hardware_lock);
 +      spin_lock_irqsave(&ha->hardware_lock, flags);
        for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
                sp = ha->outstanding_cmds[i];
  
                    sp->state));
                DEBUG3(qla2x00_print_scsi_cmd(cmd);)
  
 -              spin_unlock(&ha->hardware_lock);
 +              spin_unlock_irqrestore(&ha->hardware_lock, flags);
                if (qla2x00_abort_command(ha, sp)) {
                        DEBUG2(printk("%s(%ld): abort_command "
                            "mbx failed.\n", __func__, ha->host_no));
                            "mbx success.\n", __func__, ha->host_no));
                        ret = SUCCESS;
                }
 -              spin_lock(&ha->hardware_lock);
 +              spin_lock_irqsave(&ha->hardware_lock, flags);
  
                break;
        }
 +      spin_unlock_irqrestore(&ha->hardware_lock, flags);
  
        /* Wait for the command to be returned. */
        if (ret == SUCCESS) {
 -              spin_unlock(&ha->hardware_lock);
                if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) {
                        qla_printk(KERN_ERR, ha, 
                            "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
                            "%x.\n", ha->host_no, id, lun, serial, ret);
                }
 -              spin_lock(&ha->hardware_lock);
        }
-       spin_lock_irq(ha->host->host_lock);
  
        qla_printk(KERN_INFO, ha, 
            "scsi(%ld:%d:%d): Abort command issued -- %lx %x.\n", ha->host_no,
@@@ -588,7 -544,6 +544,7 @@@ qla2x00_eh_wait_for_pending_target_comm
        int     status;
        srb_t           *sp;
        struct scsi_cmnd *cmd;
 +      unsigned long flags;
  
        status = 0;
  
         * array
         */
        for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
 -              spin_lock(&ha->hardware_lock);
 +              spin_lock_irqsave(&ha->hardware_lock, flags);
                sp = ha->outstanding_cmds[cnt];
                if (sp) {
                        cmd = sp->cmd;
 -                      spin_unlock(&ha->hardware_lock);
 +                      spin_unlock_irqrestore(&ha->hardware_lock, flags);
                        if (cmd->device->id == t) {
                                if (!qla2x00_eh_wait_on_command(ha, cmd)) {
                                        status = 1;
                                }
                        }
                } else {
 -                      spin_unlock(&ha->hardware_lock);
 +                      spin_unlock_irqrestore(&ha->hardware_lock, flags);
                }
        }
        return (status);
@@@ -658,12 -613,8 +614,8 @@@ qla2xxx_eh_device_reset(struct scsi_cmn
        qla_printk(KERN_INFO, ha,
            "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun);
  
-       spin_unlock_irq(ha->host->host_lock);
-       if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
-               spin_lock_irq(ha->host->host_lock);
+       if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
                goto eh_dev_reset_done;
-       }
  
        if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
                if (qla2x00_device_reset(ha, fcport) == 0)
            "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no, id, lun);
  
  eh_dev_reset_done:
-       spin_lock_irq(ha->host->host_lock);
        return ret;
  }
  
@@@ -741,7 -690,6 +691,7 @@@ qla2x00_eh_wait_for_pending_commands(sc
        int     status;
        srb_t           *sp;
        struct scsi_cmnd *cmd;
 +      unsigned long flags;
  
        status = 1;
  
         * array
         */
        for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
 -              spin_lock(&ha->hardware_lock);
 +              spin_lock_irqsave(&ha->hardware_lock, flags);
                sp = ha->outstanding_cmds[cnt];
                if (sp) {
                        cmd = sp->cmd;
 -                      spin_unlock(&ha->hardware_lock);
 +                      spin_unlock_irqrestore(&ha->hardware_lock, flags);
                        status = qla2x00_eh_wait_on_command(ha, cmd);
                        if (status == 0)
                                break;
                }
                else {
 -                      spin_unlock(&ha->hardware_lock);
 +                      spin_unlock_irqrestore(&ha->hardware_lock, flags);
                }
        }
        return (status);
@@@ -805,8 -753,6 +755,6 @@@ qla2xxx_eh_bus_reset(struct scsi_cmnd *
        qla_printk(KERN_INFO, ha,
            "scsi(%ld:%d:%d): LOOP RESET ISSUED.\n", ha->host_no, id, lun);
  
-       spin_unlock_irq(ha->host->host_lock);
        if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
                DEBUG2(printk("%s failed:board disabled\n",__func__));
                goto eh_bus_reset_done;
@@@ -828,8 -774,6 +776,6 @@@ eh_bus_reset_done
        qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
            (ret == FAILED) ? "failed" : "succeded");
  
-       spin_lock_irq(ha->host->host_lock);
        return ret;
  }
  
@@@ -871,8 -815,6 +817,6 @@@ qla2xxx_eh_host_reset(struct scsi_cmnd 
        qla_printk(KERN_INFO, ha,
            "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", ha->host_no, id, lun);
  
-       spin_unlock_irq(ha->host->host_lock);
        if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
                goto eh_host_reset_lock;
  
                ret = SUCCESS;
  
  eh_host_reset_lock:
-       spin_lock_irq(ha->host->host_lock);
        qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
            (ret == FAILED) ? "failed" : "succeded");
  
@@@ -1196,34 -1136,24 +1138,24 @@@ int qla2x00_probe_one(struct pci_dev *p
  
        spin_lock_init(&ha->hardware_lock);
  
-       /* 4.23 Initialize /proc/scsi/qla2x00 counters */
-       ha->actthreads = 0;
-       ha->qthreads   = 0;
-       ha->total_isr_cnt = 0;
-       ha->total_isp_aborts = 0;
-       ha->total_lip_cnt = 0;
-       ha->total_dev_errs = 0;
-       ha->total_ios = 0;
-       ha->total_bytes = 0;
        ha->prev_topology = 0;
        ha->ports = MAX_BUSES;
  
        if (IS_QLA2100(ha)) {
-               ha->max_targets = MAX_TARGETS_2100;
+               host->max_id = MAX_TARGETS_2100;
                ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
                ha->request_q_length = REQUEST_ENTRY_CNT_2100;
                ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
                ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
                host->sg_tablesize = 32;
        } else if (IS_QLA2200(ha)) {
-               ha->max_targets = MAX_TARGETS_2200;
+               host->max_id = MAX_TARGETS_2200;
                ha->mbx_count = MAILBOX_REGISTER_COUNT;
                ha->request_q_length = REQUEST_ENTRY_CNT_2200;
                ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
                ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
        } else /*if (IS_QLA2300(ha))*/ {
-               ha->max_targets = MAX_TARGETS_2200;
+               host->max_id = MAX_TARGETS_2200;
                ha->mbx_count = MAILBOX_REGISTER_COUNT;
                ha->request_q_length = REQUEST_ENTRY_CNT_2200;
                ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
        host->unique_id = ha->instance;
        host->max_cmd_len = MAX_CMDSZ;
        host->max_channel = ha->ports - 1;
-       host->max_id = ha->max_targets;
-       host->max_lun = ha->max_luns;
+       host->max_lun = MAX_LUNS;
        host->transportt = qla2xxx_transport_template;
        if (scsi_add_host(host, &pdev->dev))
                goto probe_alloc_failed;
@@@ -2338,8 -2267,7 +2269,7 @@@ static int __ini
  qla2x00_module_init(void)
  {
        /* Allocate cache for SRBs. */
-       sprintf(srb_cachep_name, "qla2xxx_srbs");
-       srb_cachep = kmem_cache_create(srb_cachep_name, sizeof(srb_t), 0,
+       srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
            SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (srb_cachep == NULL) {
                printk(KERN_ERR
  static void __exit
  qla2x00_module_exit(void)
  {
-       /* Free SRBs cache. */
-       if (srb_cachep != NULL) {
-               if (kmem_cache_destroy(srb_cachep) != 0) {
-                       printk(KERN_ERR
-                           "qla2xxx: Unable to free SRB cache...Memory pools "
-                           "still active?\n");
-               }
-               srb_cachep = NULL;
-       }
+       kmem_cache_destroy(srb_cachep);
        fc_release_transport(qla2xxx_transport_template);
  }
  
diff --combined drivers/scsi/scsi_scan.c
index 8d0d302844a1d5a5c3a9df8530e1be0974f5c4d6,4d273ceb1d0926c60b45bb806b859b2323938d39..9fa209097e3bb2da7e3de974a3a6fcd02f0651cf
@@@ -293,6 -293,10 +293,10 @@@ static void scsi_target_dev_release(str
  {
        struct device *parent = dev->parent;
        struct scsi_target *starget = to_scsi_target(dev);
+       struct Scsi_Host *shost = dev_to_shost(parent);
+       if (shost->hostt->target_destroy)
+               shost->hostt->target_destroy(starget);
        kfree(starget);
        put_device(parent);
  }
@@@ -360,9 -364,23 +364,23 @@@ static struct scsi_target *scsi_alloc_t
        list_add_tail(&starget->siblings, &shost->__targets);
        spin_unlock_irqrestore(shost->host_lock, flags);
        /* allocate and add */
-       transport_setup_device(&starget->dev);
-       device_add(&starget->dev);
-       transport_add_device(&starget->dev);
+       transport_setup_device(dev);
+       device_add(dev);
+       transport_add_device(dev);
+       if (shost->hostt->target_alloc) {
+               int error = shost->hostt->target_alloc(starget);
+               if(error) {
+                       dev_printk(KERN_ERR, dev, "target allocation failed, error %d\n", error);
+                       /* don't want scsi_target_reap to do the final
+                        * put because it will be under the host lock */
+                       get_device(dev);
+                       scsi_target_reap(starget);
+                       put_device(dev);
+                       return NULL;
+               }
+       }
        return starget;
  
   found:
@@@ -625,6 -643,7 +643,7 @@@ static int scsi_add_lun(struct scsi_dev
        case TYPE_MEDIUM_CHANGER:
        case TYPE_ENCLOSURE:
        case TYPE_COMM:
+       case TYPE_RBC:
                sdev->writeable = 1;
                break;
        case TYPE_WORM:
@@@ -1197,7 -1216,6 +1216,7 @@@ struct scsi_device *__scsi_add_device(s
        if (!starget)
                return ERR_PTR(-ENOMEM);
  
 +      get_device(&starget->dev);
        down(&shost->scan_mutex);
        res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
        if (res != SCSI_SCAN_LUN_PRESENT)