[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <DB8PR04MB679592B0547495108BBADBD5E6AA0@DB8PR04MB6795.eurprd04.prod.outlook.com>
Date: Tue, 12 Jan 2021 01:41:36 +0000
From: Joakim Zhang <qiangqing.zhang@....com>
To: Florian Fainelli <f.fainelli@...il.com>,
"peppe.cavallaro@...com" <peppe.cavallaro@...com>,
"alexandre.torgue@...com" <alexandre.torgue@...com>,
"joabreu@...opsys.com" <joabreu@...opsys.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"kuba@...nel.org" <kuba@...nel.org>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
dl-linux-imx <linux-imx@....com>
Subject: RE: [PATCH 4/6] ethernet: stmmac: fix dma physical address of
descriptor when display ring
> -----Original Message-----
> From: Florian Fainelli <f.fainelli@...il.com>
> Sent: 2021年1月12日 1:30
> To: Joakim Zhang <qiangqing.zhang@....com>; peppe.cavallaro@...com;
> alexandre.torgue@...com; joabreu@...opsys.com; davem@...emloft.net;
> kuba@...nel.org
> Cc: netdev@...r.kernel.org; dl-linux-imx <linux-imx@....com>
> Subject: Re: [PATCH 4/6] ethernet: stmmac: fix dma physical address of
> descriptor when display ring
>
> On 1/11/21 3:35 AM, 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@....com>
> > ---
> > .../ethernet/stmicro/stmmac/dwmac4_descs.c | 5 +-
> > .../net/ethernet/stmicro/stmmac/enh_desc.c | 5 +-
> > drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 +-
> > .../net/ethernet/stmicro/stmmac/norm_desc.c | 5 +-
> > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 50
> > ++++++++++++-------
> > 5 files changed, 44 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> > b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> > index c6540b003b43..8e1ee33ba1e6 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,
> > + unsigned int dma_rx_phy, unsigned int desc_size)
> > {
> > struct dma_desc *p = (struct dma_desc *)head;
> > int i;
> > @@ -411,7 +412,7 @@ static void dwmac4_display_ring(void *head,
> > unsigned int size, bool rx)
> >
> > 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),
> > + i, (unsigned int)(dma_rx_phy + i * desc_size),
>
> This code will probably not work correctly on a machine with physical addresses
> greater than 32-bit anyway and the address bits would be truncated then,
> cannot you use a phy_addr_t or dma_addr_t and use %pa as far as the printk
> format goes?
Thanks, I will fix it.
Best Regards,
Joakim Zhang
> --
> Florian
Powered by blists - more mailing lists