Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4234237pxf; Tue, 16 Mar 2021 08:36:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEcFz4Qf01/y6HCLrWVMjNdWD0pM7kexzEO8gCJhqXbQf7F03gIxtNsvaUD9ffHv3q/8sj X-Received: by 2002:a17:906:311a:: with SMTP id 26mr30150178ejx.395.1615908998715; Tue, 16 Mar 2021 08:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615908998; cv=none; d=google.com; s=arc-20160816; b=yjbiTsoA374rxR+2hKipqValK7dYHwG0vTJ9F2JbE+QogodXYVgcrupooCH+HhJ0on xg+g5DWUTOAjCUPmDZyobSUn22wvyxXs976D8D07hIAxoNj6xEYKEERXbsfnupkOJErG WzGFEkE9UFD0485l9o36B7OPoL+32nib/4j5zW0zlc+0zDdzaQB1M8yASavjhedznQ8c MaqXQlZnRSBQk/EP9u4XgudHjaU9qc8pfqtyvcn8yOigPOzVV0612gj3uil1lyNU9G2c NDqbHSSn3+/04HuZrw6A2psRT/YBdvWpQ2V3eRGzq/jP7U6x8MFtmMqCdwQzdX6SKI/1 HZTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=jKrzBut6DNXk6+ZmMihSkMyQ7s1INSFwS5dGdAbNyU4=; b=OYSd/DMWxwwwk9jf3tyhNNvYWrU3D1OWjTR/QQpObv75zfUM87xYeqA8p2iDN0bru6 E2/dyMV/oPRX3ontVam6rEFDGhepNWXE17XSM6780nVUQU8e1z0/IiuAjOhv2w9rrn61 dO8TFcwDIdQOuvMJxxZjgO+eFAGRhsfVi2qQ71R8KKUpilBIPup5swu2nT7wGXGf97sg US9UzuL8BAfz0EvFfVuFPHRcRrKTIbHKXWpWBzzM7zf3YdRV6GzaVc1wi+VfUj60bu5P dda6dWtv+abDE0of0KmdkgfBgX9CKIAtWy9bx0ERa75aVPXfJ78/OQ5sbnsSvioD1RDB oUkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s2 header.b=THmDfPkF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t24si14484922edw.402.2021.03.16.08.36.16; Tue, 16 Mar 2021 08:36:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s2 header.b=THmDfPkF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234863AbhCPLaD (ORCPT + 99 others); Tue, 16 Mar 2021 07:30:03 -0400 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:45651 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234636AbhCPL3p (ORCPT ); Tue, 16 Mar 2021 07:29:45 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud7.xs4all.net with ESMTPA id M7tJl1XkZ4ywlM7tNlAko9; Tue, 16 Mar 2021 12:29:41 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s2; t=1615894181; bh=jKrzBut6DNXk6+ZmMihSkMyQ7s1INSFwS5dGdAbNyU4=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=THmDfPkFI4c6vEpv22okVMy7WRImNsdTGGbuhHQCs48/sDDG6RcOKSPUJHPaI/z4Y NZLdVN7Quo+HH35JIp0WocIWtX2rIHgce+Jme7HF6f7ey9GFxImYBDdKcZDDGwcOot opiUQ3zTMT7fcWflEOd+pmLwYGaG8x8Cj7J7+uaIHvsPMzaCWqxdWjaAERDGEZxr/K cwhNRSE+JH1tbT0RUv9fYzPlsIS4joSHtaonBupXTT0sGv9jra605D02asdCkYEbBq Bp1DvT9SiOQFmqa5TYnVToQOeaYOwuSLo5TAsicB5Y3/NfUHbclLBTSXxZ7pvvZ/Qw xUQ7Ukt8I2UdA== Subject: Re: [PATCH v4 11/11] uvc: use vb2 ioctl and fop helpers To: Ricardo Ribalda , Laurent Pinchart , Mauro Carvalho Chehab , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil References: <20210315173609.1547857-1-ribalda@chromium.org> <20210315173609.1547857-12-ribalda@chromium.org> From: Hans Verkuil Message-ID: <286aaafa-549a-6728-dc76-8ab2b1e6c581@xs4all.nl> Date: Tue, 16 Mar 2021 12:29:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210315173609.1547857-12-ribalda@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfLCqxChpxEFxZqVLYcP49M+6q1yKHlAHKFXV4CWShQ7RxRuoqlVPYv+G3Hi25GJ9p0KtW7paRL/eEs6+iwJ4liT0nJJTWtF0j9FL1Wp+0qK9RN35+nAh 5G/TPB8Ws5VFLAYagdmf5IBkNs7Anx0fm/XCCmu/JwG12SharXsI2gD5Hqf36e7S6lvdiPx7sToVus/bglS7+95QyJUylTTC9rJ9xQi2hHQbg0kXxgmzHIRG +P3uzbDGvjXsTPMN7Jj4cwjkGTaYSTCaY2Vceg9fozq2tmZw82UdPCJFuzP39mwVALcygXfu67PixjYcI8PiaKrwoT9/T6hU1w6d2vxDgMxuXBBOy9rSqkSq oIbRITlxpvpECc/qyiNFCaapuMZryy9ZpwnY9c/nZpZ9aCIHKNamUHmH8p5NPzKhQXkwOjpa Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ricardo, On 15/03/2021 18:36, Ricardo Ribalda wrote: > From: Hans Verkuil > > When uvc was written the vb2 ioctl and file operation helpers didn't exist. > > This patch switches uvc over to those helpers, which removes a lot of boilerplate > code and simplifies VIDIOC_G/S_PRIORITY handling and allows us to drop the > 'privileges' scheme, since that's now handled inside the vb2 helpers. > > This makes it possible for uvc to pass the v4l2-compliance streaming tests. > > Signed-off-by: Hans Verkuil You can merge this patch into 11/11. I analyzed the uvc get_unmapped_area implementation and it is 100% identical to the vb2_fop_get_unmapped_area implementation, so let's use that one instead. Regards. Hans Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index fba9646c8ba5..437e48b32480 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c @@ -247,18 +247,6 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, return 0; } -/* ----------------------------------------------------------------------------- - * V4L2 queue operations - */ - -#ifndef CONFIG_MMU -unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue, - unsigned long pgoff) -{ - return vb2_get_unmapped_area(&queue->queue, 0, 0, pgoff, 0); -} -#endif - /* ----------------------------------------------------------------------------- * */ diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 348a46637852..172336d6018c 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -1260,20 +1260,6 @@ static long uvc_v4l2_compat_ioctl32(struct file *file, } #endif -#ifndef CONFIG_MMU -static unsigned long uvc_v4l2_get_unmapped_area(struct file *file, - unsigned long addr, unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - struct uvc_fh *handle = file->private_data; - struct uvc_streaming *stream = handle->stream; - - uvc_dbg(stream->dev, CALLS, "%s\n", __func__); - - return uvc_queue_get_unmapped_area(&stream->queue, pgoff); -} -#endif - const struct v4l2_ioctl_ops uvc_ioctl_ops = { .vidioc_querycap = uvc_ioctl_querycap, .vidioc_enum_fmt_vid_cap = uvc_ioctl_enum_fmt_vid_cap, @@ -1325,7 +1311,7 @@ const struct v4l2_file_operations uvc_fops = { .mmap = vb2_fop_mmap, .poll = vb2_fop_poll, #ifndef CONFIG_MMU - .get_unmapped_area = uvc_v4l2_get_unmapped_area, + .get_unmapped_area = vb2_fop_get_unmapped_area, #endif }; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 4e6f0a25b940..a83b16ba6e6a 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -787,10 +787,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, struct uvc_buffer *buf); struct uvc_buffer *uvc_queue_get_current_buffer(struct uvc_video_queue *queue); void uvc_queue_buffer_release(struct uvc_buffer *buf); -#ifndef CONFIG_MMU -unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue, - unsigned long pgoff); -#endif + static inline int uvc_queue_streaming(struct uvc_video_queue *queue) { return vb2_is_streaming(&queue->queue);