diff mbox series

[net-next,v3,10/10] net: stmmac: platform: support parsing per channel irq from DT

Message ID 20230809165007.1439-11-jszhang@kernel.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: stmmac: add new features to xgmac | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
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 success Errors and warnings before: 1330 this patch: 1330
netdev/cc_maintainers warning 1 maintainers not CCed: mcoquelin.stm32@gmail.com
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
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 success Errors and warnings before: 1353 this patch: 1353
netdev/checkpatch warning WARNING: line length of 89 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jisheng Zhang Aug. 9, 2023, 4:50 p.m. UTC
The snps dwmac IP may support per channel interrupt. Add support to
parse the per channel irq from DT.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++----
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 23 +++++++++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)

Comments

Alexandre TORGUE Aug. 10, 2023, 2:57 p.m. UTC | #1
On 8/9/23 18:50, Jisheng Zhang wrote:
> The snps dwmac IP may support per channel interrupt. Add support to
> parse the per channel irq from DT.
> 
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> ---
>   .../net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++----
>   .../ethernet/stmicro/stmmac/stmmac_platform.c | 23 +++++++++++++++++++
>   2 files changed, 29 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 4ed5c976c7a3..245eeb7d3e83 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3612,7 +3612,7 @@ static int stmmac_request_irq_multi(struct net_device *dev)
>   	for (i = 0; i < priv->plat->rx_queues_to_use; i++) {
>   		if (i >= MTL_MAX_RX_QUEUES)
>   			break;
> -		if (priv->rx_irq[i] == 0)
> +		if (priv->rx_irq[i] <= 0)

What do you fix here ?

>   			continue;
>   
>   		int_name = priv->int_name_rx_irq[i];
> @@ -3637,7 +3637,7 @@ static int stmmac_request_irq_multi(struct net_device *dev)
>   	for (i = 0; i < priv->plat->tx_queues_to_use; i++) {
>   		if (i >= MTL_MAX_TX_QUEUES)
>   			break;
> -		if (priv->tx_irq[i] == 0)
> +		if (priv->tx_irq[i] <= 0)

same here
>   			continue;
>   
>   		int_name = priv->int_name_tx_irq[i];
> @@ -7278,8 +7278,10 @@ int stmmac_dvr_probe(struct device *device,
>   	priv->plat = plat_dat;
>   	priv->ioaddr = res->addr;
>   	priv->dev->base_addr = (unsigned long)res->addr;
> -	priv->plat->dma_cfg->perch_irq_en =
> -		(priv->plat->flags & STMMAC_FLAG_PERCH_IRQ_EN);
> +	if (res->rx_irq[0] > 0 && res->tx_irq[0] > 0) {
> +		priv->plat->flags |= STMMAC_FLAG_PERCH_IRQ_EN;
> +		priv->plat->dma_cfg->perch_irq_en = true;
> +	}
>   
>   	priv->dev->irq = res->irq;
>   	priv->wol_irq = res->wol_irq;
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 29145682b57b..9b46775b41ab 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -705,6 +705,9 @@ EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
>   int stmmac_get_platform_resources(struct platform_device *pdev,
>   				  struct stmmac_resources *stmmac_res)
>   {
> +	char irq_name[8];
> +	int i;
> +
>   	memset(stmmac_res, 0, sizeof(*stmmac_res));
>   
>   	/* Get IRQ information early to have an ability to ask for deferred
> @@ -738,6 +741,26 @@ int stmmac_get_platform_resources(struct platform_device *pdev,
>   		dev_info(&pdev->dev, "IRQ eth_lpi not found\n");
>   	}
>   
> +	for (i = 0; i < MTL_MAX_RX_QUEUES; i++) {
> +		snprintf(irq_name, sizeof(irq_name), "rx%i", i);
> +		stmmac_res->rx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
> +		if (stmmac_res->rx_irq[i] < 0) {
> +			if (stmmac_res->rx_irq[i] == -EPROBE_DEFER)
> +				return -EPROBE_DEFER;
> +			break;
> +		}
> +	}
> +
> +	for (i = 0; i < MTL_MAX_TX_QUEUES; i++) {
> +		snprintf(irq_name, sizeof(irq_name), "tx%i", i);
> +		stmmac_res->tx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
> +		if (stmmac_res->tx_irq[i] < 0) {
> +			if (stmmac_res->tx_irq[i] == -EPROBE_DEFER)
> +				return -EPROBE_DEFER;
> +			break;
> +		}
> +	}
> +
>   	stmmac_res->sfty_ce_irq = platform_get_irq_byname_optional(pdev, "sfty_ce");
>   	if (stmmac_res->sfty_ce_irq < 0) {
>   		if (stmmac_res->sfty_ce_irq == -EPROBE_DEFER)
Jisheng Zhang Aug. 10, 2023, 4:09 p.m. UTC | #2
On Thu, Aug 10, 2023 at 04:57:00PM +0200, Alexandre TORGUE wrote:
> On 8/9/23 18:50, Jisheng Zhang wrote:
> > The snps dwmac IP may support per channel interrupt. Add support to
> > parse the per channel irq from DT.
> > 
> > Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> > ---
> >   .../net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++----
> >   .../ethernet/stmicro/stmmac/stmmac_platform.c | 23 +++++++++++++++++++
> >   2 files changed, 29 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index 4ed5c976c7a3..245eeb7d3e83 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -3612,7 +3612,7 @@ static int stmmac_request_irq_multi(struct net_device *dev)
> >   	for (i = 0; i < priv->plat->rx_queues_to_use; i++) {
> >   		if (i >= MTL_MAX_RX_QUEUES)
> >   			break;
> > -		if (priv->rx_irq[i] == 0)
> > +		if (priv->rx_irq[i] <= 0)
> 
> What do you fix here ?

No bug to fix, but adjust for parsing optional channel irqs from DT:
rx_irq[i] and tx_irq[i] may come from platform_get_irq_byname_optional()
so for !STMMAC_FLAG_PERCH_IRQ_EN platforms, they can be < 0. Before

Thanks
> 
> >   			continue;
> >   		int_name = priv->int_name_rx_irq[i];
> > @@ -3637,7 +3637,7 @@ static int stmmac_request_irq_multi(struct net_device *dev)
> >   	for (i = 0; i < priv->plat->tx_queues_to_use; i++) {
> >   		if (i >= MTL_MAX_TX_QUEUES)
> >   			break;
> > -		if (priv->tx_irq[i] == 0)
> > +		if (priv->tx_irq[i] <= 0)
> 
> same here
> >   			continue;
> >   		int_name = priv->int_name_tx_irq[i];
> > @@ -7278,8 +7278,10 @@ int stmmac_dvr_probe(struct device *device,
> >   	priv->plat = plat_dat;
> >   	priv->ioaddr = res->addr;
> >   	priv->dev->base_addr = (unsigned long)res->addr;
> > -	priv->plat->dma_cfg->perch_irq_en =
> > -		(priv->plat->flags & STMMAC_FLAG_PERCH_IRQ_EN);
> > +	if (res->rx_irq[0] > 0 && res->tx_irq[0] > 0) {
> > +		priv->plat->flags |= STMMAC_FLAG_PERCH_IRQ_EN;
> > +		priv->plat->dma_cfg->perch_irq_en = true;
> > +	}
> >   	priv->dev->irq = res->irq;
> >   	priv->wol_irq = res->wol_irq;
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > index 29145682b57b..9b46775b41ab 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > @@ -705,6 +705,9 @@ EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
> >   int stmmac_get_platform_resources(struct platform_device *pdev,
> >   				  struct stmmac_resources *stmmac_res)
> >   {
> > +	char irq_name[8];
> > +	int i;
> > +
> >   	memset(stmmac_res, 0, sizeof(*stmmac_res));
> >   	/* Get IRQ information early to have an ability to ask for deferred
> > @@ -738,6 +741,26 @@ int stmmac_get_platform_resources(struct platform_device *pdev,
> >   		dev_info(&pdev->dev, "IRQ eth_lpi not found\n");
> >   	}
> > +	for (i = 0; i < MTL_MAX_RX_QUEUES; i++) {
> > +		snprintf(irq_name, sizeof(irq_name), "rx%i", i);
> > +		stmmac_res->rx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
> > +		if (stmmac_res->rx_irq[i] < 0) {
> > +			if (stmmac_res->rx_irq[i] == -EPROBE_DEFER)
> > +				return -EPROBE_DEFER;
> > +			break;
> > +		}
> > +	}
> > +
> > +	for (i = 0; i < MTL_MAX_TX_QUEUES; i++) {
> > +		snprintf(irq_name, sizeof(irq_name), "tx%i", i);
> > +		stmmac_res->tx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
> > +		if (stmmac_res->tx_irq[i] < 0) {
> > +			if (stmmac_res->tx_irq[i] == -EPROBE_DEFER)
> > +				return -EPROBE_DEFER;
> > +			break;
> > +		}
> > +	}
> > +
> >   	stmmac_res->sfty_ce_irq = platform_get_irq_byname_optional(pdev, "sfty_ce");
> >   	if (stmmac_res->sfty_ce_irq < 0) {
> >   		if (stmmac_res->sfty_ce_irq == -EPROBE_DEFER)
>
Jisheng Zhang Aug. 10, 2023, 4:21 p.m. UTC | #3
On Fri, Aug 11, 2023 at 12:09:38AM +0800, Jisheng Zhang wrote:
> On Thu, Aug 10, 2023 at 04:57:00PM +0200, Alexandre TORGUE wrote:
> > On 8/9/23 18:50, Jisheng Zhang wrote:
> > > The snps dwmac IP may support per channel interrupt. Add support to
> > > parse the per channel irq from DT.
> > > 
> > > Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> > > ---
> > >   .../net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++----
> > >   .../ethernet/stmicro/stmmac/stmmac_platform.c | 23 +++++++++++++++++++
> > >   2 files changed, 29 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > index 4ed5c976c7a3..245eeb7d3e83 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > @@ -3612,7 +3612,7 @@ static int stmmac_request_irq_multi(struct net_device *dev)
> > >   	for (i = 0; i < priv->plat->rx_queues_to_use; i++) {
> > >   		if (i >= MTL_MAX_RX_QUEUES)
> > >   			break;
> > > -		if (priv->rx_irq[i] == 0)
> > > +		if (priv->rx_irq[i] <= 0)
> > 
> > What do you fix here ?
> 
> No bug to fix, but adjust for parsing optional channel irqs from DT:
> rx_irq[i] and tx_irq[i] may come from platform_get_irq_byname_optional()
> so for !STMMAC_FLAG_PERCH_IRQ_EN platforms, they can be < 0. Before
> 

oops, I sent this email too quick before I complete it.

After this patch(parse optional channel irqs from DT), rx_irq[i] and
tx_irq[i] may come from platform_get_irq_byname_optional(),
so for STMMAC_FLAG_PERCH_IRQ_EN platforms which support less than
MTL_MAX_TX_QUEUES channels, for example 8 tx and 8 rx, the last
tx_irq[i] or rx_irq[i] can be < 0.

Thanks

> > >   			continue;
> > >   		int_name = priv->int_name_rx_irq[i];
> > > @@ -3637,7 +3637,7 @@ static int stmmac_request_irq_multi(struct net_device *dev)
> > >   	for (i = 0; i < priv->plat->tx_queues_to_use; i++) {
> > >   		if (i >= MTL_MAX_TX_QUEUES)
> > >   			break;
> > > -		if (priv->tx_irq[i] == 0)
> > > +		if (priv->tx_irq[i] <= 0)
> > 
> > same here
> > >   			continue;
> > >   		int_name = priv->int_name_tx_irq[i];
> > > @@ -7278,8 +7278,10 @@ int stmmac_dvr_probe(struct device *device,
> > >   	priv->plat = plat_dat;
> > >   	priv->ioaddr = res->addr;
> > >   	priv->dev->base_addr = (unsigned long)res->addr;
> > > -	priv->plat->dma_cfg->perch_irq_en =
> > > -		(priv->plat->flags & STMMAC_FLAG_PERCH_IRQ_EN);
> > > +	if (res->rx_irq[0] > 0 && res->tx_irq[0] > 0) {
> > > +		priv->plat->flags |= STMMAC_FLAG_PERCH_IRQ_EN;
> > > +		priv->plat->dma_cfg->perch_irq_en = true;
> > > +	}
> > >   	priv->dev->irq = res->irq;
> > >   	priv->wol_irq = res->wol_irq;
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > > index 29145682b57b..9b46775b41ab 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > > @@ -705,6 +705,9 @@ EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
> > >   int stmmac_get_platform_resources(struct platform_device *pdev,
> > >   				  struct stmmac_resources *stmmac_res)
> > >   {
> > > +	char irq_name[8];
> > > +	int i;
> > > +
> > >   	memset(stmmac_res, 0, sizeof(*stmmac_res));
> > >   	/* Get IRQ information early to have an ability to ask for deferred
> > > @@ -738,6 +741,26 @@ int stmmac_get_platform_resources(struct platform_device *pdev,
> > >   		dev_info(&pdev->dev, "IRQ eth_lpi not found\n");
> > >   	}
> > > +	for (i = 0; i < MTL_MAX_RX_QUEUES; i++) {
> > > +		snprintf(irq_name, sizeof(irq_name), "rx%i", i);
> > > +		stmmac_res->rx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
> > > +		if (stmmac_res->rx_irq[i] < 0) {
> > > +			if (stmmac_res->rx_irq[i] == -EPROBE_DEFER)
> > > +				return -EPROBE_DEFER;
> > > +			break;
> > > +		}
> > > +	}
> > > +
> > > +	for (i = 0; i < MTL_MAX_TX_QUEUES; i++) {
> > > +		snprintf(irq_name, sizeof(irq_name), "tx%i", i);
> > > +		stmmac_res->tx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
> > > +		if (stmmac_res->tx_irq[i] < 0) {
> > > +			if (stmmac_res->tx_irq[i] == -EPROBE_DEFER)
> > > +				return -EPROBE_DEFER;
> > > +			break;
> > > +		}
> > > +	}
> > > +
> > >   	stmmac_res->sfty_ce_irq = platform_get_irq_byname_optional(pdev, "sfty_ce");
> > >   	if (stmmac_res->sfty_ce_irq < 0) {
> > >   		if (stmmac_res->sfty_ce_irq == -EPROBE_DEFER)
> >
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 4ed5c976c7a3..245eeb7d3e83 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3612,7 +3612,7 @@  static int stmmac_request_irq_multi(struct net_device *dev)
 	for (i = 0; i < priv->plat->rx_queues_to_use; i++) {
 		if (i >= MTL_MAX_RX_QUEUES)
 			break;
-		if (priv->rx_irq[i] == 0)
+		if (priv->rx_irq[i] <= 0)
 			continue;
 
 		int_name = priv->int_name_rx_irq[i];
@@ -3637,7 +3637,7 @@  static int stmmac_request_irq_multi(struct net_device *dev)
 	for (i = 0; i < priv->plat->tx_queues_to_use; i++) {
 		if (i >= MTL_MAX_TX_QUEUES)
 			break;
-		if (priv->tx_irq[i] == 0)
+		if (priv->tx_irq[i] <= 0)
 			continue;
 
 		int_name = priv->int_name_tx_irq[i];
@@ -7278,8 +7278,10 @@  int stmmac_dvr_probe(struct device *device,
 	priv->plat = plat_dat;
 	priv->ioaddr = res->addr;
 	priv->dev->base_addr = (unsigned long)res->addr;
-	priv->plat->dma_cfg->perch_irq_en =
-		(priv->plat->flags & STMMAC_FLAG_PERCH_IRQ_EN);
+	if (res->rx_irq[0] > 0 && res->tx_irq[0] > 0) {
+		priv->plat->flags |= STMMAC_FLAG_PERCH_IRQ_EN;
+		priv->plat->dma_cfg->perch_irq_en = true;
+	}
 
 	priv->dev->irq = res->irq;
 	priv->wol_irq = res->wol_irq;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 29145682b57b..9b46775b41ab 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -705,6 +705,9 @@  EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
 int stmmac_get_platform_resources(struct platform_device *pdev,
 				  struct stmmac_resources *stmmac_res)
 {
+	char irq_name[8];
+	int i;
+
 	memset(stmmac_res, 0, sizeof(*stmmac_res));
 
 	/* Get IRQ information early to have an ability to ask for deferred
@@ -738,6 +741,26 @@  int stmmac_get_platform_resources(struct platform_device *pdev,
 		dev_info(&pdev->dev, "IRQ eth_lpi not found\n");
 	}
 
+	for (i = 0; i < MTL_MAX_RX_QUEUES; i++) {
+		snprintf(irq_name, sizeof(irq_name), "rx%i", i);
+		stmmac_res->rx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
+		if (stmmac_res->rx_irq[i] < 0) {
+			if (stmmac_res->rx_irq[i] == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
+			break;
+		}
+	}
+
+	for (i = 0; i < MTL_MAX_TX_QUEUES; i++) {
+		snprintf(irq_name, sizeof(irq_name), "tx%i", i);
+		stmmac_res->tx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
+		if (stmmac_res->tx_irq[i] < 0) {
+			if (stmmac_res->tx_irq[i] == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
+			break;
+		}
+	}
+
 	stmmac_res->sfty_ce_irq = platform_get_irq_byname_optional(pdev, "sfty_ce");
 	if (stmmac_res->sfty_ce_irq < 0) {
 		if (stmmac_res->sfty_ce_irq == -EPROBE_DEFER)