From: Stephen Hemminger <shemminger@osdl.org>
To: Jeff Garzik <jeff@garzik.org>
Cc: "Amit S. Kale" <amitkale@netxen.com>,
netdev@vger.kernel.org, brazilnut@us.ibm.com,
netxenproj@linsyssoft.com, rob@netxen.com, romieu@fr.zoreil.com,
sanjeev@netxen.com, wendyx@us.ibm.com
Subject: network devices don't handle pci_dma_mapping_error()'s
Date: Mon, 4 Dec 2006 10:39:49 -0800 [thread overview]
Message-ID: <20061204103949.3d05b1ff@freekitty> (raw)
In-Reply-To: <45711007.5030704@garzik.org>
On Sat, 02 Dec 2006 00:32:55 -0500
Jeff Garzik <jeff@garzik.org> wrote:
> Amit S. Kale wrote:
> > NetXen: 1G/10G Ethernet driver updates
> > - These fixes take care of driver on machines with >4G memory
> > - Driver cleanup
> >
> > Signed-off-by: Amit S. Kale <amitkale@netxen.com>
> >
> > netxen_nic.h | 29 +++++--
> > netxen_nic_ethtool.c | 19 ++--
> > netxen_nic_hw.c | 4
> > netxen_nic_hw.h | 4
> > netxen_nic_init.c | 51 +++++++++++-
> > netxen_nic_isr.c | 3
> > netxen_nic_main.c | 204 +++++++++++++++++++++++++++++++++++++++++++++++---
> > netxen_nic_phan_reg.h | 10 +-
>
> NAK, the driver itself should not be doing bounce buffering
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
I notice that no current network driver handles dma mapping errors.
Might that be part of the problem. On i386, this never happens, and
it would be rare on most others.
Why don't drivers do some checking/unwind. Here is what it would look like on
Tx for sky2...
--- sky2.orig/drivers/net/sky2.c 2006-12-04 10:12:16.000000000 -0800
+++ sky2/drivers/net/sky2.c 2006-12-04 10:37:42.000000000 -0800
@@ -1277,6 +1277,38 @@
return count;
}
+
+static inline void tx_le_done(struct sky2_port *sky2, unsigned idx)
+{
+ struct pci_dev *pdev = sky2->hw->pdev;
+ struct sky2_tx_le *le = sky2->tx_le + idx;
+ struct tx_ring_info *re = sky2->tx_ring + idx;
+
+ switch(le->opcode & ~HW_OWNER) {
+ case OP_LARGESEND:
+ case OP_PACKET:
+ pci_unmap_single(pdev,
+ pci_unmap_addr(re, mapaddr),
+ pci_unmap_len(re, maplen),
+ PCI_DMA_TODEVICE);
+ break;
+ case OP_BUFFER:
+ pci_unmap_page(pdev, pci_unmap_addr(re, mapaddr),
+ pci_unmap_len(re, maplen),
+ PCI_DMA_TODEVICE);
+ break;
+ }
+
+ if (le->ctrl & EOP) {
+ if (unlikely(netif_msg_tx_done(sky2)))
+ printk(KERN_DEBUG "%s: tx done %u\n", sky2->netdev->name,
+ idx);
+ dev_kfree_skb_any(re->skb);
+ }
+
+ le->opcode = 0; /* paranoia */
+}
+
/*
* Put one packet in ring for transmit.
* A single packet can generate multiple list elements, and
@@ -1292,7 +1324,7 @@
unsigned i, len;
dma_addr_t mapping;
u32 addr64;
- u16 mss;
+ u16 mss, first;
u8 ctrl;
if (unlikely(tx_avail(sky2) < tx_le_req(skb)))
@@ -1303,7 +1335,13 @@
dev->name, sky2->tx_prod, skb->len);
len = skb_headlen(skb);
+ first = sky2->tx_prod;
mapping = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
+ if (pci_dma_mapping_error(mapping)) {
+ printk(KERN_INFO "%s: tx dma mapping error\n", dev->name);
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
addr64 = high32(mapping);
/* Send high bits if changed or crosses boundary */
@@ -1383,6 +1421,10 @@
mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset,
frag->size, PCI_DMA_TODEVICE);
+
+ if (pci_dma_mapping_error(mapping))
+ goto map_error;
+
addr64 = high32(mapping);
if (addr64 != sky2->tx_addr64) {
le = get_tx_le(sky2);
@@ -1413,6 +1455,15 @@
dev->trans_start = jiffies;
return NETDEV_TX_OK;
+
+map_error:
+ /* map failure on fragmented send, free work from first..sky2->tx_prod */
+ printk(KERN_INFO "%s: tx dma page mapping error\n", dev->name);
+ le->ctrl |= EOP;
+ for (i = first; i != sky2->tx_prod; i = RING_NEXT(i, TX_RING_SIZE))
+ tx_le_done(sky2, i);
+ sky2->tx_prod = first;
+ return NETDEV_TX_OK;
}
/*
@@ -1424,40 +1475,12 @@
static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
{
struct net_device *dev = sky2->netdev;
- struct pci_dev *pdev = sky2->hw->pdev;
unsigned idx;
BUG_ON(done >= TX_RING_SIZE);
- for (idx = sky2->tx_cons; idx != done;
- idx = RING_NEXT(idx, TX_RING_SIZE)) {
- struct sky2_tx_le *le = sky2->tx_le + idx;
- struct tx_ring_info *re = sky2->tx_ring + idx;
-
- switch(le->opcode & ~HW_OWNER) {
- case OP_LARGESEND:
- case OP_PACKET:
- pci_unmap_single(pdev,
- pci_unmap_addr(re, mapaddr),
- pci_unmap_len(re, maplen),
- PCI_DMA_TODEVICE);
- break;
- case OP_BUFFER:
- pci_unmap_page(pdev, pci_unmap_addr(re, mapaddr),
- pci_unmap_len(re, maplen),
- PCI_DMA_TODEVICE);
- break;
- }
-
- if (le->ctrl & EOP) {
- if (unlikely(netif_msg_tx_done(sky2)))
- printk(KERN_DEBUG "%s: tx done %u\n",
- dev->name, idx);
- dev_kfree_skb_any(re->skb);
- }
-
- le->opcode = 0; /* paranoia */
- }
+ for (idx = sky2->tx_cons; idx != done; idx = RING_NEXT(idx, TX_RING_SIZE))
+ tx_le_done(sky2, idx);
sky2->tx_cons = idx;
if (tx_avail(sky2) > MAX_SKB_TX_LE + 4)
next prev parent reply other threads:[~2006-12-04 18:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-01 13:40 [PATCH 2/3] NetXen: 64-bit memory fixes Amit S. Kale
2006-12-01 18:56 ` Stephen Hemminger
2006-12-02 5:32 ` Jeff Garzik
2006-12-04 18:39 ` Stephen Hemminger [this message]
2006-12-05 7:00 ` network devices don't handle pci_dma_mapping_error()'s Muli Ben-Yehuda
2006-12-06 18:16 ` Stephen Hemminger
2006-12-06 19:33 ` Muli Ben-Yehuda
2006-12-07 6:18 ` Amit S. Kale
2006-12-07 13:04 ` Muli Ben-Yehuda
2006-12-07 0:54 ` David Miller
2006-12-07 0:58 ` Stephen Hemminger
2006-12-07 1:13 ` David Miller
2006-12-07 2:18 ` Rick Jones
2006-12-07 2:31 ` David Miller
2006-12-07 6:25 ` Amit S. Kale
2006-12-07 6:46 ` Stephen Hemminger
2006-12-07 6:55 ` Amit S. Kale
2006-12-07 7:24 ` David Miller
2006-12-07 20:07 ` Stephen Hemminger
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=20061204103949.3d05b1ff@freekitty \
--to=shemminger@osdl.org \
--cc=amitkale@netxen.com \
--cc=brazilnut@us.ibm.com \
--cc=jeff@garzik.org \
--cc=netdev@vger.kernel.org \
--cc=netxenproj@linsyssoft.com \
--cc=rob@netxen.com \
--cc=romieu@fr.zoreil.com \
--cc=sanjeev@netxen.com \
--cc=wendyx@us.ibm.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).