All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2] gianfar: Fix warnings when built on 64-bit
@ 2015-07-29 13:13 Claudiu Manoil
  2015-07-29 16:06 ` Scott Wood
  2015-07-30  5:57 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Claudiu Manoil @ 2015-07-29 13:13 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, arnd, Scott Wood

From: Scott Wood <scottwood@freescale.com>

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: 45b679c9a3cc ("gianfar: Implement PAUSE frame generation
support")
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>

---
v2 - rebased/reworked on top of net-next (instead of net);
   - removed CONFIG_PM unrelated change;

 drivers/net/ethernet/freescale/gianfar.c | 15 +++++++++------
 drivers/net/ethernet/freescale/gianfar.h |  9 +++++++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 648ca85..afa3ea7 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -2611,7 +2611,8 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
 
 		if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
 			struct skb_shared_hwtstamps shhwtstamps;
-			u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7);
+			u64 *ns = (u64 *)(((uintptr_t)skb->data + 0x10) &
+					  ~0x7UL);
 
 			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
 			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)
 
 	/* Update Last Free RxBD pointer for LFC */
 	if (unlikely(priv->tx_actual_en)) {
-		bdp = gfar_rxbd_lastfree(rx_queue);
-		gfar_write(rx_queue->rfbptr, (u32)bdp);
+		u32 bdp_dma = gfar_rxbd_dma_lastfree(rx_queue);
+
+		gfar_write(rx_queue->rfbptr, bdp_dma);
 	}
 
 	return howmany;
@@ -3563,7 +3565,6 @@ static noinline void gfar_update_link_state(struct gfar_private *priv)
 	struct phy_device *phydev = priv->phydev;
 	struct gfar_priv_rx_q *rx_queue = NULL;
 	int i;
-	struct rxbd8 *bdp;
 
 	if (unlikely(test_bit(GFAR_RESETTING, &priv->state)))
 		return;
@@ -3620,9 +3621,11 @@ static noinline void gfar_update_link_state(struct gfar_private *priv)
 		/* Turn last free buffer recording on */
 		if ((tempval1 & MACCFG1_TX_FLOW) && !tx_flow_oldval) {
 			for (i = 0; i < priv->num_rx_queues; i++) {
+				u32 bdp_dma;
+
 				rx_queue = priv->rx_queue[i];
-				bdp = gfar_rxbd_lastfree(rx_queue);
-				gfar_write(rx_queue->rfbptr, (u32)bdp);
+				bdp_dma = gfar_rxbd_dma_lastfree(rx_queue);
+				gfar_write(rx_queue->rfbptr, bdp_dma);
 			}
 
 			priv->tx_actual_en = 1;
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 4402124..8a5f4de9 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -1310,13 +1310,18 @@ static inline int gfar_rxbd_unused(struct gfar_priv_rx_q *rxq)
 	return rxq->rx_ring_size + rxq->next_to_clean - rxq->next_to_use - 1;
 }
 
-static inline struct rxbd8 *gfar_rxbd_lastfree(struct gfar_priv_rx_q *rxq)
+static inline u32 gfar_rxbd_dma_lastfree(struct gfar_priv_rx_q *rxq)
 {
+	struct rxbd8 *bdp;
+	u32 bdp_dma;
 	int i;
 
 	i = rxq->next_to_use ? rxq->next_to_use - 1 : rxq->rx_ring_size - 1;
+	bdp = &rxq->rx_bd_base[i];
+	bdp_dma = lower_32_bits(rxq->rx_bd_dma_base);
+	bdp_dma += (uintptr_t)bdp - (uintptr_t)rxq->rx_bd_base;
 
-	return &rxq->rx_bd_base[i];
+	return bdp_dma;
 }
 
 irqreturn_t gfar_receive(int irq, void *dev_id);
-- 
1.7.11.7

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

* Re: [PATCH net-next v2] gianfar: Fix warnings when built on 64-bit
  2015-07-29 13:13 [PATCH net-next v2] gianfar: Fix warnings when built on 64-bit Claudiu Manoil
@ 2015-07-29 16:06 ` Scott Wood
  2015-07-30  7:48   ` Manoil Claudiu
  2015-07-30  5:57 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Scott Wood @ 2015-07-29 16:06 UTC (permalink / raw)
  To: Claudiu Manoil; +Cc: netdev, David S. Miller, arnd

On Wed, 2015-07-29 at 16:13 +0300, Claudiu Manoil wrote:
> From: Scott Wood <scottwood@freescale.com>
> 
> 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: 45b679c9a3cc ("gianfar: Implement PAUSE frame generation
> support")
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
> 
> ---
> v2 - rebased/reworked on top of net-next (instead of net);
>    - removed CONFIG_PM unrelated change;

Are you going to submit the CONFIG_PM change separately?  It fixes a warning 
when CONFIG_PM is not enabled.

-Scott

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

* Re: [PATCH net-next v2] gianfar: Fix warnings when built on 64-bit
  2015-07-29 13:13 [PATCH net-next v2] gianfar: Fix warnings when built on 64-bit Claudiu Manoil
  2015-07-29 16:06 ` Scott Wood
@ 2015-07-30  5:57 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2015-07-30  5:57 UTC (permalink / raw)
  To: claudiu.manoil; +Cc: netdev, arnd, scottwood

From: Claudiu Manoil <claudiu.manoil@freescale.com>
Date: Wed, 29 Jul 2015 16:13:06 +0300

> From: Scott Wood <scottwood@freescale.com>
> 
> 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: 45b679c9a3cc ("gianfar: Implement PAUSE frame generation
> support")
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>

Applied, thanks.

 

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

* RE: [PATCH net-next v2] gianfar: Fix warnings when built on 64-bit
  2015-07-29 16:06 ` Scott Wood
@ 2015-07-30  7:48   ` Manoil Claudiu
  0 siblings, 0 replies; 4+ messages in thread
From: Manoil Claudiu @ 2015-07-30  7:48 UTC (permalink / raw)
  To: Scott Wood; +Cc: netdev, David S. Miller, arnd

> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Wednesday, July 29, 2015 7:06 PM
> To: Manoil Claudiu-B08782
> Cc: netdev@vger.kernel.org; David S. Miller; arnd@arndb.de
> Subject: Re: [PATCH net-next v2] gianfar: Fix warnings when built on 64-bit
> 
[...]
> 
> Are you going to submit the CONFIG_PM change separately?  It fixes a
> warning when CONFIG_PM is not enabled.
> 
Sure.  As I mentioned before, I'm already working on PM related fixes in gianfar. 
My intention is to include this change in that set, targeting net.git this time. Thanks.

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

end of thread, other threads:[~2015-07-30  7:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-29 13:13 [PATCH net-next v2] gianfar: Fix warnings when built on 64-bit Claudiu Manoil
2015-07-29 16:06 ` Scott Wood
2015-07-30  7:48   ` Manoil Claudiu
2015-07-30  5:57 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.