linux/debian/patches/features/all/drivers-infiniband-hw-ipath...

231 lines
7.9 KiB
Diff

From 1e9da7da73886eaf63449e56ebf16cf7daa4a9e5 Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben@decadent.org.uk>
Date: Mon, 17 Aug 2009 02:17:09 +0100
Subject: [PATCH 3/3] ib_ipath: use request_firmware() to load SD7220 firmware
---
drivers/infiniband/hw/ipath/Makefile | 7 ++--
drivers/infiniband/hw/ipath/ipath_7220.h | 7 ----
drivers/infiniband/hw/ipath/ipath_driver.c | 4 --
drivers/infiniband/hw/ipath/ipath_sd7220.c | 49 ++++++++++++++++++++++-----
4 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/drivers/infiniband/hw/ipath/Makefile b/drivers/infiniband/hw/ipath/Makefile
index 42d8d4c..fc892cf 100644
--- a/drivers/infiniband/hw/ipath/Makefile
+++ b/drivers/infiniband/hw/ipath/Makefile
@@ -29,10 +29,9 @@ ib_ipath-y := \
ipath_user_pages.o \
ipath_user_sdma.o \
ipath_verbs_mcast.o \
- ipath_verbs.o
-
-# IBA7220 depends on firmware to be removed
-ib_ipath-$(CONFIG_BROKEN) += ipath_iba7220.o ipath_sd7220.o
+ ipath_verbs.o \
+ ipath_iba7220.o \
+ ipath_sd7220.o
ib_ipath-$(CONFIG_HT_IRQ) += ipath_iba6110.o
ib_ipath-$(CONFIG_PCI_MSI) += ipath_iba6120.o
diff --git a/drivers/infiniband/hw/ipath/ipath_7220.h b/drivers/infiniband/hw/ipath/ipath_7220.h
index 74fa5cc..29a73e0 100644
--- a/drivers/infiniband/hw/ipath/ipath_7220.h
+++ b/drivers/infiniband/hw/ipath/ipath_7220.h
@@ -40,10 +40,6 @@
*/
int ipath_sd7220_presets(struct ipath_devdata *dd);
int ipath_sd7220_init(struct ipath_devdata *dd, int was_reset);
-int ipath_sd7220_prog_ld(struct ipath_devdata *dd, int sdnum, u8 *img,
- int len, int offset);
-int ipath_sd7220_prog_vfy(struct ipath_devdata *dd, int sdnum, const u8 *img,
- int len, int offset);
/*
* Below used for sdnum parameter, selecting one of the two sections
* used for PCIe, or the single SerDes used for IB, which is the
@@ -51,7 +47,4 @@ int ipath_sd7220_prog_vfy(struct ipath_devdata *dd, int sdnum, const u8 *img,
*/
#define IB_7220_SERDES 2
-int ipath_sd7220_ib_load(struct ipath_devdata *dd);
-int ipath_sd7220_ib_vfy(struct ipath_devdata *dd);
-
#endif /* _IPATH_7220_H */
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 20407a0..04e88b6 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -140,9 +140,7 @@ static int __devinit ipath_init_one(struct pci_dev *,
static const struct pci_device_id ipath_pci_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_INFINIPATH_HT) },
{ PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_INFINIPATH_PE800) },
-#ifdef CONFIG_BROKEN
{ PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_INFINIPATH_7220) },
-#endif
{ 0, }
};
@@ -537,7 +535,6 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
"CONFIG_PCI_MSI is not enabled\n", ent->device);
return -ENODEV;
#endif
-#ifdef CONFIG_BROKEN
case PCI_DEVICE_ID_INFINIPATH_7220:
#ifndef CONFIG_PCI_MSI
ipath_dbg("CONFIG_PCI_MSI is not enabled, "
@@ -545,7 +542,6 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
#endif
ipath_init_iba7220_funcs(dd);
break;
-#endif
default:
ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, "
"failing\n", ent->device);
diff --git a/drivers/infiniband/hw/ipath/ipath_sd7220.c b/drivers/infiniband/hw/ipath/ipath_sd7220.c
index aa47eb5..df3735d 100644
--- a/drivers/infiniband/hw/ipath/ipath_sd7220.c
+++ b/drivers/infiniband/hw/ipath/ipath_sd7220.c
@@ -37,11 +37,15 @@
#include <linux/pci.h>
#include <linux/delay.h>
+#include <linux/firmware.h>
#include "ipath_kernel.h"
#include "ipath_registers.h"
#include "ipath_7220.h"
+#define SD7220_FW_NAME "qlogic/sd7220.fw"
+MODULE_FIRMWARE(SD7220_FW_NAME);
+
/*
* The IBSerDesMappTable is a memory that holds values to be stored in
* various SerDes registers by IBC. It is not part of the normal kregs
@@ -88,6 +92,11 @@ static int ipath_internal_presets(struct ipath_devdata *dd);
static int ipath_sd_trimself(struct ipath_devdata *dd, int val);
static int epb_access(struct ipath_devdata *dd, int sdnum, int claim);
+static int
+ipath_sd7220_ib_load(struct ipath_devdata *dd, const struct firmware *fw);
+static int
+ipath_sd7220_ib_vfy(struct ipath_devdata *dd, const struct firmware *fw);
+
void ipath_set_relock_poll(struct ipath_devdata *dd, int ibup);
/*
@@ -98,9 +107,10 @@ void ipath_set_relock_poll(struct ipath_devdata *dd, int ibup);
* ipath_sd7220_init() is no longer valid. Instead, we check for the
* actual uC code having been loaded.
*/
-static int ipath_ibsd_ucode_loaded(struct ipath_devdata *dd)
+static int
+ipath_ibsd_ucode_loaded(struct ipath_devdata *dd, const struct firmware *fw)
{
- if (!dd->serdes_first_init_done && (ipath_sd7220_ib_vfy(dd) > 0))
+ if (!dd->serdes_first_init_done && (ipath_sd7220_ib_vfy(dd, fw) > 0))
dd->serdes_first_init_done = 1;
return dd->serdes_first_init_done;
}
@@ -363,6 +373,7 @@ static void ipath_sd_trimdone_monitor(struct ipath_devdata *dd,
*/
int ipath_sd7220_init(struct ipath_devdata *dd, int was_reset)
{
+ const struct firmware *fw;
int ret = 1; /* default to failure */
int first_reset;
int val_stat;
@@ -373,8 +384,14 @@ int ipath_sd7220_init(struct ipath_devdata *dd, int was_reset)
ipath_sd_trimdone_monitor(dd, "Driver-reload");
}
+ ret = request_firmware(&fw, SD7220_FW_NAME, &dd->pcidev->dev);
+ if (ret) {
+ ipath_dev_err(dd, "Failed to load IB SERDES image\n");
+ goto done;
+ }
+
/* Substitute our deduced value for was_reset */
- ret = ipath_ibsd_ucode_loaded(dd);
+ ret = ipath_ibsd_ucode_loaded(dd, fw);
if (ret < 0) {
ret = 1;
goto done;
@@ -431,7 +448,7 @@ int ipath_sd7220_init(struct ipath_devdata *dd, int was_reset)
int vfy;
int trim_done;
ipath_dbg("SerDes uC was reset, reloading PRAM\n");
- ret = ipath_sd7220_ib_load(dd);
+ ret = ipath_sd7220_ib_load(dd, fw);
if (ret < 0) {
ipath_dev_err(dd, "Failed to load IB SERDES image\n");
ret = 1;
@@ -439,7 +456,7 @@ int ipath_sd7220_init(struct ipath_devdata *dd, int was_reset)
}
/* Loaded image, try to verify */
- vfy = ipath_sd7220_ib_vfy(dd);
+ vfy = ipath_sd7220_ib_vfy(dd, fw);
if (vfy != ret) {
ipath_dev_err(dd, "SERDES PRAM VFY failed\n");
ret = 1;
@@ -500,6 +517,8 @@ int ipath_sd7220_init(struct ipath_devdata *dd, int was_reset)
done:
/* start relock timer regardless, but start at 1 second */
ipath_set_relock_poll(dd, -1);
+
+ release_firmware(fw);
return ret;
}
@@ -836,8 +855,8 @@ static int ipath_sd7220_ram_xfer(struct ipath_devdata *dd, int sdnum, u32 loc,
#define PROG_CHUNK 64
-int ipath_sd7220_prog_ld(struct ipath_devdata *dd, int sdnum,
- u8 *img, int len, int offset)
+static int ipath_sd7220_prog_ld(struct ipath_devdata *dd, int sdnum,
+ const u8 *img, int len, int offset)
{
int cnt, sofar, req;
@@ -847,7 +866,7 @@ int ipath_sd7220_prog_ld(struct ipath_devdata *dd, int sdnum,
if (req > PROG_CHUNK)
req = PROG_CHUNK;
cnt = ipath_sd7220_ram_xfer(dd, sdnum, offset + sofar,
- img + sofar, req, 0);
+ (u8 *)img + sofar, req, 0);
if (cnt < req) {
sofar = -1;
break;
@@ -860,7 +879,7 @@ int ipath_sd7220_prog_ld(struct ipath_devdata *dd, int sdnum,
#define VFY_CHUNK 64
#define SD_PRAM_ERROR_LIMIT 42
-int ipath_sd7220_prog_vfy(struct ipath_devdata *dd, int sdnum,
+static int ipath_sd7220_prog_vfy(struct ipath_devdata *dd, int sdnum,
const u8 *img, int len, int offset)
{
int cnt, sofar, req, idx, errors;
@@ -888,6 +907,18 @@ int ipath_sd7220_prog_vfy(struct ipath_devdata *dd, int sdnum,
return errors ? -errors : sofar;
}
+static int
+ipath_sd7220_ib_load(struct ipath_devdata *dd, const struct firmware *fw)
+{
+ return ipath_sd7220_prog_ld(dd, IB_7220_SERDES, fw->data, fw->size, 0);
+}
+
+static int
+ipath_sd7220_ib_vfy(struct ipath_devdata *dd, const struct firmware *fw)
+{
+ return ipath_sd7220_prog_vfy(dd, IB_7220_SERDES, fw->data, fw->size, 0);
+}
+
/* IRQ not set up at this point in init, so we poll. */
#define IB_SERDES_TRIM_DONE (1ULL << 11)
#define TRIM_TMO (30)
--
1.6.3.3