netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Joakim Zhang <qiangqing.zhang@nxp.com>
Cc: peppe.cavallaro@st.com, alexandre.torgue@st.com,
	joabreu@synopsys.com, davem@davemloft.net,
	netdev@vger.kernel.org, linux-imx@nxp.com
Subject: Re: [PATCH V4 net 3/5] net: stmmac: fix dma physical address of descriptor when display ring
Date: Sat, 6 Feb 2021 12:29:11 -0800	[thread overview]
Message-ID: <20210206122911.5037db4c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210204112144.24163-4-qiangqing.zhang@nxp.com>

On Thu,  4 Feb 2021 19:21:42 +0800 Joakim Zhang wrote:
> Driver uses dma_alloc_coherent to allocate dma memory for descriptors,
> dma_alloc_coherent will return both the virtual address and physical
> address. AFAIK, virt_to_phys could not convert virtual address to
> physical address, for which memory is allocated by dma_alloc_coherent.
> 
> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>

What does this patch fix? Theoretically incorrect value in a debug dump
or are you actually observing incorrect behavior?

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> index c6540b003b43..6f951adc5f90 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> @@ -402,7 +402,8 @@ static void dwmac4_rd_set_tx_ic(struct dma_desc *p)
>  	p->des2 |= cpu_to_le32(TDES2_INTERRUPT_ON_COMPLETION);
>  }
>  
> -static void dwmac4_display_ring(void *head, unsigned int size, bool rx)
> +static void dwmac4_display_ring(void *head, unsigned int size, bool rx,
> +				dma_addr_t dma_rx_phy, unsigned int desc_size)
>  {
>  	struct dma_desc *p = (struct dma_desc *)head;
>  	int i;
> @@ -410,8 +411,8 @@ static void dwmac4_display_ring(void *head, unsigned int size, bool rx)
>  	pr_info("%s descriptor ring:\n", rx ? "RX" : "TX");
>  
>  	for (i = 0; i < size; i++) {
> -		pr_info("%03d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n",
> -			i, (unsigned int)virt_to_phys(p),
> +		pr_info("%03d [0x%llx]: 0x%x 0x%x 0x%x 0x%x\n",
> +			i, (unsigned long long)(dma_rx_phy + i * desc_size),
>  			le32_to_cpu(p->des0), le32_to_cpu(p->des1),
>  			le32_to_cpu(p->des2), le32_to_cpu(p->des3));
>  		p++;

Why do you pass the desc_size in? The virt memory pointer is incremented
by sizeof(*p) surely

	dma_addr + i * sizeof(*p) 

would work correctly? Also please use the correct print format for
dma_addr_t, you shouldn't have to cast.

  reply	other threads:[~2021-02-06 20:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 11:21 [PATCH V4 net 0/5] ethernet: fixes for stmmac driver Joakim Zhang
2021-02-04 11:21 ` [PATCH V4 net 1/5] net: stmmac: stop each tx channel independently Joakim Zhang
2021-02-04 11:21 ` [PATCH V4 net 2/5] net: stmmac: fix watchdog timeout during suspend/resume stress test Joakim Zhang
2021-02-04 11:21 ` [PATCH V4 net 3/5] net: stmmac: fix dma physical address of descriptor when display ring Joakim Zhang
2021-02-06 20:29   ` Jakub Kicinski [this message]
2021-02-20  7:43     ` Joakim Zhang
2021-02-22 19:46       ` Jakub Kicinski
2021-02-23  7:10         ` Joakim Zhang
2021-02-04 11:21 ` [PATCH V4 net 4/5] net: stmmac: fix wrongly set buffer2 valid when sph unsupport Joakim Zhang
2021-02-04 11:21 ` [PATCH V4 net 5/5] net: stmmac: re-init rx buffers when mac resume back Joakim Zhang
2021-02-06 20:38   ` Jakub Kicinski
2021-02-20  7:52     ` Joakim Zhang
2021-02-22 19:47       ` Jakub Kicinski
2021-02-23  7:16         ` Joakim Zhang

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=20210206122911.5037db4c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=alexandre.torgue@st.com \
    --cc=davem@davemloft.net \
    --cc=joabreu@synopsys.com \
    --cc=linux-imx@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=qiangqing.zhang@nxp.com \
    /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).