[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1403311181-9328-2-git-send-email-mcgrof@do-not-panic.com>
Date: Fri, 20 Jun 2014 17:39:39 -0700
From: "Luis R. Rodriguez" <mcgrof@...not-panic.com>
To: hariprasad@...lsio.com, leedom@...lsio.com
Cc: poswald@...e.com, santosh@...lsio.com, jcheung@...e.com,
dchang@...e.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, mcgrof@...e.com
Subject: [RFT 1/3] cxgb4: make ethtool set_flash use request_firmware_nowait()
From: "Luis R. Rodriguez" <mcgrof@...e.com>
cxgb4 loading can take a while, this is part of the crusade to
change it to be asynchronous.
Cc: Casey Leedom <leedom@...lsio.com>
Cc: Hariprasad Shenai <hariprasad@...lsio.com>
Cc: Philip Oswald <poswald@...e.com>
Cc: Santosh Rastapur <santosh@...lsio.com>
Cc: Jeffrey Cheung <jcheung@...e.com>
Cc: David Chang <dchang@...e.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@...e.com>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 3 ++
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 40 ++++++++++++++++++++-----
2 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index f503dce..bcf9acf 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -647,6 +647,9 @@ struct adapter {
struct dentry *debugfs_root;
spinlock_t stats_lock;
+
+ struct completion flash_comp;
+ int flash_comp_status;
};
/* Defined bit width of user definable filter tuples
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 2f8d6b9..9cf6f3e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2713,22 +2713,48 @@ out:
return err;
}
+static void cxgb4_flash_complete(const struct firmware *fw, void *context)
+{
+ struct adapter *adap = context;
+ int ret;
+
+ if (!fw) {
+ adap->flash_comp_status = -EINVAL;
+ goto out;
+ }
+
+ ret = t4_load_fw(adap, fw->data, fw->size);
+ if (!ret)
+ adap->flash_comp_status = ret;
+
+out:
+ release_firmware(fw);
+ complete(&adap->flash_comp);
+}
+
static int set_flash(struct net_device *netdev, struct ethtool_flash *ef)
{
int ret;
- const struct firmware *fw;
struct adapter *adap = netdev2adap(netdev);
+ init_completion(&adap->flash_comp);
+ adap->flash_comp_status = 0;
+
ef->data[sizeof(ef->data) - 1] = '\0';
- ret = request_firmware(&fw, ef->data, adap->pdev_dev);
+ ret = request_firmware_nowait(THIS_MODULE, 1, ef->data,
+ adap->pdev_dev, GFP_KERNEL,
+ adap, cxgb4_flash_complete);
if (ret < 0)
return ret;
- ret = t4_load_fw(adap, fw->data, fw->size);
- release_firmware(fw);
- if (!ret)
- dev_info(adap->pdev_dev, "loaded firmware %s\n", ef->data);
- return ret;
+ wait_for_completion(&adap->flash_comp);
+
+ if (adap->flash_comp_status != 0)
+ return adap->flash_comp_status;
+
+ dev_info(adap->pdev_dev, "loaded firmware %s\n", ef->data);
+
+ return 0;
}
#define WOL_SUPPORTED (WAKE_BCAST | WAKE_MAGIC)
--
2.0.0
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists