From: Alexander Duyck <alexander.h.duyck@intel.com>
To: mcarlson@broadcom.com, mchan@broadcom.com,
sathyap@serverengines.com, subbus@serverengines.com,
davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [RFC PATCH 01/10] e1000e: remove use of skb_dma_map from e1000e driver
Date: Tue, 24 Nov 2009 17:20:18 -0800 [thread overview]
Message-ID: <20091125012018.32704.46978.stgit@gitlad.jf.intel.com> (raw)
In-Reply-To: <20091125011111.32704.3009.stgit@gitlad.jf.intel.com>
In testing we have found that skb_dma_map/unmap is incompatible with HW
IOMMU due to the fact that multiple mappings will return different results.
In order to correct this we need to remove skb_dma_map/unmap calls from the
e1000e driver.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---
drivers/net/e1000e/e1000.h | 9 ++++---
drivers/net/e1000e/netdev.c | 59 ++++++++++++++++++++++++++++++-------------
2 files changed, 47 insertions(+), 21 deletions(-)
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index c9fcef7..1be8218 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -192,12 +192,15 @@ struct e1000_buffer {
unsigned long time_stamp;
u16 length;
u16 next_to_watch;
+ u16 mapped_as_page;
};
/* Rx */
- /* arrays of page information for packet split */
- struct e1000_ps_page *ps_pages;
+ struct {
+ /* arrays of page information for packet split */
+ struct e1000_ps_page *ps_pages;
+ struct page *page;
+ };
};
- struct page *page;
};
struct e1000_ring {
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 11a5274..406d51b 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -534,10 +534,17 @@ next_desc:
static void e1000_put_txbuf(struct e1000_adapter *adapter,
struct e1000_buffer *buffer_info)
{
- buffer_info->dma = 0;
+ if (buffer_info->dma) {
+ if (buffer_info->mapped_as_page)
+ pci_unmap_page(adapter->pdev, buffer_info->dma,
+ buffer_info->length, PCI_DMA_TODEVICE);
+ else
+ pci_unmap_single(adapter->pdev, buffer_info->dma,
+ buffer_info->length,
+ PCI_DMA_TODEVICE);
+ buffer_info->dma = 0;
+ }
if (buffer_info->skb) {
- skb_dma_unmap(&adapter->pdev->dev, buffer_info->skb,
- DMA_TO_DEVICE);
dev_kfree_skb_any(buffer_info->skb);
buffer_info->skb = NULL;
}
@@ -3890,23 +3897,14 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
unsigned int mss)
{
struct e1000_ring *tx_ring = adapter->tx_ring;
+ struct pci_dev *pdev = adapter->pdev;
struct e1000_buffer *buffer_info;
unsigned int len = skb_headlen(skb);
- unsigned int offset, size, count = 0, i;
+ unsigned int offset = 0, size, count = 0, i;
unsigned int f;
- dma_addr_t *map;
i = tx_ring->next_to_use;
- if (skb_dma_map(&adapter->pdev->dev, skb, DMA_TO_DEVICE)) {
- dev_err(&adapter->pdev->dev, "TX DMA map failed\n");
- adapter->tx_dma_failed++;
- return 0;
- }
-
- map = skb_shinfo(skb)->dma_maps;
- offset = 0;
-
while (len) {
buffer_info = &tx_ring->buffer_info[i];
size = min(len, max_per_txd);
@@ -3914,11 +3912,15 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
buffer_info->length = size;
buffer_info->time_stamp = jiffies;
buffer_info->next_to_watch = i;
- buffer_info->dma = skb_shinfo(skb)->dma_head + offset;
- count++;
+ buffer_info->dma = pci_map_single(pdev, skb->data + offset,
+ size, PCI_DMA_TODEVICE);
+ buffer_info->mapped_as_page = false;
+ if (pci_dma_mapping_error(pdev, buffer_info->dma))
+ goto dma_error;
len -= size;
offset += size;
+ count++;
if (len) {
i++;
@@ -3932,7 +3934,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
frag = &skb_shinfo(skb)->frags[f];
len = frag->size;
- offset = 0;
+ offset = frag->page_offset;
while (len) {
i++;
@@ -3945,7 +3947,12 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
buffer_info->length = size;
buffer_info->time_stamp = jiffies;
buffer_info->next_to_watch = i;
- buffer_info->dma = map[f] + offset;
+ buffer_info->dma = pci_map_page(pdev, frag->page,
+ offset, size,
+ PCI_DMA_TODEVICE);
+ buffer_info->mapped_as_page = true;
+ if (pci_dma_mapping_error(pdev, buffer_info->dma))
+ goto dma_error;
len -= size;
offset += size;
@@ -3957,6 +3964,22 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
tx_ring->buffer_info[first].next_to_watch = i;
return count;
+
+dma_error:
+ dev_err(&pdev->dev, "TX DMA map failed\n");
+ buffer_info->dma = 0;
+ count--;
+
+ while (count >= 0) {
+ count--;
+ i--;
+ if (i < 0)
+ i += tx_ring->count;
+ buffer_info = &tx_ring->buffer_info[i];
+ e1000_put_txbuf(adapter, buffer_info);;
+ }
+
+ return 0;
}
static void e1000_tx_queue(struct e1000_adapter *adapter,
next prev parent reply other threads:[~2009-11-25 1:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 1:20 [RFC PATCH 00/10] Remove skb_dma_map/unmap calls Alexander Duyck
2009-11-25 1:20 ` Alexander Duyck [this message]
2009-11-25 1:20 ` [RFC PATCH 02/10] e1000: remove use of skb_dma_map from e1000 driver Alexander Duyck
2009-11-25 1:20 ` [RFC PATCH 03/10] ixgb: remove use of skb_dma_map from ixgb Alexander Duyck
2009-11-25 1:20 ` [RFC PATCH 04/10] ixgbe: remove skb_dma_map/unmap calls from driver Alexander Duyck
2009-11-25 1:20 ` [RFC PATCH 05/10] igb: remove use of skb_dma_map " Alexander Duyck
2009-11-25 1:20 ` [RFC PATCH 06/10] igbvf: remove skb_dma_map/unmap call from drivers Alexander Duyck
2009-11-25 1:20 ` [RFC PATCH 07/10] bnx2: remove skb_dma_map/unmap calls from driver Alexander Duyck
2009-11-30 10:26 ` Michael Chan
2009-12-01 0:17 ` Michael Chan
2009-11-25 1:20 ` [RFC PATCH 08/10] be2net: remove use of skb_dma_map/unmap Alexander Duyck
2009-11-27 8:58 ` Ajit Khaparde
2009-11-25 1:20 ` [RFC PATCH 09/10] tg3: " Alexander Duyck
2009-11-25 1:21 ` [RFC PATCH 10/10] skbuff: remove skb_dma_map/unmap Alexander Duyck
2009-11-25 11:30 ` [RFC PATCH 00/10] Remove skb_dma_map/unmap calls Ajit Khaparde
2009-11-25 17:25 ` Alexander Duyck
2009-11-30 7:40 ` David Miller
2009-12-01 1:03 ` Duyck, Alexander H
2009-12-01 4:16 ` David Miller
2009-12-01 4:34 ` Eric Dumazet
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=20091125012018.32704.46978.stgit@gitlad.jf.intel.com \
--to=alexander.h.duyck@intel.com \
--cc=davem@davemloft.net \
--cc=mcarlson@broadcom.com \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=sathyap@serverengines.com \
--cc=subbus@serverengines.com \
/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;
as well as URLs for NNTP newsgroup(s).