mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] net/e1000: use correct bit to check for flash presence
@ 2018-01-24 11:32 Lucas Stach
  2018-01-24 11:32 ` [PATCH 2/3] net/e1000: mark EEPROM as invalid if external flash is absent Lucas Stach
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lucas Stach @ 2018-01-24 11:32 UTC (permalink / raw)
  To: barebox

This code path was checking the same bit (E1000_EECD_EE_PRES) twice,
which doesn't look right. Use the correct bit to check for flash
presence.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/e1000/e1000.h  | 1 -
 drivers/net/e1000/eeprom.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 1558b3c7f5c7..0c83a47e9aab 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -794,7 +794,6 @@ struct e1000_eeprom_info {
 #ifndef E1000_EEPROM_GRANT_ATTEMPTS
 #define E1000_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */
 #endif
-#define E1000_EECD_FLASH_IN_USE     0x00000100  /* Flash is present with a valid signature */
 #define E1000_EECD_EE_PRES          0x00000100
 #define E1000_EECD_AUTO_RD          0x00000200  /* EEPROM Auto Read done */
 #define E1000_EECD_SIZE_EX_MASK     0x00007800  /* EEprom Size */
diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
index 748d8afe7922..ee4f768bb4cd 100644
--- a/drivers/net/e1000/eeprom.c
+++ b/drivers/net/e1000/eeprom.c
@@ -1569,7 +1569,7 @@ int e1000_register_eeprom(struct e1000_hw *hw)
 
 		if (eecd & E1000_EECD_AUTO_RD) {
 			if (eecd & E1000_EECD_EE_PRES) {
-				if (eecd & E1000_EECD_FLASH_IN_USE) {
+				if (eecd & E1000_EECD_I210_FLASH_DETECTED) {
 					uint32_t fla = e1000_read_reg(hw, E1000_FLA);
 					dev_info(hw->dev,
 						 "Hardware programmed from flash (%ssecure)\n",
-- 
2.15.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] net/e1000: mark EEPROM as invalid if external flash is absent
  2018-01-24 11:32 [PATCH 1/3] net/e1000: use correct bit to check for flash presence Lucas Stach
@ 2018-01-24 11:32 ` Lucas Stach
  2018-01-24 11:32 ` [PATCH 3/3] net/e1000: don't check EEPROM signature if populated from iNVM Lucas Stach
  2018-01-25  7:21 ` [PATCH 1/3] net/e1000: use correct bit to check for flash presence Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Lucas Stach @ 2018-01-24 11:32 UTC (permalink / raw)
  To: barebox

There is no point in registering the emulated EEPROM device if only the
iNVM is available with no external flash attached to the i210, as in
practice it's only shadowing the iNVM.

When the EEPROM is populated from iNVM, the signature is not valid, which
causes other parts of the driver to fall over. To fix this just ignore
the EEPROM in that case.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/e1000/eeprom.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
index ee4f768bb4cd..7b92aa0fb715 100644
--- a/drivers/net/e1000/eeprom.c
+++ b/drivers/net/e1000/eeprom.c
@@ -1525,20 +1525,18 @@ int e1000_register_invm(struct e1000_hw *hw)
 
 int e1000_eeprom_valid(struct e1000_hw *hw)
 {
-	uint32_t eecd;
+	uint32_t valid_mask = E1000_EECD_I210_FLASH_DETECTED |
+			      E1000_EECD_AUTO_RD | E1000_EECD_EE_PRES;
 
 	if (hw->mac_type != e1000_igb)
 		return 1;
 
 	/*
-	 * if AUTO_RD or EE_PRES are not set in EECD, the shadow RAM is invalid
-	 * (and in practise seems to contain the contents of iNVM).
+	 * If there is no flash detected or AUTO_RD or EE_PRES are not set in
+	 * EECD, the shadow RAM is invalid (and in practise seems to contain
+	 * the contents of iNVM).
 	 */
-	eecd = e1000_read_reg(hw, E1000_EECD);
-	if (!(eecd & E1000_EECD_AUTO_RD))
-		return 0;
-
-	if (!(eecd & E1000_EECD_EE_PRES))
+	if ((e1000_read_reg(hw, E1000_EECD) & valid_mask) != valid_mask)
 		return 0;
 
 	return 1;
-- 
2.15.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] net/e1000: don't check EEPROM signature if populated from iNVM
  2018-01-24 11:32 [PATCH 1/3] net/e1000: use correct bit to check for flash presence Lucas Stach
  2018-01-24 11:32 ` [PATCH 2/3] net/e1000: mark EEPROM as invalid if external flash is absent Lucas Stach
@ 2018-01-24 11:32 ` Lucas Stach
  2018-01-25  7:21 ` [PATCH 1/3] net/e1000: use correct bit to check for flash presence Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Lucas Stach @ 2018-01-24 11:32 UTC (permalink / raw)
  To: barebox

The EEPROM device will contain an invalid signature if it has been
populated from iNVM. Since the iNVM enum type has been removed, the
only way to tell if a signature check makes sense is to look at the
EEPROM valid status.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/e1000/eeprom.c | 10 ++++------
 drivers/net/e1000/main.c   |  2 +-
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
index 7b92aa0fb715..07ee81d14e0a 100644
--- a/drivers/net/e1000/eeprom.c
+++ b/drivers/net/e1000/eeprom.c
@@ -1006,12 +1006,10 @@ int e1000_validate_eeprom_checksum(struct e1000_hw *hw)
 	DEBUGFUNC();
 
 	/*
-	  Only the following three 'types' of EEPROM can be expected
-	  to have correct EEPROM checksum
-	*/
-	if (hw->eeprom.type != e1000_eeprom_spi &&
-	    hw->eeprom.type != e1000_eeprom_microwire &&
-	    hw->eeprom.type != e1000_eeprom_flash)
+	 * If the EEPROM device content isn't valid there is no point in
+	 * checking the signature.
+	 */
+	if (!e1000_eeprom_valid(hw))
 		return 0;
 
 	/* Read the EEPROM */
diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c
index 0139c4a6d758..bb6ab4eb0360 100644
--- a/drivers/net/e1000/main.c
+++ b/drivers/net/e1000/main.c
@@ -3597,7 +3597,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		}
 	}
 
-	if (!e1000_eeprom_valid(hw) || e1000_validate_eeprom_checksum(hw))
+	if (e1000_validate_eeprom_checksum(hw))
 		return 0;
 
 	e1000_get_ethaddr(edev, edev->ethaddr);
-- 
2.15.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] net/e1000: use correct bit to check for flash presence
  2018-01-24 11:32 [PATCH 1/3] net/e1000: use correct bit to check for flash presence Lucas Stach
  2018-01-24 11:32 ` [PATCH 2/3] net/e1000: mark EEPROM as invalid if external flash is absent Lucas Stach
  2018-01-24 11:32 ` [PATCH 3/3] net/e1000: don't check EEPROM signature if populated from iNVM Lucas Stach
@ 2018-01-25  7:21 ` Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2018-01-25  7:21 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Wed, Jan 24, 2018 at 12:32:14PM +0100, Lucas Stach wrote:
> This code path was checking the same bit (E1000_EECD_EE_PRES) twice,
> which doesn't look right. Use the correct bit to check for flash
> presence.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/net/e1000/e1000.h  | 1 -
>  drivers/net/e1000/eeprom.c | 2 +-
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
> index 1558b3c7f5c7..0c83a47e9aab 100644
> --- a/drivers/net/e1000/e1000.h
> +++ b/drivers/net/e1000/e1000.h
> @@ -794,7 +794,6 @@ struct e1000_eeprom_info {
>  #ifndef E1000_EEPROM_GRANT_ATTEMPTS
>  #define E1000_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */
>  #endif
> -#define E1000_EECD_FLASH_IN_USE     0x00000100  /* Flash is present with a valid signature */

I think the right fix here is:

-#define E1000_EECD_FLASH_IN_USE     0x00000100  /* Flash is present with a valid signature */
+#define E1000_EECD_FLASH_IN_USE     0x00000040  /* Flash is present with a valid signature */

Fixes commit 95c346ccaa6da2257f605d18ac7595b99f628419.

>  #define E1000_EECD_EE_PRES          0x00000100
>  #define E1000_EECD_AUTO_RD          0x00000200  /* EEPROM Auto Read done */
>  #define E1000_EECD_SIZE_EX_MASK     0x00007800  /* EEprom Size */
> diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
> index 748d8afe7922..ee4f768bb4cd 100644
> --- a/drivers/net/e1000/eeprom.c
> +++ b/drivers/net/e1000/eeprom.c
> @@ -1569,7 +1569,7 @@ int e1000_register_eeprom(struct e1000_hw *hw)
>  
>  		if (eecd & E1000_EECD_AUTO_RD) {
>  			if (eecd & E1000_EECD_EE_PRES) {
> -				if (eecd & E1000_EECD_FLASH_IN_USE) {
> +				if (eecd & E1000_EECD_I210_FLASH_DETECTED) {
>  					uint32_t fla = e1000_read_reg(hw, E1000_FLA);
>  					dev_info(hw->dev,
>  						 "Hardware programmed from flash (%ssecure)\n",
> -- 
> 2.15.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-25  7:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24 11:32 [PATCH 1/3] net/e1000: use correct bit to check for flash presence Lucas Stach
2018-01-24 11:32 ` [PATCH 2/3] net/e1000: mark EEPROM as invalid if external flash is absent Lucas Stach
2018-01-24 11:32 ` [PATCH 3/3] net/e1000: don't check EEPROM signature if populated from iNVM Lucas Stach
2018-01-25  7:21 ` [PATCH 1/3] net/e1000: use correct bit to check for flash presence Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox