This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 25f8f0ad12d7b63f1494116cbd7453c1e1fc8057
Author: raiden00pl <[email protected]>
AuthorDate: Tue Aug 18 12:01:32 2026 +0200

    drivers/net/e1000: Access registers at the required width.
    
    Launder each register value through a register with an empty asm, on
    loads and stores both, so the access is the width the source specifies.
    Same fix as usbhost_xhci_pci.c commit 4b702058f6.
    
    Signed-off-by: raiden00pl <[email protected]>
    Assisted-by: Claude Code
---
 drivers/net/e1000.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 87b103f3553..f04e341a550 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -318,6 +318,12 @@ static const struct netdev_ops_s g_e1000_ops =
  * Private Functions
  *****************************************************************************/
 
+/* The device requires 32-bit register accesses, but volatile does not pin
+ * the access width: GCC 16 narrows a 32-bit load feeding a single bit test
+ * into a byte load.  Launder the value through a register with an empty
+ * asm, on loads and stores both, to force the full-width access.
+ */
+
 /*****************************************************************************
  * Name: e1000_getreg_mem
  *****************************************************************************/
@@ -325,8 +331,11 @@ static const struct netdev_ops_s g_e1000_ops =
 static uint32_t e1000_getreg_mem(FAR struct e1000_driver_s *priv,
                                  unsigned int offset)
 {
-  uintptr_t addr = priv->base + offset;
-  return *((FAR volatile uint32_t *)addr);
+  uintptr_t addr   = priv->base + offset;
+  uint32_t  regval = *((FAR volatile uint32_t *)addr);
+
+  __asm__ __volatile__("" : "+r"(regval));
+  return regval;
 }
 
 /*****************************************************************************
@@ -338,6 +347,8 @@ static void e1000_putreg_mem(FAR struct e1000_driver_s 
*priv,
                              uint32_t value)
 {
   uintptr_t addr = priv->base + offset;
+
+  __asm__ __volatile__("" : "+r"(value));
   *((FAR volatile uint32_t *)addr) = value;
 }
 

Reply via email to