]> err.no Git - linux-2.6/blobdiff - drivers/firewire/fw-sbp2.c
firewire: fw-sbp2: don't retry login or reconnect after unplug
[linux-2.6] / drivers / firewire / fw-sbp2.c
index 19ece9b6d7425906d6cff48cee2ebfba172f5141..72fddf5a12a323decf9a4975c3d0dfadb480fa65 100644 (file)
@@ -141,15 +141,13 @@ struct sbp2_logical_unit {
 struct sbp2_target {
        struct kref kref;
        struct fw_unit *unit;
+       struct list_head lu_list;
 
        u64 management_agent_address;
        int directory_id;
        int node_id;
        int address_high;
-
-       unsigned workarounds;
-       struct list_head lu_list;
-
+       unsigned int workarounds;
        unsigned int mgt_orb_timeout;
 };
 
@@ -160,7 +158,7 @@ struct sbp2_target {
  */
 #define SBP2_MIN_LOGIN_ORB_TIMEOUT     5000U   /* Timeout in ms */
 #define SBP2_MAX_LOGIN_ORB_TIMEOUT     40000U  /* Timeout in ms */
-#define SBP2_ORB_TIMEOUT               2000    /* Timeout in ms */
+#define SBP2_ORB_TIMEOUT               2000U   /* Timeout in ms */
 #define SBP2_ORB_NULL                  0x80000000
 #define SBP2_MAX_SG_ELEMENT_LENGTH     0xf000
 
@@ -297,7 +295,7 @@ struct sbp2_command_orb {
 static const struct {
        u32 firmware_revision;
        u32 model;
-       unsigned workarounds;
+       unsigned int workarounds;
 } sbp2_workarounds_table[] = {
        /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
                .firmware_revision      = 0x002800,
@@ -501,6 +499,9 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
        unsigned int timeout;
        int retval = -ENOMEM;
 
+       if (function == SBP2_LOGOUT_REQUEST && fw_device_is_shutdown(device))
+               return 0;
+
        orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
        if (orb == NULL)
                return -ENOMEM;
@@ -621,16 +622,13 @@ static void sbp2_release_target(struct kref *kref)
        struct sbp2_logical_unit *lu, *next;
        struct Scsi_Host *shost =
                container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
-       struct fw_device *device = fw_device(tgt->unit->device.parent);
 
        list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
                if (lu->sdev)
                        scsi_remove_device(lu->sdev);
 
-               if (!fw_device_is_shutdown(device))
-                       sbp2_send_management_orb(lu, tgt->node_id,
-                                       lu->generation, SBP2_LOGOUT_REQUEST,
-                                       lu->login_id, NULL);
+               sbp2_send_management_orb(lu, tgt->node_id, lu->generation,
+                               SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
 
                fw_core_remove_address_handler(&lu->address_handler);
                list_del(&lu->link);
@@ -675,6 +673,9 @@ static void sbp2_login(struct work_struct *work)
        struct sbp2_login_response response;
        int generation, node_id, local_node_id;
 
+       if (fw_device_is_shutdown(device))
+               goto out;
+
        generation    = device->generation;
        smp_rmb();    /* node_id must not be older than generation */
        node_id       = device->node_id;
@@ -718,7 +719,11 @@ static void sbp2_login(struct work_struct *work)
        sdev = __scsi_add_device(shost, 0, 0,
                                 scsilun_to_int(&eight_bytes_lun), lu);
        if (IS_ERR(sdev)) {
-               sbp2_send_management_orb(lu, node_id, generation,
+               smp_rmb(); /* generation may have changed */
+               generation = device->generation;
+               smp_rmb(); /* node_id must not be older than generation */
+
+               sbp2_send_management_orb(lu, device->node_id, generation,
                                SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
                /*
                 * Set this back to sbp2_login so we fall back and
@@ -836,7 +841,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
                                  u32 firmware_revision)
 {
        int i;
-       unsigned w = sbp2_param_workarounds;
+       unsigned int w = sbp2_param_workarounds;
 
        if (w)
                fw_notify("Please notify linux1394-devel@lists.sourceforge.net "
@@ -942,6 +947,9 @@ static void sbp2_reconnect(struct work_struct *work)
        struct fw_device *device = fw_device(unit->device.parent);
        int generation, node_id, local_node_id;
 
+       if (fw_device_is_shutdown(device))
+               goto out;
+
        generation    = device->generation;
        smp_rmb();    /* node_id must not be older than generation */
        node_id       = device->node_id;
@@ -1197,7 +1205,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
        struct sbp2_logical_unit *lu = cmd->device->hostdata;
        struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
        struct sbp2_command_orb *orb;
-       unsigned max_payload;
+       unsigned int max_payload;
        int retval = SCSI_MLQUEUE_HOST_BUSY;
 
        /*