netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] sfc: Use __iowrite64_copy instead of a slightly different local function
@ 2014-07-27  2:14 Ben Hutchings
  2014-07-29 15:03 ` Edward Cree
  2014-07-29 22:30 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Ben Hutchings @ 2014-07-27  2:14 UTC (permalink / raw)
  To: Shradha Shah; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 3019 bytes --]

__iowrite64_copy() isn't quite the same as efx_memcpy_64(), but
it looks close enough:

- The length is in units of qwords not bytes
- It never byte-swaps, but that doesn't make a difference now as PIO
  is only enabled for x86_64
- It doesn't include any memory barriers, but that's OK as there is a
  barrier just before pushing the doorbell
- mlx4_en uses it for the same purpose

Compile-tested only.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/net/ethernet/sfc/tx.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
index ede8dcc..e03350e 100644
--- a/drivers/net/ethernet/sfc/tx.c
+++ b/drivers/net/ethernet/sfc/tx.c
@@ -189,18 +189,6 @@ struct efx_short_copy_buffer {
 	u8 buf[L1_CACHE_BYTES];
 };
 
-/* Copy in explicit 64-bit writes. */
-static void efx_memcpy_64(void __iomem *dest, void *src, size_t len)
-{
-	u64 *src64 = src;
-	u64 __iomem *dest64 = dest;
-	size_t l64 = len / 8;
-	size_t i;
-
-	for (i = 0; i < l64; i++)
-		writeq(src64[i], &dest64[i]);
-}
-
 /* Copy to PIO, respecting that writes to PIO buffers must be dword aligned.
  * Advances piobuf pointer. Leaves additional data in the copy buffer.
  */
@@ -210,7 +198,7 @@ static void efx_memcpy_toio_aligned(struct efx_nic *efx, u8 __iomem **piobuf,
 {
 	int block_len = len & ~(sizeof(copy_buf->buf) - 1);
 
-	efx_memcpy_64(*piobuf, data, block_len);
+	__iowrite64_copy(*piobuf, data, block_len >> 3);
 	*piobuf += block_len;
 	len -= block_len;
 
@@ -242,7 +230,8 @@ static void efx_memcpy_toio_aligned_cb(struct efx_nic *efx, u8 __iomem **piobuf,
 		if (copy_buf->used < sizeof(copy_buf->buf))
 			return;
 
-		efx_memcpy_64(*piobuf, copy_buf->buf, sizeof(copy_buf->buf));
+		__iowrite64_copy(*piobuf, copy_buf->buf,
+				 sizeof(copy_buf->buf) >> 3);
 		*piobuf += sizeof(copy_buf->buf);
 		data += copy_to_buf;
 		len -= copy_to_buf;
@@ -257,7 +246,8 @@ static void efx_flush_copy_buffer(struct efx_nic *efx, u8 __iomem *piobuf,
 {
 	/* if there's anything in it, write the whole buffer, including junk */
 	if (copy_buf->used)
-		efx_memcpy_64(piobuf, copy_buf->buf, sizeof(copy_buf->buf));
+		__iowrite64_copy(piobuf, copy_buf->buf,
+				 sizeof(copy_buf->buf) >> 3);
 }
 
 /* Traverse skb structure and copy fragments in to PIO buffer.
@@ -316,8 +306,8 @@ efx_enqueue_skb_pio(struct efx_tx_queue *tx_queue, struct sk_buff *skb)
 		 */
 		BUILD_BUG_ON(L1_CACHE_BYTES >
 			     SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
-		efx_memcpy_64(tx_queue->piobuf, skb->data,
-			      ALIGN(skb->len, L1_CACHE_BYTES));
+		__iowrite64_copy(tx_queue->piobuf, skb->data,
+				 ALIGN(skb->len, L1_CACHE_BYTES) >> 3);
 	}
 
 	EFX_POPULATE_QWORD_5(buffer->option,

-- 
Ben Hutchings
The generation of random numbers is too important to be left to chance.
                                                            - Robert Coveyou

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* Re: [PATCH net-next] sfc: Use __iowrite64_copy instead of a slightly different local function
  2014-07-27  2:14 [PATCH net-next] sfc: Use __iowrite64_copy instead of a slightly different local function Ben Hutchings
@ 2014-07-29 15:03 ` Edward Cree
  2014-07-29 22:30 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Edward Cree @ 2014-07-29 15:03 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Shradha Shah, netdev

On 27/07/14 03:14, Ben Hutchings wrote:
> __iowrite64_copy() isn't quite the same as efx_memcpy_64(), but
> it looks close enough:
>
> - The length is in units of qwords not bytes
> - It never byte-swaps, but that doesn't make a difference now as PIO
>   is only enabled for x86_64
> - It doesn't include any memory barriers, but that's OK as there is a
>   barrier just before pushing the doorbell
> - mlx4_en uses it for the same purpose
>
> Compile-tested only.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: Edward Cree <ecree@solarflare.com>

On my test system, __iowrite64_copy compiles to use "mov    %rax,(%rdi)"
which we believe is safe (all writes will be naturally-aligned 64-bit
accesses, as required by the hardware).

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

* Re: [PATCH net-next] sfc: Use __iowrite64_copy instead of a slightly different local function
  2014-07-27  2:14 [PATCH net-next] sfc: Use __iowrite64_copy instead of a slightly different local function Ben Hutchings
  2014-07-29 15:03 ` Edward Cree
@ 2014-07-29 22:30 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-07-29 22:30 UTC (permalink / raw)
  To: ben; +Cc: sshah, netdev

From: Ben Hutchings <ben@decadent.org.uk>
Date: Sun, 27 Jul 2014 03:14:39 +0100

> __iowrite64_copy() isn't quite the same as efx_memcpy_64(), but
> it looks close enough:
> 
> - The length is in units of qwords not bytes
> - It never byte-swaps, but that doesn't make a difference now as PIO
>   is only enabled for x86_64
> - It doesn't include any memory barriers, but that's OK as there is a
>   barrier just before pushing the doorbell
> - mlx4_en uses it for the same purpose
> 
> Compile-tested only.
> 
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Applied, thanks.

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

end of thread, other threads:[~2014-07-29 22:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-27  2:14 [PATCH net-next] sfc: Use __iowrite64_copy instead of a slightly different local function Ben Hutchings
2014-07-29 15:03 ` Edward Cree
2014-07-29 22:30 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).