All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paulo Marques <pmarques@grupopie.com>
To: Greg KH <greg@kroah.com>
Cc: Andy Lutomirski <luto@myrealbox.com>,
	linux-usb-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [linux-usb-devel] Re: [BUG] usblp_write spins forever after an error
Date: Mon, 16 Feb 2004 15:16:21 +0000	[thread overview]
Message-ID: <4030DEC5.2060609@grupopie.com> (raw)
In-Reply-To: 20040216035834.GA4089@kroah.com

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

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?"

[-- Attachment #2: usblp_patch --]
[-- Type: text/plain, Size: 1435 bytes --]

--- 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;

  reply	other threads:[~2004-02-16 15:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-15 21:55 [BUG] usblp_write spins forever after an error Andy Lutomirski
2004-02-16  3:58 ` Greg KH
2004-02-16 15:16   ` Paulo Marques [this message]
2004-03-04 11:25     ` [linux-usb-devel] " David Woodhouse
2004-03-04 12:33       ` Paulo Marques
2004-03-05  9:41         ` David Woodhouse
2004-03-05 14:27           ` Paulo Marques
2004-03-05 18:11             ` [PATCH] usblp.c (Was: usblp_write spins forever after an error) Paulo Marques
2004-03-11  1:33               ` Greg KH
2004-05-10 11:34               ` David Woodhouse
2004-02-17  4:40   ` [BUG] usblp_write spins forever after an error Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4030DEC5.2060609@grupopie.com \
    --to=pmarques@grupopie.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=luto@myrealbox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.