dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: linaro-mm-sig@lists.linaro.org, sebastian.wick@redhat.com,
	labbott@redhat.com, benjamin.gaignard@collabora.com,
	linux-media@vger.kernel.org, mchehab@kernel.org,
	ppaalanen@gmail.com, dri-devel@lists.freedesktop.org,
	nicolas@ndufresne.ca, hverkuil@xs4all.nl, jstultz@google.com,
	lmark@codeaurora.org, tfiga@chromium.org,
	sumit.semwal@linaro.org
Subject: Re: [PATCH 2/2] media: uvcvideo: expose dma-heap hint to userspace
Date: Mon, 23 Jan 2023 16:00:40 +0200	[thread overview]
Message-ID: <Y86TCFUYsWdDNDPP@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230123123756.401692-3-christian.koenig@amd.com>

Hi Christian,

Thank you for the patch.

On Mon, Jan 23, 2023 at 01:37:56PM +0100, Christian König wrote:
> Expose an indicator to let userspace know from which dma_heap
> to allocate for buffers of this device.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index e4bcb5011360..b247026b68c5 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -7,6 +7,7 @@
>   */
>  
>  #include <linux/atomic.h>
> +#include <linux/dma-heap.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/kernel.h>
>  #include <linux/list.h>
> @@ -1909,6 +1910,8 @@ static void uvc_unregister_video(struct uvc_device *dev)
>  
>  	if (dev->vdev.dev)
>  		v4l2_device_unregister(&dev->vdev);
> +	dma_heap_remove_device_link(&dev->udev->dev);
> +

Could we avoid having to call this explicitly in drivers, possibly using
devres in dma_heap_create_device_link() ?

>  #ifdef CONFIG_MEDIA_CONTROLLER
>  	if (media_devnode_is_registered(dev->mdev.devnode))
>  		media_device_unregister(&dev->mdev);
> @@ -2181,6 +2184,14 @@ static int uvc_probe(struct usb_interface *intf,
>  			 dev->uvc_version >> 8, dev->uvc_version & 0xff);
>  	}
>  
> +	/*
> +	 * UVC exports DMA-buf buffers with dirty CPU caches. For compatibility
> +	 * with device which can't snoop the CPU cache it's best practice to
> +	 * allocate DMA-bufs from the system DMA-heap.
> +	 */
> +	if (dma_heap_create_device_link(&dev->udev->dev, "system"))

I don't think this is the right device. A UVC device is usually a
composite USB device with an audio (UAC) function in addition to UVC,
and that may require a different heap (at least conceptually). Wouldn't
the video_device be a better candidate to expose the link ? This would
create a race condition though, as the link will be created after
userspace gets notified of the device being available.

> +		goto error;
> +
>  	/* Register the V4L2 device. */
>  	if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
>  		goto error;

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2023-01-23 14:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-23 12:37 DMA-heap driver hints Christian König
2023-01-23 12:37 ` [PATCH 1/2] dma-heap: add device link and unlink functions Christian König
2023-01-24  4:45   ` John Stultz
2023-01-23 12:37 ` [PATCH 2/2] media: uvcvideo: expose dma-heap hint to userspace Christian König
2023-01-23 14:00   ` Laurent Pinchart [this message]
2023-01-23 23:58   ` kernel test robot
2023-01-24  3:44   ` kernel test robot
2023-01-23 13:55 ` DMA-heap driver hints Laurent Pinchart
2023-01-23 16:29   ` Christian König
2023-01-23 16:58     ` Laurent Pinchart
2023-01-24  3:56       ` James Jones
2023-01-24  7:48         ` Christian König
2023-01-24 23:14           ` T.J. Mercier
2023-01-25 23:20             ` James Jones
2023-01-24  5:19     ` John Stultz
2023-01-24  7:15       ` Christian König
2023-01-25 18:59         ` John Stultz
2023-01-24  5:07   ` John Stultz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y86TCFUYsWdDNDPP@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hverkuil@xs4all.nl \
    --cc=jstultz@google.com \
    --cc=labbott@redhat.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.org \
    --cc=lmark@codeaurora.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas@ndufresne.ca \
    --cc=ppaalanen@gmail.com \
    --cc=sebastian.wick@redhat.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).