Re: [PATCH RFC] serial: mctrl_gpio: disable IRQs without waiting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 23, 2016 at 12:04:02PM +0100, Ingo van Lil wrote:
> mctrl_gpio_disable_ms() calls disable_irq() to disable the IRQs for the
> GPIO lines. The atmel_serial driver calls this function in atomic
> context, causing a kernel BUG if CONFIG_DEBUG_ATOMIC_SLEEP is enabled.
> 
> This patch uses disable_irq_nosync() instead to avoid waiting for
> completion of pending IRQ handlers. The only other driver that uses
> mctrl_gpio_disable_ms(), serial/imx.c, may have to be changed to call
> this function with IRQs disabled, too. Another option would be to change
> the atmel_serial driver to call the function outside of the atomic
> context.

struct uart_port doesn't have a disable_ms port and the documentation to
enable_ms tells:

        This method may be called multiple times.  Modem status
	interrupts should be disabled when the shutdown method is
	called.

So checking when the atmel driver calls disable_ms, it's not only in
shutdown. It's also done in .set_termios like:

	spin_lock_irqsave(&port->lock, flags);
	...
	if (UART_ENABLE_MS(port, termios->c_cflag))
		atmel_enable_ms(port);
	else
		atmel_disable_ms(port);

	spin_unlock_irqrestore(&port->lock, flags);

and also in .set_ldisc like:

	if (termios->c_line == N_PPS) {
		...
	} else {
		if (!UART_ENABLE_MS(port, termios->c_cflag)) {
			spin_lock_irq(&port->lock);
			atmel_disable_ms(port);
			spin_unlock_irq(&port->lock);
		}
	}
	
The imx driver calls mctrl_gpio_disable_ms only in .shutdown.

I'm not sure what is the right way forward. I think for imx we need the
sleeping variant that asserts that no irq is running any more (i.e. the
status quo).

I'm not sure about the atmel driver, so I'm just asking a few questions,
maybe Nicolas, Russell and/or Greg can round them off to a directive
what to do.

 - Is it necessary to call mctrl_gpio_disable_ms from .set_termios and
   .set_ldisc? If yes, it should probably be called without holding the
   lock. Or do we need mctrl_gpio_disable_ms_nosync?
 - Do we need a call to mctrl_gpio_disable_ms in .shutdown (which might
   be a separate issue)?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux