Message ID | 20210111113538.12077-1-qiangqing.zhang@nxp.com |
---|---|
Headers | show |
Series | ethernet: fixes for stmmac driver | expand |
On Mon, Jan 11, 2021 at 07:35:33PM +0800, Joakim Zhang wrote: > Remove redundant null check for ptp clock. > > Fixes: 1c35cc9cf6a0 ("net: stmmac: remove redundant null check before clk_disable_unprepare()") > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew
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@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?
> -----Original Message----- > From: Florian Fainelli <f.fainelli@gmail.com> > Sent: 2021年1月12日 1:30 > To: Joakim Zhang <qiangqing.zhang@nxp.com>; peppe.cavallaro@st.com; > alexandre.torgue@st.com; joabreu@synopsys.com; davem@davemloft.net; > kuba@kernel.org > Cc: netdev@vger.kernel.org; dl-linux-imx <linux-imx@nxp.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@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? Thanks, I will fix it. Best Regards, Joakim Zhang > -- > Florian