Skip to contentSkip to conversation

cnic: Fix big endian bug

PATCH Applied Michael Chan 2 participants 5 messages Jan 26, 2011

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

PATCH 1/1 cnic: Fix big endian bug

The chip's page tables did not set up properly on big endian machines, causing EEH errors on PPC machines.

---
 drivers/net/cnic.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/cnic.c +6 -6
index 263a294..7ff170c 100644
@@ -699,13 +699,13 @@ static void cnic_free_dma(struct cnic_dev *dev, struct cnic_dma *dma)
 static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma)
 {
 	int i;
-	u32 *page_table = dma->pgtbl;
+	__le32 *page_table = (__le32 *) dma->pgtbl;
 
 	for (i = 0; i < dma->num_pages; i++) {
 		/* Each entry needs to be in big endian format. */
-		*page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32);
+		*page_table = cpu_to_le32((u64) dma->pg_map_arr[i] >> 32);
 		page_table++;
-		*page_table = (u32) dma->pg_map_arr[i];
+		*page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff);
 		page_table++;
 	}
 }
@@ -713,13 +713,13 @@ static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma)
 static void cnic_setup_page_tbl_le(struct cnic_dev *dev, struct cnic_dma *dma)
 {
 	int i;
-	u32 *page_table = dma->pgtbl;
+	__le32 *page_table = (__le32 *) dma->pgtbl;
 
 	for (i = 0; i < dma->num_pages; i++) {
 		/* Each entry needs to be in little endian format. */
-		*page_table = dma->pg_map_arr[i] & 0xffffffff;
+		*page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff);
 		page_table++;
-		*page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32);
+		*page_table = cpu_to_le32((u64) dma->pg_map_arr[i] >> 32);
 		page_table++;
 	}
 }
Signature · 1 line
1.6.4.GIT
#1 lore raw

PATCH 1/1 bnx2: Eliminate AER error messages on systems not supporting it

On PPC for example, AER is not supported and we see unnecessary AER error message without this patch:

bnx2 0003:01:00.1: pci_cleanup_aer_uncorrect_error_status failed 0xfffffffb

---
 drivers/net/bnx2.c |   17 +++++++++--------
 drivers/net/bnx2.h |    1 +
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/net/bnx2.c +9 -8
index 99e7652..62c6079 100644
@@ -7966,11 +7966,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 
 		/* AER (Advanced Error Reporting) hooks */
 		err = pci_enable_pcie_error_reporting(pdev);
-		if (err) {
-			dev_err(&pdev->dev, "pci_enable_pcie_error_reporting "
-					    "failed 0x%x\n", err);
-			/* non-fatal, continue */
-		}
+		if (!err)
+			bp->flags |= BNX2_FLAG_AER_ENABLED;
 
 	} else {
 		bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
@@ -8233,8 +8230,10 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 	return 0;
 
 err_out_unmap:
-	if (bp->flags & BNX2_FLAG_PCIE)
+	if (bp->flags & BNX2_FLAG_AER_ENABLED) {
 		pci_disable_pcie_error_reporting(pdev);
+		bp->flags &= ~BNX2_FLAG_AER_ENABLED;
+	}
 
 	if (bp->regview) {
 		iounmap(bp->regview);
@@ -8422,8 +8421,10 @@ bnx2_remove_one(struct pci_dev *pdev)
 
 	kfree(bp->temp_stats_blk);
 
-	if (bp->flags & BNX2_FLAG_PCIE)
+	if (bp->flags & BNX2_FLAG_AER_ENABLED) {
 		pci_disable_pcie_error_reporting(pdev);
+		bp->flags &= ~BNX2_FLAG_AER_ENABLED;
+	}
 
 	free_netdev(dev);
 
@@ -8539,7 +8540,7 @@ static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
 	}
 	rtnl_unlock();
 
-	if (!(bp->flags & BNX2_FLAG_PCIE))
+	if (!bp->flags & BNX2_FLAG_AER_ENABLED)
 		return result;
 
 	err = pci_cleanup_aer_uncorrect_error_status(pdev);
drivers/net/bnx2.h +1 -0
index 5488a2e..f459fb2 100644
@@ -6741,6 +6741,7 @@ struct bnx2 {
 #define BNX2_FLAG_JUMBO_BROKEN		0x00000800
 #define BNX2_FLAG_CAN_KEEP_VLAN		0x00001000
 #define BNX2_FLAG_BROKEN_STATS		0x00002000
+#define BNX2_FLAG_AER_ENABLED		0x00004000
 
 	struct bnx2_napi	bnx2_napi[BNX2_MAX_MSIX_VEC];
 
Signature · 1 line
1.6.4.GIT
maintainer Applied
#2 lore raw

Re: [PATCH net-2.6] bnx2: Eliminate AER error messages on systems not supporting it

In reply to Michael Chan

From: "Michael Chan" <[email protected]>
Date: Wed, 26 Jan 2011 00:14:51 -0800

Quoted 7 lines

On PPC for example, AER is not supported and we see unnecessary AER error message without this patch:

bnx2 0003:01:00.1: pci_cleanup_aer_uncorrect_error_status failed 0xfffffffb

Applied.

maintainer
#3 lore raw

Re: [PATCH net-2.6] bnx2: Eliminate AER error messages on systems not supporting it

From: David Miller <[email protected]>
Date: Wed, 26 Jan 2011 14:26:35 -0800 (PST)

Quoted 6 lines

From: "Michael Chan" <[email protected]>
Date: Wed, 26 Jan 2011 00:14:51 -0800

Quoted 3 lines

On PPC for example, AER is not supported and we see unnecessary AER error message without this patch:

Quoted 6 lines
Quoted 4 lines

bnx2 0003:01:00.1: pci_cleanup_aer_uncorrect_error_status failed 0xfffffffb

Applied.

Please check for warnings in your build, I ammended the following fix into this commit:

drivers/net/bnx2.c +1 -1
index 62c6079..0ba59d5 100644
@@ -8540,7 +8540,7 @@ static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
 	}
 	rtnl_unlock();
 
-	if (!bp->flags & BNX2_FLAG_AER_ENABLED)
+	if (!(bp->flags & BNX2_FLAG_AER_ENABLED))
 		return result;
 
 	err = pci_cleanup_aer_uncorrect_error_status(pdev);