Commit 15962a18 authored by Arjun Vynipadath's avatar Arjun Vynipadath Committed by David S. Miller

cxgb4: Fix FW flash errors

commit 96ac18f1 ("cxgb4: Add support for new flash parts")
removed initialization of adapter->params.sf_fw_start causing issues
while flashing firmware to card. We no longer need sf_fw_start
in adapter->params as we already have macros defined for FW flash
addresses.

Fixes: 96ac18f1 ("cxgb4: Add support for new flash parts")
Signed-off-by: default avatarArjun Vynipadath <arjun@chelsio.com>
Signed-off-by: default avatarCasey Leedom <leedom@chelsio.com>
Signed-off-by: default avatarGanesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5f0850e1
...@@ -344,7 +344,6 @@ struct adapter_params { ...@@ -344,7 +344,6 @@ struct adapter_params {
unsigned int sf_size; /* serial flash size in bytes */ unsigned int sf_size; /* serial flash size in bytes */
unsigned int sf_nsec; /* # of flash sectors */ unsigned int sf_nsec; /* # of flash sectors */
unsigned int sf_fw_start; /* start of FW image in flash */
unsigned int fw_vers; /* firmware version */ unsigned int fw_vers; /* firmware version */
unsigned int bs_vers; /* bootstrap version */ unsigned int bs_vers; /* bootstrap version */
......
...@@ -2844,8 +2844,6 @@ enum { ...@@ -2844,8 +2844,6 @@ enum {
SF_RD_DATA_FAST = 0xb, /* read flash */ SF_RD_DATA_FAST = 0xb, /* read flash */
SF_RD_ID = 0x9f, /* read ID */ SF_RD_ID = 0x9f, /* read ID */
SF_ERASE_SECTOR = 0xd8, /* erase sector */ SF_ERASE_SECTOR = 0xd8, /* erase sector */
FW_MAX_SIZE = 16 * SF_SEC_SIZE,
}; };
/** /**
...@@ -3558,8 +3556,9 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size) ...@@ -3558,8 +3556,9 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size)
const __be32 *p = (const __be32 *)fw_data; const __be32 *p = (const __be32 *)fw_data;
const struct fw_hdr *hdr = (const struct fw_hdr *)fw_data; const struct fw_hdr *hdr = (const struct fw_hdr *)fw_data;
unsigned int sf_sec_size = adap->params.sf_size / adap->params.sf_nsec; unsigned int sf_sec_size = adap->params.sf_size / adap->params.sf_nsec;
unsigned int fw_img_start = adap->params.sf_fw_start; unsigned int fw_start_sec = FLASH_FW_START_SEC;
unsigned int fw_start_sec = fw_img_start / sf_sec_size; unsigned int fw_size = FLASH_FW_MAX_SIZE;
unsigned int fw_start = FLASH_FW_START;
if (!size) { if (!size) {
dev_err(adap->pdev_dev, "FW image has no data\n"); dev_err(adap->pdev_dev, "FW image has no data\n");
...@@ -3575,9 +3574,9 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size) ...@@ -3575,9 +3574,9 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size)
"FW image size differs from size in FW header\n"); "FW image size differs from size in FW header\n");
return -EINVAL; return -EINVAL;
} }
if (size > FW_MAX_SIZE) { if (size > fw_size) {
dev_err(adap->pdev_dev, "FW image too large, max is %u bytes\n", dev_err(adap->pdev_dev, "FW image too large, max is %u bytes\n",
FW_MAX_SIZE); fw_size);
return -EFBIG; return -EFBIG;
} }
if (!t4_fw_matches_chip(adap, hdr)) if (!t4_fw_matches_chip(adap, hdr))
...@@ -3604,11 +3603,11 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size) ...@@ -3604,11 +3603,11 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size)
*/ */
memcpy(first_page, fw_data, SF_PAGE_SIZE); memcpy(first_page, fw_data, SF_PAGE_SIZE);
((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0xffffffff); ((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0xffffffff);
ret = t4_write_flash(adap, fw_img_start, SF_PAGE_SIZE, first_page); ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page);
if (ret) if (ret)
goto out; goto out;
addr = fw_img_start; addr = fw_start;
for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) {
addr += SF_PAGE_SIZE; addr += SF_PAGE_SIZE;
fw_data += SF_PAGE_SIZE; fw_data += SF_PAGE_SIZE;
...@@ -3618,7 +3617,7 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size) ...@@ -3618,7 +3617,7 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size)
} }
ret = t4_write_flash(adap, ret = t4_write_flash(adap,
fw_img_start + offsetof(struct fw_hdr, fw_ver), fw_start + offsetof(struct fw_hdr, fw_ver),
sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver); sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver);
out: out:
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment