aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorManish Chopra <manish.chopra@qlogic.com>2014-09-02 04:31:25 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-02 16:54:35 -0400
commit04860eb7d911bbd958463416cc045b69ffdf73b3 (patch)
treeb077efa246bd5f32aad44e4239115f77253dc3a9 /drivers/net
parent511c24456ad19d51fcdbc5eda9df7be98c20e6b0 (diff)
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c57
1 files changed, 39 insertions, 18 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 900cab420810..d1c093dcb054 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)
6849 bnx2x_release_phy_lock(bp); 6849 bnx2x_release_phy_lock(bp);
6850} 6850}
6851 6851
6852static void bnx2x_config_endianity(struct bnx2x *bp, u32 val)
6853{
6854 REG_WR(bp, PXP2_REG_RQ_QM_ENDIAN_M, val);
6855 REG_WR(bp, PXP2_REG_RQ_TM_ENDIAN_M, val);
6856 REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, val);
6857 REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, val);
6858 REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, val);
6859
6860 /* make sure this value is 0 */
6861 REG_WR(bp, PXP2_REG_RQ_HC_ENDIAN_M, 0);
6862
6863 REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, val);
6864 REG_WR(bp, PXP2_REG_RD_TM_SWAP_MODE, val);
6865 REG_WR(bp, PXP2_REG_RD_SRC_SWAP_MODE, val);
6866 REG_WR(bp, PXP2_REG_RD_CDURD_SWAP_MODE, val);
6867}
6868
6869static void bnx2x_set_endianity(struct bnx2x *bp)
6870{
6871#ifdef __BIG_ENDIAN
6872 bnx2x_config_endianity(bp, 1);
6873#else
6874 bnx2x_config_endianity(bp, 0);
6875#endif
6876}
6877
6878static void bnx2x_reset_endianity(struct bnx2x *bp)
6879{
6880 bnx2x_config_endianity(bp, 0);
6881}
6882
6852/** 6883/**
6853 * bnx2x_init_hw_common - initialize the HW at the COMMON phase. 6884 * bnx2x_init_hw_common - initialize the HW at the COMMON phase.
6854 * 6885 *
@@ -6915,23 +6946,7 @@ static int bnx2x_init_hw_common(struct bnx2x *bp)
6915 6946
6916 bnx2x_init_block(bp, BLOCK_PXP2, PHASE_COMMON); 6947 bnx2x_init_block(bp, BLOCK_PXP2, PHASE_COMMON);
6917 bnx2x_init_pxp(bp); 6948 bnx2x_init_pxp(bp);
6918 6949 bnx2x_set_endianity(bp);
6919#ifdef __BIG_ENDIAN
6920 REG_WR(bp, PXP2_REG_RQ_QM_ENDIAN_M, 1);
6921 REG_WR(bp, PXP2_REG_RQ_TM_ENDIAN_M, 1);
6922 REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, 1);
6923 REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, 1);
6924 REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, 1);
6925 /* make sure this value is 0 */
6926 REG_WR(bp, PXP2_REG_RQ_HC_ENDIAN_M, 0);
6927
6928/* REG_WR(bp, PXP2_REG_RD_PBF_SWAP_MODE, 1); */
6929 REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, 1);
6930 REG_WR(bp, PXP2_REG_RD_TM_SWAP_MODE, 1);
6931 REG_WR(bp, PXP2_REG_RD_SRC_SWAP_MODE, 1);
6932 REG_WR(bp, PXP2_REG_RD_CDURD_SWAP_MODE, 1);
6933#endif
6934
6935 bnx2x_ilt_init_page_size(bp, INITOP_SET); 6950 bnx2x_ilt_init_page_size(bp, INITOP_SET);
6936 6951
6937 if (CHIP_REV_IS_FPGA(bp) && CHIP_IS_E1H(bp)) 6952 if (CHIP_REV_IS_FPGA(bp) && CHIP_IS_E1H(bp))
@@ -13169,9 +13184,15 @@ static void __bnx2x_remove(struct pci_dev *pdev,
13169 bnx2x_iov_remove_one(bp); 13184 bnx2x_iov_remove_one(bp);
13170 13185
13171 /* Power on: we can't let PCI layer write to us while we are in D3 */ 13186 /* Power on: we can't let PCI layer write to us while we are in D3 */
13172 if (IS_PF(bp)) 13187 if (IS_PF(bp)) {
13173 bnx2x_set_power_state(bp, PCI_D0); 13188 bnx2x_set_power_state(bp, PCI_D0);
13174 13189
13190 /* Set endianity registers to reset values in case next driver
13191 * boots in different endianty environment.
13192 */
13193 bnx2x_reset_endianity(bp);
13194 }
13195
13175 /* Disable MSI/MSI-X */ 13196 /* Disable MSI/MSI-X */
13176 bnx2x_disable_msi(bp); 13197 bnx2x_disable_msi(bp);
13177 13198