From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@infradead.org>,
Hans de Goede <hdegoede@redhat.com>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Pawel Osciak <pawel@osciak.com>,
Tomasz Stanislawski <t.stanislaws@samsung.com>,
Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [RFCv2 PATCH 19/34] v4l2-dev.c: add debug sysfs entry.
Date: Wed, 27 Jun 2012 11:54:40 +0200 [thread overview]
Message-ID: <2029394.km7RaaeAMe@avalon> (raw)
In-Reply-To: <a497cef0c59c8872218faa5d83095fe03c01a430.1340366355.git.hans.verkuil@cisco.com>
Hi Hans,
Thanks for the patch.
On Friday 22 June 2012 14:21:13 Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Since this could theoretically change the debug value while in the middle
> of v4l2-ioctl.c, we make a copy of vfd->debug to ensure consistent debug
> behavior.
In my review of RFCv1, I wrote that this could introduce a race condition:
"You test the debug value several times in the __video_do_ioctl() function. I
haven't checked in details whether changing the value between the two tests
could for instance lead to a KERN_CONT print without a previous non-KERN_CONT
message. That won't crash the machine but it should still be avoided."
Have you verified whether that problem can occur ?
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
> drivers/media/video/v4l2-dev.c | 24 ++++++++++++++++++++++++
> drivers/media/video/v4l2-ioctl.c | 9 +++++----
> 2 files changed, 29 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
> index 1500208..5c0bb18 100644
> --- a/drivers/media/video/v4l2-dev.c
> +++ b/drivers/media/video/v4l2-dev.c
> @@ -46,6 +46,29 @@ static ssize_t show_index(struct device *cd,
> return sprintf(buf, "%i\n", vdev->index);
> }
>
> +static ssize_t show_debug(struct device *cd,
> + struct device_attribute *attr, char *buf)
> +{
> + struct video_device *vdev = to_video_device(cd);
> +
> + return sprintf(buf, "%i\n", vdev->debug);
> +}
> +
> +static ssize_t set_debug(struct device *cd, struct device_attribute *attr,
> + const char *buf, size_t len)
> +{
> + struct video_device *vdev = to_video_device(cd);
> + int res = 0;
> + u16 value;
> +
> + res = kstrtou16(buf, 0, &value);
> + if (res)
> + return res;
> +
> + vdev->debug = value;
> + return len;
> +}
> +
> static ssize_t show_name(struct device *cd,
> struct device_attribute *attr, char *buf)
> {
> @@ -56,6 +79,7 @@ static ssize_t show_name(struct device *cd,
>
> static struct device_attribute video_device_attrs[] = {
> __ATTR(name, S_IRUGO, show_name, NULL),
> + __ATTR(debug, 0644, show_debug, set_debug),
> __ATTR(index, S_IRUGO, show_index, NULL),
> __ATTR_NULL
> };
> diff --git a/drivers/media/video/v4l2-ioctl.c
> b/drivers/media/video/v4l2-ioctl.c index 0531d9a..2e1421b 100644
> --- a/drivers/media/video/v4l2-ioctl.c
> +++ b/drivers/media/video/v4l2-ioctl.c
> @@ -1998,6 +1998,7 @@ static long __video_do_ioctl(struct file *file,
> void *fh = file->private_data;
> struct v4l2_fh *vfh = NULL;
> int use_fh_prio = 0;
> + int debug = vfd->debug;
> long ret = -ENOTTY;
>
> if (ops == NULL) {
> @@ -2031,7 +2032,7 @@ static long __video_do_ioctl(struct file *file,
> }
>
> write_only = _IOC_DIR(cmd) == _IOC_WRITE;
> - if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) {
> + if (write_only && debug > V4L2_DEBUG_IOCTL) {
> v4l_print_ioctl(vfd->name, cmd);
> pr_cont(": ");
> info->debug(arg, write_only);
> @@ -2053,8 +2054,8 @@ static long __video_do_ioctl(struct file *file,
> }
>
> done:
> - if (vfd->debug) {
> - if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) {
> + if (debug) {
> + if (write_only && debug > V4L2_DEBUG_IOCTL) {
> if (ret < 0)
> printk(KERN_DEBUG "%s: error %ld\n",
> video_device_node_name(vfd), ret);
> @@ -2063,7 +2064,7 @@ done:
> v4l_print_ioctl(vfd->name, cmd);
> if (ret < 0)
> pr_cont(": error %ld\n", ret);
> - else if (vfd->debug == V4L2_DEBUG_IOCTL)
> + else if (debug == V4L2_DEBUG_IOCTL)
> pr_cont("\n");
> else if (_IOC_DIR(cmd) == _IOC_NONE)
> info->debug(arg, write_only);
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2012-06-27 9:54 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-22 12:20 [RFCv2 PATCH 00/34] Core and vb2 enhancements Hans Verkuil
2012-06-22 12:20 ` [RFCv2 PATCH 01/34] Regression fixes Hans Verkuil
2012-06-22 12:20 ` [RFCv2 PATCH 02/34] v4l2-ioctl.c: move a block of code down, no other changes Hans Verkuil
2012-06-22 12:20 ` [RFCv2 PATCH 03/34] v4l2-ioctl.c: introduce INFO_FL_CLEAR to replace switch Hans Verkuil
2012-06-22 12:20 ` [RFCv2 PATCH 04/34] v4l2-ioctl.c: v4l2-ioctl: add debug and callback/offset functionality Hans Verkuil
2012-06-22 12:20 ` [RFCv2 PATCH 05/34] v4l2-ioctl.c: remove an unnecessary #ifdef Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 06/34] v4l2-ioctl.c: use the new table for querycap and i/o ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 07/34] v4l2-ioctl.c: use the new table for priority ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 08/34] v4l2-ioctl.c: use the new table for format/framebuffer ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 09/34] v4l2-ioctl.c: use the new table for overlay/streamon/off ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 10/34] v4l2-ioctl.c: use the new table for std/tuner/modulator ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 11/34] v4l2-ioctl.c: use the new table for queuing/parm ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 12/34] v4l2-ioctl.c: use the new table for control ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 13/34] v4l2-ioctl.c: use the new table for selection ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 14/34] v4l2-ioctl.c: use the new table for compression ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 15/34] v4l2-ioctl.c: use the new table for debug ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 16/34] v4l2-ioctl.c: use the new table for preset/timings ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 17/34] v4l2-ioctl.c: use the new table for the remaining ioctls Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 18/34] v4l2-ioctl.c: finalize table conversion Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 19/34] v4l2-dev.c: add debug sysfs entry Hans Verkuil
2012-06-27 9:54 ` Laurent Pinchart [this message]
2012-06-27 10:38 ` Hans Verkuil
2012-06-27 10:52 ` Laurent Pinchart
2012-06-22 12:21 ` [RFCv2 PATCH 20/34] v4l2-ioctl: remove v4l_(i2c_)print_ioctl Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 21/34] ivtv: don't mess with vfd->debug Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 22/34] cx18: " Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 23/34] vb2-core: refactor reqbufs/create_bufs Hans Verkuil
2012-06-27 9:52 ` Laurent Pinchart
2012-06-27 10:37 ` Hans Verkuil
2012-06-27 10:49 ` Laurent Pinchart
2012-06-22 12:21 ` [RFCv2 PATCH 24/34] vb2-core: add support for count == 0 in create_bufs Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 25/34] Spec: document CREATE_BUFS behavior if count == 0 Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 26/34] v4l2-dev/ioctl.c: add vb2_queue support to video_device Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 27/34] videobuf2-core: add helper functions Hans Verkuil
2012-06-27 9:42 ` Laurent Pinchart
2012-06-27 10:31 ` Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 28/34] vivi: remove pointless g/s_std support Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 29/34] vivi: embed struct video_device instead of allocating it Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 30/34] vivi: use vb2 helper functions Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 31/34] vivi: add create_bufs/preparebuf support Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 32/34] v4l2-dev.c: also add debug support for the fops Hans Verkuil
2012-06-27 9:59 ` Laurent Pinchart
2012-06-27 10:44 ` Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 33/34] pwc: use the new vb2 helpers Hans Verkuil
2012-06-22 12:21 ` [RFCv2 PATCH 34/34] pwc: v4l2-compliance fixes Hans Verkuil
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=2029394.km7RaaeAMe@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=g.liakhovetski@gmx.de \
--cc=hans.verkuil@cisco.com \
--cc=hdegoede@redhat.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=pawel@osciak.com \
--cc=t.stanislaws@samsung.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.