Thread (86 messages) 86 messages, 20 authors, 2011-01-28

Locking in the clk API

From: Alan Cox <hidden>
Date: 2011-01-27 21:07:24
Also in: linux-sh, lkml

quoted
For internal tree purposes, does .set_termios need to be atomic? Can it  
grab mutexes instead of spinlock?
I think I already answered that question above where I said "protect
against the interrupt handler accessing the port->* stuff".
I'm not sure you answered it correctly however as the locking nowdays is
a bit different.

Architecturally the termios handling doesn't need a spin lock nor is it
called under one. In fact it's vital this is the case because of USB.

I see nothing in the 2.6.37 cpm_uart code that isn't trivially fixable.
There is already a mutex protecting termios serialization so all you seem
to need to do is call clk_set_rate after rather than before dropping the
lock surely ?

Oh if you are looking at the cpm_uart code and care about it the following
in the code isn't safe as tty could possibly go NULL and be freed under
you.

     struct tty_struct *tty = port->state->port.tty;

and you ought to be doing

	tty = tty_port_tty_get(&port->state->port);

	if (tty)
		blah;
	tty_kref_put(tty);	/* put NULL is a no-op anyway */


probably in the main irq handler and pass tty to the helpers that need it.


Alan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help