On Mon, May 31, 2004 at 03:05:03PM +0200, Oliver Neukum wrote: > Hi, > > fix access to urb->status by introduction of an explicit flag > for finished data transfer. > > Regards > Oliver > > Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]>
Now that you're fixing this -- Is an unsigned char variable considered enough? I've heard about atomicity concerns on ARM, and also there might be problems with unflushed caches - mb()s may be needed ... > You can import this changeset into BK by piping this whole message to: > '| bk receive [path to repository]' or apply the patch as usual. > > =================================================================== > > > [EMAIL PROTECTED], 2004-05-31 15:00:55+02:00, [EMAIL PROTECTED] > - fix racy access to urb->status > > > cdc-acm.c | 16 ++++++++++------ > cdc-acm.h | 1 + > 2 files changed, 11 insertions(+), 6 deletions(-) > > > diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c > --- a/drivers/usb/class/cdc-acm.c Mon May 31 15:02:12 2004 > +++ b/drivers/usb/class/cdc-acm.c Mon May 31 15:02:12 2004 > @@ -223,12 +223,14 @@ > struct acm *acm = (struct acm *)urb->context; > > if (!ACM_READY(acm)) > - return; > + goto out; > > if (urb->status) > dbg("nonzero write bulk status received: %d", urb->status); > > schedule_work(&acm->work); > +out: > + acm->ready_for_write = 1; > } > > static void acm_softint(void *private) > @@ -328,7 +330,7 @@ > > if (!ACM_READY(acm)) > return -EINVAL; > - if (acm->writeurb->status == -EINPROGRESS) > + if (!acm->ready_for_write) > return 0; > if (!count) > return 0; > @@ -344,10 +346,11 @@ > acm->writeurb->transfer_buffer_length = count; > acm->writeurb->dev = acm->dev; > > - /* GFP_KERNEL probably works if from_user */ > - stat = usb_submit_urb(acm->writeurb, GFP_ATOMIC); > + acm->ready_for_write = 0; > + stat = usb_submit_urb(acm->writeurb, GFP_NOIO); > if (stat < 0) { > dbg("usb_submit_urb(write bulk) failed"); > + acm->ready_for_write = 1; > return stat; > } > > @@ -359,7 +362,7 @@ > struct acm *acm = tty->driver_data; > if (!ACM_READY(acm)) > return -EINVAL; > - return acm->writeurb->status == -EINPROGRESS ? 0 : acm->writesize; > + return !acm->ready_for_write ? 0 : acm->writesize; > } > > static int acm_tty_chars_in_buffer(struct tty_struct *tty) > @@ -367,7 +370,7 @@ > struct acm *acm = tty->driver_data; > if (!ACM_READY(acm)) > return -EINVAL; > - return acm->writeurb->status == -EINPROGRESS ? > acm->writeurb->transfer_buffer_length : 0; > + return !acm->ready_for_write ? acm->writeurb->transfer_buffer_length : 0; > } > > static void acm_tty_throttle(struct tty_struct *tty) > @@ -610,6 +613,7 @@ > acm->bh.func = acm_rx_tasklet; > acm->bh.data = (unsigned long) acm; > INIT_WORK(&acm->work, acm_softint, acm); > + acm->ready_for_write = 1; > > > if (!(buf = kmalloc(ctrlsize + readsize + acm->writesize, GFP_KERNEL))) { > diff -Nru a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h > --- a/drivers/usb/class/cdc-acm.h Mon May 31 15:02:12 2004 > +++ b/drivers/usb/class/cdc-acm.h Mon May 31 15:02:12 2004 > @@ -96,6 +96,7 @@ > unsigned int minor; /* acm minor number */ > unsigned char throttle; /* throttled by tty layer */ > unsigned char clocal; /* termios CLOCAL */ > + unsigned char ready_for_write; /* write urb can be used */ > }; > > /* "Union Functional Descriptor" from CDC spec 5.2.3.X */ > > =================================================================== > > > This BitKeeper patch contains the following changesets: > 1.1760 > ## Wrapped with gzip_uu ## > > > M'XL( -0LNT [56VW+3,!!]MKYBF3YP*8YU\2WII-S*)0-#.P6>,[(LQYXZ > M-B/)0!E_/!L'6EIH4T*;9&8WUNKHK/;[EMAIL PROTECTED];[EMAIL PROTECTED] > M3+MRU.CNI%N.6K/ I>.VQ:6@;)<Z6,<''XW6-G"2$UP_DDZ5@(_MQ&,C<?;$ > MG7[6$^_XY>M/[EMAIL PROTECTED]:I=&7=-B-G9&.7VLF1 > M:I?]66C/*>[EMAIL PROTECTED]:!3W+*9ATBN6,R9#IG/*PS0.R9K8TS\3N(@[EMAIL PROTECTED](N > MHCX*QXR1 V CEL04:!C0*! ,6#2A=!)%NY2C U<BPRX'GY+G<+N9O" *?"BJ > M;V"[EMAIL PROTECTED]/Z^==)[EMAIL PROTECTED] > [EMAIL PROTECTED];VF$E"5]%"?CN,^4B K&"[EMAIL PROTECTED]:+B"J6EH;J%SY9]CK$HF5 > MT[,P90(I;@[EMAIL PROTECTED]:!+V"8^IRF*9CE4B>:C^#_L741JG+!XT?LVF > ME>KO,)/;P!8]95$2#5W!+[=$2#>W!+N[EI!Y#D4M%U U>:6DJYH%&"WSJOG9 > M([EMAIL PROTECTED]";K\,/Y7YT76VVZ)[9. 5&O*ZQU:+1.:A2FH'0Z;QH > [EMAIL PROTECTED])S-L8%"[EMAIL PROTECTED]>!1L4HS;/R2W;<RNMJ L3E*<]XV(\'K3R > [EMAIL PROTECTED]/$=J05O&.1-](+.2577&'QIWF*EL&+W+<(!K.<NCF5=YZBN]6"Z > ML;S4%O(ZX#Q&?<W6QO,6+7)J.[>'C_"6.4%_0CR$]_<OJ0ZFP/;(@[EMAIL PROTECTED]@\S6 > MQJL*>'#O;]$/,3),$' FPA3-59!TCWBK:T 7,YS;+EM6;HY7],(3AO\?P > M^M71_/WA[/ A4A41'=A?1S/F \W!>$:[SC3P5Z;P!"A,X/[EMAIL PROTECTED] > MV81P@:R_/VBMT&:>=<7*U+I9N!)/P71G,1LX74W^[&5'E5J=V&XY+50QSG*4 > *X0^_!T>?8PD > -- Vojtech Pavlik SuSE Labs, SuSE CR ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel