Skip to contentSkip to conversation

USB update for 2.6.3

PATCH Andy Lutomirski 2 participants 2 messages Feb 20, 2004 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 4 lines · Greg KH

Paulo Marques:
o USB: fix usblp.c

Unless I'm missing something, this won't fix the usblp_write spinning bug I hit.
If it helps, I can try to reproduce it with some debugging code attached.

BTW, I'm posting from a different address, because [email protected] seems unable to post to lists.sourceforge.net. Please CC me in replies at [email protected].

--Andy

---- Original message copied for linux-usb-devel readers ----

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 2004-02-15 06:29:40.137260640 -0800 renamed from usblp.c.orig 2004-02-15 06:27:29.176169752 -0800 +4 -6
@@ -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;
#2 lore raw
Quoted 9 lines · Andy Lutomirski
Quoted 4 lines · Greg KH

Paulo Marques:
o USB: fix usblp.c

Unless I'm missing something, this won't fix the usblp_write spinning bug I hit. If it helps, I can try to reproduce it with some debugging code attached.

That is why on our latest thread about this I requested that you tested the patch to check your bug went way.

My patch *does* correct *a* bug. I tested it myself because I could trigger the bug easily, and after the patch the bug was gone.

I just wanted you to test if our bugs were different, or on the contrary, they are in fact the same.

They could be the same, because in my case, the driver would hang sending garbage to the printer. Because the printer was a dot-matrix "print what it receives" kind of printer, it would output the garbage continously. If it were a more "inteligent" printer it might refuse the garbage and not print anything at all, giving the same result as if nothing was being printed.

Anyway, if the bugs are different, then yes, another patch is needed to fix "your" bug :)

You will be the best person to do it, since you can trigger the bug, and test a before / after scenario.

Signature · 3 lines
Paulo Marques - www.grupopie.com

"In a world without walls and fences who needs windows and gates?"