[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20260130141035.272471-5-claudiu.manoil@nxp.com>
Date: Fri, 30 Jan 2026 16:10:35 +0200
From: Claudiu Manoil <claudiu.manoil@....com>
To: vladimir.oltean@....com,
wei.fang@....com,
xiaoning.wang@....com,
Frank.Li@....com
Cc: kuba@...nel.org,
davem@...emloft.net,
andrew+netdev@...n.ch,
edumazet@...gle.com,
pabeni@...hat.com,
imx@...ts.linux.dev,
netdev@...r.kernel.org
Subject: [PATCH net 4/4] net: enetc: Convert 16-bit register reads to 32-bit for ENETC v4
It is not recommended to access the 32‑bit registers of this hardware IP
using lower‑width accessors (i.e. 16‑bit), and the only exception to
this rule was introduced in the initial ENETC v1 driver for the PMAR1
register, which holds the lower 16 bits of the primary MAC address of
an SI. Meanwhile, this exception has been replicated in the v4 driver
code as well.
Since LS1028 (the only SoC with ENETC v1) is not affected by this issue,
the current patch converts the 16‑bit reads from PMAR1 starting with
ENETC v4.
Fixes: 99100d0d9922 ("net: enetc: add preliminary support for i.MX95 ENETC PF")
Signed-off-by: Claudiu Manoil <claudiu.manoil@....com>
---
.../net/ethernet/freescale/enetc/enetc4_pf.c | 2 +-
drivers/net/ethernet/freescale/enetc/enetc_hw.h | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
index c0859d200a2c..5850540634b0 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
@@ -73,7 +73,7 @@ static void enetc4_pf_get_si_primary_mac(struct enetc_hw *hw, int si,
u16 lower;
upper = __raw_readl(hw->port + ENETC4_PSIPMAR0(si));
- lower = __raw_readw(hw->port + ENETC4_PSIPMAR1(si));
+ lower = __raw_readl(hw->port + ENETC4_PSIPMAR1(si));
put_unaligned_le32(upper, addr);
put_unaligned_le16(lower, addr + 4);
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
index 7b882b8921fe..662e4fbafb74 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
@@ -708,13 +708,24 @@ struct enetc_cmd_rfse {
#define ENETC_RFSE_EN BIT(15)
#define ENETC_RFSE_MODE_BD 2
+static inline void enetc_get_primary_mac_addr(struct enetc_hw *hw, u8 *addr)
+{
+ u32 upper;
+ u16 lower;
+
+ upper = __raw_readl(hw->reg + ENETC_SIPMAR0);
+ lower = __raw_readl(hw->reg + ENETC_SIPMAR1);
+
+ put_unaligned_le32(upper, addr);
+ put_unaligned_le16(lower, addr + 4);
+}
+
static inline void enetc_load_primary_mac_addr(struct enetc_hw *hw,
struct net_device *ndev)
{
- u8 addr[ETH_ALEN] __aligned(4);
+ u8 addr[ETH_ALEN];
- *(u32 *)addr = __raw_readl(hw->reg + ENETC_SIPMAR0);
- *(u16 *)(addr + 4) = __raw_readw(hw->reg + ENETC_SIPMAR1);
+ enetc_get_primary_mac_addr(hw, addr);
eth_hw_addr_set(ndev, addr);
}
--
2.34.1
Powered by blists - more mailing lists