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.zh...@nxp.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? -- Florian