linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qlge: fix size of external list for TX address descriptors
@ 2011-11-23 23:10 Thadeu Lima de Souza Cascardo
  2011-11-24  0:10 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2011-11-23 23:10 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, linux-driver, Ron Mercer, Jitendra Kalsaria,
	Anirban Chakraborty, Thadeu Lima de Souza Cascardo

When transmiting a fragmented skb, qlge fills a descriptor with the
fragment addresses, after DMA-mapping them. If there are more than eight
fragments, it will use the eighth descriptor as a pointer to an external
list. After mapping this external list, called OAL to a structure
containing more descriptors, it fills it with the extra fragments.

However, considering that systems with pages larger than 8KiB would have
less than 8 fragments, which was true before commit a715dea3c8e, it
defined a macro for the OAL size as 0 in those cases.

Now, if a skb with more than 8 fragments (counting skb->data as one
fragment), this would start overwriting the list of addresses already
mapped and would make the driver fail to properly unmap the right
addresses on architectures with pages larger than 8KiB.

Besides that, the list of mappings was one size too small, since it must
have a mapping for the maxinum number of skb fragments plus one for
skb->data and another for the OAL. So, even on architectures with page
sizes 4KiB and 8KiB, a skb with the maximum number of fragments would
make the driver overwrite its counter for the number of mappings, which,
again, would make it fail to unmap the mapped DMA addresses.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
---
 drivers/net/ethernet/qlogic/qlge/qlge.h |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qlge/qlge.h b/drivers/net/ethernet/qlogic/qlge/qlge.h
index 8731f79..b8478aa 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge.h
+++ b/drivers/net/ethernet/qlogic/qlge/qlge.h
@@ -58,10 +58,8 @@
 
 
 #define TX_DESC_PER_IOCB 8
-/* The maximum number of frags we handle is based
- * on PAGE_SIZE...
- */
-#if (PAGE_SHIFT == 12) || (PAGE_SHIFT == 13)	/* 4k & 8k pages */
+
+#if ((MAX_SKB_FRAGS - TX_DESC_PER_IOCB) + 2) > 0
 #define TX_DESC_PER_OAL ((MAX_SKB_FRAGS - TX_DESC_PER_IOCB) + 2)
 #else /* all other page sizes */
 #define TX_DESC_PER_OAL 0
@@ -1353,7 +1351,7 @@ struct tx_ring_desc {
 	struct ob_mac_iocb_req *queue_entry;
 	u32 index;
 	struct oal oal;
-	struct map_list map[MAX_SKB_FRAGS + 1];
+	struct map_list map[MAX_SKB_FRAGS + 2];
 	int map_cnt;
 	struct tx_ring_desc *next;
 };
-- 
1.7.4.4


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

* Re: [PATCH] qlge: fix size of external list for TX address descriptors
  2011-11-23 23:10 [PATCH] qlge: fix size of external list for TX address descriptors Thadeu Lima de Souza Cascardo
@ 2011-11-24  0:10 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-11-24  0:10 UTC (permalink / raw)
  To: cascardo
  Cc: netdev, linux-kernel, linux-driver, ron.mercer,
	jitendra.kalsaria, anirban.chakraborty

From: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Date: Wed, 23 Nov 2011 21:10:42 -0200

> When transmiting a fragmented skb, qlge fills a descriptor with the
> fragment addresses, after DMA-mapping them. If there are more than eight
> fragments, it will use the eighth descriptor as a pointer to an external
> list. After mapping this external list, called OAL to a structure
> containing more descriptors, it fills it with the extra fragments.
> 
> However, considering that systems with pages larger than 8KiB would have
> less than 8 fragments, which was true before commit a715dea3c8e, it
> defined a macro for the OAL size as 0 in those cases.
> 
> Now, if a skb with more than 8 fragments (counting skb->data as one
> fragment), this would start overwriting the list of addresses already
> mapped and would make the driver fail to properly unmap the right
> addresses on architectures with pages larger than 8KiB.
> 
> Besides that, the list of mappings was one size too small, since it must
> have a mapping for the maxinum number of skb fragments plus one for
> skb->data and another for the OAL. So, even on architectures with page
> sizes 4KiB and 8KiB, a skb with the maximum number of fragments would
> make the driver overwrite its counter for the number of mappings, which,
> again, would make it fail to unmap the mapped DMA addresses.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>

Applied, thanks for the detailed commit message.

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

end of thread, other threads:[~2011-11-24  0:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-23 23:10 [PATCH] qlge: fix size of external list for TX address descriptors Thadeu Lima de Souza Cascardo
2011-11-24  0:10 ` David Miller

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