diff mbox series

[net-next,v7,1/9] net: stmmac: Pass stmmac_priv and chan in some callbacks

Message ID 8414049581ed11a2466dc75e0e1f2ef4be7d0fd9.1702990507.git.siyanteng@loongson.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series stmmac: Add Loongson platform support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 1144 this patch: 47
netdev/cc_maintainers warning 10 maintainers not CCed: edumazet@google.com linux-stm32@st-md-mailman.stormreply.com jernej.skrabec@gmail.com pabeni@redhat.com kuba@kernel.org samuel@sholland.org wens@csie.org mcoquelin.stm32@gmail.com linux-arm-kernel@lists.infradead.org linux-sunxi@lists.linux.dev
netdev/build_clang fail Errors and warnings before: 12 this patch: 21
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 1172 this patch: 48
netdev/checkpatch warning WARNING: line length of 85 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yanteng Si Dec. 19, 2023, 2:17 p.m. UTC
Loongson GMAC and GNET have some special features. To prepare for that,
pass stmmac_priv and chan to more callbacks, and adjust the callbacks
accordingly.

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c   |  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c |  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c  |  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c    |  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h     |  3 ++-
 drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c     |  3 ++-
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c  |  2 +-
 drivers/net/ethernet/stmicro/stmmac/hwif.h          | 11 ++++++-----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   |  6 +++---
 9 files changed, 18 insertions(+), 15 deletions(-)

Comments

Simon Horman Dec. 20, 2023, 3:08 p.m. UTC | #1
On Tue, Dec 19, 2023 at 10:17:04PM +0800, Yanteng Si wrote:
> Loongson GMAC and GNET have some special features. To prepare for that,
> pass stmmac_priv and chan to more callbacks, and adjust the callbacks
> accordingly.
> 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c   |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c  |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c    |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h     |  3 ++-
>  drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c     |  3 ++-
>  drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c  |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/hwif.h          | 11 ++++++-----
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   |  6 +++---
>  9 files changed, 18 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 137741b94122..7cdfa0bdb93a 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -395,7 +395,7 @@ static void sun8i_dwmac_dma_start_tx(struct stmmac_priv *priv,
>  	writel(v, ioaddr + EMAC_TX_CTL1);
>  }
>  
> -static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr)
> +static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr, u32 chan)
>  {
>  	u32 v;
>  

Hi Yanteng Si,

perhaps dwmac-sun8i.c needs to be further updated for this change?

  .../dwmac-sun8i.c:568:10: error: incompatible function pointer types initializing 'void (*)(struct stmmac_priv *, void *, struct stmmac_dma_cfg *, int)' with an expression of type 'void (void *, struct stmmac_dma_cfg *, int)' [-Wincompatible-function-pointer-types]
    568 |         .init = sun8i_dwmac_dma_init,
        |                 ^~~~~~~~~~~~~~~~~~~~
  .../dwmac-sun8i.c:574:29: error: incompatible function pointer types initializing 'void (*)(struct stmmac_priv *, void *, u32)' (aka 'void (*)(struct stmmac_priv *, void *, unsigned int)') with an expression of type 'void (void *, u32)' (aka 'void (void *, unsigned int)') [-Wincompatible-function-pointer-types]
    574 |         .enable_dma_transmission = sun8i_dwmac_enable_dma_transmission,
        |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2 errors generated.
Serge Semin Dec. 20, 2023, 6:18 p.m. UTC | #2
Hi Yanteng

On Tue, Dec 19, 2023 at 10:17:04PM +0800, Yanteng Si wrote:
> Loongson GMAC and GNET have some special features. To prepare for that,
> pass stmmac_priv and chan to more callbacks, and adjust the callbacks
> accordingly.
> 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c   |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c  |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c    |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h     |  3 ++-
>  drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c     |  3 ++-
>  drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c  |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/hwif.h          | 11 ++++++-----
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   |  6 +++---
>  9 files changed, 18 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 137741b94122..7cdfa0bdb93a 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -395,7 +395,7 @@ static void sun8i_dwmac_dma_start_tx(struct stmmac_priv *priv,
>  	writel(v, ioaddr + EMAC_TX_CTL1);
>  }
>  

> -static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr)
> +static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr, u32 chan)

As Simon correctly noted this prototype is incomplete. Although AFAICS
you never use a pointer to stmmac_priv in this method. So I guess you
could fix the callback prototype instead.

>  {
>  	u32 v;
>  
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> index daf79cdbd3ec..5e80d3eec9db 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> @@ -70,7 +70,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
>  	writel(value, ioaddr + DMA_AXI_BUS_MODE);
>  }
>  
> -static void dwmac1000_dma_init(void __iomem *ioaddr,
> +static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>  			       struct stmmac_dma_cfg *dma_cfg, int atds)
>  {
>  	u32 value = readl(ioaddr + DMA_BUS_MODE);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
> index dea270f60cc3..105e7d4d798f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
> @@ -18,7 +18,7 @@
>  #include "dwmac100.h"
>  #include "dwmac_dma.h"
>  
> -static void dwmac100_dma_init(void __iomem *ioaddr,
> +static void dwmac100_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>  			      struct stmmac_dma_cfg *dma_cfg, int atds)
>  {
>  	/* Enable Application Access by writing to DMA CSR0 */
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
> index 84d3a8551b03..dc54c4e793fd 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
> @@ -152,7 +152,7 @@ static void dwmac410_dma_init_channel(struct stmmac_priv *priv,
>  	       ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan));
>  }
>  
> -static void dwmac4_dma_init(void __iomem *ioaddr,
> +static void dwmac4_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>  			    struct stmmac_dma_cfg *dma_cfg, int atds)
>  {
>  	u32 value = readl(ioaddr + DMA_SYS_BUS_MODE);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
> index 72672391675f..e7aef136824b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
> @@ -152,7 +152,8 @@
>  #define NUM_DWMAC1000_DMA_REGS	23
>  #define NUM_DWMAC4_DMA_REGS	27
>  
> -void dwmac_enable_dma_transmission(void __iomem *ioaddr);
> +void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
> +				   void __iomem *ioaddr, u32 chan);
>  void dwmac_enable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
>  			  u32 chan, bool rx, bool tx);
>  void dwmac_disable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
> index 7907d62d3437..2f0df16fb7e4 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
> @@ -28,7 +28,8 @@ int dwmac_dma_reset(void __iomem *ioaddr)
>  }
>  
>  /* CSR1 enables the transmit DMA to check for new descriptor */
> -void dwmac_enable_dma_transmission(void __iomem *ioaddr)
> +void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
> +				   void __iomem *ioaddr, u32 chan)
>  {
>  	writel(1, ioaddr + DMA_XMT_POLL_DEMAND);
>  }
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
> index 3cde695fec91..a06f9573876f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
> @@ -19,7 +19,7 @@ static int dwxgmac2_dma_reset(void __iomem *ioaddr)
>  				  !(value & XGMAC_SWR), 0, 100000);
>  }
>  
> -static void dwxgmac2_dma_init(void __iomem *ioaddr,
> +static void dwxgmac2_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>  			      struct stmmac_dma_cfg *dma_cfg, int atds)
>  {
>  	u32 value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> index 7be04b54738b..a44aa3671fb8 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> @@ -175,8 +175,8 @@ struct dma_features;
>  struct stmmac_dma_ops {
>  	/* DMA core initialization */
>  	int (*reset)(void __iomem *ioaddr);

> -	void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
> -		     int atds);
> +	void (*init)(struct stmmac_priv *priv, void __iomem *ioaddr,
> +		     struct stmmac_dma_cfg *dma_cfg, int atds);

There is a good chance this change is also unnecessary. I'll post my
comment about that to Patch 4/9.

>  	void (*init_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
>  			  struct stmmac_dma_cfg *dma_cfg, u32 chan);
>  	void (*init_rx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
> @@ -198,7 +198,8 @@ struct stmmac_dma_ops {
>  	/* To track extra statistic (if supported) */
>  	void (*dma_diagnostic_fr)(struct stmmac_extra_stats *x,
>  				  void __iomem *ioaddr);


> -	void (*enable_dma_transmission) (void __iomem *ioaddr);
> +	void (*enable_dma_transmission)(struct stmmac_priv *priv,
> +					void __iomem *ioaddr, u32 chan);

Why do you need the pointer to the stmmac_priv structure instance
here? I failed to find a place you using it in the subsequent patches.

* Sigh, just a general note in case if somebody would wish to make
* things a bit more optimised and less complicated. The purpose of the
* enable_dma_transmission() callback is to re-activate the DMA-engine
* - exit from suspension and start poll-demanding the DMA descriptors.
* In QoS GMAC and XGMAC the same is done by updating the Tx tail
* pointer.  It's implemented in stmmac_set_tx_tail_ptr(). So basically
* both stmmac_enable_dma_transmission() and stmmac_set_tx_tail_ptr()
* should be almost always called side-by-side. Alas the current
* generic driver part doesn't do that. If it did in a some common way
* you wouldn't have needed the enable_dma_transmission() update
* because it would have already been updated to accept the
* channel/queue parameter.

-Serge(y)

>  	void (*enable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
>  			       u32 chan, bool rx, bool tx);
>  	void (*disable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
> @@ -240,7 +241,7 @@ struct stmmac_dma_ops {
>  };
>  
>  #define stmmac_dma_init(__priv, __args...) \
> -	stmmac_do_void_callback(__priv, dma, init, __args)
> +	stmmac_do_void_callback(__priv, dma, init, __priv, __args)
>  #define stmmac_init_chan(__priv, __args...) \
>  	stmmac_do_void_callback(__priv, dma, init_chan, __priv, __args)
>  #define stmmac_init_rx_chan(__priv, __args...) \
> @@ -258,7 +259,7 @@ struct stmmac_dma_ops {
>  #define stmmac_dma_diagnostic_fr(__priv, __args...) \
>  	stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args)
>  #define stmmac_enable_dma_transmission(__priv, __args...) \
> -	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args)
> +	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __priv, __args)
>  #define stmmac_enable_dma_irq(__priv, __args...) \
>  	stmmac_do_void_callback(__priv, dma, enable_dma_irq, __priv, __args)
>  #define stmmac_disable_dma_irq(__priv, __args...) \
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 47de466e432c..d868eb8dafc5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2558,7 +2558,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
>  				       true, priv->mode, true, true,
>  				       xdp_desc.len);
>  
> -		stmmac_enable_dma_transmission(priv, priv->ioaddr);
> +		stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>  
>  		xsk_tx_metadata_to_compl(meta,
>  					 &tx_q->tx_skbuff_dma[entry].xsk_meta);
> @@ -4679,7 +4679,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
>  
>  	netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
>  
> -	stmmac_enable_dma_transmission(priv, priv->ioaddr);
> +	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>  
>  	stmmac_flush_tx_descriptors(priv, queue);
>  	stmmac_tx_timer_arm(priv, queue);
> @@ -4899,7 +4899,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
>  		u64_stats_update_end_irqrestore(&txq_stats->syncp, flags);
>  	}
>  
> -	stmmac_enable_dma_transmission(priv, priv->ioaddr);
> +	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>  
>  	entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
>  	tx_q->cur_tx = entry;
> -- 
> 2.31.4
>
Yanteng Si Dec. 21, 2023, 9:40 a.m. UTC | #3
在 2023/12/20 23:08, Simon Horman 写道:
> On Tue, Dec 19, 2023 at 10:17:04PM +0800, Yanteng Si wrote:
>> Loongson GMAC and GNET have some special features. To prepare for that,
>> pass stmmac_priv and chan to more callbacks, and adjust the callbacks
>> accordingly.
>>
>> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
>> Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
>> Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
>> ---
>>   drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c   |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c  |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c    |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h     |  3 ++-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c     |  3 ++-
>>   drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c  |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/hwif.h          | 11 ++++++-----
>>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   |  6 +++---
>>   9 files changed, 18 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>> index 137741b94122..7cdfa0bdb93a 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>> @@ -395,7 +395,7 @@ static void sun8i_dwmac_dma_start_tx(struct stmmac_priv *priv,
>>   	writel(v, ioaddr + EMAC_TX_CTL1);
>>   }
>>   
>> -static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr)
>> +static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr, u32 chan)
>>   {
>>   	u32 v;
>>   
> Hi Yanteng Si,
>
> perhaps dwmac-sun8i.c needs to be further updated for this change?
>
>    .../dwmac-sun8i.c:568:10: error: incompatible function pointer types initializing 'void (*)(struct stmmac_priv *, void *, struct stmmac_dma_cfg *, int)' with an expression of type 'void (void *, struct stmmac_dma_cfg *, int)' [-Wincompatible-function-pointer-types]
>      568 |         .init = sun8i_dwmac_dma_init,
>          |                 ^~~~~~~~~~~~~~~~~~~~
>    .../dwmac-sun8i.c:574:29: error: incompatible function pointer types initializing 'void (*)(struct stmmac_priv *, void *, u32)' (aka 'void (*)(struct stmmac_priv *, void *, unsigned int)') with an expression of type 'void (void *, u32)' (aka 'void (void *, unsigned int)') [-Wincompatible-function-pointer-types]
>      574 |         .enable_dma_transmission = sun8i_dwmac_enable_dma_transmission,
>          |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    2 errors generated.

Sorry, I'll fix it.


Thanks,

Yanteng
Yanteng Si Dec. 21, 2023, 11:50 a.m. UTC | #4
在 2023/12/21 02:18, Serge Semin 写道:
> Hi Yanteng
>
> On Tue, Dec 19, 2023 at 10:17:04PM +0800, Yanteng Si wrote:
>> Loongson GMAC and GNET have some special features. To prepare for that,
>> pass stmmac_priv and chan to more callbacks, and adjust the callbacks
>> accordingly.
>>
>> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
>> Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
>> Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
>> ---
>>   drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c   |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c  |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c    |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h     |  3 ++-
>>   drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c     |  3 ++-
>>   drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c  |  2 +-
>>   drivers/net/ethernet/stmicro/stmmac/hwif.h          | 11 ++++++-----
>>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   |  6 +++---
>>   9 files changed, 18 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>> index 137741b94122..7cdfa0bdb93a 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>> @@ -395,7 +395,7 @@ static void sun8i_dwmac_dma_start_tx(struct stmmac_priv *priv,
>>   	writel(v, ioaddr + EMAC_TX_CTL1);
>>   }
>>   
>> -static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr)
>> +static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr, u32 chan)
> As Simon correctly noted this prototype is incomplete. Although AFAICS
> you never use a pointer to stmmac_priv in this method. So I guess you
> could fix the callback prototype instead.
>
>>   {
>>   	u32 v;
>>   
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
>> index daf79cdbd3ec..5e80d3eec9db 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
>> @@ -70,7 +70,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
>>   	writel(value, ioaddr + DMA_AXI_BUS_MODE);
>>   }
>>   
>> -static void dwmac1000_dma_init(void __iomem *ioaddr,
>> +static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>>   			       struct stmmac_dma_cfg *dma_cfg, int atds)
>>   {
>>   	u32 value = readl(ioaddr + DMA_BUS_MODE);
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
>> index dea270f60cc3..105e7d4d798f 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
>> @@ -18,7 +18,7 @@
>>   #include "dwmac100.h"
>>   #include "dwmac_dma.h"
>>   
>> -static void dwmac100_dma_init(void __iomem *ioaddr,
>> +static void dwmac100_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>>   			      struct stmmac_dma_cfg *dma_cfg, int atds)
>>   {
>>   	/* Enable Application Access by writing to DMA CSR0 */
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
>> index 84d3a8551b03..dc54c4e793fd 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
>> @@ -152,7 +152,7 @@ static void dwmac410_dma_init_channel(struct stmmac_priv *priv,
>>   	       ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan));
>>   }
>>   
>> -static void dwmac4_dma_init(void __iomem *ioaddr,
>> +static void dwmac4_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>>   			    struct stmmac_dma_cfg *dma_cfg, int atds)
>>   {
>>   	u32 value = readl(ioaddr + DMA_SYS_BUS_MODE);
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
>> index 72672391675f..e7aef136824b 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
>> @@ -152,7 +152,8 @@
>>   #define NUM_DWMAC1000_DMA_REGS	23
>>   #define NUM_DWMAC4_DMA_REGS	27
>>   
>> -void dwmac_enable_dma_transmission(void __iomem *ioaddr);
>> +void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
>> +				   void __iomem *ioaddr, u32 chan);
>>   void dwmac_enable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
>>   			  u32 chan, bool rx, bool tx);
>>   void dwmac_disable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
>> index 7907d62d3437..2f0df16fb7e4 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
>> @@ -28,7 +28,8 @@ int dwmac_dma_reset(void __iomem *ioaddr)
>>   }
>>   
>>   /* CSR1 enables the transmit DMA to check for new descriptor */
>> -void dwmac_enable_dma_transmission(void __iomem *ioaddr)
>> +void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
>> +				   void __iomem *ioaddr, u32 chan)
>>   {
>>   	writel(1, ioaddr + DMA_XMT_POLL_DEMAND);
>>   }
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
>> index 3cde695fec91..a06f9573876f 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
>> @@ -19,7 +19,7 @@ static int dwxgmac2_dma_reset(void __iomem *ioaddr)
>>   				  !(value & XGMAC_SWR), 0, 100000);
>>   }
>>   
>> -static void dwxgmac2_dma_init(void __iomem *ioaddr,
>> +static void dwxgmac2_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>>   			      struct stmmac_dma_cfg *dma_cfg, int atds)
>>   {
>>   	u32 value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
>> index 7be04b54738b..a44aa3671fb8 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
>> @@ -175,8 +175,8 @@ struct dma_features;
>>   struct stmmac_dma_ops {
>>   	/* DMA core initialization */
>>   	int (*reset)(void __iomem *ioaddr);
>> -	void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
>> -		     int atds);
>> +	void (*init)(struct stmmac_priv *priv, void __iomem *ioaddr,
>> +		     struct stmmac_dma_cfg *dma_cfg, int atds);
> There is a good chance this change is also unnecessary. I'll post my
> comment about that to Patch 4/9.
>
>>   	void (*init_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
>>   			  struct stmmac_dma_cfg *dma_cfg, u32 chan);
>>   	void (*init_rx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
>> @@ -198,7 +198,8 @@ struct stmmac_dma_ops {
>>   	/* To track extra statistic (if supported) */
>>   	void (*dma_diagnostic_fr)(struct stmmac_extra_stats *x,
>>   				  void __iomem *ioaddr);
>
>> -	void (*enable_dma_transmission) (void __iomem *ioaddr);
>> +	void (*enable_dma_transmission)(struct stmmac_priv *priv,
>> +					void __iomem *ioaddr, u32 chan);
> Why do you need the pointer to the stmmac_priv structure instance
> here? I failed to find a place you using it in the subsequent patches.
it's here:

@@ -70,7 +70,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, 
struct stmmac_axi *axi)
      writel(value, ioaddr + DMA_AXI_BUS_MODE);
  }

-static void dwmac1000_dma_init(void __iomem *ioaddr,
+static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem 
*ioaddr,
                     struct stmmac_dma_cfg *dma_cfg, int atds)
  {
      u32 value = readl(ioaddr + DMA_BUS_MODE);

@@ -118,7 +118,10 @@ static void dwmac1000_dma_init(struct stmmac_priv 
*priv, void __iomem *ioaddr,

      u32 dma_intr_mask;

      /* Mask interrupts by writing to CSR7 */
-    dma_intr_mask = DMA_INTR_DEFAULT_MASK;
+    if (priv->plat->flags & STMMAC_FLAG_HAS_LGMAC)
+        dma_intr_mask = DMA_INTR_DEFAULT_MASK_LOONGSON;
+    else
+        dma_intr_mask = DMA_INTR_DEFAULT_MASK;

      dma_config(ioaddr + DMA_BUS_MODE, ioaddr + DMA_INTR_ENA,

                dma_cfg, dma_intr_mask, atds);


Thank you for all your comments, I need some time to understand. :)


Thanks,

Yanteng

>
> * Sigh, just a general note in case if somebody would wish to make
> * things a bit more optimised and less complicated. The purpose of the
> * enable_dma_transmission() callback is to re-activate the DMA-engine
> * - exit from suspension and start poll-demanding the DMA descriptors.
> * In QoS GMAC and XGMAC the same is done by updating the Tx tail
> * pointer.  It's implemented in stmmac_set_tx_tail_ptr(). So basically
> * both stmmac_enable_dma_transmission() and stmmac_set_tx_tail_ptr()
> * should be almost always called side-by-side. Alas the current
> * generic driver part doesn't do that. If it did in a some common way
> * you wouldn't have needed the enable_dma_transmission() update
> * because it would have already been updated to accept the
> * channel/queue parameter.
>
> -Serge(y)
>
>>   	void (*enable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
>>   			       u32 chan, bool rx, bool tx);
>>   	void (*disable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
>> @@ -240,7 +241,7 @@ struct stmmac_dma_ops {
>>   };
>>   
>>   #define stmmac_dma_init(__priv, __args...) \
>> -	stmmac_do_void_callback(__priv, dma, init, __args)
>> +	stmmac_do_void_callback(__priv, dma, init, __priv, __args)
>>   #define stmmac_init_chan(__priv, __args...) \
>>   	stmmac_do_void_callback(__priv, dma, init_chan, __priv, __args)
>>   #define stmmac_init_rx_chan(__priv, __args...) \
>> @@ -258,7 +259,7 @@ struct stmmac_dma_ops {
>>   #define stmmac_dma_diagnostic_fr(__priv, __args...) \
>>   	stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args)
>>   #define stmmac_enable_dma_transmission(__priv, __args...) \
>> -	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args)
>> +	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __priv, __args)
>>   #define stmmac_enable_dma_irq(__priv, __args...) \
>>   	stmmac_do_void_callback(__priv, dma, enable_dma_irq, __priv, __args)
>>   #define stmmac_disable_dma_irq(__priv, __args...) \
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> index 47de466e432c..d868eb8dafc5 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> @@ -2558,7 +2558,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
>>   				       true, priv->mode, true, true,
>>   				       xdp_desc.len);
>>   
>> -		stmmac_enable_dma_transmission(priv, priv->ioaddr);
>> +		stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>>   
>>   		xsk_tx_metadata_to_compl(meta,
>>   					 &tx_q->tx_skbuff_dma[entry].xsk_meta);
>> @@ -4679,7 +4679,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
>>   
>>   	netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
>>   
>> -	stmmac_enable_dma_transmission(priv, priv->ioaddr);
>> +	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>>   
>>   	stmmac_flush_tx_descriptors(priv, queue);
>>   	stmmac_tx_timer_arm(priv, queue);
>> @@ -4899,7 +4899,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
>>   		u64_stats_update_end_irqrestore(&txq_stats->syncp, flags);
>>   	}
>>   
>> -	stmmac_enable_dma_transmission(priv, priv->ioaddr);
>> +	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>>   
>>   	entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
>>   	tx_q->cur_tx = entry;
>> -- 
>> 2.31.4
>>
Serge Semin Dec. 21, 2023, 12:53 p.m. UTC | #5
On Thu, Dec 21, 2023 at 07:50:08PM +0800, Yanteng Si wrote:
> 
> 在 2023/12/21 02:18, Serge Semin 写道:
> > Hi Yanteng
> > 
> > On Tue, Dec 19, 2023 at 10:17:04PM +0800, Yanteng Si wrote:
> > > Loongson GMAC and GNET have some special features. To prepare for that,
> > > pass stmmac_priv and chan to more callbacks, and adjust the callbacks
> > > accordingly.
> > > 
> > > Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> > > Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> > > Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
> > > ---
> > >   drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c   |  2 +-
> > >   drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c |  2 +-
> > >   drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c  |  2 +-
> > >   drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c    |  2 +-
> > >   drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h     |  3 ++-
> > >   drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c     |  3 ++-
> > >   drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c  |  2 +-
> > >   drivers/net/ethernet/stmicro/stmmac/hwif.h          | 11 ++++++-----
> > >   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   |  6 +++---
> > >   9 files changed, 18 insertions(+), 15 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> > > index 137741b94122..7cdfa0bdb93a 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> > > @@ -395,7 +395,7 @@ static void sun8i_dwmac_dma_start_tx(struct stmmac_priv *priv,
> > >   	writel(v, ioaddr + EMAC_TX_CTL1);
> > >   }
> > > -static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr)
> > > +static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr, u32 chan)
> > As Simon correctly noted this prototype is incomplete. Although AFAICS
> > you never use a pointer to stmmac_priv in this method. So I guess you
> > could fix the callback prototype instead.
> > 
> > >   {
> > >   	u32 v;
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> > > index daf79cdbd3ec..5e80d3eec9db 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> > > @@ -70,7 +70,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
> > >   	writel(value, ioaddr + DMA_AXI_BUS_MODE);
> > >   }
> > > -static void dwmac1000_dma_init(void __iomem *ioaddr,
> > > +static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
> > >   			       struct stmmac_dma_cfg *dma_cfg, int atds)
> > >   {
> > >   	u32 value = readl(ioaddr + DMA_BUS_MODE);
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
> > > index dea270f60cc3..105e7d4d798f 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
> > > @@ -18,7 +18,7 @@
> > >   #include "dwmac100.h"
> > >   #include "dwmac_dma.h"
> > > -static void dwmac100_dma_init(void __iomem *ioaddr,
> > > +static void dwmac100_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
> > >   			      struct stmmac_dma_cfg *dma_cfg, int atds)
> > >   {
> > >   	/* Enable Application Access by writing to DMA CSR0 */
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
> > > index 84d3a8551b03..dc54c4e793fd 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
> > > @@ -152,7 +152,7 @@ static void dwmac410_dma_init_channel(struct stmmac_priv *priv,
> > >   	       ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan));
> > >   }
> > > -static void dwmac4_dma_init(void __iomem *ioaddr,
> > > +static void dwmac4_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
> > >   			    struct stmmac_dma_cfg *dma_cfg, int atds)
> > >   {
> > >   	u32 value = readl(ioaddr + DMA_SYS_BUS_MODE);
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
> > > index 72672391675f..e7aef136824b 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
> > > @@ -152,7 +152,8 @@
> > >   #define NUM_DWMAC1000_DMA_REGS	23
> > >   #define NUM_DWMAC4_DMA_REGS	27
> > > -void dwmac_enable_dma_transmission(void __iomem *ioaddr);
> > > +void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
> > > +				   void __iomem *ioaddr, u32 chan);
> > >   void dwmac_enable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
> > >   			  u32 chan, bool rx, bool tx);
> > >   void dwmac_disable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
> > > index 7907d62d3437..2f0df16fb7e4 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
> > > @@ -28,7 +28,8 @@ int dwmac_dma_reset(void __iomem *ioaddr)
> > >   }
> > >   /* CSR1 enables the transmit DMA to check for new descriptor */
> > > -void dwmac_enable_dma_transmission(void __iomem *ioaddr)
> > > +void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
> > > +				   void __iomem *ioaddr, u32 chan)
> > >   {
> > >   	writel(1, ioaddr + DMA_XMT_POLL_DEMAND);
> > >   }
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
> > > index 3cde695fec91..a06f9573876f 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
> > > @@ -19,7 +19,7 @@ static int dwxgmac2_dma_reset(void __iomem *ioaddr)
> > >   				  !(value & XGMAC_SWR), 0, 100000);
> > >   }
> > > -static void dwxgmac2_dma_init(void __iomem *ioaddr,
> > > +static void dwxgmac2_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
> > >   			      struct stmmac_dma_cfg *dma_cfg, int atds)
> > >   {
> > >   	u32 value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> > > index 7be04b54738b..a44aa3671fb8 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> > > @@ -175,8 +175,8 @@ struct dma_features;
> > >   struct stmmac_dma_ops {
> > >   	/* DMA core initialization */
> > >   	int (*reset)(void __iomem *ioaddr);
> > > -	void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
> > > -		     int atds);
> > > +	void (*init)(struct stmmac_priv *priv, void __iomem *ioaddr,
> > > +		     struct stmmac_dma_cfg *dma_cfg, int atds);
> > There is a good chance this change is also unnecessary. I'll post my
> > comment about that to Patch 4/9.
> > 
> > >   	void (*init_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
> > >   			  struct stmmac_dma_cfg *dma_cfg, u32 chan);
> > >   	void (*init_rx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
> > > @@ -198,7 +198,8 @@ struct stmmac_dma_ops {
> > >   	/* To track extra statistic (if supported) */
> > >   	void (*dma_diagnostic_fr)(struct stmmac_extra_stats *x,
> > >   				  void __iomem *ioaddr);
> > 
> > > -	void (*enable_dma_transmission) (void __iomem *ioaddr);
> > > +	void (*enable_dma_transmission)(struct stmmac_priv *priv,
> > > +					void __iomem *ioaddr, u32 chan);
> > Why do you need the pointer to the stmmac_priv structure instance
> > here? I failed to find a place you using it in the subsequent patches.
> it's here:
> 
> @@ -70,7 +70,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct
> stmmac_axi *axi)
>      writel(value, ioaddr + DMA_AXI_BUS_MODE);
>  }
> 


> -static void dwmac1000_dma_init(void __iomem *ioaddr,
> +static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem

Em, my comment was about enable_dma_transmission() ! I don't see you
using the stmmac_priv pointer in any updates for that method.

> *ioaddr,
>                     struct stmmac_dma_cfg *dma_cfg, int atds)
>  {
>      u32 value = readl(ioaddr + DMA_BUS_MODE);
> 
> @@ -118,7 +118,10 @@ static void dwmac1000_dma_init(struct stmmac_priv
> *priv, void __iomem *ioaddr,
> 
>      u32 dma_intr_mask;
> 
>      /* Mask interrupts by writing to CSR7 */
> -    dma_intr_mask = DMA_INTR_DEFAULT_MASK;
> +    if (priv->plat->flags & STMMAC_FLAG_HAS_LGMAC)
> +        dma_intr_mask = DMA_INTR_DEFAULT_MASK_LOONGSON;
> +    else
> +        dma_intr_mask = DMA_INTR_DEFAULT_MASK;
> 
>      dma_config(ioaddr + DMA_BUS_MODE, ioaddr + DMA_INTR_ENA,
> 
>                dma_cfg, dma_intr_mask, atds);
> 
> 

> Thank you for all your comments, I need some time to understand. :)

Don't hesitate to ask should any question arise in my comments regard.

-Serge(y)

> 
> 
> Thanks,
> 
> Yanteng
> 
> > 
> > * Sigh, just a general note in case if somebody would wish to make
> > * things a bit more optimised and less complicated. The purpose of the
> > * enable_dma_transmission() callback is to re-activate the DMA-engine
> > * - exit from suspension and start poll-demanding the DMA descriptors.
> > * In QoS GMAC and XGMAC the same is done by updating the Tx tail
> > * pointer.  It's implemented in stmmac_set_tx_tail_ptr(). So basically
> > * both stmmac_enable_dma_transmission() and stmmac_set_tx_tail_ptr()
> > * should be almost always called side-by-side. Alas the current
> > * generic driver part doesn't do that. If it did in a some common way
> > * you wouldn't have needed the enable_dma_transmission() update
> > * because it would have already been updated to accept the
> > * channel/queue parameter.
> > 
> > -Serge(y)
> > 
> > >   	void (*enable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
> > >   			       u32 chan, bool rx, bool tx);
> > >   	void (*disable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
> > > @@ -240,7 +241,7 @@ struct stmmac_dma_ops {
> > >   };
> > >   #define stmmac_dma_init(__priv, __args...) \
> > > -	stmmac_do_void_callback(__priv, dma, init, __args)
> > > +	stmmac_do_void_callback(__priv, dma, init, __priv, __args)
> > >   #define stmmac_init_chan(__priv, __args...) \
> > >   	stmmac_do_void_callback(__priv, dma, init_chan, __priv, __args)
> > >   #define stmmac_init_rx_chan(__priv, __args...) \
> > > @@ -258,7 +259,7 @@ struct stmmac_dma_ops {
> > >   #define stmmac_dma_diagnostic_fr(__priv, __args...) \
> > >   	stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args)
> > >   #define stmmac_enable_dma_transmission(__priv, __args...) \
> > > -	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args)
> > > +	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __priv, __args)
> > >   #define stmmac_enable_dma_irq(__priv, __args...) \
> > >   	stmmac_do_void_callback(__priv, dma, enable_dma_irq, __priv, __args)
> > >   #define stmmac_disable_dma_irq(__priv, __args...) \
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > index 47de466e432c..d868eb8dafc5 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > @@ -2558,7 +2558,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
> > >   				       true, priv->mode, true, true,
> > >   				       xdp_desc.len);
> > > -		stmmac_enable_dma_transmission(priv, priv->ioaddr);
> > > +		stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
> > >   		xsk_tx_metadata_to_compl(meta,
> > >   					 &tx_q->tx_skbuff_dma[entry].xsk_meta);
> > > @@ -4679,7 +4679,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
> > >   	netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
> > > -	stmmac_enable_dma_transmission(priv, priv->ioaddr);
> > > +	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
> > >   	stmmac_flush_tx_descriptors(priv, queue);
> > >   	stmmac_tx_timer_arm(priv, queue);
> > > @@ -4899,7 +4899,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
> > >   		u64_stats_update_end_irqrestore(&txq_stats->syncp, flags);
> > >   	}
> > > -	stmmac_enable_dma_transmission(priv, priv->ioaddr);
> > > +	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
> > >   	entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
> > >   	tx_q->cur_tx = entry;
> > > -- 
> > > 2.31.4
> > > 
>
Yanteng Si Dec. 21, 2023, 1:21 p.m. UTC | #6
在 2023/12/21 20:53, Serge Semin 写道:
> On Thu, Dec 21, 2023 at 07:50:08PM +0800, Yanteng Si wrote:
>> 在 2023/12/21 02:18, Serge Semin 写道:
>>> Hi Yanteng
>>>
>>> On Tue, Dec 19, 2023 at 10:17:04PM +0800, Yanteng Si wrote:
>>>> Loongson GMAC and GNET have some special features. To prepare for that,
>>>> pass stmmac_priv and chan to more callbacks, and adjust the callbacks
>>>> accordingly.
>>>>
>>>> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
>>>> Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
>>>> Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
>>>> ---
>>>>    drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c   |  2 +-
>>>>    drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c |  2 +-
>>>>    drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c  |  2 +-
>>>>    drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c    |  2 +-
>>>>    drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h     |  3 ++-
>>>>    drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c     |  3 ++-
>>>>    drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c  |  2 +-
>>>>    drivers/net/ethernet/stmicro/stmmac/hwif.h          | 11 ++++++-----
>>>>    drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   |  6 +++---
>>>>    9 files changed, 18 insertions(+), 15 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>>>> index 137741b94122..7cdfa0bdb93a 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
>>>> @@ -395,7 +395,7 @@ static void sun8i_dwmac_dma_start_tx(struct stmmac_priv *priv,
>>>>    	writel(v, ioaddr + EMAC_TX_CTL1);
>>>>    }
>>>> -static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr)
>>>> +static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr, u32 chan)
>>> As Simon correctly noted this prototype is incomplete. Although AFAICS
>>> you never use a pointer to stmmac_priv in this method. So I guess you
>>> could fix the callback prototype instead.
>>>
>>>>    {
>>>>    	u32 v;
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
>>>> index daf79cdbd3ec..5e80d3eec9db 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
>>>> @@ -70,7 +70,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
>>>>    	writel(value, ioaddr + DMA_AXI_BUS_MODE);
>>>>    }
>>>> -static void dwmac1000_dma_init(void __iomem *ioaddr,
>>>> +static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>>    			       struct stmmac_dma_cfg *dma_cfg, int atds)
>>>>    {
>>>>    	u32 value = readl(ioaddr + DMA_BUS_MODE);
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
>>>> index dea270f60cc3..105e7d4d798f 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
>>>> @@ -18,7 +18,7 @@
>>>>    #include "dwmac100.h"
>>>>    #include "dwmac_dma.h"
>>>> -static void dwmac100_dma_init(void __iomem *ioaddr,
>>>> +static void dwmac100_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>>    			      struct stmmac_dma_cfg *dma_cfg, int atds)
>>>>    {
>>>>    	/* Enable Application Access by writing to DMA CSR0 */
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
>>>> index 84d3a8551b03..dc54c4e793fd 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
>>>> @@ -152,7 +152,7 @@ static void dwmac410_dma_init_channel(struct stmmac_priv *priv,
>>>>    	       ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan));
>>>>    }
>>>> -static void dwmac4_dma_init(void __iomem *ioaddr,
>>>> +static void dwmac4_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>>    			    struct stmmac_dma_cfg *dma_cfg, int atds)
>>>>    {
>>>>    	u32 value = readl(ioaddr + DMA_SYS_BUS_MODE);
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
>>>> index 72672391675f..e7aef136824b 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
>>>> @@ -152,7 +152,8 @@
>>>>    #define NUM_DWMAC1000_DMA_REGS	23
>>>>    #define NUM_DWMAC4_DMA_REGS	27
>>>> -void dwmac_enable_dma_transmission(void __iomem *ioaddr);
>>>> +void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
>>>> +				   void __iomem *ioaddr, u32 chan);
>>>>    void dwmac_enable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>>    			  u32 chan, bool rx, bool tx);
>>>>    void dwmac_disable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
>>>> index 7907d62d3437..2f0df16fb7e4 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
>>>> @@ -28,7 +28,8 @@ int dwmac_dma_reset(void __iomem *ioaddr)
>>>>    }
>>>>    /* CSR1 enables the transmit DMA to check for new descriptor */
>>>> -void dwmac_enable_dma_transmission(void __iomem *ioaddr)
>>>> +void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
>>>> +				   void __iomem *ioaddr, u32 chan)
>>>>    {
>>>>    	writel(1, ioaddr + DMA_XMT_POLL_DEMAND);
>>>>    }
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
>>>> index 3cde695fec91..a06f9573876f 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
>>>> @@ -19,7 +19,7 @@ static int dwxgmac2_dma_reset(void __iomem *ioaddr)
>>>>    				  !(value & XGMAC_SWR), 0, 100000);
>>>>    }
>>>> -static void dwxgmac2_dma_init(void __iomem *ioaddr,
>>>> +static void dwxgmac2_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>>    			      struct stmmac_dma_cfg *dma_cfg, int atds)
>>>>    {
>>>>    	u32 value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
>>>> index 7be04b54738b..a44aa3671fb8 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
>>>> @@ -175,8 +175,8 @@ struct dma_features;
>>>>    struct stmmac_dma_ops {
>>>>    	/* DMA core initialization */
>>>>    	int (*reset)(void __iomem *ioaddr);
>>>> -	void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
>>>> -		     int atds);
>>>> +	void (*init)(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>> +		     struct stmmac_dma_cfg *dma_cfg, int atds);
>>> There is a good chance this change is also unnecessary. I'll post my
>>> comment about that to Patch 4/9.
>>>
>>>>    	void (*init_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>>    			  struct stmmac_dma_cfg *dma_cfg, u32 chan);
>>>>    	void (*init_rx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>> @@ -198,7 +198,8 @@ struct stmmac_dma_ops {
>>>>    	/* To track extra statistic (if supported) */
>>>>    	void (*dma_diagnostic_fr)(struct stmmac_extra_stats *x,
>>>>    				  void __iomem *ioaddr);
>>>> -	void (*enable_dma_transmission) (void __iomem *ioaddr);
>>>> +	void (*enable_dma_transmission)(struct stmmac_priv *priv,
>>>> +					void __iomem *ioaddr, u32 chan);
>>> Why do you need the pointer to the stmmac_priv structure instance
>>> here? I failed to find a place you using it in the subsequent patches.
>> it's here:
>>
>> @@ -70,7 +70,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct
>> stmmac_axi *axi)
>>       writel(value, ioaddr + DMA_AXI_BUS_MODE);
>>   }
>>
>
>> -static void dwmac1000_dma_init(void __iomem *ioaddr,
>> +static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem
> Em, my comment was about enable_dma_transmission() ! I don't see you
> using the stmmac_priv pointer in any updates for that method.

Oh! I see.

you're right, it will be removed.

>
>> *ioaddr,
>>                      struct stmmac_dma_cfg *dma_cfg, int atds)
>>   {
>>       u32 value = readl(ioaddr + DMA_BUS_MODE);
>>
>> @@ -118,7 +118,10 @@ static void dwmac1000_dma_init(struct stmmac_priv
>> *priv, void __iomem *ioaddr,
>>
>>       u32 dma_intr_mask;
>>
>>       /* Mask interrupts by writing to CSR7 */
>> -    dma_intr_mask = DMA_INTR_DEFAULT_MASK;
>> +    if (priv->plat->flags & STMMAC_FLAG_HAS_LGMAC)
>> +        dma_intr_mask = DMA_INTR_DEFAULT_MASK_LOONGSON;
>> +    else
>> +        dma_intr_mask = DMA_INTR_DEFAULT_MASK;
>>
>>       dma_config(ioaddr + DMA_BUS_MODE, ioaddr + DMA_INTR_ENA,
>>
>>                 dma_cfg, dma_intr_mask, atds);
>>
>>
>> Thank you for all your comments, I need some time to understand. :)
> Don't hesitate to ask should any question arise in my comments regard.

Ok, I will.


Thanks,

Yanteng

>
> -Serge(y)
>
>>
>> Thanks,
>>
>> Yanteng
>>
>>> * Sigh, just a general note in case if somebody would wish to make
>>> * things a bit more optimised and less complicated. The purpose of the
>>> * enable_dma_transmission() callback is to re-activate the DMA-engine
>>> * - exit from suspension and start poll-demanding the DMA descriptors.
>>> * In QoS GMAC and XGMAC the same is done by updating the Tx tail
>>> * pointer.  It's implemented in stmmac_set_tx_tail_ptr(). So basically
>>> * both stmmac_enable_dma_transmission() and stmmac_set_tx_tail_ptr()
>>> * should be almost always called side-by-side. Alas the current
>>> * generic driver part doesn't do that. If it did in a some common way
>>> * you wouldn't have needed the enable_dma_transmission() update
>>> * because it would have already been updated to accept the
>>> * channel/queue parameter.
>>>
>>> -Serge(y)
>>>
>>>>    	void (*enable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>>    			       u32 chan, bool rx, bool tx);
>>>>    	void (*disable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
>>>> @@ -240,7 +241,7 @@ struct stmmac_dma_ops {
>>>>    };
>>>>    #define stmmac_dma_init(__priv, __args...) \
>>>> -	stmmac_do_void_callback(__priv, dma, init, __args)
>>>> +	stmmac_do_void_callback(__priv, dma, init, __priv, __args)
>>>>    #define stmmac_init_chan(__priv, __args...) \
>>>>    	stmmac_do_void_callback(__priv, dma, init_chan, __priv, __args)
>>>>    #define stmmac_init_rx_chan(__priv, __args...) \
>>>> @@ -258,7 +259,7 @@ struct stmmac_dma_ops {
>>>>    #define stmmac_dma_diagnostic_fr(__priv, __args...) \
>>>>    	stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args)
>>>>    #define stmmac_enable_dma_transmission(__priv, __args...) \
>>>> -	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args)
>>>> +	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __priv, __args)
>>>>    #define stmmac_enable_dma_irq(__priv, __args...) \
>>>>    	stmmac_do_void_callback(__priv, dma, enable_dma_irq, __priv, __args)
>>>>    #define stmmac_disable_dma_irq(__priv, __args...) \
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>>> index 47de466e432c..d868eb8dafc5 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>>> @@ -2558,7 +2558,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
>>>>    				       true, priv->mode, true, true,
>>>>    				       xdp_desc.len);
>>>> -		stmmac_enable_dma_transmission(priv, priv->ioaddr);
>>>> +		stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>>>>    		xsk_tx_metadata_to_compl(meta,
>>>>    					 &tx_q->tx_skbuff_dma[entry].xsk_meta);
>>>> @@ -4679,7 +4679,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
>>>>    	netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
>>>> -	stmmac_enable_dma_transmission(priv, priv->ioaddr);
>>>> +	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>>>>    	stmmac_flush_tx_descriptors(priv, queue);
>>>>    	stmmac_tx_timer_arm(priv, queue);
>>>> @@ -4899,7 +4899,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
>>>>    		u64_stats_update_end_irqrestore(&txq_stats->syncp, flags);
>>>>    	}
>>>> -	stmmac_enable_dma_transmission(priv, priv->ioaddr);
>>>> +	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
>>>>    	entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
>>>>    	tx_q->cur_tx = entry;
>>>> -- 
>>>> 2.31.4
>>>>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 137741b94122..7cdfa0bdb93a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -395,7 +395,7 @@  static void sun8i_dwmac_dma_start_tx(struct stmmac_priv *priv,
 	writel(v, ioaddr + EMAC_TX_CTL1);
 }
 
-static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr)
+static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr, u32 chan)
 {
 	u32 v;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
index daf79cdbd3ec..5e80d3eec9db 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
@@ -70,7 +70,7 @@  static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
 	writel(value, ioaddr + DMA_AXI_BUS_MODE);
 }
 
-static void dwmac1000_dma_init(void __iomem *ioaddr,
+static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 			       struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	u32 value = readl(ioaddr + DMA_BUS_MODE);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
index dea270f60cc3..105e7d4d798f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
@@ -18,7 +18,7 @@ 
 #include "dwmac100.h"
 #include "dwmac_dma.h"
 
-static void dwmac100_dma_init(void __iomem *ioaddr,
+static void dwmac100_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 			      struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	/* Enable Application Access by writing to DMA CSR0 */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
index 84d3a8551b03..dc54c4e793fd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
@@ -152,7 +152,7 @@  static void dwmac410_dma_init_channel(struct stmmac_priv *priv,
 	       ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan));
 }
 
-static void dwmac4_dma_init(void __iomem *ioaddr,
+static void dwmac4_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 			    struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	u32 value = readl(ioaddr + DMA_SYS_BUS_MODE);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
index 72672391675f..e7aef136824b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
@@ -152,7 +152,8 @@ 
 #define NUM_DWMAC1000_DMA_REGS	23
 #define NUM_DWMAC4_DMA_REGS	27
 
-void dwmac_enable_dma_transmission(void __iomem *ioaddr);
+void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
+				   void __iomem *ioaddr, u32 chan);
 void dwmac_enable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
 			  u32 chan, bool rx, bool tx);
 void dwmac_disable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
index 7907d62d3437..2f0df16fb7e4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
@@ -28,7 +28,8 @@  int dwmac_dma_reset(void __iomem *ioaddr)
 }
 
 /* CSR1 enables the transmit DMA to check for new descriptor */
-void dwmac_enable_dma_transmission(void __iomem *ioaddr)
+void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
+				   void __iomem *ioaddr, u32 chan)
 {
 	writel(1, ioaddr + DMA_XMT_POLL_DEMAND);
 }
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
index 3cde695fec91..a06f9573876f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
@@ -19,7 +19,7 @@  static int dwxgmac2_dma_reset(void __iomem *ioaddr)
 				  !(value & XGMAC_SWR), 0, 100000);
 }
 
-static void dwxgmac2_dma_init(void __iomem *ioaddr,
+static void dwxgmac2_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 			      struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	u32 value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 7be04b54738b..a44aa3671fb8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -175,8 +175,8 @@  struct dma_features;
 struct stmmac_dma_ops {
 	/* DMA core initialization */
 	int (*reset)(void __iomem *ioaddr);
-	void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
-		     int atds);
+	void (*init)(struct stmmac_priv *priv, void __iomem *ioaddr,
+		     struct stmmac_dma_cfg *dma_cfg, int atds);
 	void (*init_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
 			  struct stmmac_dma_cfg *dma_cfg, u32 chan);
 	void (*init_rx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
@@ -198,7 +198,8 @@  struct stmmac_dma_ops {
 	/* To track extra statistic (if supported) */
 	void (*dma_diagnostic_fr)(struct stmmac_extra_stats *x,
 				  void __iomem *ioaddr);
-	void (*enable_dma_transmission) (void __iomem *ioaddr);
+	void (*enable_dma_transmission)(struct stmmac_priv *priv,
+					void __iomem *ioaddr, u32 chan);
 	void (*enable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
 			       u32 chan, bool rx, bool tx);
 	void (*disable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr,
@@ -240,7 +241,7 @@  struct stmmac_dma_ops {
 };
 
 #define stmmac_dma_init(__priv, __args...) \
-	stmmac_do_void_callback(__priv, dma, init, __args)
+	stmmac_do_void_callback(__priv, dma, init, __priv, __args)
 #define stmmac_init_chan(__priv, __args...) \
 	stmmac_do_void_callback(__priv, dma, init_chan, __priv, __args)
 #define stmmac_init_rx_chan(__priv, __args...) \
@@ -258,7 +259,7 @@  struct stmmac_dma_ops {
 #define stmmac_dma_diagnostic_fr(__priv, __args...) \
 	stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args)
 #define stmmac_enable_dma_transmission(__priv, __args...) \
-	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args)
+	stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __priv, __args)
 #define stmmac_enable_dma_irq(__priv, __args...) \
 	stmmac_do_void_callback(__priv, dma, enable_dma_irq, __priv, __args)
 #define stmmac_disable_dma_irq(__priv, __args...) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 47de466e432c..d868eb8dafc5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2558,7 +2558,7 @@  static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
 				       true, priv->mode, true, true,
 				       xdp_desc.len);
 
-		stmmac_enable_dma_transmission(priv, priv->ioaddr);
+		stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
 
 		xsk_tx_metadata_to_compl(meta,
 					 &tx_q->tx_skbuff_dma[entry].xsk_meta);
@@ -4679,7 +4679,7 @@  static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
 
-	stmmac_enable_dma_transmission(priv, priv->ioaddr);
+	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
 
 	stmmac_flush_tx_descriptors(priv, queue);
 	stmmac_tx_timer_arm(priv, queue);
@@ -4899,7 +4899,7 @@  static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
 		u64_stats_update_end_irqrestore(&txq_stats->syncp, flags);
 	}
 
-	stmmac_enable_dma_transmission(priv, priv->ioaddr);
+	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
 
 	entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
 	tx_q->cur_tx = entry;