From: David Woodhouse <dwmw2@infradead.org>
To: David Miller <davem@davemloft.net>
Cc: Valdis.Kletnieks@vt.edu, alessandro.suardi@gmail.com,
jaswinderlinux@gmail.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: 2.6.28-git8: tg3 doesn't work due to firmware not loading (-git7 is ok)
Date: Sun, 11 Jan 2009 12:59:59 +0000 [thread overview]
Message-ID: <1231678799.25018.195.camel@macbook.infradead.org> (raw)
In-Reply-To: <1231676698.25018.147.camel@macbook.infradead.org>
On Sun, 2009-01-11 at 12:25 +0000, David Woodhouse wrote:
> I'll take a look and see if I can remedy that. Then we wouldn't _need_
> the FIRMWARE_IN_KERNEL option.
How about this? If it fails to load the firmware from userspace during
the initialisation, it'll try again later in tg3_open().
I _think_ that's fine, because we don't do anything else in the early
initialisation which requires the firmware to be loaded.
So if you build with CONFIG_TIGON3=y, CONFIG_FIRMWARE_IN_KERNEL=n, you
should see it fail to load the firmware at boot, but then it should load
it successfully when you bring the device up.
Untested-but-otherwise-Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 5e2dbae..f99218c 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -7535,11 +7535,45 @@ static int tg3_test_msi(struct tg3 *tp)
return err;
}
+static int tg3_request_firmware(struct tg3 *tp)
+{
+ const __be32 *fw_data;
+
+ if (request_firmware(&tp->fw, tp->fw_needed, &tp->pdev->dev)) {
+ printk(KERN_ERR "tg3: Failed to load firmware \"%s\"\n",
+ tp->fw_needed);
+ return -ENOENT;
+ }
+
+ fw_data = (void *)tp->fw->data;
+
+ /* Firmware blob starts with version numbers, followed by
+ start address and _full_ length including BSS sections
+ (which must be longer than the actual data, of course */
+
+ tp->fw_len = be32_to_cpu(fw_data[2]); /* includes bss */
+ if (tp->fw_len < (tp->fw->size - 12)) {
+ printk(KERN_ERR "tg3: bogus length %d in \"%s\"\n",
+ tp->fw_len, tp->fw_needed);
+ return -EINVAL;
+ }
+
+ /* We no longer need firmware; we have it. */
+ tp->fw_needed = NULL;
+ return 0;
+}
+
static int tg3_open(struct net_device *dev)
{
struct tg3 *tp = netdev_priv(dev);
int err;
+ if (tp->fw_needed) {
+ err = tg3_request_firmware(tp);
+ if (err)
+ return err;
+ }
+
netif_carrier_off(tp->dev);
err = tg3_set_power_state(tp, PCI_D0);
@@ -12934,7 +12968,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
struct net_device *dev;
struct tg3 *tp;
int err, pm_cap;
- const char *fw_name = NULL;
char str[40];
u64 dma_mask, persist_dma_mask;
@@ -13091,7 +13124,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
tg3_init_bufmgr_config(tp);
if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0)
- fw_name = FIRMWARE_TG3;
+ tp->fw_needed = FIRMWARE_TG3;
if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE;
@@ -13107,34 +13140,19 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
}
if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
- fw_name = FIRMWARE_TG3TSO5;
+ tp->fw_needed = FIRMWARE_TG3TSO5;
else
- fw_name = FIRMWARE_TG3TSO;
+ tp->fw_needed = FIRMWARE_TG3TSO;
}
- if (fw_name) {
- const __be32 *fw_data;
-
- err = request_firmware(&tp->fw, fw_name, &tp->pdev->dev);
- if (err) {
- printk(KERN_ERR "tg3: Failed to load firmware \"%s\"\n",
- fw_name);
- goto err_out_iounmap;
- }
-
- fw_data = (void *)tp->fw->data;
-
- /* Firmware blob starts with version numbers, followed by
- start address and _full_ length including BSS sections
- (which must be longer than the actual data, of course */
-
- tp->fw_len = be32_to_cpu(fw_data[2]); /* includes bss */
- if (tp->fw_len < (tp->fw->size - 12)) {
- printk(KERN_ERR "tg3: bogus length %d in \"%s\"\n",
- tp->fw_len, fw_name);
- err = -EINVAL;
+ if (tp->fw_needed) {
+ err = tg3_request_firmware(tp);
+ /* Failure to load firmware at this stage is not fatal; we'll
+ try again in tg3_open(). So if you have the driver built
+ into the kernel, you can still get the firmware loaded
+ after userspace is running, when the device comes up. */
+ if (err != -ENOENT)
goto err_out_fw;
- }
}
/* TSO is on by default on chips that support hardware TSO.
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
next prev parent reply other threads:[~2009-01-11 13:02 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5a4c581d0901070624t6e769966t6b034b14d4732bd@mail.gmail.com>
2009-01-08 4:03 ` 2.6.28-git8: tg3 doesn't work due to firmware not loading (-git7 is ok) Alessandro Suardi
2009-01-08 6:12 ` Jaswinder Singh Rajput
2009-01-08 20:33 ` Alessandro Suardi
2009-01-08 20:53 ` David Miller
2009-01-09 17:30 ` Alessandro Suardi
2009-01-09 22:04 ` David Miller
2009-01-09 22:29 ` Alessandro Suardi
2009-01-11 11:10 ` Valdis.Kletnieks
2009-01-11 12:08 ` David Miller
2009-01-11 12:24 ` David Woodhouse
2009-01-11 12:59 ` David Woodhouse [this message]
2009-01-11 16:42 ` Alessandro Suardi
2009-01-11 16:53 ` David Woodhouse
2009-01-11 19:24 ` Alessandro Suardi
2009-01-11 19:26 ` David Woodhouse
2009-01-11 16:48 ` Valdis.Kletnieks
2009-01-11 16:56 ` David Woodhouse
2009-01-11 21:49 ` David Miller
2009-01-11 22:29 ` Valdis.Kletnieks
2009-01-11 22:46 ` David Woodhouse
2009-01-11 21:41 ` David Miller
2009-01-12 0:10 ` Valdis.Kletnieks
2009-01-12 1:39 ` Valdis.Kletnieks
2009-01-12 8:13 ` David Woodhouse
2009-01-13 4:46 ` Valdis.Kletnieks
2009-01-13 5:52 ` Valdis.Kletnieks
2009-01-11 21:39 ` David Miller
2009-01-11 22:02 ` David Woodhouse
2009-01-11 22:05 ` David Miller
2009-01-11 22:41 ` David Woodhouse
2009-01-13 6:13 ` Willy Tarreau
2009-01-11 22:15 ` David Woodhouse
2009-01-11 22:19 ` David Miller
2009-01-13 18:39 ` Matt Carlson
2009-01-13 20:27 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1231678799.25018.195.camel@macbook.infradead.org \
--to=dwmw2@infradead.org \
--cc=Valdis.Kletnieks@vt.edu \
--cc=alessandro.suardi@gmail.com \
--cc=davem@davemloft.net \
--cc=jaswinderlinux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).