]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (powerz) Avoid cacheline sharing for DMA buffer
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 8 Apr 2026 18:45:50 +0000 (20:45 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 10 Apr 2026 15:33:08 +0000 (08:33 -0700)
Depending on the architecture the transfer buffer may share a cacheline
with the following mutex. As the buffer may be used for DMA, that is
problematic.

Use the high-level DMA helpers to make sure that cacheline sharing can
not happen.

Also drop the comment, as the helpers are documentation enough.

https://sashiko.dev/#/message/20260408175814.934BFC19421%40smtp.kernel.org

Fixes: 4381a36abdf1c ("hwmon: add POWER-Z driver")
Cc: stable@vger.kernel.org # ca085faabb42: dma-mapping: add __dma_from_device_group_begin()/end()
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20260408-powerz-cacheline-alias-v1-1-1254891be0dd@weissschuh.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/powerz.c

index 96438f5f05d489ae9fd1813bffdc1326474c5498..6e1359144cabef9f086418c9a6d503f3c630dff4 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/completion.h>
 #include <linux/device.h>
+#include <linux/dma-mapping.h>
 #include <linux/hwmon.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
@@ -33,7 +34,9 @@ struct powerz_sensor_data {
 } __packed;
 
 struct powerz_priv {
-       char transfer_buffer[64];       /* first member to satisfy DMA alignment */
+       __dma_from_device_group_begin();
+       char transfer_buffer[64];
+       __dma_from_device_group_end();
        struct mutex mutex;
        struct completion completion;
        struct urb *urb;