move ICHx GbE NVM write-protection from e1000e to PCI quirk
Subsystems (3)
PATCH 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 | 162 +++++++++++++++++++++++++++++++++++ 10 files changed, 256 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
@@ -2274,6 +2274,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
@@ -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
@@ -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
@@ -408,7 +408,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
@@ -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
@@ -4814,10 +4814,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
@@ -142,15 +142,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]" ); -struct e1000_option {enum { enable_option, range_option, list_option } type;const char *name;
@@ -424,25 +415,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 +162 -0
162 lines not on this page · raw message
Quoted 12 lines · Jeff Kirsher
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.
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>---
Quoted 15 lines
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 | 162 +++++++++++++++++++++++++++++++++++ 10 files changed, 256 insertions(+), 114 deletions(-) create mode 100644 drivers/net/e1000e/ich8lan.h create mode 100644 drivers/net/e1000e/quirks.c
This PCI quirk is put in ./drivers/net/e1000e in order to share defines and structs found in the driver source, and is only applicable to ICHx GbE LOMs supported by that driver anyway.
Signature · 2 lines
Cheers, Jeff
Quoted 30 lines · Jeff Kirsher
Quoted 12 lines · Jeff Kirsher
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.
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>---
Quoted 15 lines
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 | 162 +++++++++++++++++++++++++++++++++++ 10 files changed, 256 insertions(+), 114 deletions(-) create mode 100644 drivers/net/e1000e/ich8lan.h create mode 100644 drivers/net/e1000e/quirks.c
Quoted 3 lines
This PCI quirk is put in
./drivers/net/e1000ein order to share defines and structs found in the driver source, and is only applicable to ICHx GbE LOMs supported by that driver anyway.
Seems to be it is not difficult to put it into drivers/pci/quirks.c, where it belongs.
Jeff
Quoted 8 lines
Quoted 3 lines
This PCI quirk is put in
./drivers/net/e1000ein order to share defines and structs found in the driver source, and is only applicable to ICHx GbE LOMs supported by that driver anyway.Seems to be it is not difficult to put it into
drivers/pci/quirks.c, where it belongs.Jeff
Yes, it wouldn't be difficult to put it elsewhere but does it really belong in drivers/pci/quirks.c? The quirk is applicable only to the GbE LOM found on Intel ICH8/9/10-based platforms so one could argue it should be in arch-specific code (arch/x86/pci/fixup.c). OTOH, quirks in driver directories are not unprecedented (e.g. drivers/clocksource/acpi_pm.c, drivers/usb/host/pci-quirks.c). I patched it into the driver's directory as it would be an obvious reminder when adding support for future parts to check whether the quirk is applicable and update the list of devices accordingly.
So, what is the "right" place?
Quoted 19 lines · Bruce W
Quoted 8 lines
Quoted 3 lines
This PCI quirk is put in
./drivers/net/e1000ein order to share defines and structs found in the driver source, and is only applicable to ICHx GbE LOMs supported by that driver anyway.Seems to be it is not difficult to put it into
drivers/pci/quirks.c, where it belongs.Jeff
Yes, it wouldn't be difficult to put it elsewhere but does it really belong in
drivers/pci/quirks.c? The quirk is applicable only to the GbE LOM found on Intel ICH8/9/10-based platforms so one could argue it should be in arch-specific code (arch/x86/pci/fixup.c). OTOH, quirks in driver directories are not unprecedented (e.g.drivers/clocksource/acpi_pm.c,drivers/usb/host/pci-quirks.c). I patched it into the driver's directory as it would be an obvious reminder when adding support for future parts to check whether the quirk is applicable and update the list of devices accordingly.
Quoted 1 line
So, what is the "right" place?
If you think it's likely to apply to future devices as well, I'd say you may as well keep it in the driver.
Jesse
On Thursday, October 30, 2008 9:16 AM Jesse Barnes wrote
Quoted 7 lines
If you think it's likely to apply to future devices as well, I'd say you may
as well keep it in the driver.Jesse
Yes, it will likely apply to future devices. I assume you meant to say "may as well keep it in the driver *directory*", correct?
Thanks,
Bruce.
Quoted 10 lines · Bruce W
On Thursday, October 30, 2008 9:16 AM Jesse Barnes wrote
Quoted 5 lines
If you think it's likely to apply to future devices as well, I'd say you may
as well keep it in the driver.Jesse
Yes, it will likely apply to future devices. I assume you meant to say "may as well keep it in the driver *directory*", correct?
Well I was considering everything under drivers/net/e1000e to be part of the driver, but yeah.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center