linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependend
@ 2003-03-19  8:08 Tim Josling
  2003-03-21 20:22 ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Josling @ 2003-03-19  8:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: Philip.Blundell

 [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependent printer
 hang
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Philip (Blundell),

I have an HP1100 printer and since I upgraded to a faster CPU the 
printer has started hanging. The problem persisteed across 2.0 2.2 and 
2.4 kernel versions. I am running Red Hat Linux 8.0 on a Compaq Armada E500.

The problem occurs intermittently. The symptom is that the 'buffer 
contains data' light stays on on the printer, but data transfer stops.

I traced the problem to drivers/parport/ieee1284_ops.c function 
parport_ieee1284_write_compat. The problem occurs when the parallel port 
is not using interrupts. If the printer takes a while to respond the 
routine parport_wait_event gets called, if count == 0. However this 
routine generally waits almost no time.

Anyway, if 32 repeats of this occur e.g. for a complex document where 
the printer is slow, 'wait' ends up as a negative number from repeated 
doublings due to the way twos complement arithmetic works in C. In this 
case the routine never returns. So no more data gets sent to the printer.

Originally I fixed the problem by adding code to ensure that 'wait' 
never got set to anything above 10 seconds (10 * HZ). However the patch 
I have sent you does something different, it just ensures that 
parport_wait_event never gets called for printer without interrupt. I 
have tested this on documents which reproduce the problem

Clearly I am not an expert on the parport code, so my patch may be 
incorrect. I have traces using extra printks I put in the code, showing 
the wait variable being doubled to negative value, available on request.

Definitely my patch does fix a real problem on my system.

As far as I can tell from browsing the patches since 2.4.18, there has 
not been any other fix for this problem to date.

I would appreciate if any replues could be cc'd to me, though I will 
look at the archives to see any responses.

Regards,
Tim Josling

--- ChangeLog.original    2003-03-16 09:18:07.000000000 +1100
+++ ChangeLog    2003-03-16 09:20:35.000000000 +1100
@@ -1,3 +1,9 @@
+2003-03-16  Tim Josling  <tej@melbpc.org.au>
+
+    * ieee1284_ops.c (parport_ieee1284_write_compat): Avoid calling
+    parport_wait_event if interrupts are not enabled for device, avoid
+    output hang.
+
  2002-04-25  Tim Waugh  <twaugh@redhat.com>

      * parport_serial.c, parport_pc.c: Move some SIIG cards around.


--- ieee1284_ops.c.original    2003-03-16 08:27:33.000000000 +1100
+++ ieee1284_ops.c    2003-03-16 09:17:23.000000000 +1100
@@ -93,7 +93,7 @@
                             first time around the loop, don't let go of
                             the port.  This way, we find out if we have
                             our interrupt handler called. */
-            if (count && no_irq) {
+            if (count || no_irq) {
                  parport_release (dev);
                  __set_current_state (TASK_INTERRUPTIBLE);
                  schedule_timeout (wait);


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

* Re: [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependend
  2003-03-19  8:08 [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependend Tim Josling
@ 2003-03-21 20:22 ` Jeremy Fitzhardinge
  2003-03-22  9:23   ` [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependent hang Tim Josling
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2003-03-21 20:22 UTC (permalink / raw)
  To: Tim Josling; +Cc: Linux Kernel List, Philip.Blundell

On Wed, 2003-03-19 at 00:08, Tim Josling wrote:
> I have an HP1100 printer and since I upgraded to a faster CPU the 
> printer has started hanging. The problem persisteed across 2.0 2.2 and 
> 2.4 kernel versions. I am running Red Hat Linux 8.0 on a Compaq Armada E500.
> 
> The problem occurs intermittently. The symptom is that the 'buffer 
> contains data' light stays on on the printer, but data transfer stops.

Ah, so that's why that happens.  I've been getting the same thing with
my LJ1100.

Is this just in polled mode?  Does using interrupts constitute a
work-around for the hang?

	J


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

* Re: [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependent hang
  2003-03-21 20:22 ` Jeremy Fitzhardinge
@ 2003-03-22  9:23   ` Tim Josling
  2003-03-22 17:44     ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Josling @ 2003-03-22  9:23 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Linux Kernel List, Philip.Blundell, linux-parport

Jeremy,

Good to know someone has read my email.

According to my reading of the code, it should only happen in polled 
mode, but I have only one week of experience looking at kernel source.

So it should be a work-around, assuming interrupts work on the parallel 
port on your system :-). It is an very vexing problem, as I'm sure you know.

By the way, LJ1100s tend to get page feeding problems about the time the 
warranty runs out, but HP has a free kit you can order to fix the problem.

Tim Josling

Jeremy Fitzhardinge wrote:
> On Wed, 2003-03-19 at 00:08, Tim Josling wrote:
> 
>>I have an HP1100 printer and since I upgraded to a faster CPU the 
>>printer has started hanging. The problem persisteed across 2.0 2.2 and 
>>2.4 kernel versions. I am running Red Hat Linux 8.0 on a Compaq Armada E500.
>>
>>The problem occurs intermittently. The symptom is that the 'buffer 
>>contains data' light stays on on the printer, but data transfer stops.
> 
> 
> Ah, so that's why that happens.  I've been getting the same thing with
> my LJ1100.
> 
> Is this just in polled mode?  Does using interrupts constitute a
> work-around for the hang?
> 
> 	J
> 
> 
> 



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

* Re: [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependent hang
  2003-03-22  9:23   ` [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependent hang Tim Josling
@ 2003-03-22 17:44     ` Jeremy Fitzhardinge
  2003-03-22 20:31       ` Tim Josling
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2003-03-22 17:44 UTC (permalink / raw)
  To: Tim Josling; +Cc: Linux Kernel List, Philip.Blundell, linux-parport

On Sat, 2003-03-22 at 01:23, Tim Josling wrote:
> According to my reading of the code, it should only happen in polled 
> mode, but I have only one week of experience looking at kernel source.

I'm wondering if a better fix might be to have something like:

	if (wait * 2 > wait)
		wait *= 2;

at the bottom of the loop, so that the wrap-around doesn't happen.

> So it should be a work-around, assuming interrupts work on the parallel 
> port on your system :-). It is an very vexing problem, as I'm sure you know.
> 
> By the way, LJ1100s tend to get page feeding problems about the time the 
> warranty runs out, but HP has a free kit you can order to fix the problem.

Yes, I just installed it.  It suddenly made the printer useful again, so
I've printing more, and seeing the hangs.  I enabled interrupts, which
seems to work OK.

	J


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

* Re: [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependent hang
  2003-03-22 17:44     ` Jeremy Fitzhardinge
@ 2003-03-22 20:31       ` Tim Josling
  0 siblings, 0 replies; 5+ messages in thread
From: Tim Josling @ 2003-03-22 20:31 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Linux Kernel List, Philip.Blundell, linux-parport



Jeremy Fitzhardinge wrote:
> On Sat, 2003-03-22 at 01:23, Tim Josling wrote:
> 
>>According to my reading of the code, it should only happen in polled 
>>mode, but I have only one week of experience looking at kernel source.
> 
> 
> I'm wondering if a better fix might be to have something like:
> 
> 	if (wait * 2 > wait)
> 		wait *= 2;
> 
> at the bottom of the loop, so that the wrap-around doesn't happen.
> 

I tried
  wait *=2;
	if (wait > 10 * HZ)
		wait = 10 * HZ;
and that worked, so your theory would probably work. However to my mind 
it is a hack.

> 
>>So it should be a work-around, assuming interrupts work on the parallel 
>>port on your system :-). It is an very vexing problem, as I'm sure you know.
>>
>>By the way, LJ1100s tend to get page feeding problems about the time the 
>>warranty runs out, but HP has a free kit you can order to fix the problem.
> 
> 
> Yes, I just installed it.  It suddenly made the printer useful again, so
> I've printing more, and seeing the hangs.  I enabled interrupts, which
> seems to work OK.
> 
> 	J

Good. That (enabling interrupts fixes the problem) tends to add credence 
to my theory.

Happy printing!

Tim Josling



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

end of thread, other threads:[~2003-03-22 20:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-19  8:08 [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependend Tim Josling
2003-03-21 20:22 ` Jeremy Fitzhardinge
2003-03-22  9:23   ` [PATCH] to drivers/parport/ieee1284_ops.c to fix timing dependent hang Tim Josling
2003-03-22 17:44     ` Jeremy Fitzhardinge
2003-03-22 20:31       ` Tim Josling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).