Skip to content

Commit 1680a37

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: only use direct firmware requests
request_firmware() will fallback to user space helper and may cause long delays when driver is loaded if udev doesn't correctly handle FW requests. Since we never really made use of the user space helper functionality switch to the simpler request_firmware_direct() call. The side effect of this change is that no warning will be printed when the FW image does not exists. To help users figure out which FW file is missing print a info message when we request each file. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9511f29 commit 1680a37

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

drivers/net/ethernet/netronome/nfp/nfp_main.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ static int nfp_pcie_sriov_configure(struct pci_dev *pdev, int num_vfs)
174174
return nfp_pcie_sriov_enable(pdev, num_vfs);
175175
}
176176

177+
static const struct firmware *
178+
nfp_net_fw_request(struct pci_dev *pdev, struct nfp_pf *pf, const char *name)
179+
{
180+
const struct firmware *fw = NULL;
181+
int err;
182+
183+
err = request_firmware_direct(&fw, name, &pdev->dev);
184+
nfp_info(pf->cpp, " %s: %s\n",
185+
name, err ? "not found" : "found, loading...");
186+
if (err)
187+
return NULL;
188+
189+
return fw;
190+
}
191+
177192
/**
178193
* nfp_net_fw_find() - Find the correct firmware image for netdev mode
179194
* @pdev: PCI Device structure
@@ -184,29 +199,30 @@ static int nfp_pcie_sriov_configure(struct pci_dev *pdev, int num_vfs)
184199
static const struct firmware *
185200
nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf)
186201
{
187-
const struct firmware *fw = NULL;
188202
struct nfp_eth_table_port *port;
203+
const struct firmware *fw;
189204
const char *fw_model;
190205
char fw_name[256];
191206
const u8 *serial;
192-
int spc, err = 0;
193207
u16 interface;
194-
int i, j;
208+
int spc, i, j;
209+
210+
nfp_info(pf->cpp, "Looking for firmware file in order of priority:\n");
195211

196212
/* First try to find a firmware image specific for this device */
197213
interface = nfp_cpp_interface(pf->cpp);
198214
nfp_cpp_serial(pf->cpp, &serial);
199215
sprintf(fw_name, "netronome/serial-%pMF-%02hhx-%02hhx.nffw",
200216
serial, interface >> 8, interface & 0xff);
201-
err = request_firmware_direct(&fw, fw_name, &pdev->dev);
202-
if (!err)
203-
goto done;
217+
fw = nfp_net_fw_request(pdev, pf, fw_name);
218+
if (fw)
219+
return fw;
204220

205221
/* Then try the PCI name */
206222
sprintf(fw_name, "netronome/pci-%s.nffw", pci_name(pdev));
207-
err = request_firmware_direct(&fw, fw_name, &pdev->dev);
208-
if (!err)
209-
goto done;
223+
fw = nfp_net_fw_request(pdev, pf, fw_name);
224+
if (fw)
225+
return fw;
210226

211227
/* Finally try the card type and media */
212228
if (!pf->eth_tbl) {
@@ -241,13 +257,7 @@ nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf)
241257
if (spc <= 0)
242258
return NULL;
243259

244-
err = request_firmware(&fw, fw_name, &pdev->dev);
245-
if (err)
246-
return NULL;
247-
done:
248-
dev_info(&pdev->dev, "Loading FW image: %s\n", fw_name);
249-
250-
return fw;
260+
return nfp_net_fw_request(pdev, pf, fw_name);
251261
}
252262

253263
/**

0 commit comments

Comments
 (0)