Skip to content

Commit c28d765

Browse files
claudiu-mkuba-moo
authored andcommitted
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: 99100d0 ("net: enetc: add preliminary support for i.MX95 ENETC PF") Signed-off-by: Claudiu Manoil <[email protected]> Reviewed-by: Wei Fang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 21d0fc9 commit c28d765

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

drivers/net/ethernet/freescale/enetc/enetc4_pf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void enetc4_pf_get_si_primary_mac(struct enetc_hw *hw, int si,
7373
u16 lower;
7474

7575
upper = __raw_readl(hw->port + ENETC4_PSIPMAR0(si));
76-
lower = __raw_readw(hw->port + ENETC4_PSIPMAR1(si));
76+
lower = __raw_readl(hw->port + ENETC4_PSIPMAR1(si));
7777

7878
put_unaligned_le32(upper, addr);
7979
put_unaligned_le16(lower, addr + 4);

drivers/net/ethernet/freescale/enetc/enetc_hw.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,13 +708,24 @@ struct enetc_cmd_rfse {
708708
#define ENETC_RFSE_EN BIT(15)
709709
#define ENETC_RFSE_MODE_BD 2
710710

711+
static inline void enetc_get_primary_mac_addr(struct enetc_hw *hw, u8 *addr)
712+
{
713+
u32 upper;
714+
u16 lower;
715+
716+
upper = __raw_readl(hw->reg + ENETC_SIPMAR0);
717+
lower = __raw_readl(hw->reg + ENETC_SIPMAR1);
718+
719+
put_unaligned_le32(upper, addr);
720+
put_unaligned_le16(lower, addr + 4);
721+
}
722+
711723
static inline void enetc_load_primary_mac_addr(struct enetc_hw *hw,
712724
struct net_device *ndev)
713725
{
714-
u8 addr[ETH_ALEN] __aligned(4);
726+
u8 addr[ETH_ALEN];
715727

716-
*(u32 *)addr = __raw_readl(hw->reg + ENETC_SIPMAR0);
717-
*(u16 *)(addr + 4) = __raw_readw(hw->reg + ENETC_SIPMAR1);
728+
enetc_get_primary_mac_addr(hw, addr);
718729
eth_hw_addr_set(ndev, addr);
719730
}
720731

0 commit comments

Comments
 (0)