be2net: make SET_LOOPBACK_MODE cmd asynchrounous
authorSuresh Reddy <Suresh.Reddy@emulex.com>
Fri, 10 Jul 2015 09:32:50 +0000 (05:32 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sat, 11 Jul 2015 06:24:30 +0000 (23:24 -0700)
The SET_LOOPBACK_MODE command is always issued from ethtool only in a
process context. So, while waiting for the cmd to complete, the driver
can sleep instead of holding spin_lock_bh() on the mcc_lock. This is done
by calling be_mcc_notify() instead of be_mcc_notify_wait() (that returns
only after the cmd completes while the MCCQ is locked).

Signed-off-by: Suresh Reddy <suresh.reddy@avagotech.com>
Signed-off-by: Sathya Perla <sathya.perla@avagotech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/emulex/benet/be_cmds.c
drivers/net/ethernet/emulex/benet/be_cmds.h
drivers/net/ethernet/emulex/benet/be_ethtool.c

index 93934d347a235561b508f27312e82a9d7ea84d6c..ecad46f796539f9b5a4dcc331939fee6da3bb1d3 100644 (file)
@@ -172,6 +172,12 @@ static void be_async_cmd_process(struct be_adapter *adapter,
                return;
        }
 
+       if (opcode == OPCODE_LOWLEVEL_SET_LOOPBACK_MODE &&
+           subsystem == CMD_SUBSYSTEM_LOWLEVEL) {
+               complete(&adapter->et_cmd_compl);
+               return;
+       }
+
        if ((opcode == OPCODE_COMMON_WRITE_FLASHROM ||
             opcode == OPCODE_COMMON_WRITE_OBJECT) &&
            subsystem == CMD_SUBSYSTEM_COMMON) {
@@ -2600,7 +2606,7 @@ int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num,
        wrb = wrb_from_mccq(adapter);
        if (!wrb) {
                status = -EBUSY;
-               goto err;
+               goto err_unlock;
        }
 
        req = embedded_payload(wrb);
@@ -2614,8 +2620,19 @@ int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num,
        req->loopback_type = loopback_type;
        req->loopback_state = enable;
 
-       status = be_mcc_notify_wait(adapter);
-err:
+       status = be_mcc_notify(adapter);
+       if (status)
+               goto err_unlock;
+
+       spin_unlock_bh(&adapter->mcc_lock);
+
+       if (!wait_for_completion_timeout(&adapter->et_cmd_compl,
+                                        msecs_to_jiffies(SET_LB_MODE_TIMEOUT)))
+               status = -ETIMEDOUT;
+
+       return status;
+
+err_unlock:
        spin_unlock_bh(&adapter->mcc_lock);
        return status;
 }
index f0a92b7e4e7d3d4063c91dc58a9ff758678df7c1..a4479f7488d3cb663091283da9781b2ff99b7505 100644 (file)
@@ -1495,6 +1495,8 @@ struct be_cmd_resp_acpi_wol_magic_config_v1 {
 #define BE_PME_D3COLD_CAP              0x80
 
 /********************** LoopBack test *********************/
+#define SET_LB_MODE_TIMEOUT            12000
+
 struct be_cmd_req_loopback_test {
        struct be_cmd_req_hdr hdr;
        u32 loopback_type;
index b2476dbfd103120affb5e216a31d304dda570a67..d20ff054c1f78fd8515b7c858391591ced1272a9 100644 (file)
@@ -847,10 +847,21 @@ err:
 static u64 be_loopback_test(struct be_adapter *adapter, u8 loopback_type,
                            u64 *status)
 {
-       be_cmd_set_loopback(adapter, adapter->hba_port_num, loopback_type, 1);
+       int ret;
+
+       ret = be_cmd_set_loopback(adapter, adapter->hba_port_num,
+                                 loopback_type, 1);
+       if (ret)
+               return ret;
+
        *status = be_cmd_loopback_test(adapter, adapter->hba_port_num,
                                       loopback_type, 1500, 2, 0xabc);
-       be_cmd_set_loopback(adapter, adapter->hba_port_num, BE_NO_LOOPBACK, 1);
+
+       ret = be_cmd_set_loopback(adapter, adapter->hba_port_num,
+                                 BE_NO_LOOPBACK, 1);
+       if (ret)
+               return ret;
+
        return *status;
 }