RE: [PATCH] mei: allocate client DMA buffers on the parent device
From: Usyskin, Alexander
Date: Mon Nov 16 2026 - 02:57:52 EST
> Subject: [PATCH] mei: allocate client DMA buffers on the parent device
>
> Since commit 7704e6be4ed2 ("mei: hook mei_device on class device"),
> struct mei_device embeds its class device as dev and keeps the PCI
> device in dev->parent. The DMA ring moved its coherent allocation to
> dev->parent, but mei_cl_dma_alloc() and mei_cl_dma_free() still pass
> &cl->dev->dev, the class device, which has no DMA mask. The allocation
> warns in dma_alloc_attrs() and fails, so mei_cldev_dma_map() returns
> -ENOMEM and iwlmei, its only user, cannot bind:
>
> WARNING: kernel/dma/mapping.c:639 at dma_alloc_attrs+0x48/0x300
> ...
> dmam_alloc_attrs+0x5b/0xb0
> mei_cl_dma_alloc_and_map+0x152/0x6a0 [mei]
> mei_cldev_dma_map+0x77/0xf0 [mei]
> iwl_mei_probe+0x19e/0x6b0 [iwlmei]
> ...
> iwlmei 0000:00:16.0-13280904-7792-4fcb-a1aa-5e70cbb1e865: Couldn't
> allocate the shared memory: -12
>
> This was seen on an HP ZBook Firefly 14 G10 (Intel Wi-Fi 6E AX211, CSME
> 16.1) with IWLMEI built. It went unnoticed because IWLMEI depends on
> BROKEN.
>
> With this change iwlmei binds and the Wi-Fi handover between CSME and
> the host works on that machine.
>
> Allocate and free the buffers on dev->parent, as the DMA ring does.
>
Ops, good catch.
Thanks for the fix!
Acked-by: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
> Fixes: 7704e6be4ed2 ("mei: hook mei_device on class device")
> Signed-off-by: Andrei Rusu de Castro <arc@empyreal.works>
> ---
> drivers/misc/mei/client.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
> index 26d2b2742d50..a0f698b5d296 100644
> --- a/drivers/misc/mei/client.c
> +++ b/drivers/misc/mei/client.c
> @@ -2248,7 +2248,7 @@ int mei_cl_irq_dma_unmap(struct mei_cl *cl, struct
> mei_cl_cb *cb,
>
> static int mei_cl_dma_alloc(struct mei_cl *cl, u8 buf_id, size_t size)
> {
> - cl->dma.vaddr = dmam_alloc_coherent(&cl->dev->dev, size,
> + cl->dma.vaddr = dmam_alloc_coherent(cl->dev->parent, size,
> &cl->dma.daddr, GFP_KERNEL);
> if (!cl->dma.vaddr)
> return -ENOMEM;
> @@ -2262,7 +2262,7 @@ static int mei_cl_dma_alloc(struct mei_cl *cl, u8
> buf_id, size_t size)
> static void mei_cl_dma_free(struct mei_cl *cl)
> {
> cl->dma.buffer_id = 0;
> - dmam_free_coherent(&cl->dev->dev,
> + dmam_free_coherent(cl->dev->parent,
> cl->dma.size, cl->dma.vaddr, cl->dma.daddr);
> cl->dma.size = 0;
> cl->dma.vaddr = NULL;
> --
> 2.55.0
>