]> err.no Git - linux-2.6/blobdiff - drivers/ieee1394/sbp2.c
Merge ../linux-2.6
[linux-2.6] / drivers / ieee1394 / sbp2.c
index ecd59ef8c8a361a34916cd486f5b083577b31612..5413dc43b9f1b2eb5bda4f976434535e91af3e1e 100644 (file)
@@ -151,6 +151,16 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device (default = 1)"
  * - skip mode page 8
  *   Suppress sending of mode_sense for mode page 8 if the device pretends to
  *   support the SCSI Primary Block commands instead of Reduced Block Commands.
+ *
+ * - fix capacity
+ *   Tell sd_mod to correct the last sector number reported by read_capacity.
+ *   Avoids access beyond actual disk limits on devices with an off-by-one bug.
+ *   Don't use this with devices which don't have this bug.
+ *
+ * - override internal blacklist
+ *   Instead of adding to the built-in blacklist, use only the workarounds
+ *   specified in the module load parameter.
+ *   Useful if a blacklist entry interfered with a non-broken device.
  */
 static int sbp2_default_workarounds;
 module_param_named(workarounds, sbp2_default_workarounds, int, 0644);
@@ -158,6 +168,8 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
        ", 128kB max transfer = " __stringify(SBP2_WORKAROUND_128K_MAX_TRANS)
        ", 36 byte inquiry = "    __stringify(SBP2_WORKAROUND_INQUIRY_36)
        ", skip mode page 8 = "   __stringify(SBP2_WORKAROUND_MODE_SENSE_8)
+       ", fix capacity = "       __stringify(SBP2_WORKAROUND_FIX_CAPACITY)
+       ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
        ", or a combination)");
 
 /* legacy parameter */
@@ -291,6 +303,7 @@ static struct hpsb_protocol_driver sbp2_driver = {
  */
 static const struct {
        u32 firmware_revision;
+       u32 model_id;
        unsigned workarounds;
 } sbp2_workarounds_table[] = {
        /* TSB42AA9 */ {
@@ -305,6 +318,31 @@ static const struct {
        /* Symbios bridge */ {
                .firmware_revision      = 0xa0b800,
                .workarounds            = SBP2_WORKAROUND_128K_MAX_TRANS,
+       },
+       /*
+        * Note about the following Apple iPod blacklist entries:
+        *
+        * There are iPods (2nd gen, 3rd gen) with model_id==0.  Since our
+        * matching logic treats 0 as a wildcard, we cannot match this ID
+        * without rewriting the matching routine.  Fortunately these iPods
+        * do not feature the read_capacity bug according to one report.
+        * Read_capacity behaviour as well as model_id could change due to
+        * Apple-supplied firmware updates though.
+        */
+       /* iPod 4th generation */ {
+               .firmware_revision      = 0x0a2700,
+               .model_id               = 0x000021,
+               .workarounds            = SBP2_WORKAROUND_FIX_CAPACITY,
+       },
+       /* iPod mini */ {
+               .firmware_revision      = 0x0a2700,
+               .model_id               = 0x000023,
+               .workarounds            = SBP2_WORKAROUND_FIX_CAPACITY,
+       },
+       /* iPod Photo */ {
+               .firmware_revision      = 0x0a2700,
+               .model_id               = 0x00007e,
+               .workarounds            = SBP2_WORKAROUND_FIX_CAPACITY,
        }
 };
 
@@ -797,12 +835,17 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
 
        /* Register the status FIFO address range. We could use the same FIFO
         * for targets at different nodes. However we need different FIFOs per
-        * target in order to support multi-unit devices. */
+        * target in order to support multi-unit devices.
+        * The FIFO is located out of the local host controller's physical range
+        * but, if possible, within the posted write area. Status writes will
+        * then be performed as unified transactions. This slightly reduces
+        * bandwidth usage, and some Prolific based devices seem to require it.
+        */
        scsi_id->status_fifo_addr = hpsb_allocate_and_register_addrspace(
                        &sbp2_highlevel, ud->ne->host, &sbp2_ops,
                        sizeof(struct sbp2_status_block), sizeof(quadlet_t),
-                       ~0ULL, ~0ULL);
-       if (!scsi_id->status_fifo_addr) {
+                       0x010000000000ULL, CSR1212_ALL_SPACE_END);
+       if (scsi_id->status_fifo_addr == ~0ULL) {
                SBP2_ERR("failed to allocate status FIFO address range");
                goto failed_alloc;
        }
@@ -1555,19 +1598,27 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
                workarounds |= SBP2_WORKAROUND_INQUIRY_36;
        }
 
-       for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
-               if (sbp2_workarounds_table[i].firmware_revision !=
-                   (firmware_revision & 0xffff00))
-                       continue;
-               workarounds |= sbp2_workarounds_table[i].workarounds;
-               break;
-       }
+       if (!(workarounds & SBP2_WORKAROUND_OVERRIDE))
+               for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
+                       if (sbp2_workarounds_table[i].firmware_revision &&
+                           sbp2_workarounds_table[i].firmware_revision !=
+                           (firmware_revision & 0xffff00))
+                               continue;
+                       if (sbp2_workarounds_table[i].model_id &&
+                           sbp2_workarounds_table[i].model_id != ud->model_id)
+                               continue;
+                       workarounds |= sbp2_workarounds_table[i].workarounds;
+                       break;
+               }
 
        if (workarounds)
-               SBP2_INFO("Workarounds for node " NODE_BUS_FMT ": "
-                         "0x%x (firmware_revision 0x%x)",
+               SBP2_INFO("Workarounds for node " NODE_BUS_FMT ": 0x%x "
+                         "(firmware_revision 0x%06x, vendor_id 0x%06x,"
+                         " model_id 0x%06x)",
                          NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
-                         workarounds, firmware_revision);
+                         workarounds, firmware_revision,
+                         ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id,
+                         ud->model_id);
 
        /* We would need one SCSI host template for each target to adjust
         * max_sectors on the fly, therefore warn only. */
@@ -2488,6 +2539,8 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
        if (sdev->type == TYPE_DISK &&
            scsi_id->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
                sdev->skip_ms_page_8 = 1;
+       if (scsi_id->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
+               sdev->fix_capacity = 1;
        return 0;
 }