aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-01-03 22:33:50 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-04 06:55:19 -0500
commit9de4dfb4c7176e5bb232a21cdd8df78da2b15cac (patch)
treedb7484f7c29d9d738aaddee39ddd46fe59cfbc27
parente5e025401f6e926c1d9dc3f3f2813cf98a2d8708 (diff)
[CASSINI]: Revert 'dont touch page_count'.
This reverts changeset fa4f0774d7c6cccb4d1fda76b91dd8eddcb2dd6a ([CASSINI]: dont touch page_count) because it breaks the driver. The local page counting added by this changeset did not account for the asynchronous page count changes done by kfree_skb() and friends. The change adds extra atomics and on top of it all appears to be totally unnecessary as well. Signed-off-by: David S. Miller <davem@davemloft.net> Acked-by: Nick Piggin <npiggin@suse.de>
-rw-r--r--drivers/net/cassini.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 9030ca54a5bd..9c77eadb6767 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -336,30 +336,6 @@ static inline void cas_mask_intr(struct cas *cp)
336 cas_disable_irq(cp, i); 336 cas_disable_irq(cp, i);
337} 337}
338 338
339static inline void cas_buffer_init(cas_page_t *cp)
340{
341 struct page *page = cp->buffer;
342 atomic_set((atomic_t *)&page->lru.next, 1);
343}
344
345static inline int cas_buffer_count(cas_page_t *cp)
346{
347 struct page *page = cp->buffer;
348 return atomic_read((atomic_t *)&page->lru.next);
349}
350
351static inline void cas_buffer_inc(cas_page_t *cp)
352{
353 struct page *page = cp->buffer;
354 atomic_inc((atomic_t *)&page->lru.next);
355}
356
357static inline void cas_buffer_dec(cas_page_t *cp)
358{
359 struct page *page = cp->buffer;
360 atomic_dec((atomic_t *)&page->lru.next);
361}
362
363static void cas_enable_irq(struct cas *cp, const int ring) 339static void cas_enable_irq(struct cas *cp, const int ring)
364{ 340{
365 if (ring == 0) { /* all but TX_DONE */ 341 if (ring == 0) { /* all but TX_DONE */
@@ -497,7 +473,6 @@ static int cas_page_free(struct cas *cp, cas_page_t *page)
497{ 473{
498 pci_unmap_page(cp->pdev, page->dma_addr, cp->page_size, 474 pci_unmap_page(cp->pdev, page->dma_addr, cp->page_size,
499 PCI_DMA_FROMDEVICE); 475 PCI_DMA_FROMDEVICE);
500 cas_buffer_dec(page);
501 __free_pages(page->buffer, cp->page_order); 476 __free_pages(page->buffer, cp->page_order);
502 kfree(page); 477 kfree(page);
503 return 0; 478 return 0;
@@ -527,7 +502,6 @@ static cas_page_t *cas_page_alloc(struct cas *cp, const gfp_t flags)
527 page->buffer = alloc_pages(flags, cp->page_order); 502 page->buffer = alloc_pages(flags, cp->page_order);
528 if (!page->buffer) 503 if (!page->buffer)
529 goto page_err; 504 goto page_err;
530 cas_buffer_init(page);
531 page->dma_addr = pci_map_page(cp->pdev, page->buffer, 0, 505 page->dma_addr = pci_map_page(cp->pdev, page->buffer, 0,
532 cp->page_size, PCI_DMA_FROMDEVICE); 506 cp->page_size, PCI_DMA_FROMDEVICE);
533 return page; 507 return page;
@@ -606,7 +580,7 @@ static void cas_spare_recover(struct cas *cp, const gfp_t flags)
606 list_for_each_safe(elem, tmp, &list) { 580 list_for_each_safe(elem, tmp, &list) {
607 cas_page_t *page = list_entry(elem, cas_page_t, list); 581 cas_page_t *page = list_entry(elem, cas_page_t, list);
608 582
609 if (cas_buffer_count(page) > 1) 583 if (page_count(page->buffer) > 1)
610 continue; 584 continue;
611 585
612 list_del(elem); 586 list_del(elem);
@@ -1374,7 +1348,7 @@ static inline cas_page_t *cas_page_spare(struct cas *cp, const int index)
1374 cas_page_t *page = cp->rx_pages[1][index]; 1348 cas_page_t *page = cp->rx_pages[1][index];
1375 cas_page_t *new; 1349 cas_page_t *new;
1376 1350
1377 if (cas_buffer_count(page) == 1) 1351 if (page_count(page->buffer) == 1)
1378 return page; 1352 return page;
1379 1353
1380 new = cas_page_dequeue(cp); 1354 new = cas_page_dequeue(cp);
@@ -1394,7 +1368,7 @@ static cas_page_t *cas_page_swap(struct cas *cp, const int ring,
1394 cas_page_t **page1 = cp->rx_pages[1]; 1368 cas_page_t **page1 = cp->rx_pages[1];
1395 1369
1396 /* swap if buffer is in use */ 1370 /* swap if buffer is in use */
1397 if (cas_buffer_count(page0[index]) > 1) { 1371 if (page_count(page0[index]->buffer) > 1) {
1398 cas_page_t *new = cas_page_spare(cp, index); 1372 cas_page_t *new = cas_page_spare(cp, index);
1399 if (new) { 1373 if (new) {
1400 page1[index] = page0[index]; 1374 page1[index] = page0[index];
@@ -2066,7 +2040,6 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
2066 skb->len += hlen - swivel; 2040 skb->len += hlen - swivel;
2067 2041
2068 get_page(page->buffer); 2042 get_page(page->buffer);
2069 cas_buffer_inc(page);
2070 frag->page = page->buffer; 2043 frag->page = page->buffer;
2071 frag->page_offset = off; 2044 frag->page_offset = off;
2072 frag->size = hlen - swivel; 2045 frag->size = hlen - swivel;
@@ -2091,7 +2064,6 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
2091 frag++; 2064 frag++;
2092 2065
2093 get_page(page->buffer); 2066 get_page(page->buffer);
2094 cas_buffer_inc(page);
2095 frag->page = page->buffer; 2067 frag->page = page->buffer;
2096 frag->page_offset = 0; 2068 frag->page_offset = 0;
2097 frag->size = hlen; 2069 frag->size = hlen;
@@ -2255,7 +2227,7 @@ static int cas_post_rxds_ringN(struct cas *cp, int ring, int num)
2255 released = 0; 2227 released = 0;
2256 while (entry != last) { 2228 while (entry != last) {
2257 /* make a new buffer if it's still in use */ 2229 /* make a new buffer if it's still in use */
2258 if (cas_buffer_count(page[entry]) > 1) { 2230 if (page_count(page[entry]->buffer) > 1) {
2259 cas_page_t *new = cas_page_dequeue(cp); 2231 cas_page_t *new = cas_page_dequeue(cp);
2260 if (!new) { 2232 if (!new) {
2261 /* let the timer know that we need to 2233 /* let the timer know that we need to