linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] HID: intel-ish-hid: fix cache management mistake
@ 2024-05-28 11:57 Arnd Bergmann
  2024-05-28 11:57 ` [PATCH 2/2] HID: intel-ish-hid: fix endian-conversion Arnd Bergmann
  2024-05-29  6:46 ` [PATCH 1/2] HID: intel-ish-hid: fix cache management mistake Zhang, Lixu
  0 siblings, 2 replies; 14+ messages in thread
From: Arnd Bergmann @ 2024-05-28 11:57 UTC (permalink / raw)
  To: Srinivas Pandruvada, Jiri Kosina, Benjamin Tissoires, Zhang Lixu
  Cc: Arnd Bergmann, linux-input, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The low-level cache operation on a coherent buffer is incorrect,
as coherent DMA memory may not actually be cached. Instead, use a DMA
barrier that ensures that the data is visible to the DMA master before
the address is and move the memcpy() before the reference.

Fixes: 579a267e4617 ("HID: intel-ish-hid: Implement loading firmware from host feature")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
I noticed this one while looking at the bug that was fixed in
236049723826 ("HID: intel-ish-hid: Fix build error for COMPILE_TEST")
---
 drivers/hid/intel-ish-hid/ishtp/loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/intel-ish-hid/ishtp/loader.c b/drivers/hid/intel-ish-hid/ishtp/loader.c
index 2785b04a2f5a..062d1b25eaa7 100644
--- a/drivers/hid/intel-ish-hid/ishtp/loader.c
+++ b/drivers/hid/intel-ish-hid/ishtp/loader.c
@@ -33,7 +33,6 @@
 
 #define dev_fmt(fmt) "ISH loader: " fmt
 
-#include <linux/cacheflush.h>
 #include <linux/container_of.h>
 #include <linux/dev_printk.h>
 #include <linux/dma-mapping.h>
@@ -175,10 +174,11 @@ static int prepare_dma_bufs(struct ishtp_device *dev,
 			return -ENOMEM;
 
 		fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma_addr);
+
+		memcpy(dma_bufs[i], ish_fw->data + offset, fragment->fragment_tbl[i].length);
+		dma_wmb();
 		fragment->fragment_tbl[i].length = clamp(ish_fw->size - offset, 0, fragment_size);
 		fragment->fragment_tbl[i].fw_off = offset;
-		memcpy(dma_bufs[i], ish_fw->data + offset, fragment->fragment_tbl[i].length);
-		clflush_cache_range(dma_bufs[i], fragment_size);
 
 		offset += fragment->fragment_tbl[i].length;
 	}
-- 
2.39.2


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

end of thread, other threads:[~2024-05-31 16:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28 11:57 [PATCH 1/2] HID: intel-ish-hid: fix cache management mistake Arnd Bergmann
2024-05-28 11:57 ` [PATCH 2/2] HID: intel-ish-hid: fix endian-conversion Arnd Bergmann
2024-05-28 12:45   ` Arnd Bergmann
2024-05-28 21:06   ` kernel test robot
2024-05-28 21:17   ` kernel test robot
2024-05-29  7:05   ` Zhang, Lixu
2024-05-29 13:18     ` Arnd Bergmann
2024-05-31  3:49       ` srinivas pandruvada
2024-05-31 16:29         ` Arnd Bergmann
2024-05-29  6:46 ` [PATCH 1/2] HID: intel-ish-hid: fix cache management mistake Zhang, Lixu
2024-05-29  7:06   ` Arnd Bergmann
2024-05-29 22:25     ` srinivas pandruvada
2024-05-30  7:41       ` Zhang, Lixu
2024-05-31  8:51       ` Zhang, Lixu

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).