diff mbox series

[net-next,1/3] net: dsa: qca8k: do not write port mask twice in bridge join/leave

Message ID 9e5682c68a4930dae2e277b9cecc8b8ec97ba2af.1718899575.git.mschiffer@universe-factory.net (mailing list archive)
State Accepted
Commit e85d3e6fea05c8ae21a40809a3c6b7adc97411c7
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: qca8k: cleanup and port isolation | 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 success Errors and warnings before: 842 this patch: 842
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 849 this patch: 849
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: 849 this patch: 849
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 25 lines checked
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
netdev/contest success net-next-2024-06-21--03-00 (tests: 659)

Commit Message

Matthias Schiffer June 20, 2024, 5:25 p.m. UTC
qca8k_port_bridge_join() set QCA8K_PORT_LOOKUP_CTRL() for i == port twice,
once in the loop handling all other port's masks, and finally at the end
with the accumulated port_mask.

The first time it would incorrectly set the port's own bit in the mask,
only to correct the mistake a moment later. qca8k_port_bridge_leave() had
the same issue, but here the regmap_clear_bits() was a no-op rather than
setting an unintended value.

Remove the duplicate assignment by skipping the whole loop iteration for
i == port. The unintended bit setting doesn't seem to have any negative
effects (even when not reverted right away), so the change is submitted
as a simple cleanup rather than a fix.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 drivers/net/dsa/qca/qca8k-common.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Wojciech Drewek June 21, 2024, 10:48 a.m. UTC | #1
On 20.06.2024 19:25, Matthias Schiffer wrote:
> qca8k_port_bridge_join() set QCA8K_PORT_LOOKUP_CTRL() for i == port twice,
> once in the loop handling all other port's masks, and finally at the end
> with the accumulated port_mask.
> 
> The first time it would incorrectly set the port's own bit in the mask,
> only to correct the mistake a moment later. qca8k_port_bridge_leave() had
> the same issue, but here the regmap_clear_bits() was a no-op rather than
> setting an unintended value.
> 
> Remove the duplicate assignment by skipping the whole loop iteration for
> i == port. The unintended bit setting doesn't seem to have any negative
> effects (even when not reverted right away), so the change is submitted
> as a simple cleanup rather than a fix.
> 
> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
> ---

Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/dsa/qca/qca8k-common.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c
> index 7f80035c5441..b33df84070d3 100644
> --- a/drivers/net/dsa/qca/qca8k-common.c
> +++ b/drivers/net/dsa/qca/qca8k-common.c
> @@ -653,6 +653,8 @@ int qca8k_port_bridge_join(struct dsa_switch *ds, int port,
>  	port_mask = BIT(cpu_port);
>  
>  	for (i = 0; i < QCA8K_NUM_PORTS; i++) {
> +		if (i == port)
> +			continue;
>  		if (dsa_is_cpu_port(ds, i))
>  			continue;
>  		if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
> @@ -665,8 +667,7 @@ int qca8k_port_bridge_join(struct dsa_switch *ds, int port,
>  				      BIT(port));
>  		if (ret)
>  			return ret;
> -		if (i != port)
> -			port_mask |= BIT(i);
> +		port_mask |= BIT(i);
>  	}
>  
>  	/* Add all other ports to this ports portvlan mask */
> @@ -685,6 +686,8 @@ void qca8k_port_bridge_leave(struct dsa_switch *ds, int port,
>  	cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
>  
>  	for (i = 0; i < QCA8K_NUM_PORTS; i++) {
> +		if (i == port)
> +			continue;
>  		if (dsa_is_cpu_port(ds, i))
>  			continue;
>  		if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
diff mbox series

Patch

diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c
index 7f80035c5441..b33df84070d3 100644
--- a/drivers/net/dsa/qca/qca8k-common.c
+++ b/drivers/net/dsa/qca/qca8k-common.c
@@ -653,6 +653,8 @@  int qca8k_port_bridge_join(struct dsa_switch *ds, int port,
 	port_mask = BIT(cpu_port);
 
 	for (i = 0; i < QCA8K_NUM_PORTS; i++) {
+		if (i == port)
+			continue;
 		if (dsa_is_cpu_port(ds, i))
 			continue;
 		if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
@@ -665,8 +667,7 @@  int qca8k_port_bridge_join(struct dsa_switch *ds, int port,
 				      BIT(port));
 		if (ret)
 			return ret;
-		if (i != port)
-			port_mask |= BIT(i);
+		port_mask |= BIT(i);
 	}
 
 	/* Add all other ports to this ports portvlan mask */
@@ -685,6 +686,8 @@  void qca8k_port_bridge_leave(struct dsa_switch *ds, int port,
 	cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
 
 	for (i = 0; i < QCA8K_NUM_PORTS; i++) {
+		if (i == port)
+			continue;
 		if (dsa_is_cpu_port(ds, i))
 			continue;
 		if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))