public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] usblp_write spins forever after an error
@ 2004-02-15 21:55 Andy Lutomirski
  2004-02-16  3:58 ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Lutomirski @ 2004-02-15 21:55 UTC (permalink / raw)
  To: linux-usb-devel, linux-kernel

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).

The printer is a Kyocera Mita FS-1900 (which has some other problems with the 
linux USB code: usblp_check_status often times out, even though the printer is 
bidirectional -- but that's a whole different issue).

It looks like the problem is that the write failed, so wcomplete got set
to 1 and the status is nonzero.  This case appears to be mishandled in usblp.c:

         while (writecount < count) {
                 if (!usblp->wcomplete) {
			[... not reaching this code]
                 }

                 down (&usblp->sem);
                 if (!usblp->present) {
                         up (&usblp->sem);
                         return -ENODEV;
                 }
                 if (usblp->writeurb->status != 0) {

			[ check status? ]

                         schedule ();
                         continue; <-- problem
                 }

After the write fails, the current code keeps checking the same status, and 
never checks for signals or fails.  I'm not sure what the right fix is, but it 
might be something like this:

--- ./usblp.c.orig      2004-02-15 06:27:29.176169752 -0800
+++ ./usblp.c   2004-02-15 06:29:40.137260640 -0800
@@ -645,13 +645,11 @@
                                 err = usblp->writeurb->status;
                         } else
                                 err = usblp_check_status(usblp, err);
-                       up (&usblp->sem);

-                       /* if the fault was due to disconnect, let khubd's
-                        * call to usblp_disconnect() grab usblp->sem ...
-                        */
-                       schedule ();
-                       continue;
+                       writecount += usblp->writeurb->transfer_buffer_length;
+                       up (&usblp->sem);
+                       count = writecount ? writecount : err;
+                       break;
                 }

                 writecount += usblp->writeurb->transfer_buffer_length;


--Andy

Please CC me -- I'm not subscribed.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-05-10 11:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [linux-usb-devel] " Paulo Marques
2004-03-04 11:25     ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox