Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 247133
b: refs/heads/master
c: dbf28e2
h: refs/heads/master
i:
  247131: 8a6b2f1
v: v3
  • Loading branch information
Johannes Berg authored and Wey-Yi Guy committed Apr 22, 2011
1 parent 64e7ed1 commit d878bdf
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 99 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ca7966c88e44233fac113579071a6f55e00ef5ac
refs/heads/master: dbf28e21ca391110e90ccad05dda79d2e2f60e0e
23 changes: 10 additions & 13 deletions trunk/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,16 @@ static int iwlagn_load_section(struct iwl_priv *priv, const char *name,
}

static int iwlagn_load_given_ucode(struct iwl_priv *priv,
struct fw_desc *inst_image,
struct fw_desc *data_image)
struct fw_img *image)
{
int ret = 0;

ret = iwlagn_load_section(priv, "INST", inst_image,
ret = iwlagn_load_section(priv, "INST", &image->code,
IWLAGN_RTC_INST_LOWER_BOUND);
if (ret)
return ret;

return iwlagn_load_section(priv, "DATA", data_image,
return iwlagn_load_section(priv, "DATA", &image->data,
IWLAGN_RTC_DATA_LOWER_BOUND);
}

Expand Down Expand Up @@ -557,16 +556,16 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv,
* iwl_verify_ucode - determine which instruction image is in SRAM,
* and verify its contents
*/
static int iwl_verify_ucode(struct iwl_priv *priv, struct fw_desc *fw_desc)
static int iwl_verify_ucode(struct iwl_priv *priv, struct fw_img *img)
{
if (!iwlcore_verify_inst_sparse(priv, fw_desc)) {
if (!iwlcore_verify_inst_sparse(priv, &img->code)) {
IWL_DEBUG_INFO(priv, "uCode is good in inst SRAM\n");
return 0;
}

IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");

iwl_print_mismatch_inst(priv, fw_desc);
iwl_print_mismatch_inst(priv, &img->code);
return -EIO;
}

Expand Down Expand Up @@ -602,8 +601,7 @@ static void iwlagn_alive_fn(struct iwl_priv *priv,
#define UCODE_CALIB_TIMEOUT (2*HZ)

int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
struct fw_desc *inst_image,
struct fw_desc *data_image,
struct fw_img *image,
int subtype, int alternate_subtype)
{
struct iwl_notification_wait alive_wait;
Expand All @@ -621,7 +619,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
old_type = priv->ucode_type;
priv->ucode_type = subtype;

ret = iwlagn_load_given_ucode(priv, inst_image, data_image);
ret = iwlagn_load_given_ucode(priv, image);
if (ret) {
priv->ucode_type = old_type;
iwlagn_remove_notification(priv, &alive_wait);
Expand Down Expand Up @@ -656,7 +654,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
return -EIO;
}

ret = iwl_verify_ucode(priv, inst_image);
ret = iwl_verify_ucode(priv, image);
if (ret) {
priv->ucode_type = old_type;
return ret;
Expand Down Expand Up @@ -684,7 +682,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv)
lockdep_assert_held(&priv->mutex);

/* No init ucode required? Curious, but maybe ok */
if (!priv->ucode_init.len)
if (!priv->ucode_init.code.len)
return 0;

if (priv->ucode_type != UCODE_SUBTYPE_NONE_LOADED)
Expand All @@ -696,7 +694,6 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv)

/* Will also start the device */
ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init,
&priv->ucode_init_data,
UCODE_SUBTYPE_INIT, -1);
if (ret)
goto error;
Expand Down
98 changes: 45 additions & 53 deletions trunk/drivers/net/wireless/iwlwifi/iwl-agn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,12 +1173,42 @@ static struct attribute_group iwl_attribute_group = {
*
******************************************************************************/

static void iwl_free_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc)
{
if (desc->v_addr)
dma_free_coherent(&pci_dev->dev, desc->len,
desc->v_addr, desc->p_addr);
desc->v_addr = NULL;
desc->len = 0;
}

static void iwl_free_fw_img(struct pci_dev *pci_dev, struct fw_img *img)
{
iwl_free_fw_desc(pci_dev, &img->code);
iwl_free_fw_desc(pci_dev, &img->data);
}

static int iwl_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc,
const void *data, size_t len)
{
if (!len) {
desc->v_addr = NULL;
return -EINVAL;
}

desc->v_addr = dma_alloc_coherent(&pci_dev->dev, len,
&desc->p_addr, GFP_KERNEL);
if (!desc->v_addr)
return -ENOMEM;
desc->len = len;
memcpy(desc->v_addr, data, len);
return 0;
}

static void iwl_dealloc_ucode_pci(struct iwl_priv *priv)
{
iwl_free_fw_desc(priv->pci_dev, &priv->ucode_code);
iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data);
iwl_free_fw_desc(priv->pci_dev, &priv->ucode_init);
iwl_free_fw_desc(priv->pci_dev, &priv->ucode_init_data);
iwl_free_fw_img(priv->pci_dev, &priv->ucode_rt);
iwl_free_fw_img(priv->pci_dev, &priv->ucode_init);
}

struct iwlagn_ucode_capabilities {
Expand Down Expand Up @@ -1647,24 +1677,20 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
/* Runtime instructions and 2 copies of data:
* 1) unmodified from disk
* 2) backup cache for save/restore during power-downs */
priv->ucode_code.len = pieces.inst_size;
iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_code);

priv->ucode_data.len = pieces.data_size;
iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data);

if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr)
if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_rt.code,
pieces.inst, pieces.inst_size))
goto err_pci_alloc;
if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_rt.data,
pieces.data, pieces.data_size))
goto err_pci_alloc;

/* Initialization instructions and data */
if (pieces.init_size && pieces.init_data_size) {
priv->ucode_init.len = pieces.init_size;
iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init);

priv->ucode_init_data.len = pieces.init_data_size;
iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data);

if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr)
if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init.code,
pieces.init, pieces.init_size))
goto err_pci_alloc;
if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init.data,
pieces.init_data, pieces.init_data_size))
goto err_pci_alloc;
}

Expand Down Expand Up @@ -1701,39 +1727,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
else
priv->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM;

/* Copy images into buffers for card's bus-master reads ... */

/* Runtime instructions (first block of data in file) */
IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n",
pieces.inst_size);
memcpy(priv->ucode_code.v_addr, pieces.inst, pieces.inst_size);

IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr);

/*
* Runtime data
* NOTE: Copy into backup buffer will be done in iwl_up()
*/
IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n",
pieces.data_size);
memcpy(priv->ucode_data.v_addr, pieces.data, pieces.data_size);

/* Initialization instructions */
if (pieces.init_size) {
IWL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n",
pieces.init_size);
memcpy(priv->ucode_init.v_addr, pieces.init, pieces.init_size);
}

/* Initialization data */
if (pieces.init_data_size) {
IWL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n",
pieces.init_data_size);
memcpy(priv->ucode_init_data.v_addr, pieces.init_data,
pieces.init_data_size);
}

/*
* figure out the offset of chain noise reset and gain commands
* base on the size of standard phy calibration commands table size
Expand Down Expand Up @@ -2450,8 +2443,7 @@ static int __iwl_up(struct iwl_priv *priv)
}

ret = iwlagn_load_ucode_wait_alive(priv,
&priv->ucode_code,
&priv->ucode_data,
&priv->ucode_rt,
UCODE_SUBTYPE_REGULAR,
UCODE_SUBTYPE_REGULAR_NEW);
if (ret) {
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/net/wireless/iwlwifi/iwl-agn.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
void iwlagn_send_prio_tbl(struct iwl_priv *priv);
int iwlagn_run_init_ucode(struct iwl_priv *priv);
int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
struct fw_desc *inst_image,
struct fw_desc *data_image,
struct fw_img *image,
int subtype, int alternate_subtype);

/* lib */
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/wireless/iwlwifi/iwl-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
priv->dbgfs_sram_offset = 0x800000;
if (priv->ucode_type == UCODE_SUBTYPE_INIT)
priv->dbgfs_sram_len = priv->ucode_init_data.len;
priv->dbgfs_sram_len = priv->ucode_init.data.len;
else
priv->dbgfs_sram_len = priv->ucode_data.len;
priv->dbgfs_sram_len = priv->ucode_rt.data.len;
}
len = priv->dbgfs_sram_len;

Expand Down
11 changes: 7 additions & 4 deletions trunk/drivers/net/wireless/iwlwifi/iwl-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ struct fw_desc {
u32 len; /* bytes */
};

struct fw_img {
struct fw_desc code, data;
};

/* v1/v2 uCode file layout */
struct iwl_ucode_header {
__le32 ver; /* major/minor/API/serial */
Expand Down Expand Up @@ -1266,10 +1270,9 @@ struct iwl_priv {
int fw_index; /* firmware we're trying to load */
u32 ucode_ver; /* version of ucode, copy of
iwl_ucode.ver */
struct fw_desc ucode_code; /* runtime inst */
struct fw_desc ucode_data; /* runtime data original */
struct fw_desc ucode_init; /* initialization inst */
struct fw_desc ucode_init_data; /* initialization data */
struct fw_img ucode_rt;
struct fw_img ucode_init;

enum iwlagn_ucode_subtype ucode_type;
u8 ucode_write_complete; /* the image write is complete */
char firmware_name[25];
Expand Down
24 changes: 0 additions & 24 deletions trunk/drivers/net/wireless/iwlwifi/iwl-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,6 @@ static inline int iwl_queue_dec_wrap(int index, int n_bd)
return --index & (n_bd - 1);
}

/* TODO: Move fw_desc functions to iwl-pci.ko */
static inline void iwl_free_fw_desc(struct pci_dev *pci_dev,
struct fw_desc *desc)
{
if (desc->v_addr)
dma_free_coherent(&pci_dev->dev, desc->len,
desc->v_addr, desc->p_addr);
desc->v_addr = NULL;
desc->len = 0;
}

static inline int iwl_alloc_fw_desc(struct pci_dev *pci_dev,
struct fw_desc *desc)
{
if (!desc->len) {
desc->v_addr = NULL;
return -EINVAL;
}

desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len,
&desc->p_addr, GFP_KERNEL);
return (desc->v_addr != NULL) ? 0 : -ENOMEM;
}

/*
* we have 8 bits used like this:
*
Expand Down

0 comments on commit d878bdf

Please sign in to comment.