Re: [PARPORT] interrupt-driven lp


Andrea Arcangeli (arcangeli@mbox.queen.it)
Fri, 2 Jan 1998 13:29:25 +0100 (CET)


On Thu, 1 Jan 1998, Philip Blundell wrote:

>>Well, I fixed all bugs in the parport-971230.diff patch. Now the sharing
>>is perfect. The patch is against parport-971230.diff (with lp.h patch
>>included).
>
>I don't really like the look of that. You've completely changed the way
>parport_yield works, and it no longer seems to take any notice of whether
>another device is waiting.

extern __inline__ unsigned int parport_yield(struct pardevice *dev,
                                             unsigned int block)
{
        unsigned long int timeslip = (jiffies - dev->time);
        if ((timeslip < dev->timeslice) ||
                                  (atomic_read(&dev->port->waiters) == 0))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                return 1;
        parport_release(dev);
        /* some times we _had_to_ schedule() here */
        return (block)?parport_claim_or_block(dev):parport_claim(dev);
}

If you want to take backward compatibility you must don' t take any notice
about others __waiters__ devices. This was why ppa (not a waiter
pardevice) remains locked at first (waiting for a lp_parport_release).

We can easily change PARPORT_YIELD from
#define PARPORT_YIELD(dev) (jiffies - (dev)->time > (dev)->timeslice)
to:
#define PARPORT_YIELD(dev) ((jiffies - (dev)->time > (dev)->timeslice) \
        && (atomic_read(&(dev)->port->waiters) != 0))

if and when _all_ pardevice will be also _waiters_ pardevice.

>Can you have another go with the patch I made earlier today and see if you can
>come up with something a bit better?

I think this is the best and efficient way to handle the parport_yield.
For example in lp when we run lp_schedule we __must__ schedule() at least
one time and not only parport_claim_or_block(). We check for need_resched
before run lp_schedule(). If we don' t check for need_reshed means that we
had to TASK_INTERRUPTIBLE sleep waiting for a timeout, so we __must__
schedule() with parport __released__. Your parport_yield() function can' t
run well for all kind of pardevices. I think that it' s device dependent
choose what do in fucntion of PARPORT_YIELD().

Andrea[s] Arcangeli

-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --



This archive was generated by hypermail 2.0b3 on Wed 30 Dec 1998 - 10:17:17 EST