Hi, I have been working on supporting a composite builtin driver with UVC using a dwc3 USB controller. At userspace I am using userptr in order to push the buffers to the driver. Currently we are working with scatter gather support from the videobuf2-dma-sg API, this in order to avoid unnecessary copies that are normally used in the memcpy of uvc_video_encode_data function inside uvc_video.c, and using uvc_video_encode_isoc_sg instead. Everything works fine when we are using memory coming from a malloc at userspace, but when we use the CMEM allocated memory pointers we are getting the following error when queueing the buffers: Cannot allocate memory (12). I managed to track down the issue up until the vb2_dma_sg_get_userptr function from the videobuf2-dma-sg API, and I see that we are failing at creating the vector of pages thus failing to create the scatterlist for the buffer. I tried to workaround this by creating a manual scatterlist with a mapped memory vaddr taking inspiration on how the videobuf2-vmalloc API works (it is important to mention this works for the CMEM pointers, but doing the memcpy), by doing this inside the vb2_dma_sg_get_userptr function: unsigned long *nums = frame_vector_pfns(vec); buf->vaddr = (__force void *) ioremap(__pfn_to_phys(nums[0]), size + offset); buf->num_pages = 1; sg_alloc_table(buf->dma_sgt, buf->num_pages, GFP_KERNEL); sgt = buf->dma_sgt; for_each_sgtable_sg(sgt, sg, i) { sg_set_buf(sg, (void *)(buf->vaddr), size+offset); } The problem is, the buffers we are receiving at the host are corrupted, which lets me think that we are probably reading from another memory that has no relation with the CMEM pointer memory. In summary, this is the current situation we have and the CMEM_alloc + videobuf2-dma-sg is the desired one that is not working. allocation \ mem ops videobuf2-vmalloc videobuf2-dma-sg ----------------------- -------------------- ------------------- malloc working working CMEM_alloc working not working My question here is: Is this approach correct? Or are we trying to do something that doesn't have support? Is there another correct way that we should be trying in order to send the CMEM buffers without doing any memory copy at all? As of right now, the UVC functions only support doing the memcpy or using the scatterlist, which is why we are using the second one. Any thoughts or insight will be very appreciated. Thank you in advance, -- Roberto Gutierrez Sánchez Computer Engineer Embedded Software Developer RidgeRun Embedded Solutions