On (21/08/03 12:15), Hans Verkuil wrote: > > static void *vb2_dc_vaddr(struct vb2_buffer *vb, void *buf_priv) > > { > > struct vb2_dc_buf *buf = buf_priv; > > - struct dma_buf_map map; > > - int ret; > > > > - if (!buf->vaddr && buf->db_attach) { > > - ret = dma_buf_vmap(buf->db_attach->dmabuf, &map); > > - buf->vaddr = ret ? NULL : map.vaddr; > > + if (buf->vaddr) > > + return buf->vaddr; > > + > > + if (buf->db_attach) { > > + struct dma_buf_map map; > > + > > + if (!dma_buf_vmap(buf->db_attach->dmabuf, &map)) > > + buf->vaddr = map.vaddr; > > + > > + return buf->vaddr; > > } > > > > + if (!buf->coherent_mem) > > + buf->vaddr = dma_vmap_noncontiguous(buf->dev, buf->size, > > + buf->dma_sgt); > > return buf->vaddr; > > } > > This function really needs a bunch of comments. > > What I want to see here specifically is under which circumstances this function > can return NULL. > > - dma_buf_vmap returns an error > - for non-coherent memory dma_vmap_noncontiguous returns an error > - coherent memory with DMA_ATTR_NO_KERNEL_MAPPING set. Done.