V4L/DVB:usbvideo:don't use part of buffer for USB transfer #4

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Monday, October 13, 2008 - 3:15 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a31a40...
Commit:     a31a4055473bf0a7b2b06cb2262347200d0711e1
Parent:     d63beb9ef004ff9587b3c466361276254d57d7a7
Author:     Ming Lei <tom.leiming@gmail.com>
AuthorDate: Tue Sep 16 03:32:20 2008 -0300
Committer:  Mauro Carvalho Chehab <mchehab@redhat.com>
CommitDate: Sun Oct 12 09:37:08 2008 -0200

    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 <tom.leiming@gmail.com>
    Acked-by: Laurent Pinchart <laurent.pinchart@skynet.be>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/video/uvc/uvc_status.c |   11 +++++++++--
 drivers/media/video/uvc/uvcvideo.h   |    4 +++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/uvc/uvc_status.c b/drivers/media/video/uvc/uvc_status.c
index 75e678a..5d60b26 100644
--- a/drivers/media/video/uvc/uvc_status.c
+++ b/drivers/media/video/uvc/uvc_status.c
@@ -177,9 +177,15 @@ int uvc_status_init(struct uvc_device *dev)
 
 	uvc_input_init(dev);
 
+	dev->status = kzalloc(UVC_MAX_STATUS_SIZE, GFP_KERNEL);
+	if (dev->status == NULL)
+		return -ENOMEM;
+
 	dev->int_urb = usb_alloc_urb(0, GFP_KERNEL);
-	if (dev->int_urb == NULL)
+	if (dev->int_urb == NULL) {
+		kfree(dev->status);
 		return -ENOMEM;
+	}
 
 	pipe = usb_rcvintpipe(dev->udev, ep->desc.bEndpointAddress);
 
@@ -192,7 +198,7 @@ int uvc_status_init(struct uvc_device *dev)
 		interval = fls(interval) - 1;
 
 	usb_fill_int_urb(dev->int_urb, dev->udev, pipe,
-		dev->status, sizeof dev->status, uvc_status_complete,
+		dev->status, UVC_MAX_STATUS_SIZE, uvc_status_complete,
 		dev, interval);
 
 	return usb_submit_urb(dev->int_urb, GFP_KERNEL);
@@ -202,6 +208,7 @@ void uvc_status_cleanup(struct uvc_device *dev)
 {
 	usb_kill_urb(dev->int_urb);
 	usb_free_urb(dev->int_urb);
+	kfree(dev->status);
 	uvc_input_cleanup(dev);
 }
 
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index bafe340..9a6bc1a 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -303,6 +303,8 @@ struct uvc_xu_control {
 #define UVC_MAX_FRAME_SIZE	(16*1024*1024)
 /* Maximum number of video buffers. */
 #define UVC_MAX_VIDEO_BUFFERS	32
+/* Maximum status buffer size in bytes of interrupt URB. */
+#define UVC_MAX_STATUS_SIZE	16
 
 #define UVC_CTRL_CONTROL_TIMEOUT	300
 #define UVC_CTRL_STREAMING_TIMEOUT	1000
@@ -634,7 +636,7 @@ struct uvc_device {
 	/* Status Interrupt Endpoint */
 	struct usb_host_endpoint *int_ep;
 	struct urb *int_urb;
-	__u8 status[16];
+	__u8 *status;
 	struct input_dev *input;
 
 	/* Video Streaming interfaces */
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
V4L/DVB:usbvideo:don't use part of buffer for USB transfer #4, Linux Kernel Mailing ..., (Mon Oct 13, 3:15 pm)