aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/brocade
diff options
context:
space:
mode:
authorJing Huang <huangj@Brocade.COM>2012-04-04 01:42:08 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-04 18:19:17 -0400
commite491c77ed37de43cc89cfb4930f80f9a36dff1b8 (patch)
treebdc74ac23f2c8d3f191c067acbfabc7eeaad9c1f /drivers/net/ethernet/brocade
parent695e00789a2703e79da9adf3cd868fe54142885e (diff)
bna: Serialize smem access during adapter initialization
Use init semaphore to serialize execution of the "unlock IOC semaphore" code. Added bfa_ioc_fwver_clear() function to clear the firmware header if last firmwar boot is not from driver. Signed-off-by: Jing Huang <huangj@brocade.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/brocade')
-rw-r--r--drivers/net/ethernet/brocade/bna/bfa_ioc.c50
1 files changed, 42 insertions, 8 deletions
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index 77977d735dd7..7a3e79c7834b 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -1207,27 +1207,62 @@ bfa_nw_ioc_sem_release(void __iomem *sem_reg)
1207 writel(1, sem_reg); 1207 writel(1, sem_reg);
1208} 1208}
1209 1209
1210/* Clear fwver hdr */
1211static void
1212bfa_ioc_fwver_clear(struct bfa_ioc *ioc)
1213{
1214 u32 pgnum, pgoff, loff = 0;
1215 int i;
1216
1217 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
1218 pgoff = PSS_SMEM_PGOFF(loff);
1219 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1220
1221 for (i = 0; i < (sizeof(struct bfi_ioc_image_hdr) / sizeof(u32)); i++) {
1222 writel(0, ioc->ioc_regs.smem_page_start + loff);
1223 loff += sizeof(u32);
1224 }
1225}
1226
1227
1210static void 1228static void
1211bfa_ioc_hw_sem_init(struct bfa_ioc *ioc) 1229bfa_ioc_hw_sem_init(struct bfa_ioc *ioc)
1212{ 1230{
1213 struct bfi_ioc_image_hdr fwhdr; 1231 struct bfi_ioc_image_hdr fwhdr;
1214 u32 fwstate = readl(ioc->ioc_regs.ioc_fwstate); 1232 u32 fwstate, r32;
1215 1233
1216 if (fwstate == BFI_IOC_UNINIT) 1234 /* Spin on init semaphore to serialize. */
1235 r32 = readl(ioc->ioc_regs.ioc_init_sem_reg);
1236 while (r32 & 0x1) {
1237 udelay(20);
1238 r32 = readl(ioc->ioc_regs.ioc_init_sem_reg);
1239 }
1240
1241 fwstate = readl(ioc->ioc_regs.ioc_fwstate);
1242 if (fwstate == BFI_IOC_UNINIT) {
1243 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1217 return; 1244 return;
1245 }
1218 1246
1219 bfa_nw_ioc_fwver_get(ioc, &fwhdr); 1247 bfa_nw_ioc_fwver_get(ioc, &fwhdr);
1220 1248
1221 if (swab32(fwhdr.exec) == BFI_FWBOOT_TYPE_NORMAL) 1249 if (swab32(fwhdr.exec) == BFI_FWBOOT_TYPE_NORMAL) {
1250 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1222 return; 1251 return;
1252 }
1223 1253
1254 bfa_ioc_fwver_clear(ioc);
1224 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate); 1255 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate);
1256 writel(BFI_IOC_UNINIT, ioc->ioc_regs.alt_ioc_fwstate);
1225 1257
1226 /* 1258 /*
1227 * Try to lock and then unlock the semaphore. 1259 * Try to lock and then unlock the semaphore.
1228 */ 1260 */
1229 readl(ioc->ioc_regs.ioc_sem_reg); 1261 readl(ioc->ioc_regs.ioc_sem_reg);
1230 writel(1, ioc->ioc_regs.ioc_sem_reg); 1262 writel(1, ioc->ioc_regs.ioc_sem_reg);
1263
1264 /* Unlock init semaphore */
1265 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1231} 1266}
1232 1267
1233static void 1268static void
@@ -1585,11 +1620,6 @@ bfa_ioc_download_fw(struct bfa_ioc *ioc, u32 boot_type,
1585 u32 i; 1620 u32 i;
1586 u32 asicmode; 1621 u32 asicmode;
1587 1622
1588 /**
1589 * Initialize LMEM first before code download
1590 */
1591 bfa_ioc_lmem_init(ioc);
1592
1593 fwimg = bfa_cb_image_get_chunk(bfa_ioc_asic_gen(ioc), chunkno); 1623 fwimg = bfa_cb_image_get_chunk(bfa_ioc_asic_gen(ioc), chunkno);
1594 1624
1595 pgnum = bfa_ioc_smem_pgnum(ioc, loff); 1625 pgnum = bfa_ioc_smem_pgnum(ioc, loff);
@@ -1914,6 +1944,10 @@ bfa_ioc_pll_init(struct bfa_ioc *ioc)
1914 bfa_ioc_pll_init_asic(ioc); 1944 bfa_ioc_pll_init_asic(ioc);
1915 1945
1916 ioc->pllinit = true; 1946 ioc->pllinit = true;
1947
1948 /* Initialize LMEM */
1949 bfa_ioc_lmem_init(ioc);
1950
1917 /* 1951 /*
1918 * release semaphore. 1952 * release semaphore.
1919 */ 1953 */