Commit 5138826b authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

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.
Reported-by: default avatarBreno Leitao <leitao@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7cc2edb8
...@@ -699,13 +699,13 @@ static void cnic_free_dma(struct cnic_dev *dev, struct cnic_dma *dma) ...@@ -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) static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma)
{ {
int i; int i;
u32 *page_table = dma->pgtbl; __le32 *page_table = (__le32 *) dma->pgtbl;
for (i = 0; i < dma->num_pages; i++) { for (i = 0; i < dma->num_pages; i++) {
/* Each entry needs to be in big endian format. */ /* 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++;
*page_table = (u32) dma->pg_map_arr[i]; *page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff);
page_table++; page_table++;
} }
} }
...@@ -713,13 +713,13 @@ static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma) ...@@ -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) static void cnic_setup_page_tbl_le(struct cnic_dev *dev, struct cnic_dma *dma)
{ {
int i; int i;
u32 *page_table = dma->pgtbl; __le32 *page_table = (__le32 *) dma->pgtbl;
for (i = 0; i < dma->num_pages; i++) { for (i = 0; i < dma->num_pages; i++) {
/* Each entry needs to be in little endian format. */ /* 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++;
*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++;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment