mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 03/16] net/e1000: Don't use coherent memory for Rx buffer
Date: Wed,  6 Feb 2019 17:22:01 -0800	[thread overview]
Message-ID: <20190207012214.5060-4-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190207012214.5060-1-andrew.smirnov@gmail.com>

In order to avoid issues on AArch64, convert the driver to use regular
memory and add appropriate DMA sync calls. Drop needless (uchar *)
cast while at it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/net/e1000/e1000.h |  1 +
 drivers/net/e1000/main.c  | 18 ++++++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 0a9e107c0..52ad3d4cd 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -2182,6 +2182,7 @@ struct e1000_hw {
 	struct e1000_tx_desc *tx_base;
 	struct e1000_rx_desc *rx_base;
 	unsigned char *packet;
+	dma_addr_t packet_dma;
 
 	int tx_tail;
 	int rx_tail, rx_last;
diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c
index 0ef8fd623..7358763f9 100644
--- a/drivers/net/e1000/main.c
+++ b/drivers/net/e1000/main.c
@@ -3215,7 +3215,7 @@ static void fill_rx(struct e1000_hw *hw)
 	for (i = 0; i < 4; i++)
 		*bla++ = 0;
 
-	rd->buffer_addr = cpu_to_le64((unsigned long)hw->packet);
+	rd->buffer_addr = cpu_to_le64(hw->packet_dma);
 
 	e1000_write_reg(hw, E1000_RDT, hw->rx_tail);
 }
@@ -3406,9 +3406,11 @@ static int e1000_poll(struct eth_device *edev)
 
 	len = le32_to_cpu(rd->length);
 
-	dma_sync_single_for_cpu((unsigned long)hw->packet, len, DMA_FROM_DEVICE);
+	dma_sync_single_for_cpu(hw->packet_dma, len, DMA_FROM_DEVICE);
 
-	net_receive(edev, (uchar *)hw->packet, len);
+	net_receive(edev, hw->packet, len);
+
+	dma_sync_single_for_device(hw->packet_dma, len, DMA_FROM_DEVICE);
 	fill_rx(hw);
 	return 1;
 }
@@ -3561,7 +3563,6 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	hw->tx_base = dma_alloc_coherent(16 * sizeof(*hw->tx_base), DMA_ADDRESS_BROKEN);
 	hw->rx_base = dma_alloc_coherent(16 * sizeof(*hw->rx_base), DMA_ADDRESS_BROKEN);
-	hw->packet = dma_alloc_coherent(4096, DMA_ADDRESS_BROKEN);
 
 	edev = &hw->edev;
 
@@ -3570,6 +3571,15 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	pdev->dev.priv = hw;
 	edev->priv = hw;
 
+	hw->packet = dma_alloc(PAGE_SIZE);
+	if (!hw->packet)
+		return -ENOMEM;
+
+	hw->packet_dma = dma_map_single(hw->dev, hw->packet, PAGE_SIZE,
+					DMA_FROM_DEVICE);
+	if (dma_mapping_error(hw->dev, hw->packet_dma))
+		return -EFAULT;
+
 	hw->hw_addr = pci_iomap(pdev, 0);
 
 	/* MAC and Phy settings */
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-02-07  1:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07  1:21 [PATCH 00/16] E1000 driver AArch64 related fixes Andrey Smirnov
2019-02-07  1:21 ` [PATCH 01/16] ARM: Select HAS_DMA for AArch64 Andrey Smirnov
2019-02-07  1:22 ` [PATCH 02/16] include: Import io-64-nonatomic-*.h from Linux Andrey Smirnov
2019-02-07  1:22 ` Andrey Smirnov [this message]
2019-02-07  1:22 ` [PATCH 04/16] net/e1000: Convert e1000_transmit to use dma_map_single() Andrey Smirnov
2019-02-07  1:22 ` [PATCH 05/16] net/e1000: Fix debug print warning Andrey Smirnov
2019-02-07  1:22 ` [PATCH 06/16] net/e1000: Fix incorrect "Rx ready" check Andrey Smirnov
2019-02-07  1:22 ` [PATCH 07/16] net/e1000: Get rid of pointer arithmetic in e1000_poll Andrey Smirnov
2019-02-07  1:22 ` [PATCH 08/16] net/e1000: Improve Rx descriptor handling in e1000_poll() Andrey Smirnov
2019-02-07  1:22 ` [PATCH 09/16] net/e1000: Remove pointer arithmetic in e1000_transmit() Andrey Smirnov
2019-02-07  1:22 ` [PATCH 10/16] net/e1000: Improve Tx descriptor handling in e1000_transmit Andrey Smirnov
2019-02-07  1:22 ` [PATCH 11/16] net/e1000: Make use of readl_poll_timeout() in e1000_transmit() Andrey Smirnov
2019-02-07  1:22 ` [PATCH 12/16] net/e1000: Rename fill_rx() to e1000_fill_rx() Andrey Smirnov
2019-02-07  1:22 ` [PATCH 13/16] net/e1000: Remove pointer arithmetic from e1000_fill_rx() Andrey Smirnov
2019-02-07  1:22 ` [PATCH 14/16] net/e1000: Consolidate next index calculation code Andrey Smirnov
2019-02-07  1:22 ` [PATCH 15/16] net/e1000: Improve RX buffer handling in e1000_fill_rx() Andrey Smirnov
2019-02-07  1:22 ` [PATCH 16/16] net/e1000: Do not hardcode TDBAH and RDBAH to 0 Andrey Smirnov
2019-02-11  7:48 ` [PATCH 00/16] E1000 driver AArch64 related fixes Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190207012214.5060-4-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox