netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: netdev@vger.kernel.org,
	Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>,
	Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Subject: Re: [PATCH net-next 3/5] cassini: Remove unnecessary use of kmap_atomic()
Date: Fri, 18 Nov 2022 09:35:05 +0100	[thread overview]
Message-ID: <3752791.kQq0lBPeGt@suse> (raw)
In-Reply-To: <20221117222557.2196195-4-anirudh.venkataramanan@intel.com>

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




  reply	other threads:[~2022-11-18  8:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 22:25 [PATCH net-next 0/5] Remove uses of kmap_atomic() Anirudh Venkataramanan
2022-11-17 22:25 ` [PATCH net-next 1/5] ch_ktls: Use kmap_local_page() instead " Anirudh Venkataramanan
2022-11-18  8:14   ` Fabio M. De Francesco
2022-11-18 18:27     ` Anirudh Venkataramanan
2022-11-18 20:18       ` Fabio M. De Francesco
2022-11-18 20:38         ` Anirudh Venkataramanan
2022-11-19  1:22   ` Ira Weiny
2022-11-17 22:25 ` [PATCH net-next 2/5] sfc: " Anirudh Venkataramanan
2022-11-18  8:23   ` Fabio M. De Francesco
2022-11-18 17:47     ` Anirudh Venkataramanan
2022-11-18 19:26       ` Fabio M. De Francesco
2022-11-18 20:34         ` Anirudh Venkataramanan
2022-11-19  1:25   ` Ira Weiny
2022-11-17 22:25 ` [PATCH net-next 3/5] cassini: Remove unnecessary use " Anirudh Venkataramanan
2022-11-18  8:35   ` Fabio M. De Francesco [this message]
2022-11-18 17:55     ` Anirudh Venkataramanan
2022-11-18 20:30       ` Fabio M. De Francesco
2022-11-17 22:25 ` [PATCH net-next 4/5] cassini: Use kmap_local_page() instead " Anirudh Venkataramanan
2022-11-18  8:53   ` Fabio M. De Francesco
2022-11-17 22:25 ` [PATCH net-next 5/5] sunvnet: " Anirudh Venkataramanan
2022-11-18  9:11   ` Fabio M. De Francesco
2022-11-18 20:45     ` Fabio M. De Francesco
2022-11-19  0:47       ` Anirudh Venkataramanan
2022-11-22 11:29 ` [PATCH net-next 0/5] Remove uses " Leon Romanovsky
2022-11-22 18:50   ` Jakub Kicinski
2022-11-22 21:06     ` Anirudh Venkataramanan
2022-11-23  7:34       ` Leon Romanovsky
2022-11-23 18:38         ` Anirudh Venkataramanan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3752791.kQq0lBPeGt@suse \
    --to=fmdefrancesco@gmail.com \
    --cc=anirudh.venkataramanan@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).