* [PATCH] HID: intel-ish-hid: Fix build error for COMPILE_TEST
@ 2024-05-23 1:14 Zhang Lixu
2024-05-23 12:15 ` Jiri Kosina
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Lixu @ 2024-05-23 1:14 UTC (permalink / raw)
To: linux-input, srinivas.pandruvada, jikos, benjamin.tissoires; +Cc: lixu.zhang
kernel test robot reported build error due to a pointer type mismatch:
.../ishtp/loader.c:172:8: error: incompatible pointer types passing
'__le64 *' (aka 'unsigned long long *') to parameter of type
'dma_addr_t *' (aka 'unsigned int *')
The issue arises because the driver, which is primarily intended for
x86-64, is also built for i386 when COMPILE_TEST is enabled.
Resolve type mismatch by using a temporary dma_addr_t variable to hold
the DMA address. Populate this temporary variable in dma_alloc_coherent()
function, and then convert and store the address in the
fragment->fragment_tbl[i].ddr_adrs field in the correct format.
Similarly, convert the ddr_adrs field back to dma_addr_t when freeing
the DMA buffer with dma_free_coherent().
Fixes: 579a267e4617 ("HID: intel-ish-hid: Implement loading firmware from host feature")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202405201313.SAStVPrT-lkp@intel.com/
Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
---
drivers/hid/intel-ish-hid/ishtp/loader.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/intel-ish-hid/ishtp/loader.c b/drivers/hid/intel-ish-hid/ishtp/loader.c
index 993f8b390e57..2785b04a2f5a 100644
--- a/drivers/hid/intel-ish-hid/ishtp/loader.c
+++ b/drivers/hid/intel-ish-hid/ishtp/loader.c
@@ -138,12 +138,13 @@ static void release_dma_bufs(struct ishtp_device *dev,
struct loader_xfer_dma_fragment *fragment,
void **dma_bufs, u32 fragment_size)
{
+ dma_addr_t dma_addr;
int i;
for (i = 0; i < FRAGMENT_MAX_NUM; i++) {
if (dma_bufs[i]) {
- dma_free_coherent(dev->devc, fragment_size, dma_bufs[i],
- fragment->fragment_tbl[i].ddr_adrs);
+ dma_addr = le64_to_cpu(fragment->fragment_tbl[i].ddr_adrs);
+ dma_free_coherent(dev->devc, fragment_size, dma_bufs[i], dma_addr);
dma_bufs[i] = NULL;
}
}
@@ -164,15 +165,16 @@ static int prepare_dma_bufs(struct ishtp_device *dev,
struct loader_xfer_dma_fragment *fragment,
void **dma_bufs, u32 fragment_size)
{
+ dma_addr_t dma_addr;
u32 offset = 0;
int i;
for (i = 0; i < fragment->fragment_cnt && offset < ish_fw->size; i++) {
- dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size,
- &fragment->fragment_tbl[i].ddr_adrs, GFP_KERNEL);
+ dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size, &dma_addr, GFP_KERNEL);
if (!dma_bufs[i])
return -ENOMEM;
+ fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma_addr);
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);
base-commit: de7e71ef8bed222dd144d8878091ecb6d5dfd208
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] HID: intel-ish-hid: Fix build error for COMPILE_TEST
2024-05-23 1:14 [PATCH] HID: intel-ish-hid: Fix build error for COMPILE_TEST Zhang Lixu
@ 2024-05-23 12:15 ` Jiri Kosina
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2024-05-23 12:15 UTC (permalink / raw)
To: Zhang Lixu; +Cc: linux-input, srinivas.pandruvada, benjamin.tissoires
On Thu, 23 May 2024, Zhang Lixu wrote:
> kernel test robot reported build error due to a pointer type mismatch:
>
> .../ishtp/loader.c:172:8: error: incompatible pointer types passing
> '__le64 *' (aka 'unsigned long long *') to parameter of type
> 'dma_addr_t *' (aka 'unsigned int *')
>
> The issue arises because the driver, which is primarily intended for
> x86-64, is also built for i386 when COMPILE_TEST is enabled.
>
> Resolve type mismatch by using a temporary dma_addr_t variable to hold
> the DMA address. Populate this temporary variable in dma_alloc_coherent()
> function, and then convert and store the address in the
> fragment->fragment_tbl[i].ddr_adrs field in the correct format.
> Similarly, convert the ddr_adrs field back to dma_addr_t when freeing
> the DMA buffer with dma_free_coherent().
>
> Fixes: 579a267e4617 ("HID: intel-ish-hid: Implement loading firmware from host feature")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202405201313.SAStVPrT-lkp@intel.com/
> Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
Applied to hid.git#for-6.9/upstream-fixes.
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-23 12:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23 1:14 [PATCH] HID: intel-ish-hid: Fix build error for COMPILE_TEST Zhang Lixu
2024-05-23 12:15 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox