[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20130716111208.GA8940@hmsreliant.think-freely.org>
Date: Tue, 16 Jul 2013 07:12:08 -0400
From: Neil Horman <nhorman@...driver.com>
To: Ben Hutchings <bhutchings@...arflare.com>
Cc: netdev@...r.kernel.org, Jay Cliburn <jcliburn@...il.com>,
Chris Snook <chris.snook@...il.com>,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [net PATCH] atl1e: fix dma mapping warnings
On Tue, Jul 16, 2013 at 01:01:17AM +0100, Ben Hutchings wrote:
> On Fri, 2013-07-12 at 10:58 -0400, Neil Horman wrote:
> [...]
> > The usual straighforward failure to check for dma_mapping_error after a map
> > operation is completed.
> [...]
> > --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
> > +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
> > @@ -1665,7 +1665,7 @@ check_sum:
> > return 0;
> > }
> >
> > -static void atl1e_tx_map(struct atl1e_adapter *adapter,
> > +static int atl1e_tx_map(struct atl1e_adapter *adapter,
> > struct sk_buff *skb, struct atl1e_tpd_desc *tpd)
> > {
> > struct atl1e_tpd_desc *use_tpd = NULL;
> > @@ -1677,6 +1677,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
> > u16 nr_frags;
> > u16 f;
> > int segment;
> > + int ring_start = adapter->tx_ring.next_to_use;
> >
> > nr_frags = skb_shinfo(skb)->nr_frags;
> > segment = (tpd->word3 >> TPD_SEGMENT_EN_SHIFT) & TPD_SEGMENT_EN_MASK;
> > @@ -1689,6 +1690,9 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
> > tx_buffer->length = map_len;
> > tx_buffer->dma = pci_map_single(adapter->pdev,
> > skb->data, hdr_len, PCI_DMA_TODEVICE);
> > + if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma))
> > + return -ENOSPC;
> > +
>
> Odd choice of error code.
Seems fine to me, especially since its handled internally to the driver
(atl1e_xmit_frame still returns NETDEV_TX_OK to the stack).
>
> > ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE);
> > mapped_len += map_len;
> > use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
> > @@ -1715,6 +1719,13 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
> > tx_buffer->dma =
> > pci_map_single(adapter->pdev, skb->data + mapped_len,
> > map_len, PCI_DMA_TODEVICE);
> > +
> > + if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) {
> > + /* Reset the tx rings next pointer */
> > + adapter->tx_ring.next_to_use = ring_start;
> > + return -ENOSPC;
> > + }
> [...]
>
> This is not enough; you also need to unmap the DMA mappings that have
> already been made.
>
Yep, you're right, thanks for pointing that out, I'll send a followon patch.
Neil
> Ben.
>
> --
> Ben Hutchings, Staff Engineer, Solarflare
> Not speaking for my employer; that's the marketing department's job.
> They asked us to note that Solarflare product names are trademarked.
>
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists