Merge branch 'master' into for_paulus
[linux-drm-fsl-dcu.git] / drivers / scsi / aic7xxx / aic79xx_osm.c
index 998999c0a972154efb9d191367a450efac768de9..c7fe478f481377d4b7add47574c6c3463dbd7b7a 100644 (file)
@@ -293,7 +293,7 @@ static uint32_t aic79xx_seltime;
  * force all outstanding transactions to be serviced prior to a new
  * transaction.
  */
-uint32_t aic79xx_periodic_otag;
+static uint32_t aic79xx_periodic_otag;
 
 /* Some storage boxes are using an LSI chip which has a bug making it
  * impossible to use aic79xx Rev B chip in 320 speeds.  The following
@@ -321,7 +321,7 @@ MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(AIC79XX_DRIVER_VERSION);
 module_param(aic79xx, charp, 0444);
 MODULE_PARM_DESC(aic79xx,
-"period delimited, options string.\n"
+"period-delimited options string:\n"
 "      verbose                 Enable verbose/diagnostic logging\n"
 "      allow_memio             Allow device registers to be memory mapped\n"
 "      debug                   Bitmask of debug values to enable\n"
@@ -346,7 +346,7 @@ MODULE_PARM_DESC(aic79xx,
 "              Shorten the selection timeout to 128ms\n"
 "\n"
 "      options aic79xx 'aic79xx=verbose.tag_info:{{}.{}.{..10}}.seltime:1'\n"
-"\n");
+);
 
 static void ahd_linux_handle_scsi_status(struct ahd_softc *,
                                         struct scsi_device *,
@@ -646,7 +646,7 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
        struct  ahd_initiator_tinfo *tinfo;
        struct  ahd_tmode_tstate *tstate;
        unsigned long flags;
-       DECLARE_COMPLETION(done);
+       DECLARE_COMPLETION_ONSTACK(done);
 
        reset_scb = NULL;
        paused = FALSE;
@@ -773,6 +773,7 @@ struct scsi_host_template aic79xx_driver_template = {
 #endif
        .can_queue              = AHD_MAX_QUEUE,
        .this_id                = -1,
+       .max_sectors            = 8192,
        .cmd_per_lun            = 2,
        .use_clustering         = ENABLE_CLUSTERING,
        .slave_alloc            = ahd_linux_slave_alloc,
@@ -1125,15 +1126,6 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
        return 0;
 }
 
-uint64_t
-ahd_linux_get_memsize(void)
-{
-       struct sysinfo si;
-
-       si_meminfo(&si);
-       return ((uint64_t)si.totalram << PAGE_SHIFT);
-}
-
 /*
  * Place the SCSI bus into a known state by either resetting it,
  * or forcing transfer negotiations on the next command to any
@@ -1557,7 +1549,7 @@ ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev,
  * SCSI controller interrupt handler.
  */
 irqreturn_t
-ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs)
+ahd_linux_isr(int irq, void *dev_id)
 {
        struct  ahd_softc *ahd;
        u_long  flags;
@@ -1813,9 +1805,9 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
                        u_int sense_offset;
 
                        if (scb->flags & SCB_SENSE) {
-                               sense_size = MIN(sizeof(struct scsi_sense_data)
+                               sense_size = min(sizeof(struct scsi_sense_data)
                                               - ahd_get_sense_residual(scb),
-                                                sizeof(cmd->sense_buffer));
+                                                (u_long)sizeof(cmd->sense_buffer));
                                sense_offset = 0;
                        } else {
                                /*
@@ -1824,7 +1816,8 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
                                 */
                                siu = (struct scsi_status_iu_header *)
                                    scb->sense_data;
-                               sense_size = MIN(scsi_4btoul(siu->sense_length),
+                               sense_size = min_t(size_t,
+                                               scsi_4btoul(siu->sense_length),
                                                sizeof(cmd->sense_buffer));
                                sense_offset = SIU_SENSE_OFFSET(siu);
                        }
@@ -2251,7 +2244,7 @@ done:
        if (paused)
                ahd_unpause(ahd);
        if (wait) {
-               DECLARE_COMPLETION(done);
+               DECLARE_COMPLETION_ONSTACK(done);
 
                ahd->platform_data->eh_done = &done;
                ahd_unlock(ahd, &flags);
@@ -2634,8 +2627,22 @@ static void ahd_linux_set_pcomp_en(struct scsi_target *starget, int pcomp)
                       pcomp ? "Enable" : "Disable");
 #endif
 
-       if (pcomp)
+       if (pcomp) {
+               uint8_t precomp;
+
+               if (ahd->unit < ARRAY_SIZE(aic79xx_iocell_info)) {
+                       struct ahd_linux_iocell_opts *iocell_opts;
+
+                       iocell_opts = &aic79xx_iocell_info[ahd->unit];
+                       precomp = iocell_opts->precomp;
+               } else {
+                       precomp = AIC79XX_DEFAULT_PRECOMP;
+               }
                ppr_options |= MSG_EXT_PPR_PCOMP_EN;
+               AHD_SET_PRECOMP(ahd, precomp);
+       } else {
+               AHD_SET_PRECOMP(ahd, 0);
+       }
 
        ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
                            starget->channel + 'A', ROLE_INITIATOR);
@@ -2678,7 +2685,25 @@ static void ahd_linux_set_hold_mcs(struct scsi_target *starget, int hold)
        ahd_unlock(ahd, &flags);
 }
 
+static void ahd_linux_get_signalling(struct Scsi_Host *shost)
+{
+       struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
+       unsigned long flags;
+       u8 mode;
+
+       ahd_lock(ahd, &flags);
+       ahd_pause(ahd);
+       mode = ahd_inb(ahd, SBLKCTL);
+       ahd_unpause(ahd);
+       ahd_unlock(ahd, &flags);
 
+       if (mode & ENAB40)
+               spi_signalling(shost) = SPI_SIGNAL_LVD;
+       else if (mode & ENAB20)
+               spi_signalling(shost) = SPI_SIGNAL_SE;
+       else
+               spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
+}
 
 static struct spi_function_template ahd_linux_transport_functions = {
        .set_offset     = ahd_linux_set_offset,
@@ -2703,6 +2728,7 @@ static struct spi_function_template ahd_linux_transport_functions = {
        .show_pcomp_en  = 1,
        .set_hold_mcs   = ahd_linux_set_hold_mcs,
        .show_hold_mcs  = 1,
+       .get_signalling = ahd_linux_get_signalling,
 };
 
 static int __init