diff mbox series

[net-next,3/5] cassini: Remove unnecessary use of kmap_atomic()

Message ID 20221117222557.2196195-4-anirudh.venkataramanan@intel.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Remove uses of kmap_atomic() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/cc_maintainers warning 5 maintainers not CCed: pabeni@redhat.com christophe.jaillet@wanadoo.fr davem@davemloft.net edumazet@google.com kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Anirudh Venkataramanan Nov. 17, 2022, 10:25 p.m. UTC
Pages for Rx buffers are allocated in cas_page_alloc() using either
GFP_ATOMIC or GFP_KERNEL. Memory allocated with GFP_KERNEL/GFP_ATOMIC
can't come from highmem and so there's no need to kmap() them. Just use
page_address() instead.

I don't have hardware, so this change has only been compile tested.

Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
---
 drivers/net/ethernet/sun/cassini.c | 34 ++++++++++--------------------
 1 file changed, 11 insertions(+), 23 deletions(-)

Comments

Fabio M. De Francesco Nov. 18, 2022, 8:35 a.m. UTC | #1
On giovedì 17 novembre 2022 23:25:55 CET Anirudh Venkataramanan wrote:
> Pages for Rx buffers are allocated in cas_page_alloc() using either
> GFP_ATOMIC or GFP_KERNEL. Memory allocated with GFP_KERNEL/GFP_ATOMIC
> can't come from highmem and so there's no need to kmap() them. Just use
> page_address() instead.
> 
> I don't have hardware, so this change has only been compile tested.
> 
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
> ---
>  drivers/net/ethernet/sun/cassini.c | 34 ++++++++++--------------------
>  1 file changed, 11 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/ethernet/sun/cassini.c
> b/drivers/net/ethernet/sun/cassini.c index 0aca193..2f66cfc 100644
> --- a/drivers/net/ethernet/sun/cassini.c
> +++ b/drivers/net/ethernet/sun/cassini.c
> @@ -1915,7 +1915,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct
> cas_rx_comp *rxc, int off, swivel = RX_SWIVEL_OFF_VAL;
>  	struct cas_page *page;
>  	struct sk_buff *skb;
> -	void *addr, *crcaddr;
> +	void *crcaddr;
>  	__sum16 csum;
>  	char *p;
> 
> @@ -1936,7 +1936,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct
> cas_rx_comp *rxc, skb_reserve(skb, swivel);
> 
>  	p = skb->data;
> -	addr = crcaddr = NULL;
> +	crcaddr = NULL;
>  	if (hlen) { /* always copy header pages */
>  		i = CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
>  		page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)]
[CAS_VAL(RX_INDEX_NUM, i)];
> @@ -1948,12 +1948,10 @@ static int cas_rx_process_pkt(struct cas *cp, struct
> cas_rx_comp *rxc, i += cp->crc_size;
>  		dma_sync_single_for_cpu(&cp->pdev->dev, page->dma_addr + 
off,
>  					i, DMA_FROM_DEVICE);
> -		addr = cas_page_map(page->buffer);
> -		memcpy(p, addr + off, i);
> +		memcpy(p, page_address(page->buffer) + off, i);
>  		dma_sync_single_for_device(&cp->pdev->dev,
>  					   page->dma_addr + off, i,
>  					   DMA_FROM_DEVICE);
> -		cas_page_unmap(addr);
>  		RX_USED_ADD(page, 0x100);
>  		p += hlen;
>  		swivel = 0;
> @@ -1984,12 +1982,11 @@ static int cas_rx_process_pkt(struct cas *cp, struct
> cas_rx_comp *rxc, /* make sure we always copy a header */
>  		swivel = 0;
>  		if (p == (char *) skb->data) { /* not split */
> -			addr = cas_page_map(page->buffer);
> -			memcpy(p, addr + off, RX_COPY_MIN);
> +			memcpy(p, page_address(page->buffer) + off,
> +			       RX_COPY_MIN);
>  			dma_sync_single_for_device(&cp->pdev->dev,
>  						   page->dma_addr 
+ off, i,
>  						   
DMA_FROM_DEVICE);
> -			cas_page_unmap(addr);
>  			off += RX_COPY_MIN;
>  			swivel = RX_COPY_MIN;
>  			RX_USED_ADD(page, cp->mtu_stride);
> @@ -2036,10 +2033,8 @@ static int cas_rx_process_pkt(struct cas *cp, struct
> cas_rx_comp *rxc, RX_USED_ADD(page, hlen + cp->crc_size);
>  		}
> 
> -		if (cp->crc_size) {
> -			addr = cas_page_map(page->buffer);
> -			crcaddr  = addr + off + hlen;
> -		}
> +		if (cp->crc_size)
> +			crcaddr = page_address(page->buffer) + off + 
hlen;
> 
>  	} else {
>  		/* copying packet */
> @@ -2061,12 +2056,10 @@ static int cas_rx_process_pkt(struct cas *cp, struct
> cas_rx_comp *rxc, i += cp->crc_size;
>  		dma_sync_single_for_cpu(&cp->pdev->dev, page->dma_addr + 
off,
>  					i, DMA_FROM_DEVICE);
> -		addr = cas_page_map(page->buffer);
> -		memcpy(p, addr + off, i);
> +		memcpy(p, page_address(page->buffer) + off, i);
>  		dma_sync_single_for_device(&cp->pdev->dev,
>  					   page->dma_addr + off, i,
>  					   DMA_FROM_DEVICE);
> -		cas_page_unmap(addr);
>  		if (p == (char *) skb->data) /* not split */
>  			RX_USED_ADD(page, cp->mtu_stride);
>  		else
> @@ -2081,20 +2074,17 @@ static int cas_rx_process_pkt(struct cas *cp, struct
> cas_rx_comp *rxc, page->dma_addr,
>  						dlen + cp-
>crc_size,
>  						DMA_FROM_DEVICE);
> -			addr = cas_page_map(page->buffer);
> -			memcpy(p, addr, dlen + cp->crc_size);
> +			memcpy(p, page_address(page->buffer), dlen + cp-
>crc_size);
>  			dma_sync_single_for_device(&cp->pdev->dev,
>  						   page->dma_addr,
>  						   dlen + cp-
>crc_size,
>  						   
DMA_FROM_DEVICE);
> -			cas_page_unmap(addr);
>  			RX_USED_ADD(page, dlen + cp->crc_size);
>  		}
>  end_copy_pkt:
> -		if (cp->crc_size) {
> -			addr    = NULL;
> +		if (cp->crc_size)
>  			crcaddr = skb->data + alloclen;
> -		}
> +

This is a different logical change. Some maintainers I met would have asked  
for a separate patch, but I'm OK with it being here.

>  		skb_put(skb, alloclen);
>  	}
> 
> @@ -2103,8 +2093,6 @@ static int cas_rx_process_pkt(struct cas *cp, struct
> cas_rx_comp *rxc, /* checksum includes FCS. strip it out. */
>  		csum = csum_fold(csum_partial(crcaddr, cp->crc_size,
>  					      csum_unfold(csum)));
> -		if (addr)
> -			cas_page_unmap(addr);
>  	}
>  	skb->protocol = eth_type_trans(skb, cp->dev);
>  	if (skb->protocol == htons(ETH_P_IP)) {
> --
> 2.37.2

Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>

Thanks,

Fabio
Anirudh Venkataramanan Nov. 18, 2022, 5:55 p.m. UTC | #2
On 11/18/2022 12:35 AM, Fabio M. De Francesco wrote:
> On giovedì 17 novembre 2022 23:25:55 CET Anirudh Venkataramanan wrote:
>> Pages for Rx buffers are allocated in cas_page_alloc() using either
>> GFP_ATOMIC or GFP_KERNEL. Memory allocated with GFP_KERNEL/GFP_ATOMIC
>> can't come from highmem and so there's no need to kmap() them. Just use
>> page_address() instead.
>>
>> I don't have hardware, so this change has only been compile tested.
>>
>> Cc: Ira Weiny <ira.weiny@intel.com>
>> Cc: Fabio M. De Francesco <fmdefrancesco@gmail.com>
>> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
>> ---
>>   drivers/net/ethernet/sun/cassini.c | 34 ++++++++++--------------------
>>   1 file changed, 11 insertions(+), 23 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/sun/cassini.c
>> b/drivers/net/ethernet/sun/cassini.c index 0aca193..2f66cfc 100644
>> --- a/drivers/net/ethernet/sun/cassini.c
>> +++ b/drivers/net/ethernet/sun/cassini.c
>> @@ -1915,7 +1915,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct
>> cas_rx_comp *rxc, int off, swivel = RX_SWIVEL_OFF_VAL;
>>   	struct cas_page *page;
>>   	struct sk_buff *skb;
>> -	void *addr, *crcaddr;
>> +	void *crcaddr;
>>   	__sum16 csum;
>>   	char *p;
>>
>> @@ -1936,7 +1936,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct
>> cas_rx_comp *rxc, skb_reserve(skb, swivel);
>>
>>   	p = skb->data;
>> -	addr = crcaddr = NULL;
>> +	crcaddr = NULL;
>>   	if (hlen) { /* always copy header pages */
>>   		i = CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
>>   		page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)]
> [CAS_VAL(RX_INDEX_NUM, i)];
>> @@ -1948,12 +1948,10 @@ static int cas_rx_process_pkt(struct cas *cp, struct
>> cas_rx_comp *rxc, i += cp->crc_size;
>>   		dma_sync_single_for_cpu(&cp->pdev->dev, page->dma_addr +
> off,
>>   					i, DMA_FROM_DEVICE);
>> -		addr = cas_page_map(page->buffer);
>> -		memcpy(p, addr + off, i);
>> +		memcpy(p, page_address(page->buffer) + off, i);
>>   		dma_sync_single_for_device(&cp->pdev->dev,
>>   					   page->dma_addr + off, i,
>>   					   DMA_FROM_DEVICE);
>> -		cas_page_unmap(addr);
>>   		RX_USED_ADD(page, 0x100);
>>   		p += hlen;
>>   		swivel = 0;
>> @@ -1984,12 +1982,11 @@ static int cas_rx_process_pkt(struct cas *cp, struct
>> cas_rx_comp *rxc, /* make sure we always copy a header */
>>   		swivel = 0;
>>   		if (p == (char *) skb->data) { /* not split */
>> -			addr = cas_page_map(page->buffer);
>> -			memcpy(p, addr + off, RX_COPY_MIN);
>> +			memcpy(p, page_address(page->buffer) + off,
>> +			       RX_COPY_MIN);
>>   			dma_sync_single_for_device(&cp->pdev->dev,
>>   						   page->dma_addr
> + off, i,
>>   						
> DMA_FROM_DEVICE);
>> -			cas_page_unmap(addr);
>>   			off += RX_COPY_MIN;
>>   			swivel = RX_COPY_MIN;
>>   			RX_USED_ADD(page, cp->mtu_stride);
>> @@ -2036,10 +2033,8 @@ static int cas_rx_process_pkt(struct cas *cp, struct
>> cas_rx_comp *rxc, RX_USED_ADD(page, hlen + cp->crc_size);
>>   		}
>>
>> -		if (cp->crc_size) {
>> -			addr = cas_page_map(page->buffer);
>> -			crcaddr  = addr + off + hlen;
>> -		}
>> +		if (cp->crc_size)
>> +			crcaddr = page_address(page->buffer) + off +
> hlen;
>>
>>   	} else {
>>   		/* copying packet */
>> @@ -2061,12 +2056,10 @@ static int cas_rx_process_pkt(struct cas *cp, struct
>> cas_rx_comp *rxc, i += cp->crc_size;
>>   		dma_sync_single_for_cpu(&cp->pdev->dev, page->dma_addr +
> off,
>>   					i, DMA_FROM_DEVICE);
>> -		addr = cas_page_map(page->buffer);
>> -		memcpy(p, addr + off, i);
>> +		memcpy(p, page_address(page->buffer) + off, i);
>>   		dma_sync_single_for_device(&cp->pdev->dev,
>>   					   page->dma_addr + off, i,
>>   					   DMA_FROM_DEVICE);
>> -		cas_page_unmap(addr);
>>   		if (p == (char *) skb->data) /* not split */
>>   			RX_USED_ADD(page, cp->mtu_stride);
>>   		else
>> @@ -2081,20 +2074,17 @@ static int cas_rx_process_pkt(struct cas *cp, struct
>> cas_rx_comp *rxc, page->dma_addr,
>>   						dlen + cp-
>> crc_size,
>>   						DMA_FROM_DEVICE);
>> -			addr = cas_page_map(page->buffer);
>> -			memcpy(p, addr, dlen + cp->crc_size);
>> +			memcpy(p, page_address(page->buffer), dlen + cp-
>> crc_size);
>>   			dma_sync_single_for_device(&cp->pdev->dev,
>>   						   page->dma_addr,
>>   						   dlen + cp-
>> crc_size,
>>   						
> DMA_FROM_DEVICE);
>> -			cas_page_unmap(addr);
>>   			RX_USED_ADD(page, dlen + cp->crc_size);
>>   		}
>>   end_copy_pkt:
>> -		if (cp->crc_size) {
>> -			addr    = NULL;
>> +		if (cp->crc_size)
>>   			crcaddr = skb->data + alloclen;
>> -		}
>> +
> 
> This is a different logical change. Some maintainers I met would have asked
> for a separate patch, but I'm OK with it being here.

cas_page_map()/cap_page_unmap() were using addr. Once these went away 
addr became unnecessary. It would be weird to leave the declaration, 
init and reinit for a variable that's not of any use, and so it was 
removed as well. It's cleaner this way.

Ani
Fabio M. De Francesco Nov. 18, 2022, 8:30 p.m. UTC | #3
On venerdì 18 novembre 2022 18:55:36 CET Anirudh Venkataramanan wrote:
> On 11/18/2022 12:35 AM, Fabio M. De Francesco wrote:
> > On giovedì 17 novembre 2022 23:25:55 CET Anirudh Venkataramanan wrote:
> >> Pages for Rx buffers are allocated in cas_page_alloc() using either
> >> GFP_ATOMIC or GFP_KERNEL. Memory allocated with GFP_KERNEL/GFP_ATOMIC
> >> can't come from highmem and so there's no need to kmap() them. Just use
> >> page_address() instead.
> >> 
> >> I don't have hardware, so this change has only been compile tested.
> >> 
> >> Cc: Ira Weiny <ira.weiny@intel.com>
> >> Cc: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> >> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
> >> ---
> >> 
> >>   drivers/net/ethernet/sun/cassini.c | 34 ++++++++++--------------------
> >>   1 file changed, 11 insertions(+), 23 deletions(-)
> >> 
> >> diff --git a/drivers/net/ethernet/sun/cassini.c
> >> b/drivers/net/ethernet/sun/cassini.c index 0aca193..2f66cfc 100644
> >> --- a/drivers/net/ethernet/sun/cassini.c
> >> +++ b/drivers/net/ethernet/sun/cassini.c
> >> @@ -1915,7 +1915,7 @@ static int cas_rx_process_pkt(struct cas *cp, 
struct
> >> cas_rx_comp *rxc, int off, swivel = RX_SWIVEL_OFF_VAL;
> >> 
> >>   	struct cas_page *page;
> >>   	struct sk_buff *skb;
> >> 
> >> -	void *addr, *crcaddr;
> >> +	void *crcaddr;
> >> 
> >>   	__sum16 csum;
> >>   	char *p;
> >> 
> >> @@ -1936,7 +1936,7 @@ static int cas_rx_process_pkt(struct cas *cp, 
struct
> >> cas_rx_comp *rxc, skb_reserve(skb, swivel);
> >> 
> >>   	p = skb->data;
> >> 
> >> -	addr = crcaddr = NULL;
> >> +	crcaddr = NULL;
> >> 
> >>   	if (hlen) { /* always copy header pages */
> >>   	
> >>   		i = CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
> >>   		page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)]
> > 
> > [CAS_VAL(RX_INDEX_NUM, i)];
> > 
> >> @@ -1948,12 +1948,10 @@ static int cas_rx_process_pkt(struct cas *cp,
> >> struct
> >> cas_rx_comp *rxc, i += cp->crc_size;
> >> 
> >>   		dma_sync_single_for_cpu(&cp->pdev->dev, page->dma_addr +
> > 
> > off,
> > 
> >>   					i, DMA_FROM_DEVICE);
> >> 
> >> -		addr = cas_page_map(page->buffer);
> >> -		memcpy(p, addr + off, i);
> >> +		memcpy(p, page_address(page->buffer) + off, i);
> >> 
> >>   		dma_sync_single_for_device(&cp->pdev->dev,
> >>   		
> >>   					   page->dma_addr + off, i,
> >>   					   DMA_FROM_DEVICE);
> >> 
> >> -		cas_page_unmap(addr);
> >> 
> >>   		RX_USED_ADD(page, 0x100);
> >>   		p += hlen;
> >>   		swivel = 0;
> >> 
> >> @@ -1984,12 +1982,11 @@ static int cas_rx_process_pkt(struct cas *cp,
> >> struct
> >> cas_rx_comp *rxc, /* make sure we always copy a header */
> >> 
> >>   		swivel = 0;
> >>   		if (p == (char *) skb->data) { /* not split */
> >> 
> >> -			addr = cas_page_map(page->buffer);
> >> -			memcpy(p, addr + off, RX_COPY_MIN);
> >> +			memcpy(p, page_address(page->buffer) + off,
> >> +			       RX_COPY_MIN);
> >> 
> >>   			dma_sync_single_for_device(&cp->pdev->dev,
> >>   			
> >>   						   page->dma_addr
> > 
> > + off, i,
> > 
> > DMA_FROM_DEVICE);
> > 
> >> -			cas_page_unmap(addr);
> >> 
> >>   			off += RX_COPY_MIN;
> >>   			swivel = RX_COPY_MIN;
> >>   			RX_USED_ADD(page, cp->mtu_stride);
> >> 
> >> @@ -2036,10 +2033,8 @@ static int cas_rx_process_pkt(struct cas *cp, 
struct
> >> cas_rx_comp *rxc, RX_USED_ADD(page, hlen + cp->crc_size);
> >> 
> >>   		}
> >> 
> >> -		if (cp->crc_size) {
> >> -			addr = cas_page_map(page->buffer);
> >> -			crcaddr  = addr + off + hlen;
> >> -		}
> >> +		if (cp->crc_size)
> >> +			crcaddr = page_address(page->buffer) + off +
> > 
> > hlen;
> > 
> >>   	} else {
> >>   	
> >>   		/* copying packet */
> >> 
> >> @@ -2061,12 +2056,10 @@ static int cas_rx_process_pkt(struct cas *cp,
> >> struct
> >> cas_rx_comp *rxc, i += cp->crc_size;
> >> 
> >>   		dma_sync_single_for_cpu(&cp->pdev->dev, page->dma_addr +
> > 
> > off,
> > 
> >>   					i, DMA_FROM_DEVICE);
> >> 
> >> -		addr = cas_page_map(page->buffer);
> >> -		memcpy(p, addr + off, i);
> >> +		memcpy(p, page_address(page->buffer) + off, i);
> >> 
> >>   		dma_sync_single_for_device(&cp->pdev->dev,
> >>   		
> >>   					   page->dma_addr + off, i,
> >>   					   DMA_FROM_DEVICE);
> >> 
> >> -		cas_page_unmap(addr);
> >> 
> >>   		if (p == (char *) skb->data) /* not split */
> >>   		
> >>   			RX_USED_ADD(page, cp->mtu_stride);
> >>   		
> >>   		else
> >> 
> >> @@ -2081,20 +2074,17 @@ static int cas_rx_process_pkt(struct cas *cp,
> >> struct
> >> cas_rx_comp *rxc, page->dma_addr,
> >> 
> >>   						dlen + cp-
> >> 
> >> crc_size,
> >> 
> >>   						DMA_FROM_DEVICE);
> >> 
> >> -			addr = cas_page_map(page->buffer);
> >> -			memcpy(p, addr, dlen + cp->crc_size);
> >> +			memcpy(p, page_address(page->buffer), dlen + cp-
> >> crc_size);
> >> 
> >>   			dma_sync_single_for_device(&cp->pdev->dev,
> >>   			
> >>   						   page->dma_addr,
> >>   						   dlen + cp-
> >> 
> >> crc_size,
> > 
> > DMA_FROM_DEVICE);
> > 
> >> -			cas_page_unmap(addr);
> >> 
> >>   			RX_USED_ADD(page, dlen + cp->crc_size);
> >>   		
> >>   		}
> >>   
> >>   end_copy_pkt:
> >> -		if (cp->crc_size) {
> >> -			addr    = NULL;
> >> +		if (cp->crc_size)
> >> 
> >>   			crcaddr = skb->data + alloclen;
> >> 
> >> -		}
> >> +
> > 
> > This is a different logical change. Some maintainers I met would have 
asked
> > for a separate patch, but I'm OK with it being here.
> 
> cas_page_map()/cap_page_unmap() were using addr. Once these went away
> addr became unnecessary. It would be weird to leave the declaration,
> init and reinit for a variable that's not of any use, and so it was
> removed as well. It's cleaner this way.
> 
> Ani

Oh, sorry. You are right here. I didn't notice this connection. I probably 
took too little time to read your code carefully and interpreted those two 
lines another way :-(

Thanks,

Fabio
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 0aca193..2f66cfc 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -1915,7 +1915,7 @@  static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 	int off, swivel = RX_SWIVEL_OFF_VAL;
 	struct cas_page *page;
 	struct sk_buff *skb;
-	void *addr, *crcaddr;
+	void *crcaddr;
 	__sum16 csum;
 	char *p;
 
@@ -1936,7 +1936,7 @@  static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 	skb_reserve(skb, swivel);
 
 	p = skb->data;
-	addr = crcaddr = NULL;
+	crcaddr = NULL;
 	if (hlen) { /* always copy header pages */
 		i = CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
 		page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
@@ -1948,12 +1948,10 @@  static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 			i += cp->crc_size;
 		dma_sync_single_for_cpu(&cp->pdev->dev, page->dma_addr + off,
 					i, DMA_FROM_DEVICE);
-		addr = cas_page_map(page->buffer);
-		memcpy(p, addr + off, i);
+		memcpy(p, page_address(page->buffer) + off, i);
 		dma_sync_single_for_device(&cp->pdev->dev,
 					   page->dma_addr + off, i,
 					   DMA_FROM_DEVICE);
-		cas_page_unmap(addr);
 		RX_USED_ADD(page, 0x100);
 		p += hlen;
 		swivel = 0;
@@ -1984,12 +1982,11 @@  static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 		/* make sure we always copy a header */
 		swivel = 0;
 		if (p == (char *) skb->data) { /* not split */
-			addr = cas_page_map(page->buffer);
-			memcpy(p, addr + off, RX_COPY_MIN);
+			memcpy(p, page_address(page->buffer) + off,
+			       RX_COPY_MIN);
 			dma_sync_single_for_device(&cp->pdev->dev,
 						   page->dma_addr + off, i,
 						   DMA_FROM_DEVICE);
-			cas_page_unmap(addr);
 			off += RX_COPY_MIN;
 			swivel = RX_COPY_MIN;
 			RX_USED_ADD(page, cp->mtu_stride);
@@ -2036,10 +2033,8 @@  static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 			RX_USED_ADD(page, hlen + cp->crc_size);
 		}
 
-		if (cp->crc_size) {
-			addr = cas_page_map(page->buffer);
-			crcaddr  = addr + off + hlen;
-		}
+		if (cp->crc_size)
+			crcaddr = page_address(page->buffer) + off + hlen;
 
 	} else {
 		/* copying packet */
@@ -2061,12 +2056,10 @@  static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 			i += cp->crc_size;
 		dma_sync_single_for_cpu(&cp->pdev->dev, page->dma_addr + off,
 					i, DMA_FROM_DEVICE);
-		addr = cas_page_map(page->buffer);
-		memcpy(p, addr + off, i);
+		memcpy(p, page_address(page->buffer) + off, i);
 		dma_sync_single_for_device(&cp->pdev->dev,
 					   page->dma_addr + off, i,
 					   DMA_FROM_DEVICE);
-		cas_page_unmap(addr);
 		if (p == (char *) skb->data) /* not split */
 			RX_USED_ADD(page, cp->mtu_stride);
 		else
@@ -2081,20 +2074,17 @@  static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 						page->dma_addr,
 						dlen + cp->crc_size,
 						DMA_FROM_DEVICE);
-			addr = cas_page_map(page->buffer);
-			memcpy(p, addr, dlen + cp->crc_size);
+			memcpy(p, page_address(page->buffer), dlen + cp->crc_size);
 			dma_sync_single_for_device(&cp->pdev->dev,
 						   page->dma_addr,
 						   dlen + cp->crc_size,
 						   DMA_FROM_DEVICE);
-			cas_page_unmap(addr);
 			RX_USED_ADD(page, dlen + cp->crc_size);
 		}
 end_copy_pkt:
-		if (cp->crc_size) {
-			addr    = NULL;
+		if (cp->crc_size)
 			crcaddr = skb->data + alloclen;
-		}
+
 		skb_put(skb, alloclen);
 	}
 
@@ -2103,8 +2093,6 @@  static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 		/* checksum includes FCS. strip it out. */
 		csum = csum_fold(csum_partial(crcaddr, cp->crc_size,
 					      csum_unfold(csum)));
-		if (addr)
-			cas_page_unmap(addr);
 	}
 	skb->protocol = eth_type_trans(skb, cp->dev);
 	if (skb->protocol == htons(ETH_P_IP)) {