Re: Bringing the OpenCBM driver into the staging tree

Previous thread: I worte a Pci RAID card driver, share to everybody for more advise by crazyrushstar on Wednesday, October 18, 2006 - 2:13 am. (4 messages)

Next thread: New to Kernel programming and device drivers by Tharanga Abeyseela on Wednesday, April 21, 2010 - 4:03 pm. (4 messages)
From: Frédéric Brière
Date: Saturday, April 17, 2010 - 10:35 am

[I originally sent this message via Gmane, but I think it got gobbled up
somewhere.]


Hi everybody,

I have offered the OpenCBM team a hand in helping them bring their
driver into the (staging, at first) kernel tree.  I have a couple of
technical questions about the whole process, so I sure wouldn't mind
hearing your comments on this.

(The OpenCBM driver allows for communicating with old Commodore
peripherals, via the parallel port and a custom cable.  See
<http://sourceforge.net/projects/opencbm/> for more details.)


Our main concern is that this driver would be rejected by the kernel
maintainers, due to the fact that it busy-waits with interrupts
disabled, for up to 32ms (in the very worst and unlikely case).
Although I have found similar instances in the kernel tree, none of them
disabled interrupts for as long as this.  (The longest was 5ms, by
rs_put_char() in drivers/serial/68328serial.c.)  Unfortunately, this is
the only way to achieve the precise timing required.


If this is deemed acceptable, and the driver can be included, would you
recommend sending a patch ASAP, or doing as much clean-up as possible
beforehand?

Upstream will want to keep maintaining their own copy of the driver for
a while (to support older kernels), which will obviously differ from the
kernel tree version (if only for the gazillion ifdefs).  My concern is
that right after the driver is introduced, somebody will run
checkpatch.pl on it or re-indent it or what-have-you, thus making it
even harder to backport changes from one version to the other.  (OTOH,
I'm aware that waiting for the patch to be perfect before sending it
usually means it will never get sent in the near future.)

Are there any tricks that make it easier to maintain such a pair of
in-tree and out-of-tree drivers?


In a similar vein, as OpenCBM features both Linux and Windows drivers,
the upstream developers were thinking of trying to merge both of them,
to avoid code duplication.  Obviously, this would be ...
From: Gary Jennejohn
Date: Sunday, April 18, 2010 - 2:40 am

On Sat, 17 Apr 2010 13:35:50 -0400

Worse is that there is a potential infinite loop with all interrupts
blocked in cbm_raw_write().

It's a pity that Linux doesn't allowing blocking single interrupts, like
that various BSDs out there.

--
Gary Jennejohn
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Frédéric Brière
Date: Sunday, April 18, 2010 - 5:52 am

Do you mean the one that was fixed in 0.4.3rc1?

<http://opencbm.cvs.sourceforge.net/viewvc/opencbm/cbm4win/sys/linux/cbm_module.c?r1=1.13.2.18&r2=1.13.2.19>

That was a sticking point for me too.  :)

(The loop was subsequently upped to 1ms, but it's still better than

Do you mean the ability to disable a specific IRQ?  I'm curious -- how
would that help?  The issue here is that the module needs to take a
certain action within a strict time interval, so any interrupt could
throw it off.

(I guess the real pity is the lack of real-time in the vanilla kernel.)


-- 
The world is coming to an end ... SAVE YOUR BUFFERS!!!

_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Greg KH
Date: Sunday, April 18, 2010 - 8:26 am

Linux has the lowest latency of any operating system out there, and
there is a very popular real-time patch available that is constantly
getting smaller as more of it migrates into the main kernel tree.

And how would that help out a driver that wants to do things that would
hurt real-time stuff?

thanks,

greg k-h
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Frédéric Brière
Date: Sunday, April 18, 2010 - 10:46 am

I don't think there would be any reason for this module to exist in a
real-time kernel; AFAIK, its only raison d'être is to enforce a strict
timing that would be impossible in a typical userspace application.


-- 
This dungeon is owned and operated by Frobozz Magic Co., Ltd.

_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Greg KH
Date: Monday, April 19, 2010 - 3:38 pm

Can someone post the code as a patch so that we can review it properly
that way?

thanks,

greg k-h
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Frédéric Brière
Date: Thursday, April 22, 2010 - 2:38 pm

Will do.


-- 
Yes, we will be going to OSI, Mars, and Pluto, but not necessarily in
that order.
		-- George Michaelson

_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Gary Jennejohn
Date: Sunday, April 18, 2010 - 9:23 am

On Sun, 18 Apr 2010 12:52:14 +0000 (UTC)

Yes.  I downloaded the ZIP archive which is obviously out of date.

As to blocking individual interrupts - it would still be generally useful IMO,
even if it wouldn't benefit you.

--
Gary Jennejohn
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Greg KH
Date: Monday, April 19, 2010 - 3:39 pm

Who would it benifit?  Seriously, I can't think of a situation that you
really want to do that, all of the work in this area of the kernel for
the past few years is to prevent this from happening (moving interrupt
handlers into threads for example), to make the overall system faster
and more "level".

thanks,

greg k-h
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Greg KH
Date: Sunday, April 18, 2010 - 8:24 am

Um, what do you mean?  You can implicitly block an interrupt, but why
would you want to do that?

thanks,

greg k-h
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Gary Jennejohn
Date: Sunday, April 18, 2010 - 9:37 am

On Sun, 18 Apr 2010 08:24:59 -0700

Plenty of reasons.  One can block the interrupt to a certain driver which
may require that for weird hardware reasons while reenabling and allowing
other interrupts to be fielded and served.

That's how the VAX and Motorola 680x0 worked and AT&T Ver. III and IV had
the splx() macros to block individual interrupts.  I worked on this stuff
in the 1980's and it was extremely convenient.

Modern HW may not require it as much, but always blocking all interrupts
with cli() isn't optimal, although it does force one to come up with
creative solutions/workarounds :)

But it's been a while since I looked at interrupt handling in Linux and
maybe that has changed.

--
Gary Jennejohn
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Matt Mackall
Date: Sunday, April 18, 2010 - 10:22 am

Bear in mind that Linux has about two orders of magnitude more drivers
than all of the above put together and that Greg manages a large share
of them, not to mention most of the driver framework. If your question

cli() has been deprecated for a very long time. It's usefulness to
drivers is just about nil in a multiprocessor environment. The modern
equivalent (local_irq_disable) is used in only a small handful of truly
ancient drivers.

-- 
http://selenic.com : development and support for Mercurial and Linux


_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Greg KH
Date: Sunday, April 18, 2010 - 8:24 am

I'll take anything in staging as long as:
  - the license is acceptable
  - the code builds
  - someone is going to "own" it to help get it merged to the main




Again, it's up to you, but I would not recommend maintaining 2 versions
after the code is in the main kernel tree, as it will quickly get quite


They backport the changes that go upstream in Linux to their other
trees.  But it can take a lot of work to do so at times.

thanks,

greg k-h
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Frédéric Brière
Date: Sunday, April 18, 2010 - 10:22 am

For precise timing purposes when polling the parallel port.  (Forgive
the alliteration.)

For example, a talking device will pull CLK down for 20us and release
it, after which DATA must be read within 70us.  Or, when sending a byte,
after the listener has released DATA, transmission must start within
200us.  (Notice how we don't always monitor the same line.)

In such cases, if an interrupt were to be triggered and take too much
time, the whole communication would be garbled.

(There is one case, when a listener is signaling that it is ready, which
has no upper bound and does not require prompt action.  That's when we
use the parport IRQ.)


BTW, I should point out that the 32ms above is the absolute worst case,
and would require a device to maliciously skirt on the maximum timing

You tell me, you're the kernel demi-God.  :)

Basically, this module needs a guaranteed sub-20us resolution when
polling the parallel port for inbound data.  (The PC parport
unfortunately only has one line capable of triggering an IRQ, which is
already used for the case above.)  And it may need an even greater
resolution when sending data, as other devices may not be so forgiving
of timing errors.


-- 
[FORTRAN] will persist for some time -- probably for at least the next decade.
		-- T. Cheatham

_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Greg KH
Date: Monday, April 19, 2010 - 3:42 pm

Is this on a shared interrupt?  And what type of processor are you

This seems like a very large abuse of the 'I know, let's bit-bang the
data out by hand' principle.  For such strict timing requirements, it's
almost always better to just build a simple piece of hardware to handle
it for you.

Is this a new device out in the wild, or something very old?

And post the code for inclusion, we can take it from there.

thanks,

greg k-h
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Matt Mackall
Date: Monday, April 19, 2010 - 3:53 pm

Something very old. It's for talking to Commodore floppy drives over a
hand-made parallel port cable, presumably for recovering very old data.

Nonetheless, I think this can be handled on reasonably modern hardware
with an appropriate mix of polling in a real-time thread (waiting for
high-precision clock edges) and high-res timers (all other timeouts).

-- 
http://selenic.com : development and support for Mercurial and Linux


_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
From: Greg KH
Date: Monday, April 19, 2010 - 4:00 pm

That sounds very reasonable.

greg k-h
_______________________________________________
Kernel-mentors mailing list
Kernel-mentors@selenic.com
http://selenic.com/mailman/listinfo/kernel-mentors
Previous thread: I worte a Pci RAID card driver, share to everybody for more advise by crazyrushstar on Wednesday, October 18, 2006 - 2:13 am. (4 messages)

Next thread: New to Kernel programming and device drivers by Tharanga Abeyseela on Wednesday, April 21, 2010 - 4:03 pm. (4 messages)