瀏覽代碼

[PATCH] fix for race problem in DVB USB drivers (dibusb)

Fixed race between submitting streaming URBs in the driver and starting
the actual transfer in hardware (demodulator and USB controller) which
sometimes lead to garbled data transfers. URBs are now submitted first,
then the transfer is enabled. Dibusb devices and clones are now fully
functional again.

Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Patrick Boettcher 20 年之前
父節點
當前提交
8126fdbc76
共有 2 個文件被更改,包括 17 次插入7 次删除
  1. 14 5
      drivers/media/dvb/dvb-usb/dibusb-common.c
  2. 3 2
      drivers/media/dvb/dvb-usb/dvb-usb-dvb.c

+ 14 - 5
drivers/media/dvb/dvb-usb/dibusb-common.c

@@ -70,13 +70,22 @@ EXPORT_SYMBOL(dibusb_power_ctrl);
 
 
 int dibusb2_0_streaming_ctrl(struct dvb_usb_device *d, int onoff)
 int dibusb2_0_streaming_ctrl(struct dvb_usb_device *d, int onoff)
 {
 {
-	u8 b[2];
-	b[0] = DIBUSB_REQ_SET_IOCTL;
-	b[1] = onoff ? DIBUSB_IOCTL_CMD_ENABLE_STREAM : DIBUSB_IOCTL_CMD_DISABLE_STREAM;
+	u8 b[3] = { 0 };
+	int ret;
+
+	if ((ret = dibusb_streaming_ctrl(d,onoff)) < 0)
+		return ret;
 
 
-	dvb_usb_generic_write(d,b,3);
+	if (onoff) {
+		b[0] = DIBUSB_REQ_SET_STREAMING_MODE;
+		b[1] = 0x00;
+		if ((ret = dvb_usb_generic_write(d,b,2)) < 0)
+			return ret;
+	}
 
 
-	return dibusb_streaming_ctrl(d,onoff);
+	b[0] = DIBUSB_REQ_SET_IOCTL;
+	b[1] = onoff ? DIBUSB_IOCTL_CMD_ENABLE_STREAM : DIBUSB_IOCTL_CMD_DISABLE_STREAM;
+	return dvb_usb_generic_write(d,b,3);
 }
 }
 EXPORT_SYMBOL(dibusb2_0_streaming_ctrl);
 EXPORT_SYMBOL(dibusb2_0_streaming_ctrl);
 
 

+ 3 - 2
drivers/media/dvb/dvb-usb/dvb-usb-dvb.c

@@ -23,12 +23,12 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
 	 */
 	 */
 	if (newfeedcount == 0) {
 	if (newfeedcount == 0) {
 		deb_ts("stop feeding\n");
 		deb_ts("stop feeding\n");
+		dvb_usb_urb_kill(d);
 
 
 		if (d->props.streaming_ctrl != NULL)
 		if (d->props.streaming_ctrl != NULL)
 			if ((ret = d->props.streaming_ctrl(d,0)))
 			if ((ret = d->props.streaming_ctrl(d,0)))
 				err("error while stopping stream.");
 				err("error while stopping stream.");
 
 
-		dvb_usb_urb_kill(d);
 	}
 	}
 
 
 	d->feedcount = newfeedcount;
 	d->feedcount = newfeedcount;
@@ -44,6 +44,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
 	 * for reception.
 	 * for reception.
 	 */
 	 */
 	if (d->feedcount == onoff && d->feedcount > 0) {
 	if (d->feedcount == onoff && d->feedcount > 0) {
+		deb_ts("submitting all URBs\n");
+		dvb_usb_urb_submit(d);
 
 
 		deb_ts("controlling pid parser\n");
 		deb_ts("controlling pid parser\n");
 		if (d->props.caps & DVB_USB_HAS_PID_FILTER &&
 		if (d->props.caps & DVB_USB_HAS_PID_FILTER &&
@@ -59,7 +61,6 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
 				return -ENODEV;
 				return -ENODEV;
 			}
 			}
 
 
-		dvb_usb_urb_submit(d);
 	}
 	}
 	return 0;
 	return 0;
 }
 }