Skip to contentSkip to conversation

firewire: core: fix source bus ID detection for AT context in big-endian systems

PATCH Applied Takashi Sakamoto 1 participant 2 messages Sep 8 – Sep 9

Subsystems (2)
lore
Share & tools
lore

Takashi Sakamoto

author maintainer
#0 lore raw

PATCH 1/1 firewire: core: fix source bus ID detection for AT context in big-endian systems

The source bus ID bit in AT DMA context is not detected correctly on big-endian systems because the little-endian data is not converted to CPU endianness.

Fix the bug. The helper functions related to this are never used in driver code, so extend the test to check the field instead.

Fixes 8db9d1557122 ("firewire: ohci: add static inline functions to serialize/deserialize data of AT DMA")
---
 drivers/firewire/ohci-serdes-test.c | 4 ++--
 drivers/firewire/ohci.h             | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/firewire/ohci-serdes-test.c +2 -2
index 258f668619ef..87b136e041de 100644
@@ -43,7 +43,7 @@ static void test_self_id_receive_buffer_deserialization(struct kunit *test)
 static void test_at_data_serdes(struct kunit *test)
 {
 	static const __le32 expected[] = {
-		cpu_to_le32(0x00020e80),
+		cpu_to_le32(0x00820e80),
 		cpu_to_le32(0xffc2ffff),
 		cpu_to_le32(0xe0000000),
 	};
@@ -56,7 +56,7 @@ static void test_at_data_serdes(struct kunit *test)
 	unsigned int destination_id = ohci1394_at_data_get_destination_id(expected);
 	u64 destination_offset = ohci1394_at_data_get_destination_offset(expected);
 
-	KUNIT_EXPECT_FALSE(test, has_src_bus_id);
+	KUNIT_EXPECT_TRUE(test, has_src_bus_id);
 	KUNIT_EXPECT_EQ(test, 0x02, speed);
 	KUNIT_EXPECT_EQ(test, 0x03, tlabel);
 	KUNIT_EXPECT_EQ(test, 0x02, retry);
drivers/firewire/ohci.h +1 -1
index 218666cfe14a..63ccf2f44504 100644
@@ -178,7 +178,7 @@
 
 static inline bool ohci1394_at_data_get_src_bus_id(const __le32 *data)
 {
-	return !!((data[0] & OHCI1394_AT_DATA_Q0_srcBusID_MASK) >> OHCI1394_AT_DATA_Q0_srcBusID_SHIFT);
+	return !!((le32_to_cpu(data[0]) & OHCI1394_AT_DATA_Q0_srcBusID_MASK) >> OHCI1394_AT_DATA_Q0_srcBusID_SHIFT);
 }
 
 static inline void ohci1394_at_data_set_src_bus_id(__le32 *data, bool src_bus_id)
Signature · 1 line
2.53.0
author maintainer Applied
#1 lore raw

Hi,

Quoted 7 lines · Takashi Sakamoto

The source bus ID bit in AT DMA context is not detected correctly on big-endian systems because the little-endian data is not converted to CPU endianness.

Fix the bug. The helper functions related to this are never used in driver code, so extend the test to check the field instead.

Quoted 7 lines
Fixes 8db9d1557122 ("firewire: ohci: add static inline functions to serialize/deserialize data of AT DMA")
---
 drivers/firewire/ohci-serdes-test.c | 4 ++--
 drivers/firewire/ohci.h             | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Applied to for-next branch.

Regards

Takashi Sakamoto