Re: usbrsa: dead lock usbrsa_write/usbrsa_write_room

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello 


> I could make write_room return the ACTUAL fill-level information of 
>the device. Now, the tty layer would potentially hand over more bytes to
>generic_write that it can handle. This would result in only a part of the 
>data been but to URBs and sent off to the device. 
> I would a assume that the tty layer would just issue another write_room,
> learn that there is still room available on the device, and then try to 
> sent the remaining bytes via  a another generic_write. As now at least some 
> of the URBs are already recycled, it can sent off more data to the device.

I gave it a shot.  My basic assumption was wrong -- the tty layer apparently
relies on  write_room returning the number of bytes that a subsequent write 
will transfer. If write_room returns more bytes that write will actually take,
characters will be swallowed.


Here in detail what happens :
[the write function can transfer 640 bytes max, i.e. a pool 
of 10 URBs with 64 bytes payload each]
[the buffer of the serial device can take up to 4096 bytes -- 
this is what write_room returns]

write_room(): 4096 bytes free
write(bytes=1095)
write -- sent=640 bytes -- remaining=455 bytes

[now the tty layer tries to transfer  the remaining bytes. It remains
unsuccessful until the transmission of at least 1 URBs has finished, and it is
recycled. The bytes in between 2 successful calls to write ,i.e. 
#bytes sent != 0, are swallowed] 

write_room(): 4096 bytes free
write(bytes=1)
write -- sent=0 bytes
write_room(): 4096 bytes free
write(bytes=454)
write -- sent=0 bytes
write_room(): 4096 bytes free
write(bytes=1)
write -- sent=0 bytes
write_room(): 4096 bytes free
write(bytes=453)
write -- sent=0 bytes
...
usbrsa_write_callback() -- URB #0 freed
usbrsa_write_callback() -- URB #1 freed
write_room(): 4096 bytes free
[ 34 bytes swallowed]
write(bytes=421)
write -- sent=128 bytes -- remaining=293 bytes
write_room(): 4096 bytes free
write(bytes=1)
write -- sent=0 bytes
write_room(): 4096 bytes free
write(bytes=292)
write -- sent=0 bytes
....





--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux