Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 455230

Summary: v4l2 ioctl debug messages cannot be turned off
Product: Red Hat Enterprise Linux 5 Reporter: Howard Gray <howard.gray>
Component: kernelAssignee: Mauro Carvalho Chehab <mchehab>
Status: CLOSED ERRATA QA Contact: Martin Jenner <mjenner>
Severity: medium Docs Contact:
Priority: low    
Version: 5.2CC: adrian, arnd, dzickus, lwang, mchehab
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-01-20 20:25:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Description Flags
Patch to correct "dbgarg" macro and allow V4L2 ioctl debug messages to be turned on or off with the debug flags
patch for this problem from the upstream kernel none

Description Howard Gray 2008-07-14 09:09:28 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9) Gecko/2008061015 Firefox/3.0

Description of problem:
The kernel always produces debug messages for every V4L ioctl called. The debug flags in the video device (e.g. V4L2_DEBUG_IOCTL_ARG) are ignored. The macro "dbgarg" used to produce the messages (in file drivers/media/video/videodev.c from line 17) is faulty. Later kernel versions have a corrected macro.

Version-Release number of selected component (if applicable):
RHEL5u1 with kernel-debug-2.6.18-95.el5.ppc64.rpm prerelease kernel 

How reproducible:

Steps to Reproduce:
1.Connect a V4L2 device.
2.In the driver for the V4L2 device ensure that the "debug" field in the "struct video_device" is 0 (i.e. no debug messages required).
3.Run a V4L2 application and observe the kernel log.

Actual Results:
Many messages like these are seen in the kernel log and cannot be turned off:

v4l2 ioctl VIDIOC_S_INPUT, dir=rw (0xc0045627)
v4l2 ioctl VIDIOC_QUERYCAP, dir=r- (0x40685600)
v4l2 ioctl VIDIOC_G_FMT, dir=rw (0xc0d05604)
v4l2 ioctl VIDIOC_S_STD, dir=-w (0x80085618)
v4l2 ioctl VIDIOC_G_FMT, dir=rw (0xc0d05604)
v4l2 ioctl VIDIOC_S_FMT, dir=rw (0xc0d05605)
v4l2 ioctl VIDIOC_TRY_FMT, dir=rw (0xc0d05640)
v4l2 ioctl VIDIOC_TRY_FMT, dir=rw (0xc0d05640)
v4l2 ioctl VIDIOC_TRY_FMT, dir=rw (0xc0d05640)
v4l2 ioctl VIDIOC_TRY_FMT, dir=rw (0xc0d05640)
v4l2 ioctl VIDIOC_TRY_FMT, dir=rw (0xc0d05640)
v4l2 ioctl VIDIOC_TRY_FMT, dir=rw (0xc0d05640)
v4l2 ioctl VIDIOC_TRY_FMT, dir=rw (0xc0d05640)
v4l2 ioctl VIDIOC_TRY_FMT, dir=rw (0xc0d05640)

Expected Results:
The "debug" field in the "struct video_device" should control the output of V4L2 ioctl debug messages but it is ignored.

Additional info:

Comment 1 Howard Gray 2008-07-14 09:14:43 UTC
Created attachment 311686 [details]
Patch to correct "dbgarg" macro and allow V4L2 ioctl debug messages to be turned on or off with the debug flags

This is a backport from newer kernel versions, Without this patch the use of
V4L2 devices on RHEL 5.2 will be made considerably more difficult due to the
very high amount of debug messages created.

Comment 2 Arnd Bergmann 2008-07-14 11:02:49 UTC
The patch only corrects the dbgarg macro, not dbgarg2, which has the same bug.

Comment 3 Howard Gray 2008-07-14 11:24:10 UTC
No, I do not agree. The dbgarg2 macro consists only of an "if" followed by a
single line:

#define dbgarg2(fmt, arg...) \
                if (vfd->debug & V4L2_DEBUG_IOCTL_ARG)                  \
                        printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg);

So "{" ... "}" brackets are not strictly needed here unless for style purposes.
Later kernel versions (e.g. 2.6.23) have only a corrected version of dbgarg not

Comment 4 Arnd Bergmann 2008-07-14 11:39:24 UTC
Created attachment 311689 [details]
patch for this problem from the upstream kernel

Yes, you're right, the curly braces are not needed.

For correctness, it would be better to use the 

do {
  if (vfd->debug)
} while (0)

form though for both macros, fixing the code in the same way as upstream.

If it's not clear why, the 'do { } while (0)' form avoids problems with users

if (condition)

that would otherwise turn into

if (condition)
   if (vfd->debug)

which is something completely different.

For reference, the attached patch was merged into mainline to address this

Comment 5 Howard Gray 2008-07-14 12:17:19 UTC
Fine by me. Best to use the upstream patch, of course.

Comment 6 Mauro Carvalho Chehab 2008-08-12 13:30:53 UTC
sent to rhkernel-list

Comment 7 Don Zickus 2008-09-03 03:40:41 UTC
in kernel-2.6.18-107.el5
You can download this test kernel from

Comment 11 Adrian Reber 2009-01-15 11:08:44 UTC
Will this fix appear in RHEL5.2?

Comment 12 errata-xmlrpc 2009-01-20 20:25:00 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.