netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next PATCH] net: phy: aquantia: drop wrong endianness conversion for addr and CRC
@ 2023-11-22 17:08 Christian Marangi
  2023-11-22 17:24 ` Russell King (Oracle)
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Marangi @ 2023-11-22 17:08 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Christian Marangi,
	Robert Marko, netdev, linux-kernel
  Cc: kernel test robot

On further testing on BE target with kernel test robot, it was notice
that the endianness conversion for addr and CRC in fw_load_memory was
wrong and actually not needed. Values in define doesn't get converted
and are passed as is and hardcoded values are already in what the PHY
require, that is LE.

Also drop the cpu_to_be32 for CRC calculation as it's wrong and use
_swab32 instead, the word is taked from firmware and is always LE, the
mailbox will emit a BE CRC hence the word needs to be always swapped and
the endianness of the host needs to be ignored.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202311210414.sEJZjlcD-lkp@intel.com/
Fixes: e93984ebc1c8 ("net: phy: aquantia: add firmware load support")
Tested-by: Robert Marko <robimarko@gmail.com> # ipq8072 LE device
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
Replacement of net: phy: aquantia: make mailbox interface4 lsw addr
mask more specific

 drivers/net/phy/aquantia/aquantia_firmware.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/aquantia/aquantia_firmware.c b/drivers/net/phy/aquantia/aquantia_firmware.c
index c5f292b1c4c8..bd093633d0cf 100644
--- a/drivers/net/phy/aquantia/aquantia_firmware.c
+++ b/drivers/net/phy/aquantia/aquantia_firmware.c
@@ -93,9 +93,9 @@ static int aqr_fw_load_memory(struct phy_device *phydev, u32 addr,
 	u16 crc = 0, up_crc;
 	size_t pos;
 
-	/* PHY expect addr in LE */
-	addr = (__force u32)cpu_to_le32(addr);
-
+	/* PHY expect addr in LE. Hardcoded addr in defines are
+	 * already in this format.
+	 */
 	phy_write_mmd(phydev, MDIO_MMD_VEND1,
 		      VEND1_GLOBAL_MAILBOX_INTERFACE1,
 		      VEND1_GLOBAL_MAILBOX_INTERFACE1_CRC_RESET);
@@ -128,7 +128,7 @@ static int aqr_fw_load_memory(struct phy_device *phydev, u32 addr,
 		 * We convert word to big-endian as PHY is BE and mailbox will
 		 * return a BE CRC.
 		 */
-		word = (__force u32)cpu_to_be32(word);
+		word = __swab32(word);
 		crc = crc_ccitt_false(crc, (u8 *)&word, sizeof(word));
 	}
 
-- 
2.40.1


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

end of thread, other threads:[~2023-11-22 22:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-22 17:08 [net-next PATCH] net: phy: aquantia: drop wrong endianness conversion for addr and CRC Christian Marangi
2023-11-22 17:24 ` Russell King (Oracle)
2023-11-22 17:53   ` Christian Marangi
2023-11-22 18:23     ` Jakub Kicinski
2023-11-22 18:39       ` Christian Marangi
2023-11-22 18:53     ` Russell King (Oracle)
2023-11-22 19:55       ` Christian Marangi
2023-11-22 20:25         ` Russell King (Oracle)
2023-11-22 21:09           ` Christian Marangi
2023-11-22 22:31             ` Russell King (Oracle)
2023-11-22 22:37               ` Christian Marangi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).