Bug 455230 - v4l2 ioctl debug messages cannot be turned off
v4l2 ioctl debug messages cannot be turned off
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel (Show other bugs)
5.2
All Linux
low Severity medium
: rc
: ---
Assigned To: Mauro Carvalho Chehab
Martin Jenner
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-14 05:09 EDT by Howard Gray
Modified: 2009-01-20 15:25 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-01-20 15:25:00 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch to correct "dbgarg" macro and allow V4L2 ioctl debug messages to be turned on or off with the debug flags (708 bytes, patch)
2008-07-14 05:14 EDT, Howard Gray
no flags Details | Diff
patch for this problem from the upstream kernel (1.60 KB, patch)
2008-07-14 07:39 EDT, Arnd Bergmann
no flags Details | Diff

  None (edit)
Description Howard Gray 2008-07-14 05:09:28 EDT
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:
Always


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 05:14:43 EDT
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 07:02:49 EDT
The patch only corrects the dbgarg macro, not dbgarg2, which has the same bug.
Comment 3 Howard Gray 2008-07-14 07:24:10 EDT
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
dbgarg2.
Comment 4 Arnd Bergmann 2008-07-14 07:39:24 EDT
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)
     printk(...);
} 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
like

if (condition)
   dbgarg(...)
else
   bar();

that would otherwise turn into

if (condition)
   if (vfd->debug)
       printk(...);
   else
       bar();

which is something completely different.

For reference, the attached patch was merged into mainline to address this
problem.
Comment 5 Howard Gray 2008-07-14 08:17:19 EDT
Fine by me. Best to use the upstream patch, of course.
Comment 6 Mauro Carvalho Chehab 2008-08-12 09:30:53 EDT
sent to rhkernel-list
Comment 7 Don Zickus 2008-09-02 23:40:41 EDT
in kernel-2.6.18-107.el5
You can download this test kernel from http://people.redhat.com/dzickus/el5
Comment 11 Adrian Reber 2009-01-15 06:08:44 EST
Will this fix appear in RHEL5.2?
Comment 12 errata-xmlrpc 2009-01-20 15:25:00 EST
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.

http://rhn.redhat.com/errata/RHSA-2009-0225.html

Note You need to log in before you can comment on or make changes to this bug.