提交 fa4f0774 编写于 作者: N Nick Piggin 提交者: David S. Miller

[CASSINI]: dont touch page_count

Remove page refcount manipulations from cassini driver by using
another field in struct page. Needed for lockless pagecache.
Signed-off-by: NNick Piggin <npiggin@suse.de>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 dbd2915c
...@@ -335,6 +335,30 @@ static inline void cas_mask_intr(struct cas *cp) ...@@ -335,6 +335,30 @@ static inline void cas_mask_intr(struct cas *cp)
cas_disable_irq(cp, i); cas_disable_irq(cp, i);
} }
static inline void cas_buffer_init(cas_page_t *cp)
{
struct page *page = cp->buffer;
atomic_set((atomic_t *)&page->lru.next, 1);
}
static inline int cas_buffer_count(cas_page_t *cp)
{
struct page *page = cp->buffer;
return atomic_read((atomic_t *)&page->lru.next);
}
static inline void cas_buffer_inc(cas_page_t *cp)
{
struct page *page = cp->buffer;
atomic_inc((atomic_t *)&page->lru.next);
}
static inline void cas_buffer_dec(cas_page_t *cp)
{
struct page *page = cp->buffer;
atomic_dec((atomic_t *)&page->lru.next);
}
static void cas_enable_irq(struct cas *cp, const int ring) static void cas_enable_irq(struct cas *cp, const int ring)
{ {
if (ring == 0) { /* all but TX_DONE */ if (ring == 0) { /* all but TX_DONE */
...@@ -472,6 +496,7 @@ static int cas_page_free(struct cas *cp, cas_page_t *page) ...@@ -472,6 +496,7 @@ static int cas_page_free(struct cas *cp, cas_page_t *page)
{ {
pci_unmap_page(cp->pdev, page->dma_addr, cp->page_size, pci_unmap_page(cp->pdev, page->dma_addr, cp->page_size,
PCI_DMA_FROMDEVICE); PCI_DMA_FROMDEVICE);
cas_buffer_dec(page);
__free_pages(page->buffer, cp->page_order); __free_pages(page->buffer, cp->page_order);
kfree(page); kfree(page);
return 0; return 0;
...@@ -501,6 +526,7 @@ static cas_page_t *cas_page_alloc(struct cas *cp, const gfp_t flags) ...@@ -501,6 +526,7 @@ static cas_page_t *cas_page_alloc(struct cas *cp, const gfp_t flags)
page->buffer = alloc_pages(flags, cp->page_order); page->buffer = alloc_pages(flags, cp->page_order);
if (!page->buffer) if (!page->buffer)
goto page_err; goto page_err;
cas_buffer_init(page);
page->dma_addr = pci_map_page(cp->pdev, page->buffer, 0, page->dma_addr = pci_map_page(cp->pdev, page->buffer, 0,
cp->page_size, PCI_DMA_FROMDEVICE); cp->page_size, PCI_DMA_FROMDEVICE);
return page; return page;
...@@ -579,7 +605,7 @@ static void cas_spare_recover(struct cas *cp, const gfp_t flags) ...@@ -579,7 +605,7 @@ static void cas_spare_recover(struct cas *cp, const gfp_t flags)
list_for_each_safe(elem, tmp, &list) { list_for_each_safe(elem, tmp, &list) {
cas_page_t *page = list_entry(elem, cas_page_t, list); cas_page_t *page = list_entry(elem, cas_page_t, list);
if (page_count(page->buffer) > 1) if (cas_buffer_count(page) > 1)
continue; continue;
list_del(elem); list_del(elem);
...@@ -1347,7 +1373,7 @@ static inline cas_page_t *cas_page_spare(struct cas *cp, const int index) ...@@ -1347,7 +1373,7 @@ static inline cas_page_t *cas_page_spare(struct cas *cp, const int index)
cas_page_t *page = cp->rx_pages[1][index]; cas_page_t *page = cp->rx_pages[1][index];
cas_page_t *new; cas_page_t *new;
if (page_count(page->buffer) == 1) if (cas_buffer_count(page) == 1)
return page; return page;
new = cas_page_dequeue(cp); new = cas_page_dequeue(cp);
...@@ -1367,7 +1393,7 @@ static cas_page_t *cas_page_swap(struct cas *cp, const int ring, ...@@ -1367,7 +1393,7 @@ static cas_page_t *cas_page_swap(struct cas *cp, const int ring,
cas_page_t **page1 = cp->rx_pages[1]; cas_page_t **page1 = cp->rx_pages[1];
/* swap if buffer is in use */ /* swap if buffer is in use */
if (page_count(page0[index]->buffer) > 1) { if (cas_buffer_count(page0[index]) > 1) {
cas_page_t *new = cas_page_spare(cp, index); cas_page_t *new = cas_page_spare(cp, index);
if (new) { if (new) {
page1[index] = page0[index]; page1[index] = page0[index];
...@@ -2039,6 +2065,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc, ...@@ -2039,6 +2065,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
skb->len += hlen - swivel; skb->len += hlen - swivel;
get_page(page->buffer); get_page(page->buffer);
cas_buffer_inc(page);
frag->page = page->buffer; frag->page = page->buffer;
frag->page_offset = off; frag->page_offset = off;
frag->size = hlen - swivel; frag->size = hlen - swivel;
...@@ -2063,6 +2090,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc, ...@@ -2063,6 +2090,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
frag++; frag++;
get_page(page->buffer); get_page(page->buffer);
cas_buffer_inc(page);
frag->page = page->buffer; frag->page = page->buffer;
frag->page_offset = 0; frag->page_offset = 0;
frag->size = hlen; frag->size = hlen;
...@@ -2225,7 +2253,7 @@ static int cas_post_rxds_ringN(struct cas *cp, int ring, int num) ...@@ -2225,7 +2253,7 @@ static int cas_post_rxds_ringN(struct cas *cp, int ring, int num)
released = 0; released = 0;
while (entry != last) { while (entry != last) {
/* make a new buffer if it's still in use */ /* make a new buffer if it's still in use */
if (page_count(page[entry]->buffer) > 1) { if (cas_buffer_count(page[entry]) > 1) {
cas_page_t *new = cas_page_dequeue(cp); cas_page_t *new = cas_page_dequeue(cp);
if (!new) { if (!new) {
/* let the timer know that we need to /* let the timer know that we need to
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册