diff options
author | Bruce Allan <bruce.w.allan@intel.com> | 2009-07-01 09:28:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-07-03 23:09:35 -0400 |
commit | 28c9195a570a32de2760310ca278d44a4fd060a4 (patch) | |
tree | 3a91e857274ede2dcdcbe8d2510ec149a23ca785 /drivers/net/e1000e | |
parent | 60f1292fcbdff03ef5caea56404d3d81d05026f6 (diff) |
e1000e: prevent NVM corruption on sectors larger than 4K
Limit NVM writes to 4K sections to prevent NVM corruption on larger
sector allocations (up to 64K).
Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/e1000e')
-rw-r--r-- | drivers/net/e1000e/ich8lan.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c index bf9b97db76b9..0e0755f0db3f 100644 --- a/drivers/net/e1000e/ich8lan.c +++ b/drivers/net/e1000e/ich8lan.c | |||
@@ -338,6 +338,7 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw) | |||
338 | { | 338 | { |
339 | struct e1000_nvm_info *nvm = &hw->nvm; | 339 | struct e1000_nvm_info *nvm = &hw->nvm; |
340 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; | 340 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
341 | union ich8_hws_flash_status hsfsts; | ||
341 | u32 gfpreg; | 342 | u32 gfpreg; |
342 | u32 sector_base_addr; | 343 | u32 sector_base_addr; |
343 | u32 sector_end_addr; | 344 | u32 sector_end_addr; |
@@ -374,6 +375,20 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw) | |||
374 | /* Adjust to word count */ | 375 | /* Adjust to word count */ |
375 | nvm->flash_bank_size /= sizeof(u16); | 376 | nvm->flash_bank_size /= sizeof(u16); |
376 | 377 | ||
378 | /* | ||
379 | * Make sure the flash bank size does not overwrite the 4k | ||
380 | * sector ranges. We may have 64k allotted to us but we only care | ||
381 | * about the first 2 4k sectors. Therefore, if we have anything less | ||
382 | * than 64k set in the HSFSTS register, we will reduce the bank size | ||
383 | * down to 4k and let the rest remain unused. If berasesz == 3, then | ||
384 | * we are working in 64k mode. Otherwise we are not. | ||
385 | */ | ||
386 | if (nvm->flash_bank_size > E1000_ICH8_SHADOW_RAM_WORDS) { | ||
387 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); | ||
388 | if (hsfsts.hsf_status.berasesz != 3) | ||
389 | nvm->flash_bank_size = E1000_ICH8_SHADOW_RAM_WORDS; | ||
390 | } | ||
391 | |||
377 | nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS; | 392 | nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS; |
378 | 393 | ||
379 | /* Clear shadow ram */ | 394 | /* Clear shadow ram */ |
@@ -1932,7 +1947,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank) | |||
1932 | break; | 1947 | break; |
1933 | case 1: | 1948 | case 1: |
1934 | sector_size = ICH_FLASH_SEG_SIZE_4K; | 1949 | sector_size = ICH_FLASH_SEG_SIZE_4K; |
1935 | iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_4K; | 1950 | iteration = 1; |
1936 | break; | 1951 | break; |
1937 | case 2: | 1952 | case 2: |
1938 | if (hw->mac.type == e1000_ich9lan) { | 1953 | if (hw->mac.type == e1000_ich9lan) { |
@@ -1944,7 +1959,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank) | |||
1944 | break; | 1959 | break; |
1945 | case 3: | 1960 | case 3: |
1946 | sector_size = ICH_FLASH_SEG_SIZE_64K; | 1961 | sector_size = ICH_FLASH_SEG_SIZE_64K; |
1947 | iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_64K; | 1962 | iteration = 1; |
1948 | break; | 1963 | break; |
1949 | default: | 1964 | default: |
1950 | return -E1000_ERR_NVM; | 1965 | return -E1000_ERR_NVM; |