* Re: Validation of DMA params breaks e100 driver (2.6.28-rc2) [not found] <4909E08F.9040306@users.sourceforge.net> @ 2008-10-31 21:01 ` Russell King - ARM Linux 2008-11-14 1:21 ` Brandeburg, Jesse 0 siblings, 1 reply; 5+ messages in thread From: Russell King - ARM Linux @ 2008-10-31 21:01 UTC (permalink / raw) To: Anders Grafström; +Cc: linux-arm-kernel, netdev On Thu, Oct 30, 2008 at 05:27:59PM +0100, Anders Grafström wrote: > The e100 driver triggers BUG_ON(buf->direction != dir) > by doing pci_map_single(..., PCI_DMA_BIDIRECTIONAL) > and pci_dma_sync_single_for_device(..., PCI_DMA_TODEVICE). > > I'm guessing it's allowed to do that and that something like > the patch below is called for? No, it is not allowed to do that - that's why it's called "BUG_ON". Changing the DMA direction, especially with dmabounce will result in unexpected behaviour. > ----------------- > > [PATCH] [ARM] dma: Fix DMA params validation > > This patch makes the DMA params validation less strict > and more like the generic implementation. > > Signed-off-by: Anders Grafström <grfstrm@users.sourceforge.net> > --- > arch/arm/common/dmabounce.c | 13 ++++++------- > 1 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c > index f030f07..a0c9c7b 100644 > --- a/arch/arm/common/dmabounce.c > +++ b/arch/arm/common/dmabounce.c > @@ -289,7 +289,6 @@ static inline void unmap_single(struct device *dev, dma_addr_t dma_addr, > > if (buf) { > BUG_ON(buf->size != size); > - BUG_ON(buf->direction != dir); > > dev_dbg(dev, > "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", > @@ -382,8 +381,6 @@ int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, > if (!buf) > return 1; > > - BUG_ON(buf->direction != dir); > - > dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", > __func__, buf->ptr, virt_to_dma(dev, buf->ptr), > buf->safe, buf->safe_dma_addr); > @@ -394,7 +391,9 @@ int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, > dev_dbg(dev, "%s: copy back safe %p to unsafe %p size %d\n", > __func__, buf->safe + off, buf->ptr + off, sz); > memcpy(buf->ptr + off, buf->safe + off, sz); > - } > + } else > + BUG_ON(dir != DMA_TO_DEVICE); > + > return 0; > } > EXPORT_SYMBOL(dmabounce_sync_for_cpu); > @@ -411,8 +410,6 @@ int dmabounce_sync_for_device(struct device *dev, dma_addr_t addr, > if (!buf) > return 1; > > - BUG_ON(buf->direction != dir); > - > dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", > __func__, buf->ptr, virt_to_dma(dev, buf->ptr), > buf->safe, buf->safe_dma_addr); > @@ -423,7 +420,9 @@ int dmabounce_sync_for_device(struct device *dev, dma_addr_t addr, > dev_dbg(dev, "%s: copy out unsafe %p to safe %p, size %d\n", > __func__,buf->ptr + off, buf->safe + off, sz); > memcpy(buf->safe + off, buf->ptr + off, sz); > - } > + } else > + BUG_ON(dir != DMA_FROM_DEVICE); > + > return 0; > } > EXPORT_SYMBOL(dmabounce_sync_for_device); > -- > 1.5.6.5 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Validation of DMA params breaks e100 driver (2.6.28-rc2) 2008-10-31 21:01 ` Validation of DMA params breaks e100 driver (2.6.28-rc2) Russell King - ARM Linux @ 2008-11-14 1:21 ` Brandeburg, Jesse 2008-11-14 2:42 ` David Miller 2008-11-14 20:37 ` Anders Grafström 0 siblings, 2 replies; 5+ messages in thread From: Brandeburg, Jesse @ 2008-11-14 1:21 UTC (permalink / raw) To: Russell King - ARM Linux Cc: e1000-devel, netdev@vger.kernel.org, =?X-UNKNOWN?Q?Anders_Grafstr=F6m?=, linux-arm-kernel@lists.arm.linux.org.uk [-- Attachment #1: Type: TEXT/PLAIN, Size: 5403 bytes --] On Fri, 31 Oct 2008, Russell King - ARM Linux wrote: > On Thu, Oct 30, 2008 at 05:27:59PM +0100, Anders Grafström wrote: > > The e100 driver triggers BUG_ON(buf->direction != dir) > > by doing pci_map_single(..., PCI_DMA_BIDIRECTIONAL) > > and pci_dma_sync_single_for_device(..., PCI_DMA_TODEVICE). > > > > I'm guessing it's allowed to do that and that something like > > the patch below is called for? > > No, it is not allowed to do that - that's why it's called "BUG_ON". > Changing the DMA direction, especially with dmabounce will result > in unexpected behaviour. okay, how about this patch... only compile tested as I couldn't get net-next-2.6 to boot on my test machine. I'll get some testing done on this, but in the meantime.... e100: fix dma error in direction for mapping From: Jesse Brandeburg <jesse.brandeburg@intel.com> Russell King - ARM Linux wrote: > On Thu, Oct 30, 2008 at 05:27:59PM +0100, Anders Grafström wrote: >> The e100 driver triggers BUG_ON(buf->direction != dir) >> by doing pci_map_single(..., PCI_DMA_BIDIRECTIONAL) >> and pci_dma_sync_single_for_device(..., PCI_DMA_TODEVICE). >> >> I'm guessing it's allowed to do that and that something like >> the patch below is called for? > > No, it is not allowed to do that - that's why it's called "BUG_ON". > Changing the DMA direction, especially with dmabounce will result > in unexpected behaviour. This is my attempt to fix this issue: Reported by: Anders Grafstrom <grfstrm@users.sourceforge.net> CC: Russell King <linux@arm.linux.org.uk> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> --- drivers/net/e100.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 62cdefa..c9c7079 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c @@ -166,7 +166,7 @@ #define DRV_NAME "e100" #define DRV_EXT "-NAPI" -#define DRV_VERSION "3.5.23-k4"DRV_EXT +#define DRV_VERSION "3.5.23-k6"DRV_EXT #define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" #define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation" #define PFX DRV_NAME ": " @@ -1804,7 +1804,7 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; put_unaligned_le32(rx->dma_addr, &prev_rfd->link); pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr, - sizeof(struct rfd), PCI_DMA_TODEVICE); + sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); } return 0; @@ -1823,7 +1823,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, /* Need to sync before taking a peek at cb_complete bit */ pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr, - sizeof(struct rfd), PCI_DMA_FROMDEVICE); + sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); rfd_status = le16_to_cpu(rfd->status); DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status); @@ -1850,7 +1850,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, /* Get data */ pci_unmap_single(nic->pdev, rx->dma_addr, - RFD_BUF_LEN, PCI_DMA_FROMDEVICE); + RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); /* If this buffer has the el bit, but we think the receiver * is still running, check to see if it really stopped while @@ -1942,7 +1942,7 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done, new_before_last_rfd->command |= cpu_to_le16(cb_el); pci_dma_sync_single_for_device(nic->pdev, new_before_last_rx->dma_addr, sizeof(struct rfd), - PCI_DMA_TODEVICE); + PCI_DMA_BIDIRECTIONAL); /* Now that we have a new stopping point, we can clear the old * stopping point. We must sync twice to get the proper @@ -1950,11 +1950,11 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done, old_before_last_rfd->command &= ~cpu_to_le16(cb_el); pci_dma_sync_single_for_device(nic->pdev, old_before_last_rx->dma_addr, sizeof(struct rfd), - PCI_DMA_TODEVICE); + PCI_DMA_BIDIRECTIONAL); old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN); pci_dma_sync_single_for_device(nic->pdev, old_before_last_rx->dma_addr, sizeof(struct rfd), - PCI_DMA_TODEVICE); + PCI_DMA_BIDIRECTIONAL); } if(restart_required) { @@ -1977,7 +1977,7 @@ static void e100_rx_clean_list(struct nic *nic) for(rx = nic->rxs, i = 0; i < count; rx++, i++) { if(rx->skb) { pci_unmap_single(nic->pdev, rx->dma_addr, - RFD_BUF_LEN, PCI_DMA_FROMDEVICE); + RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); dev_kfree_skb(rx->skb); } } @@ -2020,7 +2020,7 @@ static int e100_rx_alloc_list(struct nic *nic) before_last->command |= cpu_to_le16(cb_el); before_last->size = 0; pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr, - sizeof(struct rfd), PCI_DMA_TODEVICE); + sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); nic->rx_to_use = nic->rx_to_clean = nic->rxs; nic->ru_running = RU_SUSPENDED; @@ -2221,7 +2221,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) msleep(10); pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr, - RFD_BUF_LEN, PCI_DMA_FROMDEVICE); + RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), skb->data, ETH_DATA_LEN)) [-- Attachment #2: Type: text/plain, Size: 363 bytes --] ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ [-- Attachment #3: Type: text/plain, Size: 164 bytes --] _______________________________________________ E1000-devel mailing list E1000-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/e1000-devel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: Validation of DMA params breaks e100 driver (2.6.28-rc2) 2008-11-14 1:21 ` Brandeburg, Jesse @ 2008-11-14 2:42 ` David Miller 2008-11-14 20:37 ` Anders Grafström 1 sibling, 0 replies; 5+ messages in thread From: David Miller @ 2008-11-14 2:42 UTC (permalink / raw) To: jesse.brandeburg; +Cc: linux, grfstrm, linux-arm-kernel, netdev, e1000-devel From: "Brandeburg, Jesse" <jesse.brandeburg@intel.com> Date: Thu, 13 Nov 2008 17:21:50 -0800 (Pacific Standard Time) > On Fri, 31 Oct 2008, Russell King - ARM Linux wrote: > > > On Thu, Oct 30, 2008 at 05:27:59PM +0100, Anders Grafström wrote: > > > The e100 driver triggers BUG_ON(buf->direction != dir) > > > by doing pci_map_single(..., PCI_DMA_BIDIRECTIONAL) > > > and pci_dma_sync_single_for_device(..., PCI_DMA_TODEVICE). > > > > > > I'm guessing it's allowed to do that and that something like > > > the patch below is called for? > > > > No, it is not allowed to do that - that's why it's called "BUG_ON". > > Changing the DMA direction, especially with dmabounce will result > > in unexpected behaviour. > > okay, how about this patch... only compile tested as I couldn't get > net-next-2.6 to boot on my test machine. I'll get some testing done on > this, but in the meantime.... > > e100: fix dma error in direction for mapping > > From: Jesse Brandeburg <jesse.brandeburg@intel.com> FWIW this looks good to me. Acked-by: David S. Miller <davem@davemloft.net> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Validation of DMA params breaks e100 driver (2.6.28-rc2) 2008-11-14 1:21 ` Brandeburg, Jesse 2008-11-14 2:42 ` David Miller @ 2008-11-14 20:37 ` Anders Grafström 2008-11-14 22:30 ` Brandeburg, Jesse 1 sibling, 1 reply; 5+ messages in thread From: Anders Grafström @ 2008-11-14 20:37 UTC (permalink / raw) To: Brandeburg, Jesse Cc: Russell King - ARM Linux, linux-arm-kernel@lists.arm.linux.org.uk, netdev@vger.kernel.org, e1000-devel Brandeburg, Jesse wrote: > On Fri, 31 Oct 2008, Russell King - ARM Linux wrote: > >> On Thu, Oct 30, 2008 at 05:27:59PM +0100, Anders Grafström wrote: >>> The e100 driver triggers BUG_ON(buf->direction != dir) >>> by doing pci_map_single(..., PCI_DMA_BIDIRECTIONAL) >>> and pci_dma_sync_single_for_device(..., PCI_DMA_TODEVICE). >>> >>> I'm guessing it's allowed to do that and that something like >>> the patch below is called for? >> No, it is not allowed to do that - that's why it's called "BUG_ON". >> Changing the DMA direction, especially with dmabounce will result >> in unexpected behaviour. > > okay, how about this patch... only compile tested as I couldn't get > net-next-2.6 to boot on my test machine. I'll get some testing done on > this, but in the meantime.... > > e100: fix dma error in direction for mapping > > From: Jesse Brandeburg <jesse.brandeburg@intel.com> I failed to save this patch (flowed format?) but I applied it manually to 2.6.28-rc4 and tried it. Appears to work. ------------------------------------------------------------------- List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Validation of DMA params breaks e100 driver (2.6.28-rc2) 2008-11-14 20:37 ` Anders Grafström @ 2008-11-14 22:30 ` Brandeburg, Jesse 0 siblings, 0 replies; 5+ messages in thread From: Brandeburg, Jesse @ 2008-11-14 22:30 UTC (permalink / raw) To: Anders Grafström Cc: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org, Russell King - ARM Linux, linux-arm-kernel@lists.arm.linux.org.uk Anders Grafström wrote: > Brandeburg, Jesse wrote: >> On Fri, 31 Oct 2008, Russell King - ARM Linux wrote: >> >>> On Thu, Oct 30, 2008 at 05:27:59PM +0100, Anders Grafström wrote: >>>> The e100 driver triggers BUG_ON(buf->direction != dir) >>>> by doing pci_map_single(..., PCI_DMA_BIDIRECTIONAL) >>>> and pci_dma_sync_single_for_device(..., PCI_DMA_TODEVICE). >>>> >>>> I'm guessing it's allowed to do that and that something like >>>> the patch below is called for? >>> No, it is not allowed to do that - that's why it's called "BUG_ON". >>> Changing the DMA direction, especially with dmabounce will result >>> in unexpected behaviour. >> >> okay, how about this patch... only compile tested as I couldn't get >> net-next-2.6 to boot on my test machine. I'll get some testing done >> on this, but in the meantime.... >> >> e100: fix dma error in direction for mapping >> >> From: Jesse Brandeburg <jesse.brandeburg@intel.com> > > I failed to save this patch (flowed format?) but I applied it manually > to 2.6.28-rc4 and tried it. Appears to work. Strange... sorry for the thrash on the patch, and thanks for testing! ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-14 22:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <4909E08F.9040306@users.sourceforge.net>
2008-10-31 21:01 ` Validation of DMA params breaks e100 driver (2.6.28-rc2) Russell King - ARM Linux
2008-11-14 1:21 ` Brandeburg, Jesse
2008-11-14 2:42 ` David Miller
2008-11-14 20:37 ` Anders Grafström
2008-11-14 22:30 ` Brandeburg, Jesse
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).