lkml.org 
[lkml]   [2004]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [linux-usb-devel] Re: [BUG] usblp_write spins forever after an error
Greg KH wrote:

> On Sun, Feb 15, 2004 at 01:55:32PM -0800, Andy Lutomirski wrote:
>
>>I recently cancelled a print job with the printer's cancel function, and
>>the CUPS backend got stuck in usblp_write (using 100% CPU and not
>>responding to signals).
>>

I wrote a patch some time ago to correct a bug exactly at usblp_write. It is
still not in the main kernel, but you can give it a try and see if it helps. It
applies cleanly against 2.6.2-rc2, but I guess it should apply to 2.6.2-rc3.

This patch corrected a problem for me, that happened when a printer presents an
out-of-paper status while printing a document. The driver would send endless
garbage to the printer.

I hope this helps,

--
Paulo Marques - www.grupopie.com
"In a world without walls and fences who needs windows and gates?"
--- drivers/usb/class/usblp.c.orig 2004-02-09 14:46:27.000000000 +0000
+++ drivers/usb/class/usblp.c 2004-02-09 15:03:32.281551096 +0000
@@ -603,7 +603,7 @@ static ssize_t usblp_write(struct file *
{
DECLARE_WAITQUEUE(wait, current);
struct usblp *usblp = file->private_data;
- int timeout, err = 0;
+ int timeout, err = 0, transfer_length;
size_t writecount = 0;

while (writecount < count) {
@@ -654,19 +654,13 @@ static ssize_t usblp_write(struct file *
continue;
}

- writecount += usblp->writeurb->transfer_buffer_length;
- usblp->writeurb->transfer_buffer_length = 0;
+ transfer_length=(count - writecount);
+ if (transfer_length > USBLP_BUF_SIZE)
+ transfer_length = USBLP_BUF_SIZE;

- if (writecount == count) {
- up (&usblp->sem);
- break;
- }
+ usblp->writeurb->transfer_buffer_length = transfer_length;

- usblp->writeurb->transfer_buffer_length = (count - writecount) < USBLP_BUF_SIZE ?
- (count - writecount) : USBLP_BUF_SIZE;
-
- if (copy_from_user(usblp->writeurb->transfer_buffer, buffer + writecount,
- usblp->writeurb->transfer_buffer_length)) {
+ if (copy_from_user(usblp->writeurb->transfer_buffer, buffer + writecount, transfer_length)) {
up(&usblp->sem);
return writecount ? writecount : -EFAULT;
}
@@ -683,6 +677,8 @@ static ssize_t usblp_write(struct file *
break;
}
up (&usblp->sem);
+
+ writecount += transfer_length;
}

return count;
\
 
 \ /
  Last update: 2005-03-22 14:00    [W:0.060 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site