netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-2.6] jme: Fix unmap error (Causing system freeze)
@ 2011-07-21  2:57 cooldavid
  2011-07-21 19:30 ` Chris Wright
  2011-07-22  7:45 ` Michał Mirosław
  0 siblings, 2 replies; 5+ messages in thread
From: cooldavid @ 2011-07-21  2:57 UTC (permalink / raw)
  To: David Miller
  Cc: Jason Lamb, linux-netdev, Guo-Fu Tseng, Jason Long, Marcus Becker,
	Aries Lee, Devinchiu, Marc Schiffbauer, stable

From: Guo-Fu Tseng <cooldavid@cooldavid.org>


This patch add the missing dma_unmap().
Which solved the critical issue of system freeze on heavy load.

Michal Miroslaw's rejected patch:
[PATCH v2 10/46] net: jme: convert to generic DMA API
Pointed out the issue also, thank you Michal.
But the fix was incorrect. It would unmap needed address
when low memory.

Got lots of feedback from End user and Gentoo Bugzilla.
https://bugs.gentoo.org/show_bug.cgi?id=373109
Thank you all. :)

Cc: stable@kernel.org
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
---
 drivers/net/jme.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index b5b174a..1973814 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -753,20 +753,28 @@ jme_make_new_rx_buf(struct jme_adapter *jme, int i)
 	struct jme_ring *rxring = &(jme->rxring[0]);
 	struct jme_buffer_info *rxbi = rxring->bufinf + i;
 	struct sk_buff *skb;
+	dma_addr_t mapping;
 
 	skb = netdev_alloc_skb(jme->dev,
 		jme->dev->mtu + RX_EXTRA_LEN);
 	if (unlikely(!skb))
 		return -ENOMEM;
 
+	mapping = pci_map_page(jme->pdev, virt_to_page(skb->data),
+			       offset_in_page(skb->data), skb_tailroom(skb),
+			       PCI_DMA_FROMDEVICE);
+	if (unlikely(pci_dma_mapping_error(jme->pdev, mapping))) {
+		dev_kfree_skb(skb);
+		return -ENOMEM;
+	}
+
+	if (likely(rxbi->mapping))
+		pci_unmap_page(jme->pdev, rxbi->mapping,
+			       rxbi->len, PCI_DMA_FROMDEVICE);
+
 	rxbi->skb = skb;
 	rxbi->len = skb_tailroom(skb);
-	rxbi->mapping = pci_map_page(jme->pdev,
-					virt_to_page(skb->data),
-					offset_in_page(skb->data),
-					rxbi->len,
-					PCI_DMA_FROMDEVICE);
-
+	rxbi->mapping = mapping;
 	return 0;
 }
 
-- 
1.7.3.4

_______________________________________________
stable mailing list
stable@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/stable

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-2.6] jme: Fix unmap error (Causing system freeze)
  2011-07-21  2:57 [PATCH net-2.6] jme: Fix unmap error (Causing system freeze) cooldavid
@ 2011-07-21 19:30 ` Chris Wright
  2011-07-21 22:23   ` David Miller
  2011-07-22  7:45 ` Michał Mirosław
  1 sibling, 1 reply; 5+ messages in thread
From: Chris Wright @ 2011-07-21 19:30 UTC (permalink / raw)
  To: cooldavid
  Cc: Jason Lamb, linux-netdev, Jason Long, stable, Marcus Becker,
	Aries Lee, Devinchiu, Marc Schiffbauer, David Miller

* cooldavid@cooldavid.org (cooldavid@cooldavid.org) wrote:
> From: Guo-Fu Tseng <cooldavid@cooldavid.org>
> 
> This patch add the missing dma_unmap().
> Which solved the critical issue of system freeze on heavy load.
> 
> Michal Miroslaw's rejected patch:
> [PATCH v2 10/46] net: jme: convert to generic DMA API
> Pointed out the issue also, thank you Michal.
> But the fix was incorrect. It would unmap needed address
> when low memory.
> 
> Got lots of feedback from End user and Gentoo Bugzilla.
> https://bugs.gentoo.org/show_bug.cgi?id=373109
> Thank you all. :)

Also referred to in kernel bugzilla:

https://bugzilla.kernel.org/show_bug.cgi?id=39312

> Cc: stable@kernel.org
> Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>

Acked-by: Chris Wright <chrisw@sous-sol.org>

_______________________________________________
stable mailing list
stable@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/stable

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-2.6] jme: Fix unmap error (Causing system freeze)
  2011-07-21 19:30 ` Chris Wright
@ 2011-07-21 22:23   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2011-07-21 22:23 UTC (permalink / raw)
  To: chrisw
  Cc: jason, netdev, cooldavid, jason, marcus.disi, arieslee, devinchiu,
	mschiff, stable

From: Chris Wright <chrisw@sous-sol.org>
Date: Thu, 21 Jul 2011 12:30:08 -0700

> * cooldavid@cooldavid.org (cooldavid@cooldavid.org) wrote:
>> From: Guo-Fu Tseng <cooldavid@cooldavid.org>
>> 
>> This patch add the missing dma_unmap().
>> Which solved the critical issue of system freeze on heavy load.
>> 
>> Michal Miroslaw's rejected patch:
>> [PATCH v2 10/46] net: jme: convert to generic DMA API
>> Pointed out the issue also, thank you Michal.
>> But the fix was incorrect. It would unmap needed address
>> when low memory.
>> 
>> Got lots of feedback from End user and Gentoo Bugzilla.
>> https://bugs.gentoo.org/show_bug.cgi?id=373109
>> Thank you all. :)
> 
> Also referred to in kernel bugzilla:
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=39312
> 
>> Cc: stable@kernel.org
>> Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
> 
> Acked-by: Chris Wright <chrisw@sous-sol.org>

Applied, but it's too late for 3.0 so I'll just submit it to all
the -stable branches after 3.0-final is released.

Thanks.

_______________________________________________
stable mailing list
stable@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/stable

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-2.6] jme: Fix unmap error (Causing system freeze)
  2011-07-21  2:57 [PATCH net-2.6] jme: Fix unmap error (Causing system freeze) cooldavid
  2011-07-21 19:30 ` Chris Wright
@ 2011-07-22  7:45 ` Michał Mirosław
  2011-07-22  8:49   ` Guo-Fu Tseng
  1 sibling, 1 reply; 5+ messages in thread
From: Michał Mirosław @ 2011-07-22  7:45 UTC (permalink / raw)
  To: cooldavid
  Cc: David Miller, linux-netdev, Aries Lee, Devinchiu, Jason Lamb,
	Marcus Becker, Marc Schiffbauer, Jason Long, stable

2011/7/21  <cooldavid@cooldavid.org>:
> From: Guo-Fu Tseng <cooldavid@cooldavid.org>
>
> This patch add the missing dma_unmap().
> Which solved the critical issue of system freeze on heavy load.
>
> Michal Miroslaw's rejected patch:
> [PATCH v2 10/46] net: jme: convert to generic DMA API
> Pointed out the issue also, thank you Michal.
> But the fix was incorrect. It would unmap needed address
> when low memory.

My patch also fixed another issue - from correctness point of view,
you should not use virt_to_page+dma_map_page here, but dma_map_single.

Best Regards,
Michał Mirosław

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-2.6] jme: Fix unmap error (Causing system freeze)
  2011-07-22  7:45 ` Michał Mirosław
@ 2011-07-22  8:49   ` Guo-Fu Tseng
  0 siblings, 0 replies; 5+ messages in thread
From: Guo-Fu Tseng @ 2011-07-22  8:49 UTC (permalink / raw)
  To: Michał Mirosław 
  Cc: Jason Lamb, linux-netdev, Jason Long, stable, Marcus Becker,
	Aries Lee, Devinchiu, Marc Schiffbauer, David Miller

On Fri, 22 Jul 2011 09:45:42 +0200, Michał Mirosław wrote
> 2011/7/21  <cooldavid@cooldavid.org>:
> > From: Guo-Fu Tseng <cooldavid@cooldavid.org>
> >
> > This patch add the missing dma_unmap().
> > Which solved the critical issue of system freeze on heavy load.
> >
> > Michal Miroslaw's rejected patch:
> > [PATCH v2 10/46] net: jme: convert to generic DMA API
> > Pointed out the issue also, thank you Michal.
> > But the fix was incorrect. It would unmap needed address
> > when low memory.
> 
> My patch also fixed another issue - from correctness point of view,
> you should not use virt_to_page+dma_map_page here, but dma_map_single.
> 
> Best Regards,
> Michał Mirosław
Hi Michał:

Yes, I did noticed that. :)

And I agreed that using {dma|pci}_map_single is better than
calling virt_to_page in driver.

It's just that I'm not sure if it is really preferred to use
dma_map_single over pci_map_single for PCI device driver?

You are very welcome to send another patch for converting the
DMA API using.

Guo-Fu Tseng

_______________________________________________
stable mailing list
stable@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/stable

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-22  8:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-21  2:57 [PATCH net-2.6] jme: Fix unmap error (Causing system freeze) cooldavid
2011-07-21 19:30 ` Chris Wright
2011-07-21 22:23   ` David Miller
2011-07-22  7:45 ` Michał Mirosław
2011-07-22  8:49   ` Guo-Fu Tseng

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).