diff options
author | Brice Goglin <brice@myri.com> | 2007-04-10 15:21:08 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-11 11:54:44 -0400 |
commit | ae8509b1876e6e1074edc9846296e80983e30502 (patch) | |
tree | bc7ee82e0134ea9b88a2e26c367e97160536caf4 /drivers | |
parent | 6cdbd77e8883aac2e24f8b19b91e5b1c839213a0 (diff) |
myri10ge: fix management of the firmware 4KB boundary crossing restriction
Simpler way of dealing with the firmware 4KB boundary crossing
restriction for rx buffers. This fixes a variety of memory
corruption issues when using an "uncommon" MTU with a 16KB
page size.
Signed-off-by: Brice Goglin <brice@myri.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/myri10ge/myri10ge.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index c216e6a5d235..1e7fa2facbe1 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -900,19 +900,9 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, | |||
900 | /* try to refill entire ring */ | 900 | /* try to refill entire ring */ |
901 | while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) { | 901 | while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) { |
902 | idx = rx->fill_cnt & rx->mask; | 902 | idx = rx->fill_cnt & rx->mask; |
903 | 903 | if (rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE) { | |
904 | if ((bytes < MYRI10GE_ALLOC_SIZE / 2) && | ||
905 | (rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE)) { | ||
906 | /* we can use part of previous page */ | 904 | /* we can use part of previous page */ |
907 | get_page(rx->page); | 905 | get_page(rx->page); |
908 | #if MYRI10GE_ALLOC_SIZE > 4096 | ||
909 | /* Firmware cannot cross 4K boundary.. */ | ||
910 | if ((rx->page_offset >> 12) != | ||
911 | ((rx->page_offset + bytes - 1) >> 12)) { | ||
912 | rx->page_offset = | ||
913 | (rx->page_offset + bytes) & ~4095; | ||
914 | } | ||
915 | #endif | ||
916 | } else { | 906 | } else { |
917 | /* we need a new page */ | 907 | /* we need a new page */ |
918 | page = | 908 | page = |
@@ -941,6 +931,13 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, | |||
941 | 931 | ||
942 | /* start next packet on a cacheline boundary */ | 932 | /* start next packet on a cacheline boundary */ |
943 | rx->page_offset += SKB_DATA_ALIGN(bytes); | 933 | rx->page_offset += SKB_DATA_ALIGN(bytes); |
934 | |||
935 | #if MYRI10GE_ALLOC_SIZE > 4096 | ||
936 | /* don't cross a 4KB boundary */ | ||
937 | if ((rx->page_offset >> 12) != | ||
938 | ((rx->page_offset + bytes - 1) >> 12)) | ||
939 | rx->page_offset = (rx->page_offset + 4096) & ~4095; | ||
940 | #endif | ||
944 | rx->fill_cnt++; | 941 | rx->fill_cnt++; |
945 | 942 | ||
946 | /* copy 8 descriptors to the firmware at a time */ | 943 | /* copy 8 descriptors to the firmware at a time */ |