[PATCH RESEND] ethernet: stmmac: fix for none child queue node for tx node

Jianqun Xu posted 1 patch 4 years ago
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH RESEND] ethernet: stmmac: fix for none child queue node for tx node
Posted by Jianqun Xu 4 years ago
In case of nothing to be set for tx node result in no child queue node
for the tx node, this patch init the queue to tx_queues_to_use instead
of 0 to support dt file set no queue node for tx node.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 2d8c095f3856..4f01a41c485c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -279,7 +279,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
 
 		queue++;
 	}
-	if (queue != plat->tx_queues_to_use) {
+	if (queue != plat->tx_queues_to_use && of_get_child_count(tx_node)) {
 		ret = -EINVAL;
 		dev_err(&pdev->dev, "Not all TX queues were configured\n");
 		goto out;
-- 
2.25.1
Re: [PATCH RESEND] ethernet: stmmac: fix for none child queue node for tx node
Posted by Jakub Kicinski 4 years ago
On Thu, 28 Apr 2022 09:09:27 +0800 Jianqun Xu wrote:
> In case of nothing to be set for tx node result in no child queue node
> for the tx node, this patch init the queue to tx_queues_to_use instead
> of 0 to support dt file set no queue node for tx node.
> 
> Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>

Something needs to initialize the settings
(plat->tx_queues_cfg[queue].#) to the defaults, no? 
Just ignoring the error may not be enough.

Also has this ever worked? If you're trying to make the driver work for
DTs that never worked (and are arguably invalid) -- please change the
subject from "fix..." to "support...".

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 2d8c095f3856..4f01a41c485c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -279,7 +279,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
>  
>  		queue++;
>  	}
> -	if (queue != plat->tx_queues_to_use) {
> +	if (queue != plat->tx_queues_to_use && of_get_child_count(tx_node)) {
>  		ret = -EINVAL;
>  		dev_err(&pdev->dev, "Not all TX queues were configured\n");
>  		goto out;
[PATCH V2] ethernet: stmmac: support driver work for DTs without child queue node
Posted by Jianqun Xu 4 years ago
The driver use the value of property 'snps,rx-queues-to-use' to loop
same numbers child nodes as queues, such as:

    gmac {
        rx-queues-config {
            snps,rx-queues-to-use = <1>;
            queue0 {
                // nothing need here.
	    };
	};
    };

Since a patch for dtc from rockchip will delete all node without any
properties or child node, the queue0 node will be deleted, that caused
the driver fail to probe:

    rk_gmac-dwmac: probe of ffa80000.ethernet failed with error -22

This patch try to support driver work well for DTs without setting for
the child queue nodes and then have none child queue nodes.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
---
v2:
 - change subject and update commit comment, sugguested by Kicinski

 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 2d8c095f3856..4f01a41c485c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -279,7 +279,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
 
 		queue++;
 	}
-	if (queue != plat->tx_queues_to_use) {
+	if (queue != plat->tx_queues_to_use && of_get_child_count(tx_node)) {
 		ret = -EINVAL;
 		dev_err(&pdev->dev, "Not all TX queues were configured\n");
 		goto out;
-- 
2.25.1
Re: [PATCH V2] ethernet: stmmac: support driver work for DTs without child queue node
Posted by Jakub Kicinski 4 years ago
On Fri, 29 Apr 2022 08:46:05 +0800 Jianqun Xu wrote:
> The driver use the value of property 'snps,rx-queues-to-use' to loop
> same numbers child nodes as queues, such as:
> 
>     gmac {
>         rx-queues-config {
>             snps,rx-queues-to-use = <1>;
>             queue0 {
>                 // nothing need here.
> 	    };
> 	};
>     };

I think you mean tx, not rx, given the code.

>  
>  		queue++;
>  	}
> -	if (queue != plat->tx_queues_to_use) {
> +	if (queue != plat->tx_queues_to_use && of_get_child_count(tx_node)) {
>  		ret = -EINVAL;
>  		dev_err(&pdev->dev, "Not all TX queues were configured\n");
>  		goto out;

Also what about the init to defaults I asked about?
Re: [PATCH V2] ethernet: stmmac: support driver work for DTs without child queue node
Posted by Andrew Lunn 4 years ago
On Fri, Apr 29, 2022 at 08:46:05AM +0800, Jianqun Xu wrote:
> The driver use the value of property 'snps,rx-queues-to-use' to loop
> same numbers child nodes as queues, such as:
> 
>     gmac {
>         rx-queues-config {
>             snps,rx-queues-to-use = <1>;
>             queue0 {
>                 // nothing need here.
> 	    };
> 	};
>     };
> 
> Since a patch for dtc from rockchip will delete all node without any
> properties or child node, the queue0 node will be deleted, that caused
> the driver fail to probe:

Is this the in tree dtc? Do you have a commit hash for it? That should
probably be used as a Fixes: tag. Or that change to dtc needs
reverting because it breaks stuff.

	  Andrew