[pvrusb2] usb weakiness and streaming errors

Ingo Flaschberger if at xip.at
Thu Jan 5 06:46:18 CST 2006


Hi

I have attached a patch to provide a little bit of error tolerance in 
stream reads from the usb bus.

After 3 continous failed reads the stream is dropped and not after the 
first one like now.

Kind regards,
 	ingo flaschberger

geschaeftsleitung
crossip communications gmbH
------------------------------
sebastian kneipp gasse 1
a-1020 wien
fix: +43-1-726 15 22-217
fax: +43-1-726 15 22-111
mob: +43-699-105 86 719
www.xip.at
------------------------------
-------------- next part --------------
diff -r -u pvrusb2-mci-20060103_org/driver/pvrusb2-ioread.c pvrusb2-mci-20060103/driver/pvrusb2-ioread.c
--- pvrusb2-mci-20060103_org/driver/pvrusb2-ioread.c	2005-11-12 08:08:29.000000000 +0100
+++ pvrusb2-mci-20060103/driver/pvrusb2-ioread.c	2006-01-05 13:35:04.000000000 +0100
@@ -40,6 +40,8 @@
 	struct semaphore sem;
 };
 
+int read_fail = 0;
+
 static int pvr2_ioread_init(struct pvr2_ioread *cp)
 {
 	unsigned int idx;
@@ -270,9 +272,13 @@
 						   " pvr2_ioread_read id=%p"
 						   " buffer_error=%d",
 						   cp,stat);
-					pvr2_ioread_stop(cp);
-					ret = -EIO;
-					break;
+					// Do not fail at the first error
+					read_fail++;
+					if (read_fail >= read_maxfail) {
+						pvr2_ioread_stop(cp);
+						ret = -EIO;
+						break;
+					}
 				}
 				src = 0;
 			} else {
@@ -284,6 +290,8 @@
 				}
 				src += cp->resid_offs;
 				bcnt -= cp->resid_offs;
+				// Reset read fail error counter
+				read_fail = 0;
 			}
 			if (bcnt > cnt) {
 				// Can't read the entire buffer this time
diff -r -u pvrusb2-mci-20060103_org/driver/pvrusb2-ioread.h pvrusb2-mci-20060103/driver/pvrusb2-ioread.h
--- pvrusb2-mci-20060103_org/driver/pvrusb2-ioread.h	2005-11-12 08:08:29.000000000 +0100
+++ pvrusb2-mci-20060103/driver/pvrusb2-ioread.h	2006-01-05 13:32:51.000000000 +0100
@@ -23,6 +23,8 @@
 
 #include "pvrusb2-io.h"
 
+#define read_maxfail 3
+
 struct pvr2_ioread;
 
 struct pvr2_ioread *pvr2_ioread_create(void);


More information about the pvrusb2 mailing list