mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: octeon: fix race condition and log macro in ethernet-rgmii.c
@ 2026-11-07 15:52 Oscar Alejandro Sánchez Lucero via B4 Relay
  2026-11-07 19:15 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Oscar Alejandro Sánchez Lucero via B4 Relay @ 2026-11-07 15:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, Oscar Alejandro Sánchez Lucero

From: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>

Fix a race condition in cvm_oct_check_preamble_errors() by moving the
read assignment of priv->link_info inside the global_register_lock
protected critical section. This prevents unsynchronized read-accesses
concurring with status mutations from concurrent polling contexts.

Additionally, modernize the message output by replacing the obsolete
printk_ratelimited() call with netdev_notice_ratelimited().

Signed-off-by: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>
---
 drivers/staging/octeon/ethernet-rgmii.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c
index 0c4fac31540a..a9a245b5580a 100644
--- a/drivers/staging/octeon/ethernet-rgmii.c
+++ b/drivers/staging/octeon/ethernet-rgmii.c
@@ -9,8 +9,6 @@
 #include <linux/netdevice.h>
 #include <linux/interrupt.h>
 #include <linux/phy.h>
-#include <linux/ratelimit.h>
-#include <net/dst.h>
 
 #include "octeon-ethernet.h"
 #include "ethernet-defines.h"
@@ -56,14 +54,14 @@ static void cvm_oct_check_preamble_errors(struct net_device *dev)
 	union cvmx_helper_link_info link_info;
 	unsigned long flags;
 
-	link_info.u64 = priv->link_info;
-
 	/*
 	 * Take the global register lock since we are going to
 	 * touch registers that affect more than one port.
 	 */
 	spin_lock_irqsave(&global_register_lock, flags);
 
+	link_info.u64 = priv->link_info;
+
 	if (link_info.s.speed == 10 && priv->last_speed == 10) {
 		/*
 		 * Read the GMXX_RXX_INT_REG[PCTERR] bit and see if we are
@@ -74,7 +72,7 @@ static void cvm_oct_check_preamble_errors(struct net_device *dev)
 		union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg;
 
 		gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG
-							(index, interface));
+		(index, interface));
 		if (gmxx_rxx_int_reg.s.pcterr) {
 			/*
 			 * We are getting preamble errors at 10Mbps. Most
@@ -83,8 +81,8 @@ static void cvm_oct_check_preamble_errors(struct net_device *dev)
 			 * disable preamble checking and do it in software.
 			 */
 			cvm_oct_set_hw_preamble(priv, false);
-			printk_ratelimited("%s: Using 10Mbps with software preamble removal\n",
-					   dev->name);
+			net_notice_ratelimited("%s: Using 10Mbps with software preamble removal\n",
+					       dev->name);
 		}
 	} else {
 		/*

---
base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b
change-id: 20261107-octeon-rgmii-fixes-ae461403b1b2

Best regards,
-- 
Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>



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

end of thread, other threads:[~2026-11-07 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 15:52 [PATCH] staging: octeon: fix race condition and log macro in ethernet-rgmii.c Oscar Alejandro Sánchez Lucero via B4 Relay
2026-11-07 19:15 ` Greg Kroah-Hartman

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®