Skip to content

Commit b4b67f2

Browse files
Scott Wooddavem330
authored andcommitted
gianfar: Fix warnings when built on 64-bit
As part of defconfig consolidation using fragments, we'd like to be able to have the same drivers enabled on 32-bit and 64-bit. Gianfar happens to only exist on 32-bit systems, and when building the resulting 64-bit kernel warnings were produced. A couple of the warnings are trivial, but the rfbptr code has deeper issues. It uses the virtual address as the DMA address, which again, happens to work in the environments where this driver is currently used, but is not the right thing to do. Fixes: 45b679c ("gianfar: Implement PAUSE frame generation support") Signed-off-by: Scott Wood <[email protected]> Signed-off-by: Claudiu Manoil <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 97493e6 commit b4b67f2

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

drivers/net/ethernet/freescale/gianfar.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,8 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
26112611

26122612
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
26132613
struct skb_shared_hwtstamps shhwtstamps;
2614-
u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7);
2614+
u64 *ns = (u64 *)(((uintptr_t)skb->data + 0x10) &
2615+
~0x7UL);
26152616

26162617
memset(&shhwtstamps, 0, sizeof(shhwtstamps));
26172618
shhwtstamps.hwtstamp = ns_to_ktime(*ns);
@@ -3043,8 +3044,9 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
30433044

30443045
/* Update Last Free RxBD pointer for LFC */
30453046
if (unlikely(priv->tx_actual_en)) {
3046-
bdp = gfar_rxbd_lastfree(rx_queue);
3047-
gfar_write(rx_queue->rfbptr, (u32)bdp);
3047+
u32 bdp_dma = gfar_rxbd_dma_lastfree(rx_queue);
3048+
3049+
gfar_write(rx_queue->rfbptr, bdp_dma);
30483050
}
30493051

30503052
return howmany;
@@ -3563,7 +3565,6 @@ static noinline void gfar_update_link_state(struct gfar_private *priv)
35633565
struct phy_device *phydev = priv->phydev;
35643566
struct gfar_priv_rx_q *rx_queue = NULL;
35653567
int i;
3566-
struct rxbd8 *bdp;
35673568

35683569
if (unlikely(test_bit(GFAR_RESETTING, &priv->state)))
35693570
return;
@@ -3620,9 +3621,11 @@ static noinline void gfar_update_link_state(struct gfar_private *priv)
36203621
/* Turn last free buffer recording on */
36213622
if ((tempval1 & MACCFG1_TX_FLOW) && !tx_flow_oldval) {
36223623
for (i = 0; i < priv->num_rx_queues; i++) {
3624+
u32 bdp_dma;
3625+
36233626
rx_queue = priv->rx_queue[i];
3624-
bdp = gfar_rxbd_lastfree(rx_queue);
3625-
gfar_write(rx_queue->rfbptr, (u32)bdp);
3627+
bdp_dma = gfar_rxbd_dma_lastfree(rx_queue);
3628+
gfar_write(rx_queue->rfbptr, bdp_dma);
36263629
}
36273630

36283631
priv->tx_actual_en = 1;

drivers/net/ethernet/freescale/gianfar.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,13 +1310,18 @@ static inline int gfar_rxbd_unused(struct gfar_priv_rx_q *rxq)
13101310
return rxq->rx_ring_size + rxq->next_to_clean - rxq->next_to_use - 1;
13111311
}
13121312

1313-
static inline struct rxbd8 *gfar_rxbd_lastfree(struct gfar_priv_rx_q *rxq)
1313+
static inline u32 gfar_rxbd_dma_lastfree(struct gfar_priv_rx_q *rxq)
13141314
{
1315+
struct rxbd8 *bdp;
1316+
u32 bdp_dma;
13151317
int i;
13161318

13171319
i = rxq->next_to_use ? rxq->next_to_use - 1 : rxq->rx_ring_size - 1;
1320+
bdp = &rxq->rx_bd_base[i];
1321+
bdp_dma = lower_32_bits(rxq->rx_bd_dma_base);
1322+
bdp_dma += (uintptr_t)bdp - (uintptr_t)rxq->rx_bd_base;
13181323

1319-
return &rxq->rx_bd_base[i];
1324+
return bdp_dma;
13201325
}
13211326

13221327
irqreturn_t gfar_receive(int irq, void *dev_id);

0 commit comments

Comments
 (0)