Em Thursday 24 April 2008 19:17:36 Laurent Pinchart escreveu:
> Hi Herton,
>
> On Thursday 24 April 2008, Herton Ronaldo Krzesinski wrote:
> > Em Wednesday 23 April 2008 00:01:14 Herton Ronaldo Krzesinski escreveu:
> > uvcvideo: device USB2.0 Camera requested null bandwidth, defaulting to
> > lowest. kopete: page allocation failure. order:5, mode:0x0
> > Pid: 6996, comm: kopete Not tainted 2.6.24.4-desktop-2mdvoem #1
> > [<c010645a>] show_trace_log_lvl+0x1a/0x30
> > [<c0106ec2>] show_trace+0x12/0x20
> > [<c010794c>] dump_stack+0x6c/0x80
> > [<c016e5a8>] __alloc_pages+0x278/0x360
> > [<c016e6df>] __get_free_pages+0x4f/0x60
> > [<c010a25a>] dma_alloc_coherent+0xba/0x110
> > [<ccdd7a17>] hcd_buffer_alloc+0x47/0x80 [usbcore]
> > [<ccdcd335>] usb_buffer_alloc+0x25/0x30 [usbcore]
> > [<ccf59bf8>] uvc_init_video+0x158/0x3b0 [uvcvideo]
> > [<ccf59e9a>] uvc_video_enable+0x4a/0x50 [uvcvideo]
> > [<ccf59229>] uvc_v4l2_do_ioctl+0x999/0xfb0 [uvcvideo]
> > [<ccf40283>] video_usercopy+0xc3/0x230 [videodev]
> > [<ccf58263>] uvc_v4l2_ioctl+0x43/0x50 [uvcvideo]
> > [<c019a578>] do_ioctl+0x88/0xa0
> > [<c019a7af>] vfs_ioctl+0x21f/0x2a0
> > [<c019a883>] sys_ioctl+0x53/0x70
> > [<c010532e>] sysenter_past_esp+0x6b/0xa1
> > =======================
> > Mem-info:
> > DMA per-cpu:
> > CPU 0: Hot: hi: 0, btch: 1 usd: 0 Cold: hi: 0, btch: 1
> > usd: 0
> > CPU 1: Hot: hi: 0, btch: 1 usd: 0 Cold: hi: 0, btch: 1
> > usd: 0
> > Normal per-cpu:
> > CPU 0: Hot: hi: 42, btch: 7 usd: 33 Cold: hi: 14, btch: 3
> > usd: 13
> > CPU 1: Hot: hi: 42, btch: 7 usd: 40 Cold: hi: 14, btch: 3
> > usd: 12
> > Active:30836 inactive:8955 dirty:0 writeback:0 unstable:0
> > free:528 slab:3006 mapped:12950 pagetables:371 bounce:0
> > DMA free:836kB min:144kB low:180kB high:216kB active:9980kB
> > inactive:1260kB present:16256kB pages_scanned:65 all_unreclaimable? no
> > lowmem_reserve[]: 0 173 173 173
> > Normal free:1276kB min:1608kB low:2008kB high:2412kB active:113364kB
> > inactive:34560kB present:177292kB pages_scanned:0 all_unreclaimable? no
> > lowmem_reserve[]: 0 0 0 0
> > DMA: 9*4kB 0*8kB 1*16kB 1*32kB 0*64kB 0*128kB 1*256kB 1*512kB 0*1024kB
> > 0*2048kB 0*4096kB = 852kB
> > Normal: 30*4kB 4*8kB 0*16kB 0*32kB 0*64kB 1*128kB 0*256kB 0*512kB
> > 1*1024kB 0*2048kB 0*4096kB = 1304kB
> > Swap cache: add 0, delete 0, find 0/0, race 0+0
> > Free swap = 1084348kB
> > Total swap = 1084348kB
> > Free swap: 1084348kB
> > 48768 pages of RAM
> > 0 pages of HIGHMEM
> > 1454 reserved pages
> > 58649 pages shared
> > 0 pages swap cached
> > 0 pages dirty
> > 0 pages writeback
> > 12950 pages mapped
> > 3006 pages slab
> > 371 pages pagetableS
> >
> > Without lowering UVC_MAX_ISO_PACKETS I get the above in one machine (it
> > has indeed not much main memory, it's a notebook where free reports
> > 184MB, main memory is shared with onboard video it seems). But recently I
> > saw streaming issues after lowering it in another webcam, so I'm not
> > using this anymore for every machine, then I didn't catch too the -45
> > errors anymore, now I finally discovered what was happening.
> >
> > So may be we have two bugs here then:
> > - Memory allocation in uvcvideo doesn't work for all cases, urb
> > allocation should be revisited or is it ok?
>
> The only sensible option I can think of would be to lower
> UVC_MAX_ISO_PACKETS. The UVC driver tries not to put too much pressure on
> system memory but it still needs URB buffers. Lowering UVC_MAX_ISO_PACKETS
> will decrease memory pressure but will increase CPU usage, so it's a
> tradeoff, like always.
If anyone needs I made the following patch to change UVC_MAX_ISO_PACKETS as a
module parameter:
--- linux-2.6.24/3rdparty/uvc/uvc_video.c.orig 2008-04-29 13:59:23.000000000
-0300
+++ linux-2.6.24/3rdparty/uvc/uvc_video.c 2008-04-29 14:20:42.000000000
-0300
@@ -594,7 +594,7 @@ static int uvc_init_video_isoc(struct uv
/* Compute the number of isochronous packets to allocate by dividing
* the maximum video frame size by the packet size. Limit the result
- * to UVC_MAX_ISO_PACKETS.
+ * to uvc_max_iso_pkts.
*/
psize = le16_to_cpu(ep->desc.wMaxPacketSize);
psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
@@ -604,8 +604,8 @@ static int uvc_init_video_isoc(struct uv
return -EINVAL;
npackets = (size + psize - 1) / psize;
- if (npackets > UVC_MAX_ISO_PACKETS)
- npackets = UVC_MAX_ISO_PACKETS;
+ if (npackets > uvc_max_iso_pkts)
+ npackets = uvc_max_iso_pkts;
size = npackets * psize;
@@ -661,14 +661,14 @@ static int uvc_init_video_bulk(struct uv
/* Compute the bulk URB size. Some devices set the maximum payload
* size to a value too high for memory-constrained devices. We must
* then transfer the payload accross multiple URBs. To be consistant
- * with isochronous mode, allocate maximum UVC_MAX_ISO_PACKETS per bulk
+ * with isochronous mode, allocate maximum uvc_max_iso_pkts per bulk
* URB.
*/
psize = le16_to_cpu(ep->desc.wMaxPacketSize) & 0x07ff;
size = video->streaming->ctrl.dwMaxPayloadTransferSize;
video->bulk.max_payload_size = size;
- if (size > psize * UVC_MAX_ISO_PACKETS)
- size = psize * UVC_MAX_ISO_PACKETS;
+ if (size > psize * uvc_max_iso_pkts)
+ size = psize * uvc_max_iso_pkts;
pipe = usb_rcvbulkpipe(video->dev->udev, ep->desc.bEndpointAddress);
--- linux-2.6.24/3rdparty/uvc/uvcvideo.h.orig 2008-04-29 14:01:21.000000000
-0300
+++ linux-2.6.24/3rdparty/uvc/uvcvideo.h 2008-04-29 14:02:07.000000000
-0300
@@ -673,6 +673,7 @@ struct uvc_driver {
#define UVC_TRACE_SUSPEND (1 << 8)
#define UVC_TRACE_STATUS (1 << 9)
+extern unsigned int uvc_max_iso_pkts;
extern unsigned int uvc_trace_param;
#define uvc_trace(flag, msg...) \
--- linux-2.6.24/3rdparty/uvc/uvc_driver.c.orig 2008-04-29 13:45:18.000000000
-0300
+++ linux-2.6.24/3rdparty/uvc/uvc_driver.c 2008-04-29 14:19:27.000000000
-0300
@@ -51,6 +51,7 @@
#define DRIVER_VERSION "v0.1.0"
#endif
+unsigned int uvc_max_iso_pkts = UVC_MAX_ISO_PACKETS;
static unsigned int uvc_quirks_param;
unsigned int uvc_trace_param;
@@ -1581,6 +1582,17 @@ static int uvc_probe(struct usb_interfac
"linux-uvc-devel mailing list.\n");
}
+ if (uvc_max_iso_pkts > UVC_MAX_ISO_PACKETS) {
+ uvc_printk(KERN_INFO, "Given max_iso_pkts greater then the "
+ "maximum allowed\n");
+ uvc_printk(KERN_INFO, "Limiting max_iso_pkts to "
+ "UVC_MAX_ISO_PACKETS=%u\n", UVC_MAX_ISO_PACKETS);
+ uvc_max_iso_pkts = UVC_MAX_ISO_PACKETS;
+ } else {
+ uvc_printk(KERN_INFO, "Using UVC_MAX_ISO_PACKETS=%u\n",
+ uvc_max_iso_pkts);
+ }
+
/* Initialize controls */
if (uvc_ctrl_init_device(dev) < 0)
goto error;
@@ -1925,6 +1937,8 @@ static void __exit uvc_cleanup(void)
module_init(uvc_init);
module_exit(uvc_cleanup);
+module_param_named(max_iso_pkts, uvc_max_iso_pkts, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(max_iso_pkts, "Maximum isochronous packets limit");
module_param_named(quirks, uvc_quirks_param, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(quirks, "Forced device quirks");
module_param_named(trace, uvc_trace_param, uint, S_IRUGO|S_IWUSR);
>
> Thanks for the report.
>
> Best regards,
>
> Laurent Pinchart
--
[]'s
Herton
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel