Merge branch 'upstream'
authorJeff Garzik <jeff@garzik.org>
Thu, 30 Mar 2006 00:58:22 +0000 (19:58 -0500)
committerJeff Garzik <jeff@garzik.org>
Thu, 30 Mar 2006 00:58:22 +0000 (19:58 -0500)
1  2 
drivers/scsi/libata-scsi.c
include/linux/libata.h

index b53ef494a20631347dd54d674ca18cc4ac07c01a,628191bfd990a56e039611e8332bafda0ce07c92..410c78795ca8b14c79de7d8f925c4dbc69885ea4
@@@ -41,6 -41,7 +41,7 @@@
  #include <scsi/scsi_eh.h>
  #include <scsi/scsi_device.h>
  #include <scsi/scsi_request.h>
+ #include <scsi/scsi_transport.h>
  #include <linux/libata.h>
  #include <linux/hdreg.h>
  #include <asm/uaccess.h>
@@@ -52,6 -53,7 +53,7 @@@
  typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd);
  static struct ata_device *
  ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev);
+ enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
  
  #define RW_RECOVERY_MPAGE 0x1
  #define RW_RECOVERY_MPAGE_LEN 12
@@@ -92,6 -94,14 +94,14 @@@ static const u8 def_control_mpage[CONTR
        0, 30   /* extended self test time, see 05-359r1 */
  };
  
+ /*
+  * libata transport template.  libata doesn't do real transport stuff.
+  * It just needs the eh_timed_out hook.
+  */
+ struct scsi_transport_template ata_scsi_transport_template = {
+       .eh_timed_out           = ata_scsi_timed_out,
+ };
  
  static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
                                   void (*done)(struct scsi_cmnd *))
@@@ -246,7 -256,7 +256,7 @@@ int ata_task_ioctl(struct scsi_device *
        scsi_cmd[14] = args[0];
  
        /* Good values for timeout and retries?  Values below
-          from scsi_ioctl_send_command() for default case... */        
+          from scsi_ioctl_send_command() for default case... */
        if (scsi_execute_req(scsidev, scsi_cmd, DMA_NONE, NULL, 0, &sshdr,
                             (10*HZ), 5))
                rc = -EIO;
  
  int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
  {
-       struct ata_port *ap;
-       struct ata_device *dev;
        int val = -EINVAL, rc = -EINVAL;
  
-       ap = (struct ata_port *) &scsidev->host->hostdata[0];
-       if (!ap)
-               goto out;
-       dev = ata_scsi_find_dev(ap, scsidev);
-       if (!dev) {
-               rc = -ENODEV;
-               goto out;
-       }
        switch (cmd) {
        case ATA_IOC_GET_IO32:
                val = 0;
                break;
        }
  
- out:
        return rc;
  }
  
@@@ -404,12 -401,12 +401,12 @@@ int ata_scsi_device_resume(struct scsi_
        return ata_device_resume(ap, dev);
  }
  
- int ata_scsi_device_suspend(struct scsi_device *sdev)
+ int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
  {
        struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
        struct ata_device *dev = &ap->device[sdev->id];
  
-       return ata_device_suspend(ap, dev);
+       return ata_device_suspend(ap, dev, state);
  }
  
  /**
   *    LOCKING:
   *    spin_lock_irqsave(host_set lock)
   */
- void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, 
+ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
                        u8 *ascq)
  {
        int i;
                /* Look for drv_err */
                for (i = 0; sense_table[i][0] != 0xFF; i++) {
                        /* Look for best matches first */
-                       if ((sense_table[i][0] & drv_err) == 
+                       if ((sense_table[i][0] & drv_err) ==
                            sense_table[i][0]) {
                                *sk = sense_table[i][1];
                                *asc = sense_table[i][2];
                }
        }
        /* No error?  Undecoded? */
-       printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", 
+       printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n",
               id, drv_stat);
  
        /* We need a sensible error return here, which is tricky, and one
@@@ -678,7 -675,7 +675,7 @@@ static void ata_scsi_dev_config(struct 
         */
        max_sectors = ATA_MAX_SECTORS;
        if (dev->flags & ATA_DFLAG_LBA48)
 -              max_sectors = 2048;
 +              max_sectors = ATA_MAX_SECTORS_LBA48;
        if (dev->max_sectors)
                max_sectors = dev->max_sectors;
  
@@@ -1140,14 -1137,14 +1137,14 @@@ static unsigned int ata_scsi_verify_xla
  
                DPRINTK("block %u track %u cyl %u head %u sect %u\n",
                        (u32)block, track, cyl, head, sect);
-               
-               /* Check whether the converted CHS can fit. 
-                  Cylinder: 0-65535 
+               /* Check whether the converted CHS can fit.
+                  Cylinder: 0-65535
                   Head: 0-15
                   Sector: 1-255*/
-               if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) 
+               if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
                        goto out_of_range;
-               
                tf->command = ATA_CMD_VERIFY;
                tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */
                tf->lbal = sect;
@@@ -1279,7 -1276,7 +1276,7 @@@ static unsigned int ata_scsi_rw_xlat(st
                tf->lbal = block & 0xff;
  
                tf->device |= ATA_LBA;
-       } else { 
+       } else {
                /* CHS */
                u32 sect, head, cyl, track;
  
                DPRINTK("block %u track %u cyl %u head %u sect %u\n",
                        (u32)block, track, cyl, head, sect);
  
-               /* Check whether the converted CHS can fit. 
-                  Cylinder: 0-65535 
+               /* Check whether the converted CHS can fit.
+                  Cylinder: 0-65535
                   Head: 0-15
                   Sector: 1-255*/
                if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
@@@ -1687,7 -1684,7 +1684,7 @@@ unsigned int ata_scsiop_inq_83(struct a
  
        if (buflen > (ATA_SERNO_LEN + num + 3)) {
                /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
-               rbuf[num + 0] = 2;      
+               rbuf[num + 0] = 2;
                rbuf[num + 3] = ATA_SERNO_LEN;
                num += 4;
                ata_id_string(args->id, (unsigned char *) rbuf + num,
        if (buflen > (sat_model_serial_desc_len + num + 3)) {
                /* SAT defined lu model and serial numbers descriptor */
                /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */
-               rbuf[num + 0] = 2;      
-               rbuf[num + 1] = 1;      
+               rbuf[num + 0] = 2;
+               rbuf[num + 1] = 1;
                rbuf[num + 3] = sat_model_serial_desc_len;
                num += 4;
                memcpy(rbuf + num, "ATA     ", 8);
@@@ -2587,6 -2584,21 +2584,21 @@@ static inline void ata_scsi_dump_cdb(st
  #endif
  }
  
+ static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
+                                      struct ata_port *ap, struct ata_device *dev)
+ {
+       if (dev->class == ATA_DEV_ATA) {
+               ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
+                                                             cmd->cmnd[0]);
+               if (xlat_func)
+                       ata_scsi_translate(ap, dev, cmd, done, xlat_func);
+               else
+                       ata_scsi_simulate(ap, dev, cmd, done);
+       } else
+               ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
+ }
  /**
   *    ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device
   *    @cmd: SCSI command to be sent
@@@ -2621,24 -2633,13 +2633,13 @@@ int ata_scsi_queuecmd(struct scsi_cmnd 
        ata_scsi_dump_cdb(ap, cmd);
  
        dev = ata_scsi_find_dev(ap, scsidev);
-       if (unlikely(!dev)) {
+       if (likely(dev))
+               __ata_scsi_queuecmd(cmd, done, ap, dev);
+       else {
                cmd->result = (DID_BAD_TARGET << 16);
                done(cmd);
-               goto out_unlock;
        }
  
-       if (dev->class == ATA_DEV_ATA) {
-               ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
-                                                             cmd->cmnd[0]);
-               if (xlat_func)
-                       ata_scsi_translate(ap, dev, cmd, done, xlat_func);
-               else
-                       ata_scsi_simulate(ap, dev, cmd, done);
-       } else
-               ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
- out_unlock:
        spin_unlock(&ap->host_set->lock);
        spin_lock(shost->host_lock);
        return 0;
diff --combined include/linux/libata.h
index 4dff3cf9d3890f9dc1789e4ff86f1749d83f254e,0d61357604d5b24726c9dd2fd410b264a75182bb..c2215469a101c3d02576af0e14d855ffc3878e9e
@@@ -110,7 -110,6 +110,7 @@@ enum 
        ATA_DEF_QUEUE           = 1,
        ATA_MAX_QUEUE           = 1,
        ATA_MAX_SECTORS         = 200,  /* FIXME */
 +      ATA_MAX_SECTORS_LBA48   = 65535,
        ATA_MAX_BUS             = 2,
        ATA_DEF_BUSY_WAIT       = 10000,
        ATA_SHORT_PAUSE         = (HZ >> 6) + 1,
        ATA_QCFLAG_DMAMAP       = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
        ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */
  
+       /* host set flags */
+       ATA_HOST_SIMPLEX        = (1 << 0),     /* Host is simplex, one DMA channel per host_set only */
+       
        /* various lengths of time */
-       ATA_TMOUT_EDD           = 5 * HZ,       /* heuristic */
        ATA_TMOUT_PIO           = 30 * HZ,
        ATA_TMOUT_BOOT          = 30 * HZ,      /* heuristic */
        ATA_TMOUT_BOOT_QUICK    = 7 * HZ,       /* heuristic */
@@@ -280,6 -281,7 +282,7 @@@ struct ata_probe_ent 
        unsigned long           irq;
        unsigned int            irq_flags;
        unsigned long           host_flags;
+       unsigned long           host_set_flags;
        void __iomem            *mmio_base;
        void                    *private_data;
  };
@@@ -292,6 -294,9 +295,9 @@@ struct ata_host_set 
        unsigned int            n_ports;
        void                    *private_data;
        const struct ata_port_operations *ops;
+       unsigned long           flags;
+       int                     simplex_claimed;        /* Keep seperate in case we
+                                                          ever need to do this locked */
        struct ata_port *       ports[0];
  };
  
@@@ -359,6 -364,11 +365,11 @@@ struct ata_device 
        unsigned int            max_sectors;    /* per-device max sectors */
        unsigned int            cdb_len;
  
+       /* per-dev xfer mask */
+       unsigned int            pio_mask;
+       unsigned int            mwdma_mask;
+       unsigned int            udma_mask;
        /* for CHS addressing */
        u16                     cylinders;      /* Number of cylinders */
        u16                     heads;          /* Number of heads */
@@@ -396,6 -406,7 +407,7 @@@ struct ata_port 
  
        struct ata_host_stats   stats;
        struct ata_host_set     *host_set;
+       struct device           *dev;
  
        struct work_struct      port_task;
  
@@@ -415,6 -426,7 +427,7 @@@ struct ata_port_operations 
  
        void (*set_piomode) (struct ata_port *, struct ata_device *);
        void (*set_dmamode) (struct ata_port *, struct ata_device *);
+       unsigned long (*mode_filter) (const struct ata_port *, struct ata_device *, unsigned long);
  
        void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf);
        void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
        void (*dev_select)(struct ata_port *ap, unsigned int device);
  
        void (*phy_reset) (struct ata_port *ap); /* obsolete */
+       void (*set_mode) (struct ata_port *ap);
        int (*probe_reset) (struct ata_port *ap, unsigned int *classes);
  
        void (*post_set_mode) (struct ata_port *ap);
@@@ -510,16 -523,15 +524,15 @@@ extern void ata_host_set_remove(struct 
  extern int ata_scsi_detect(struct scsi_host_template *sht);
  extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
  extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
- extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
  extern int ata_scsi_error(struct Scsi_Host *host);
  extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
  extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
  extern int ata_scsi_release(struct Scsi_Host *host);
  extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
  extern int ata_scsi_device_resume(struct scsi_device *);
- extern int ata_scsi_device_suspend(struct scsi_device *);
+ extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state);
  extern int ata_device_resume(struct ata_port *, struct ata_device *);
- extern int ata_device_suspend(struct ata_port *, struct ata_device *);
+ extern int ata_device_suspend(struct ata_port *, struct ata_device *, pm_message_t state);
  extern int ata_ratelimit(void);
  extern unsigned int ata_busy_sleep(struct ata_port *ap,
                                   unsigned long timeout_pat,
@@@ -570,6 -582,8 +583,8 @@@ extern int ata_std_bios_param(struct sc
                              struct block_device *bdev,
                              sector_t capacity, int geom[]);
  extern int ata_scsi_slave_config(struct scsi_device *sdev);
+ extern struct ata_device *ata_dev_pair(struct ata_port *ap, 
+                                      struct ata_device *adev);
  
  /*
   * Timing helpers