Re: [PATCH] drm/virtio: Use vmalloc for command buffer allocations.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Thu, Aug 29, 2019 at 11:09 PM Gerd Hoffmann <kraxel@xxxxxxxxxx> wrote:
  Hi,

>  {
>       if (vbuf->resp_size > MAX_INLINE_RESP_SIZE)
>               kfree(vbuf->resp_buf);
> -     kfree(vbuf->data_buf);
> +     kvfree(vbuf->data_buf);

if (is_vmalloc_addr(vbuf->data_buf)) ...

needed here I gues?

kvfree() handles vmalloc/kmalloc/kvmalloc internally by doing that check.
 

> +/* Create sg_table from a vmalloc'd buffer. */
> +static struct sg_table *vmalloc_to_sgt(char *data, uint32_t size)

Hmm, isn't there an existing function for that?
I'd be surprised if virtio-gpu is the first driver needing this ...

And it case there really isn't one this should probably added to the
vmalloc or scatterlist code, not the virtio-gpu driver.

There's a few other similar ones around:
- pack_sg_list in net/9p/trans_virtio.c, assumes contiguous array of scatterlist and non-vmalloc
- videobuf_vmalloc_to_sg in drivers/media/v4l2-core/videobuf-dma-sg.c, assumes contiguous array of scatterlist and that the buffer being converted is page aligned (the l
- vmalloc_to_sg() in drivers/media/common/saa7146/saa7146_core.c, duplicate of videobuf_vmalloc_to_sg

None of the existing ones seemed to do what was needed and the convention seemed to pack an sg table as needed for the usage and just keep it in the module so that's what I followed.  I'm not very familiar with these APIs so maybe there's something I missed, but I did look through the helpers in lib/scatterlist.c and didn't see anything.  If you think it is better suited to live in scatterlist I can prepare another change for that.

Dave

cheers,
  Gerd

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux