mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling
@ 2024-08-08  9:47 Javier Carrasco
  2024-08-08  9:47 ` [PATCH PARTIAL RESEND 1/2] net: mvpp2: use port_count to remove ports Javier Carrasco
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Javier Carrasco @ 2024-08-08  9:47 UTC (permalink / raw)
  To: Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Javier Carrasco, Jonathan Cameron

These two patches used to be part of another series [1] that did not
apply to the networking tree without conflicts. This is therefore just a
partial resend with no code modifications, just rebased onto net/main.

Link: https://lore.kernel.org/all/20240806181026.5fe7f777@kernel.org/ [1]
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
Javier Carrasco (2):
      net: mvpp2: use port_count to remove ports
      net: mvpp2: use device_for_each_child_node() to access device child nodes

 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 31 +++++++------------------
 1 file changed, 9 insertions(+), 22 deletions(-)
---
base-commit: b928e7d19dfd8a336e13ec0d21e1d60dc285efd5
change-id: 20240807-mvpp2_child_nodes-b92f8eae0f87

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH PARTIAL RESEND 1/2] net: mvpp2: use port_count to remove ports
  2024-08-08  9:47 [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling Javier Carrasco
@ 2024-08-08  9:47 ` Javier Carrasco
  2024-08-08  9:47 ` [PATCH PARTIAL RESEND 2/2] net: mvpp2: use device_for_each_child_node() to access device child nodes Javier Carrasco
  2024-08-11 16:12 ` [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Javier Carrasco @ 2024-08-08  9:47 UTC (permalink / raw)
  To: Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Javier Carrasco

As discussed in [1], there is no need to iterate over child nodes to
remove the list of ports. Instead, a loop up to `port_count` ports can
be used, and is in fact more reliable in case the child node
availability changes.

The suggested approach removes the need for the `fwnode` and
`port_fwnode` variables in mvpp2_remove() as well.

Link: https://lore.kernel.org/all/ZqdRgDkK1PzoI2Pf@shell.armlinux.org.uk/ [1]
Suggested-by: Russell King <linux@armlinux.org.uk>
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 0d62a33afa80..0b5b2425de12 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -7655,12 +7655,8 @@ static int mvpp2_probe(struct platform_device *pdev)
 err_port_probe:
 	fwnode_handle_put(port_fwnode);
 
-	i = 0;
-	fwnode_for_each_available_child_node(fwnode, port_fwnode) {
-		if (priv->port_list[i])
-			mvpp2_port_remove(priv->port_list[i]);
-		i++;
-	}
+	for (i = 0; i < priv->port_count; i++)
+		mvpp2_port_remove(priv->port_list[i]);
 err_axi_clk:
 	clk_disable_unprepare(priv->axi_clk);
 err_mg_core_clk:
@@ -7677,18 +7673,13 @@ static int mvpp2_probe(struct platform_device *pdev)
 static void mvpp2_remove(struct platform_device *pdev)
 {
 	struct mvpp2 *priv = platform_get_drvdata(pdev);
-	struct fwnode_handle *fwnode = pdev->dev.fwnode;
-	int i = 0, poolnum = MVPP2_BM_POOLS_NUM;
-	struct fwnode_handle *port_fwnode;
+	int i, poolnum = MVPP2_BM_POOLS_NUM;
 
 	mvpp2_dbgfs_cleanup(priv);
 
-	fwnode_for_each_available_child_node(fwnode, port_fwnode) {
-		if (priv->port_list[i]) {
-			mutex_destroy(&priv->port_list[i]->gather_stats_lock);
-			mvpp2_port_remove(priv->port_list[i]);
-		}
-		i++;
+	for (i = 0; i < priv->port_count; i++) {
+		mutex_destroy(&priv->port_list[i]->gather_stats_lock);
+		mvpp2_port_remove(priv->port_list[i]);
 	}
 
 	destroy_workqueue(priv->stats_queue);
@@ -7711,7 +7702,7 @@ static void mvpp2_remove(struct platform_device *pdev)
 				  aggr_txq->descs_dma);
 	}
 
-	if (is_acpi_node(port_fwnode))
+	if (!dev_of_node(&pdev->dev))
 		return;
 
 	clk_disable_unprepare(priv->axi_clk);

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH PARTIAL RESEND 2/2] net: mvpp2: use device_for_each_child_node() to access device child nodes
  2024-08-08  9:47 [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling Javier Carrasco
  2024-08-08  9:47 ` [PATCH PARTIAL RESEND 1/2] net: mvpp2: use port_count to remove ports Javier Carrasco
@ 2024-08-08  9:47 ` Javier Carrasco
  2024-08-11 16:12 ` [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Javier Carrasco @ 2024-08-08  9:47 UTC (permalink / raw)
  To: Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Javier Carrasco, Jonathan Cameron

The iterated nodes are direct children of the device node, and the
`device_for_each_child_node()` macro accounts for child node
availability.

`fwnode_for_each_available_child_node()` is meant to access the child
nodes of an fwnode, and therefore not direct child nodes of the device
node.

The child nodes within mvpp2_probe are not accessed outside the loops,
and the scoped version of the macro can be used to automatically
decrement the refcount on early exits.

Use `device_for_each_child_node()` and its scoped variant to indicate
device's direct child nodes.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 0b5b2425de12..216cc7b860d6 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -7417,8 +7417,6 @@ static int mvpp2_get_sram(struct platform_device *pdev,
 
 static int mvpp2_probe(struct platform_device *pdev)
 {
-	struct fwnode_handle *fwnode = pdev->dev.fwnode;
-	struct fwnode_handle *port_fwnode;
 	struct mvpp2 *priv;
 	struct resource *res;
 	void __iomem *base;
@@ -7591,7 +7589,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 	}
 
 	/* Map DTS-active ports. Should be done before FIFO mvpp2_init */
-	fwnode_for_each_available_child_node(fwnode, port_fwnode) {
+	device_for_each_child_node_scoped(&pdev->dev, port_fwnode) {
 		if (!fwnode_property_read_u32(port_fwnode, "port-id", &i))
 			priv->port_map |= BIT(i);
 	}
@@ -7614,7 +7612,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 		goto err_axi_clk;
 
 	/* Initialize ports */
-	fwnode_for_each_available_child_node(fwnode, port_fwnode) {
+	device_for_each_child_node_scoped(&pdev->dev, port_fwnode) {
 		err = mvpp2_port_probe(pdev, port_fwnode, priv);
 		if (err < 0)
 			goto err_port_probe;
@@ -7653,8 +7651,6 @@ static int mvpp2_probe(struct platform_device *pdev)
 	return 0;
 
 err_port_probe:
-	fwnode_handle_put(port_fwnode);
-
 	for (i = 0; i < priv->port_count; i++)
 		mvpp2_port_remove(priv->port_list[i]);
 err_axi_clk:

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling
  2024-08-08  9:47 [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling Javier Carrasco
  2024-08-08  9:47 ` [PATCH PARTIAL RESEND 1/2] net: mvpp2: use port_count to remove ports Javier Carrasco
  2024-08-08  9:47 ` [PATCH PARTIAL RESEND 2/2] net: mvpp2: use device_for_each_child_node() to access device child nodes Javier Carrasco
@ 2024-08-11 16:12 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-11 16:12 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: marcin.s.wojtas, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Jonathan.Cameron

Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 08 Aug 2024 11:47:31 +0200 you wrote:
> These two patches used to be part of another series [1] that did not
> apply to the networking tree without conflicts. This is therefore just a
> partial resend with no code modifications, just rebased onto net/main.
> 
> Link: https://lore.kernel.org/all/20240806181026.5fe7f777@kernel.org/ [1]
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> 
> [...]

Here is the summary with links:
  - [PARTIAL,RESEND,1/2] net: mvpp2: use port_count to remove ports
    https://git.kernel.org/netdev/net-next/c/e81d00a6b3b7
  - [PARTIAL,RESEND,2/2] net: mvpp2: use device_for_each_child_node() to access device child nodes
    https://git.kernel.org/netdev/net-next/c/a7b32744475c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-11 16:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-08  9:47 [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling Javier Carrasco
2024-08-08  9:47 ` [PATCH PARTIAL RESEND 1/2] net: mvpp2: use port_count to remove ports Javier Carrasco
2024-08-08  9:47 ` [PATCH PARTIAL RESEND 2/2] net: mvpp2: use device_for_each_child_node() to access device child nodes Javier Carrasco
2024-08-11 16:12 ` [PATCH PARTIAL RESEND 0/2] net: mvpp2: rework child node/port removal handling patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®