]> err.no Git - linux-2.6/blobdiff - drivers/firewire/fw-sbp2.c
Merge branch 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6] / drivers / firewire / fw-sbp2.c
index 71146ba01e63b3fe110d8feca6ce9916ff64927a..227d2e036cd812f4e259fd13413298a818d16d6f 100644 (file)
@@ -153,6 +153,7 @@ struct sbp2_target {
        struct list_head lu_list;
 
        u64 management_agent_address;
+       u64 guid;
        int directory_id;
        int node_id;
        int address_high;
@@ -173,7 +174,8 @@ struct sbp2_target {
 #define SBP2_ORB_TIMEOUT               2000U   /* Timeout in ms */
 #define SBP2_ORB_NULL                  0x80000000
 #define SBP2_MAX_SG_ELEMENT_LENGTH     0xf000
-#define SBP2_RETRY_LIMIT               0xf     /* 15 retries */
+#define SBP2_RETRY_LIMIT               0xf             /* 15 retries */
+#define SBP2_CYCLE_LIMIT               (0xc8 << 12)    /* 200 125us cycles */
 
 /* Unit directory keys */
 #define SBP2_CSR_UNIT_CHARACTERISTICS  0x3a
@@ -693,10 +695,8 @@ static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
        if (!tgt->dont_block && !lu->blocked &&
            lu->generation != card->generation) {
                lu->blocked = true;
-               if (++tgt->blocked == 1) {
+               if (++tgt->blocked == 1)
                        scsi_block_requests(shost);
-                       fw_notify("blocked %s\n", lu->tgt->bus_id);
-               }
        }
        spin_unlock_irqrestore(&card->lock, flags);
 }
@@ -723,10 +723,8 @@ static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu)
        }
        spin_unlock_irqrestore(&card->lock, flags);
 
-       if (unblock) {
+       if (unblock)
                scsi_unblock_requests(shost);
-               fw_notify("unblocked %s\n", lu->tgt->bus_id);
-       }
 }
 
 /*
@@ -786,7 +784,7 @@ static void sbp2_release_target(struct kref *kref)
                kfree(lu);
        }
        scsi_remove_host(shost);
-       fw_notify("released %s\n", tgt->bus_id);
+       fw_notify("released %s, target %d:0:0\n", tgt->bus_id, shost->host_no);
 
        fw_unit_put(tgt->unit);
        scsi_host_put(shost);
@@ -817,6 +815,22 @@ complete_set_busy_timeout(struct fw_card *card, int rcode,
        complete(done);
 }
 
+/*
+ * Write retransmit retry values into the BUSY_TIMEOUT register.
+ * - The single-phase retry protocol is supported by all SBP-2 devices, but the
+ *   default retry_limit value is 0 (i.e. never retry transmission). We write a
+ *   saner value after logging into the device.
+ * - The dual-phase retry protocol is optional to implement, and if not
+ *   supported, writes to the dual-phase portion of the register will be
+ *   ignored. We try to write the original 1394-1995 default here.
+ * - In the case of devices that are also SBP-3-compliant, all writes are
+ *   ignored, as the register is read-only, but contains single-phase retry of
+ *   15, which is what we're trying to set for all SBP-2 device anyway, so this
+ *   write attempt is safe and yields more consistent behavior for all devices.
+ *
+ * See section 8.3.2.3.5 of the 1394-1995 spec, section 6.2 of the SBP-2 spec,
+ * and section 6.4 of the SBP-3 spec for further details.
+ */
 static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
 {
        struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
@@ -824,8 +838,7 @@ static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
        struct fw_transaction t;
        static __be32 busy_timeout;
 
-       /* FIXME: we should try to set dual-phase cycle_limit too */
-       busy_timeout = cpu_to_be32(SBP2_RETRY_LIMIT);
+       busy_timeout = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT);
 
        fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST,
                        lu->tgt->node_id, lu->generation, device->max_speed,
@@ -1038,7 +1051,8 @@ static int sbp2_scan_unit_dir(struct sbp2_target *tgt, u32 *directory,
                        break;
 
                case SBP2_CSR_LOGICAL_UNIT_DIRECTORY:
-                       if (sbp2_scan_logical_unit_dir(tgt, ci.p + value) < 0)
+                       /* Adjust for the increment in the iterator */
+                       if (sbp2_scan_logical_unit_dir(tgt, ci.p - 1 + value) < 0)
                                return -ENOMEM;
                        break;
                }
@@ -1102,6 +1116,7 @@ static int sbp2_probe(struct device *dev)
        kref_init(&tgt->kref);
        INIT_LIST_HEAD(&tgt->lu_list);
        tgt->bus_id = unit->device.bus_id;
+       tgt->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4];
 
        if (fw_device_enable_phys_dma(device) < 0)
                goto fail_shost_put;
@@ -1473,7 +1488,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
        if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0)
                goto out;
 
-       memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
+       memcpy(orb->request.command_block, cmd->cmnd, cmd->cmd_len);
 
        orb->base.callback = complete_command_orb;
        orb->base.request_bus =
@@ -1559,16 +1574,14 @@ sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr,
 {
        struct scsi_device *sdev = to_scsi_device(dev);
        struct sbp2_logical_unit *lu;
-       struct fw_device *device;
 
        if (!sdev)
                return 0;
 
        lu = sdev->hostdata;
-       device = fw_device(lu->tgt->unit->device.parent);
 
-       return sprintf(buf, "%08x%08x:%06x:%04x\n",
-                       device->config_rom[3], device->config_rom[4],
+       return sprintf(buf, "%016llx:%06x:%04x\n",
+                       (unsigned long long)lu->tgt->guid,
                        lu->tgt->directory_id, lu->lun);
 }