netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] bnx2x: Configure device endianity on driver load and reset endianity on removal.
@ 2014-09-01 14:17 Manish Chopra
  2014-09-01 15:33 ` Manish Chopra
  0 siblings, 1 reply; 5+ messages in thread
From: Manish Chopra @ 2014-09-01 14:17 UTC (permalink / raw)
  To: davem; +Cc: netdev, Ariel.Elior, Yuval.Mintz

Some hosts can be both little and big endian.
In certain scenarios a big endian kernel can kexec a little endian kernel.

This patch fixes this case from both ends:
1) Return endianity to original values on shutdown (in case little endian kernel boots after we shutdown).
2) Do not rely on HW reset values when loading driver in little endian kernel
   but configure them explicitly (in case previous kernel was big endian and did not reset the HW).

Signed-off-by: Manish Chopra <manish.chopra@qlogic.com>
Signed-off-by: Ariel Elior <Ariel.Elior@qlogic.com>
---

Hi David,

Please consider applying this patch to `net'

Thanks,
Manish

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |   54 +++++++++++++++-------
 1 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 900cab4..418d798 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -6849,6 +6849,37 @@ static void bnx2x__common_init_phy(struct bnx2x *bp)
 	bnx2x_release_phy_lock(bp);
 }
 
+static void bnx2x_config_endianity(struct bnx2x *bp, u32 val)
+{
+	REG_WR(bp, PXP2_REG_RQ_QM_ENDIAN_M, val);
+	REG_WR(bp, PXP2_REG_RQ_TM_ENDIAN_M, val);
+	REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, val);
+	REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, val);
+	REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, val);
+
+	/* make sure this value is 0 */
+	REG_WR(bp, PXP2_REG_RQ_HC_ENDIAN_M, 0);
+
+	REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, val);
+	REG_WR(bp, PXP2_REG_RD_TM_SWAP_MODE, val);
+	REG_WR(bp, PXP2_REG_RD_SRC_SWAP_MODE, val);
+	REG_WR(bp, PXP2_REG_RD_CDURD_SWAP_MODE, val);
+}
+
+static inline void bnx2x_set_endianity(struct bnx2x *bp)
+{
+#ifdef __BIG_ENDIAN
+	bnx2x_config_endianity(bp, 1);
+#else
+	bnx2x_config_endianity(bp, 0);
+#endif
+}
+
+static inline void bnx2x_reset_endianity(struct bnx2x *bp)
+{
+	bnx2x_config_endianity(bp, 0);
+}
+
 /**
  * bnx2x_init_hw_common - initialize the HW at the COMMON phase.
  *
@@ -6915,23 +6946,7 @@ static int bnx2x_init_hw_common(struct bnx2x *bp)
 
 	bnx2x_init_block(bp, BLOCK_PXP2, PHASE_COMMON);
 	bnx2x_init_pxp(bp);
-
-#ifdef __BIG_ENDIAN
-	REG_WR(bp, PXP2_REG_RQ_QM_ENDIAN_M, 1);
-	REG_WR(bp, PXP2_REG_RQ_TM_ENDIAN_M, 1);
-	REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, 1);
-	REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, 1);
-	REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, 1);
-	/* make sure this value is 0 */
-	REG_WR(bp, PXP2_REG_RQ_HC_ENDIAN_M, 0);
-
-/*	REG_WR(bp, PXP2_REG_RD_PBF_SWAP_MODE, 1); */
-	REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, 1);
-	REG_WR(bp, PXP2_REG_RD_TM_SWAP_MODE, 1);
-	REG_WR(bp, PXP2_REG_RD_SRC_SWAP_MODE, 1);
-	REG_WR(bp, PXP2_REG_RD_CDURD_SWAP_MODE, 1);
-#endif
-
+	bnx2x_set_endianity(bp);
 	bnx2x_ilt_init_page_size(bp, INITOP_SET);
 
 	if (CHIP_REV_IS_FPGA(bp) && CHIP_IS_E1H(bp))
@@ -13172,6 +13187,11 @@ static void __bnx2x_remove(struct pci_dev *pdev,
 	if (IS_PF(bp))
 		bnx2x_set_power_state(bp, PCI_D0);
 
+	/* Set endianity registers to reset values in case next driver
+	 * boots in different endianty environment.
+	 */
+	bnx2x_reset_endianity(bp);
+
 	/* Disable MSI/MSI-X */
 	bnx2x_disable_msi(bp);
 
-- 
1.7.1

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

* RE: [PATCH net] bnx2x: Configure device endianity on driver load and reset endianity on removal.
  2014-09-01 14:17 [PATCH net] bnx2x: Configure device endianity on driver load and reset endianity on removal Manish Chopra
@ 2014-09-01 15:33 ` Manish Chopra
  2014-09-01 21:53   ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Manish Chopra @ 2014-09-01 15:33 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Ariel Elior, Yuval Mintz

> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> On Behalf Of Manish Chopra
> Sent: Monday, September 01, 2014 7:47 PM
> To: David Miller
> Cc: netdev; Ariel Elior; Yuval Mintz
> Subject: [PATCH net] bnx2x: Configure device endianity on driver load and reset
> endianity on removal.
> 
> Some hosts can be both little and big endian.
> In certain scenarios a big endian kernel can kexec a little endian kernel.
> 
> This patch fixes this case from both ends:
> 1) Return endianity to original values on shutdown (in case little endian kernel
> boots after we shutdown).
> 2) Do not rely on HW reset values when loading driver in little endian kernel
>    but configure them explicitly (in case previous kernel was big endian and did
> not reset the HW).
> 
> Signed-off-by: Manish Chopra <manish.chopra@qlogic.com>
> Signed-off-by: Ariel Elior <Ariel.Elior@qlogic.com>
> ---
> 
> Hi David,
> 
> Please consider applying this patch to `net'
> 
> Thanks,
> Manish

David, Please drop this patch as it might create issue for VFs.
I will send updated V2 patch with proper fix. 

Thanks,
Manish 
 

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

* Re: [PATCH net] bnx2x: Configure device endianity on driver load and reset endianity on removal.
  2014-09-01 15:33 ` Manish Chopra
@ 2014-09-01 21:53   ` David Miller
  2014-09-02  5:47     ` Yuval Mintz
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2014-09-01 21:53 UTC (permalink / raw)
  To: manish.chopra; +Cc: netdev, Ariel.Elior, Yuval.Mintz

From: Manish Chopra <manish.chopra@qlogic.com>
Date: Mon, 1 Sep 2014 15:33:20 +0000

>> -----Original Message-----
>> This patch fixes this case from both ends:
>> 1) Return endianity to original values on shutdown (in case little endian kernel
>> boots after we shutdown).
>> 2) Do not rely on HW reset values when loading driver in little endian kernel
>>    but configure them explicitly (in case previous kernel was big endian and did
>> not reset the HW).
 ...
> David, Please drop this patch as it might create issue for VFs.
> I will send updated V2 patch with proper fix. 

I think part #2 is the only reasonable part of this patch, and that's
what you'll have to backport to -stable kernels to sort this out
properly.

Adding "unconfiguration" hacks into a driver to deal with driver bugs
is really not kosher, sorry.

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

* RE: [PATCH net] bnx2x: Configure device endianity on driver load and reset endianity on removal.
  2014-09-01 21:53   ` David Miller
@ 2014-09-02  5:47     ` Yuval Mintz
  2014-09-02  5:56       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Yuval Mintz @ 2014-09-02  5:47 UTC (permalink / raw)
  To: David Miller, Manish Chopra; +Cc: netdev, Ariel Elior

>> This patch fixes this case from both ends:
>>> 1) Return endianity to original values on shutdown (in case little endian kernel
>>> boots after we shutdown).
>>> 2) Do not rely on HW reset values when loading driver in little endian kernel
>>>    but configure them explicitly (in case previous kernel was big endian and did
>>> not reset the HW).
 ...
>> David, Please drop this patch as it might create issue for VFs.
>> I will send updated V2 patch with proper fix.

>I think part #2 is the only reasonable part of this patch, and that's
>what you'll have to backport to -stable kernels to sort this out
>properly.

>Adding "unconfiguration" hacks into a driver to deal with driver bugs
>is really not kosher, sorry.

Why call this a hack? 
It's true #2 can solve the issue on its own for new kernels, but given the various existing distros out there (that don't include the fix) the effort of supporting those by adding #1 seems to be very small.

I wouldn't say it's not kosher; more like milchig. 

But then again, this is your domain and in truth constellations needing this fix are quite odd. If you insist we'll throw #1 away.

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

* Re: [PATCH net] bnx2x: Configure device endianity on driver load and reset endianity on removal.
  2014-09-02  5:47     ` Yuval Mintz
@ 2014-09-02  5:56       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2014-09-02  5:56 UTC (permalink / raw)
  To: Yuval.Mintz; +Cc: manish.chopra, netdev, Ariel.Elior

From: Yuval Mintz <Yuval.Mintz@qlogic.com>
Date: Tue, 2 Sep 2014 05:47:49 +0000

> It's true #2 can solve the issue on its own for new kernels, but
> given the various existing distros out there (that don't include the
> fix) the effort of supporting those by adding #1 seems to be very
> small.

Ok, fair enough.

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

end of thread, other threads:[~2014-09-02  5:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-01 14:17 [PATCH net] bnx2x: Configure device endianity on driver load and reset endianity on removal Manish Chopra
2014-09-01 15:33 ` Manish Chopra
2014-09-01 21:53   ` David Miller
2014-09-02  5:47     ` Yuval Mintz
2014-09-02  5:56       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).