Skip to contentSkip to conversation

move ICHx GbE NVM write-protection from e1000e to PCI quirk

PATCH New Jeff Kirsher 1 participant 1 message Nov 14, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 move ICHx GbE NVM write-protection from e1000e to PCI quirk

From: Bruce Allan <[email protected]>

The write-protection method being in the driver probe routine is called late in the boot sequence, and not at all if the driver is never loaded. By making it a PCI quirk the NVM is protected much earlier whether or not the driver is loaded. The write-protection quirk can be disabled with a new kernel parameter in the unlikely event the NVM needs to be modified.

---

 Documentation/kernel-parameters.txt |    4 +
 drivers/net/Makefile                |    1 
 drivers/net/e1000e/Makefile         |    1 
 drivers/net/e1000e/e1000.h          |    1 
 drivers/net/e1000e/ethtool.c        |    6 +
 drivers/net/e1000e/ich8lan.c        |   93 +++-----------------
 drivers/net/e1000e/ich8lan.h        |   68 +++++++++++++++
 drivers/net/e1000e/netdev.c         |    4 -
 drivers/net/e1000e/param.c          |   30 ------
 drivers/net/e1000e/quirks.c         |  163 +++++++++++++++++++++++++++++++++++
 10 files changed, 257 insertions(+), 114 deletions(-)
 create mode 100644 drivers/net/e1000e/ich8lan.h
 create mode 100644 drivers/net/e1000e/quirks.c
Documentation/kernel-parameters.txt +4 -0
index c86c074..73affad 100644
@@ -2386,6 +2386,10 @@ and is between 256 and 4096 characters. It is defined in the file
 	norandmaps	Don't use address space randomization
 			Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space
 
+	ichlan_protect=	[KNL] Intel ICHx GbE NVM write-protection
+			Format: { enable (default) | disable }
+			disable: disable NVM write protection
+
 ______________________________________________________________________
 
 TODO:
drivers/net/Makefile +1 -0
index f19acf8..e3979dc 100644
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_E1000) += e1000/
 obj-$(CONFIG_E1000E) += e1000e/
+obj-y += e1000e/
 obj-$(CONFIG_IBM_NEW_EMAC) += ibm_newemac/
 obj-$(CONFIG_IGB) += igb/
 obj-$(CONFIG_IXGBE) += ixgbe/
drivers/net/e1000e/Makefile +1 -0
index 360c913..a3eb70c 100644
@@ -35,3 +35,4 @@ obj-$(CONFIG_E1000E) += e1000e.o
 e1000e-objs := 82571.o ich8lan.o es2lan.o \
 	       lib.o phy.o param.o ethtool.o netdev.o
 
+obj-y += quirks.o
drivers/net/e1000e/e1000.h +0 -1
index c55fd6f..96a5979 100644
@@ -413,7 +413,6 @@ extern bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw);
 extern bool e1000e_get_laa_state_82571(struct e1000_hw *hw);
 extern void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state);
 
-extern void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw);
 extern void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
 						 bool state);
 extern void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw);
drivers/net/e1000e/ethtool.c +5 -1
index 62421ce..436b33c 100644
@@ -533,8 +533,12 @@ static int e1000_set_eeprom(struct net_device *netdev,
 	if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16)))
 		return -EFAULT;
 
-	if (adapter->flags & FLAG_READ_ONLY_NVM)
+	if (adapter->flags & FLAG_READ_ONLY_NVM) {
+		e_info("NVM is read-only. Reboot with 'ichlan_protect=disable' "
+		       "only if you absolutely *must* change the EEPROM/NVM, "
+		       "otherwise leave it read-only to prevent corruption.\n");
 		return -EINVAL;
+	}
 
 	max_len = hw->nvm.word_size * 2;
 
drivers/net/e1000e/ich8lan.c +15 -78

145 lines not on this page · raw message

drivers/net/e1000e/ich8lan.h new file +68 -0

68 lines not on this page · raw message

drivers/net/e1000e/netdev.c +0 -4
index 91795f7..3c4789a 100644
@@ -4849,10 +4849,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 	if (err)
 		goto err_hw_init;
 
-	if ((adapter->flags & FLAG_IS_ICH) &&
-	    (adapter->flags & FLAG_READ_ONLY_NVM))
-		e1000e_write_protect_nvm_ich8lan(&adapter->hw);
-
 	hw->mac.ops.get_bus_info(&adapter->hw);
 
 	adapter->hw.phy.autoneg_wait_to_complete = 0;
drivers/net/e1000e/param.c +0 -30
index e909f96..bdf1eb0 100644
@@ -143,15 +143,6 @@ E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
 E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
 
 /*
- * Write Protect NVM
- *
- * Valid Range: 0, 1
- *
- * Default Value: 1 (enabled)
- */
-E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
-
-/*
  * Enable CRC Stripping
  *
  * Valid Range: 0, 1
@@ -449,25 +440,4 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
 								       opt.def);
 		}
 	}
-	{ /* Write-protect NVM */
-		const struct e1000_option opt = {
-			.type = enable_option,
-			.name = "Write-protect NVM",
-			.err  = "defaulting to Enabled",
-			.def  = OPTION_ENABLED
-		};
-
-		if (adapter->flags & FLAG_IS_ICH) {
-			if (num_WriteProtectNVM > bd) {
-				unsigned int write_protect_nvm = WriteProtectNVM[bd];
-				e1000_validate_option(&write_protect_nvm, &opt,
-						      adapter);
-				if (write_protect_nvm)
-					adapter->flags |= FLAG_READ_ONLY_NVM;
-			} else {
-				if (opt.def)
-					adapter->flags |= FLAG_READ_ONLY_NVM;
-			}
-		}
-	}
 }
drivers/net/e1000e/quirks.c new file +163 -0

163 lines not on this page · raw message