All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/9] omap-keypad: Use disable_irq_nosync() from within irq handlers.
@ 2009-04-16  5:54 Ben Nizette
  2009-04-16  6:22 ` HowTo write a driver for 2 multiplexed PS/2 ports over 1 UART? Heiko Schocher
  0 siblings, 1 reply; 6+ messages in thread
From: Ben Nizette @ 2009-04-16  5:54 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-kernel, linux-input


disable_irq() should wait for all running handlers to complete
before returning.  As such, if it's used to disable an interrupt
from that interrupt's handler it will deadlock.  This replaces
the dangerous instances with the _nosync() variant which doesn't
have this problem.

This patch may be overly paranoid, it'd be cleaner to just
disable all the row irqs _nosync() but it wouldn't be as
correct.  Up to $MAINTAINER :-)

Signed-off-by: Ben Nizette <bn@niasdigital.com>
---
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index 058fa8b..9606a1c 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -100,8 +100,16 @@ static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
 	/* disable keyboard interrupt and schedule for handling */
 	if (cpu_is_omap24xx()) {
 		int i;
-		for (i = 0; i < omap_kp->rows; i++)
-			disable_irq(gpio_to_irq(row_gpios[i]));
+		for (i = 0; i < omap_kp->rows; i++) {
+			/* The interrupt which we're currently handling should
+			 * be disabled _nosync() to avoid deadlocks waiting
+			 * for this handler to complete.  All others should
+			 * be disabled the regular way for SMP safety. */
+			if (gpio_to_irq(row_gpios[i]) == irq)
+				disable_irq_nosync(gpio_to_irq(row_gpios[i]));
+			else
+				disable_irq(gpio_to_irq(row_gpios[i]));
+		}
 	} else
 		/* disable keyboard interrupt and schedule for handling */
 		omap_writew(1, OMAP_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
-- 
1.6.0.2




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

* HowTo write a driver for 2 multiplexed PS/2 ports over 1 UART?
  2009-04-16  5:54 [PATCH 3/9] omap-keypad: Use disable_irq_nosync() from within irq handlers Ben Nizette
@ 2009-04-16  6:22 ` Heiko Schocher
  2009-04-18 23:46   ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Heiko Schocher @ 2009-04-16  6:22 UTC (permalink / raw)
  To: linux-input

Hello,

I maybe get a projekt, where I have 2 PS/2 ports (a keyboard and a mousse)
connected to one UART and the multiplexing is done by a PIC.

I searched in actual 2.6 Kernel sources for such a solution, but
couln;t find one. Overlooked I something?

For 2.4er Kernel there was such a driver, see

http://git.denx.de/?p=linuxppc_2_4_devel.git;a=blob;f=drivers/char/ps2mult.c

but, I think, this is no longer portable to 2.6.

So, thats why I am here and want to ask the experts how to solve
this problem in a mainline acceptable way, before I make a hack,
that never has a chance to go in mainline.

Some suggestions from me (maybe they are all bad)

I looked in drivers/input/serio/serio.c and could think of adding
the multiplexing in serio_interrupt(), and call serio_driver specific
serio->drv->interrupt functions, when I know, which byte come from
which device. But, if I see it right, I can only add one "struct
serio_driver *drv;" driver to one serio port, so it is not possible
to handle 2 or more devices over one serio port :-(
Maybe we enhance this too ... ?

Or I make a combinated (keyboard/mousse) driver which uses one
serio port ... but I think thats a bad idea, also no idea, in which
directory i have to add such a driver.

So I think it would nice to have the possibility to add more than
one serio_driver to a serio_port and add a "multiplexer" layer ...
but I am new to the input layer, so I ask the experts.

Hopefully I just missed something in actual code, and there is
better/easier way? ;-)

TIA
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* Re: HowTo write a driver for 2 multiplexed PS/2 ports over 1 UART?
  2009-04-16  6:22 ` HowTo write a driver for 2 multiplexed PS/2 ports over 1 UART? Heiko Schocher
@ 2009-04-18 23:46   ` Dmitry Torokhov
  2009-04-19 10:04     ` Heiko Schocher
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2009-04-18 23:46 UTC (permalink / raw)
  To: Heiko Schocher; +Cc: linux-input

Hi Heiko,

On Thu, Apr 16, 2009 at 08:22:34AM +0200, Heiko Schocher wrote:
> Hello,
> 
> I maybe get a projekt, where I have 2 PS/2 ports (a keyboard and a mousse)
> connected to one UART and the multiplexing is done by a PIC.
> 
> I searched in actual 2.6 Kernel sources for such a solution, but
> couln;t find one. Overlooked I something?
> 
> For 2.4er Kernel there was such a driver, see
> 
> http://git.denx.de/?p=linuxppc_2_4_devel.git;a=blob;f=drivers/char/ps2mult.c
> 
> but, I think, this is no longer portable to 2.6.
> 
> So, thats why I am here and want to ask the experts how to solve
> this problem in a mainline acceptable way, before I make a hack,
> that never has a chance to go in mainline.
> 
> Some suggestions from me (maybe they are all bad)
> 
> I looked in drivers/input/serio/serio.c and could think of adding
> the multiplexing in serio_interrupt(), and call serio_driver specific
> serio->drv->interrupt functions, when I know, which byte come from
> which device. But, if I see it right, I can only add one "struct
> serio_driver *drv;" driver to one serio port, so it is not possible
> to handle 2 or more devices over one serio port :-(
> Maybe we enhance this too ... ?
> 
> Or I make a combinated (keyboard/mousse) driver which uses one
> serio port ... but I think thats a bad idea, also no idea, in which
> directory i have to add such a driver.
> 
> So I think it would nice to have the possibility to add more than
> one serio_driver to a serio_port and add a "multiplexer" layer ...
> but I am new to the input layer, so I ask the experts.
> 
> Hopefully I just missed something in actual code, and there is
> better/easier way? ;-)
>

You need to create 2 serio ports in your driver and have it send data
into appropriate port, depending on what device it came from. If you
take a look at i8042 driver it does exactly that. We have 1 serio port
for keyboard and eithe 1 or 4 AUX serio ports. In i8042_interrupt we
check the status bit to figure to which serio port incoming byte should
be routed and act accordingly.

Hope this helps.

-- 
Dmitry

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

* Re: HowTo write a driver for 2 multiplexed PS/2 ports over 1 UART?
  2009-04-18 23:46   ` Dmitry Torokhov
@ 2009-04-19 10:04     ` Heiko Schocher
  2009-04-20  0:48       ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Heiko Schocher @ 2009-04-19 10:04 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

Hello Dmitry,

Dmitry Torokhov wrote:
> On Thu, Apr 16, 2009 at 08:22:34AM +0200, Heiko Schocher wrote:
>> Hello,
>>
>> I maybe get a projekt, where I have 2 PS/2 ports (a keyboard and a mousse)
>> connected to one UART and the multiplexing is done by a PIC.
>>
>> I searched in actual 2.6 Kernel sources for such a solution, but
>> couln;t find one. Overlooked I something?
>>
>> For 2.4er Kernel there was such a driver, see
>>
>> http://git.denx.de/?p=linuxppc_2_4_devel.git;a=blob;f=drivers/char/ps2mult.c
>>
>> but, I think, this is no longer portable to 2.6.
>>
>> So, thats why I am here and want to ask the experts how to solve
>> this problem in a mainline acceptable way, before I make a hack,
>> that never has a chance to go in mainline.
>>
>> Some suggestions from me (maybe they are all bad)
>>
>> I looked in drivers/input/serio/serio.c and could think of adding
>> the multiplexing in serio_interrupt(), and call serio_driver specific
>> serio->drv->interrupt functions, when I know, which byte come from
>> which device. But, if I see it right, I can only add one "struct
>> serio_driver *drv;" driver to one serio port, so it is not possible
>> to handle 2 or more devices over one serio port :-(
>> Maybe we enhance this too ... ?
>>
>> Or I make a combinated (keyboard/mousse) driver which uses one
>> serio port ... but I think thats a bad idea, also no idea, in which
>> directory i have to add such a driver.
>>
>> So I think it would nice to have the possibility to add more than
>> one serio_driver to a serio_port and add a "multiplexer" layer ...
>> but I am new to the input layer, so I ask the experts.
>>
>> Hopefully I just missed something in actual code, and there is
>> better/easier way? ;-)
>>
> 
> You need to create 2 serio ports in your driver and have it send data
> into appropriate port, depending on what device it came from. If you
> take a look at i8042 driver it does exactly that. We have 1 serio port
> for keyboard and eithe 1 or 4 AUX serio ports. In i8042_interrupt we
> check the status bit to figure to which serio port incoming byte should
> be routed and act accordingly.

Ah, thanks for this hint :-)

OK, so I have to write a serial driver for the uart on my hardware,
and add this in drivers/serio, right?

Hmm.. spontaneous I think (maybe it is a bad thought), what do you
think to the following approach:

I didn;t want to write a new serio driver for my uart (mpc5200 internal
PSC Uart), because there is a working tty driver for this, and the multi-
plexing functionality is just a protocoll ... so I think of using
the drivers/serio/serport.c and add this "multiplexing" functionality
to the serport.c driver ... is this worth about to think?

this should be a more general approach then writting a special serial
driver for "my" UART ... what do you think?

> Hope this helps.

of course, thanks!

bye
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* Re: HowTo write a driver for 2 multiplexed PS/2 ports over 1 UART?
  2009-04-19 10:04     ` Heiko Schocher
@ 2009-04-20  0:48       ` Dmitry Torokhov
  2009-04-20  4:45         ` Heiko Schocher
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2009-04-20  0:48 UTC (permalink / raw)
  To: hs; +Cc: linux-input

Hi Heiko,

On Sunday 19 April 2009 03:04:25 Heiko Schocher wrote:
> Hello Dmitry,
>
> Dmitry Torokhov wrote:
> >
> > You need to create 2 serio ports in your driver and have it send data
> > into appropriate port, depending on what device it came from. If you
> > take a look at i8042 driver it does exactly that. We have 1 serio port
> > for keyboard and eithe 1 or 4 AUX serio ports. In i8042_interrupt we
> > check the status bit to figure to which serio port incoming byte should
> > be routed and act accordingly.
>
> Ah, thanks for this hint :-)
>
> OK, so I have to write a serial driver for the uart on my hardware,
> and add this in drivers/serio, right?
>
> Hmm.. spontaneous I think (maybe it is a bad thought), what do you
> think to the following approach:
>
> I didn;t want to write a new serio driver for my uart (mpc5200 internal
> PSC Uart), because there is a working tty driver for this, and the multi-
> plexing functionality is just a protocoll ... so I think of using
> the drivers/serio/serport.c and add this "multiplexing" functionality
> to the serport.c driver ... is this worth about to think?
>
> this should be a more general approach then writting a special serial
> driver for "my" UART ... what do you think?
>

Yes, this is definitely better solution. I did not realize that there
was a working driver for your UART. It would be best if your solution
extended (and was compatible with) current N_MOUSE line discipline.

-- 
Dmitry

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

* Re: HowTo write a driver for 2 multiplexed PS/2 ports over 1 UART?
  2009-04-20  0:48       ` Dmitry Torokhov
@ 2009-04-20  4:45         ` Heiko Schocher
  0 siblings, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2009-04-20  4:45 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

Hello Dmitry,

Dmitry Torokhov wrote:
> On Sunday 19 April 2009 03:04:25 Heiko Schocher wrote:
>> Hello Dmitry,
>>
>> Dmitry Torokhov wrote:
>>> You need to create 2 serio ports in your driver and have it send data
>>> into appropriate port, depending on what device it came from. If you
>>> take a look at i8042 driver it does exactly that. We have 1 serio port
>>> for keyboard and eithe 1 or 4 AUX serio ports. In i8042_interrupt we
>>> check the status bit to figure to which serio port incoming byte should
>>> be routed and act accordingly.
>> Ah, thanks for this hint :-)
>>
>> OK, so I have to write a serial driver for the uart on my hardware,
>> and add this in drivers/serio, right?
>>
>> Hmm.. spontaneous I think (maybe it is a bad thought), what do you
>> think to the following approach:
>>
>> I didn;t want to write a new serio driver for my uart (mpc5200 internal
>> PSC Uart), because there is a working tty driver for this, and the multi-
>> plexing functionality is just a protocoll ... so I think of using
>> the drivers/serio/serport.c and add this "multiplexing" functionality
>> to the serport.c driver ... is this worth about to think?
>>
>> this should be a more general approach then writting a special serial
>> driver for "my" UART ... what do you think?
>>
> 
> Yes, this is definitely better solution. I did not realize that there
> was a working driver for your UART. It would be best if your solution
> extended (and was compatible with) current N_MOUSE line discipline.

OK, thanks for your info, I hope I get this project, so I can do this
job.

bye
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

end of thread, other threads:[~2009-04-20  5:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-16  5:54 [PATCH 3/9] omap-keypad: Use disable_irq_nosync() from within irq handlers Ben Nizette
2009-04-16  6:22 ` HowTo write a driver for 2 multiplexed PS/2 ports over 1 UART? Heiko Schocher
2009-04-18 23:46   ` Dmitry Torokhov
2009-04-19 10:04     ` Heiko Schocher
2009-04-20  0:48       ` Dmitry Torokhov
2009-04-20  4:45         ` Heiko Schocher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.