]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86: intel_scu_ipc: Replace workaround by 32-bit IO
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 21 Oct 2024 13:34:30 +0000 (16:34 +0300)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 22 Oct 2024 08:34:04 +0000 (11:34 +0300)
The theory is that the so called workaround in pwr_reg_rdwr() is
the actual reader of the data in 32-bit chunks. For some reason
the 8-bit IO won't fail after that. Replace the workaround by using
32-bit IO explicitly and then memcpy() as much data as was requested
by the user. The same approach is already in use in
intel_scu_ipc_dev_command_with_size().

Tested-by: Ferry Toth <fntoth@gmail.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20241021133705.2933464-3-andriy.shevchenko@linux.intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel_scu_ipc.c

index 8d11d18701a4f5b85db215aa3274d2334f20c44d..290b386275422d8d8b49444e132cda050ae7867e 100644 (file)
@@ -217,12 +217,6 @@ static inline u8 ipc_read_status(struct intel_scu_ipc_dev *scu)
        return __raw_readl(scu->ipc_base + IPC_STATUS);
 }
 
-/* Read ipc byte data */
-static inline u8 ipc_data_readb(struct intel_scu_ipc_dev *scu, u32 offset)
-{
-       return readb(scu->ipc_base + IPC_READ_BUFFER + offset);
-}
-
 /* Read ipc u32 data */
 static inline u32 ipc_data_readl(struct intel_scu_ipc_dev *scu, u32 offset)
 {
@@ -326,10 +320,9 @@ static int pwr_reg_rdwr(struct intel_scu_ipc_dev *scu, u16 *addr, u8 *data,
 
        err = intel_scu_ipc_check_status(scu);
        if (!err) { /* Read rbuf */
-               /* Workaround: values are read as 0 without memcpy_fromio */
-               memcpy_fromio(cbuf, scu->ipc_base + 0x90, 16);
-               for (nc = 0; nc < count; nc++)
-                       data[nc] = ipc_data_readb(scu, nc);
+               for (nc = 0, offset = 0; nc < 4; nc++, offset += 4)
+                       wbuf[nc] = ipc_data_readl(scu, offset);
+               memcpy(data, wbuf, count);
        }
        mutex_unlock(&ipclock);
        return err;