Thread (3 messages) 3 messages, 2 authors, 2009-06-01

Re: NIU driver unmap_page call

From: Andy Fleming <hidden>
Date: 2009-06-01 20:58:38

On Jun 1, 2009, at 5:11 AM, David Miller wrote:
From: Andy Fleming <redacted>
Date: Fri, 29 May 2009 17:38:50 -0500
quoted
I'm trying to figure out what this code does:

              if ((page->index + rp->rbr_block_size) - rcr_size ==  
addr) {
                      *link = (struct page *) page->mapping;
                      np->ops->unmap_page(np->device, page->index,
                                          PAGE_SIZE,  
DMA_FROM_DEVICE);
                      page->index = 0;
                      page->mapping = NULL;
                      rp->rbr_refill_pending++;
              } else
                      get_page(page);

It's clear it's taking the opportunity to remove the page from the
hash table, and to unmap the page, but I'm not familiar enough with
this nic to understand what the if statement is looking for.  My  
first
thought was that it was looking to see if this was the first buffer  
in
the page?
It's looking to see if this is the LAST chunk in the page, not the
first.

Hmm... I'm still misunderstanding something.  rbr_blocks_per_page  
implies that each page has multiple blocks.  This looks like it is  
checking to see if the current buffer is the last buffer in the  
block.  There is similar code in the niu_rx_pkt_ignore function, which  
uses PAGE_SIZE in place of rbr_block_size.


rcr_size is the size of the sub-buffers within the page that the
chip is carving out of the page.

Since when we allocated the page initially this obtained on reference
to the page, we increment for every chunk given out to an SKB except
the last one.
But in niu_rbr_add_page(), the function does:

                 atomic_add(rp->rbr_blocks_per_page - 1,
                            &compound_head(page)->_count);

Which I thought was already doing the necessary accounting.

Andy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help