Skip to content

Commit a31a405

Browse files
ming1Mauro Carvalho Chehab
authored and
Mauro Carvalho Chehab
committed
V4L/DVB:usbvideo:don't use part of buffer for USB transfer #4
The status[] is part of uvc_device structure. We can't make sure the address of status is at a cache-line boundary in all archs,so status[] might share a cache-line with some fields in uvc_structure. This can lead to some cache coherence issues(http://lwn.net/Articles/2265/). Use dynamically allocated buffer instead. Signed-off-by: Ming Lei <[email protected]> Acked-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent d63beb9 commit a31a405

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

drivers/media/video/uvc/uvc_status.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,15 @@ int uvc_status_init(struct uvc_device *dev)
177177

178178
uvc_input_init(dev);
179179

180+
dev->status = kzalloc(UVC_MAX_STATUS_SIZE, GFP_KERNEL);
181+
if (dev->status == NULL)
182+
return -ENOMEM;
183+
180184
dev->int_urb = usb_alloc_urb(0, GFP_KERNEL);
181-
if (dev->int_urb == NULL)
185+
if (dev->int_urb == NULL) {
186+
kfree(dev->status);
182187
return -ENOMEM;
188+
}
183189

184190
pipe = usb_rcvintpipe(dev->udev, ep->desc.bEndpointAddress);
185191

@@ -192,7 +198,7 @@ int uvc_status_init(struct uvc_device *dev)
192198
interval = fls(interval) - 1;
193199

194200
usb_fill_int_urb(dev->int_urb, dev->udev, pipe,
195-
dev->status, sizeof dev->status, uvc_status_complete,
201+
dev->status, UVC_MAX_STATUS_SIZE, uvc_status_complete,
196202
dev, interval);
197203

198204
return usb_submit_urb(dev->int_urb, GFP_KERNEL);
@@ -202,6 +208,7 @@ void uvc_status_cleanup(struct uvc_device *dev)
202208
{
203209
usb_kill_urb(dev->int_urb);
204210
usb_free_urb(dev->int_urb);
211+
kfree(dev->status);
205212
uvc_input_cleanup(dev);
206213
}
207214

drivers/media/video/uvc/uvcvideo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ struct uvc_xu_control {
303303
#define UVC_MAX_FRAME_SIZE (16*1024*1024)
304304
/* Maximum number of video buffers. */
305305
#define UVC_MAX_VIDEO_BUFFERS 32
306+
/* Maximum status buffer size in bytes of interrupt URB. */
307+
#define UVC_MAX_STATUS_SIZE 16
306308

307309
#define UVC_CTRL_CONTROL_TIMEOUT 300
308310
#define UVC_CTRL_STREAMING_TIMEOUT 1000
@@ -634,7 +636,7 @@ struct uvc_device {
634636
/* Status Interrupt Endpoint */
635637
struct usb_host_endpoint *int_ep;
636638
struct urb *int_urb;
637-
__u8 status[16];
639+
__u8 *status;
638640
struct input_dev *input;
639641

640642
/* Video Streaming interfaces */

0 commit comments

Comments
 (0)