mbox series

[0/6] ethernet: fixes for stmmac driver

Message ID 20210111113538.12077-1-qiangqing.zhang@nxp.com
Headers show
Series ethernet: fixes for stmmac driver | expand

Message

Joakim Zhang Jan. 11, 2021, 11:35 a.m. UTC
Fixes for stmmac driver.

Joakim Zhang (6):
  ethernet: stmmac: remove redundant null check for ptp clock
  ethernet: stmmac: stop each tx channal independently
  ethernet: stmmac: fix watchdog timeout during suspend/resume stress
    test
  ethernet: stmmac: fix dma physical address of descriptor when display
    ring
  ethernet: stmmac: fix wrongly set buffer2 valid when sph unsupport
  ethernet: stmmac: re-init rx buffers when mac resume back

 .../ethernet/stmicro/stmmac/dwmac4_descs.c    |  14 +-
 .../net/ethernet/stmicro/stmmac/dwmac4_lib.c  |   4 -
 .../ethernet/stmicro/stmmac/dwxgmac2_descs.c  |   2 +-
 .../net/ethernet/stmicro/stmmac/enh_desc.c    |   5 +-
 drivers/net/ethernet/stmicro/stmmac/hwif.h    |   5 +-
 .../net/ethernet/stmicro/stmmac/norm_desc.c   |   5 +-
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 136 +++++++++++++++---
 7 files changed, 134 insertions(+), 37 deletions(-)

Comments

Andrew Lunn Jan. 11, 2021, 5:13 p.m. UTC | #1
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
Florian Fainelli Jan. 11, 2021, 5:30 p.m. UTC | #2
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?
Joakim Zhang Jan. 12, 2021, 1:41 a.m. UTC | #3
> -----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