[PATCH v2 05/12] OMAP: Serial: Hold console lock for console usage.

Kevin Hilman khilman at ti.com
Thu May 5 10:52:03 EDT 2011


Govindraj <govindraj.ti at gmail.com> writes:

> On Thu, May 5, 2011 at 2:13 AM, Kevin Hilman <khilman at ti.com> wrote:
>> "Govindraj.R" <govindraj.raja at ti.com> writes:
>>
>>> Acquire console lock before enabling and writing to console-uart
>>> to avoid any recursive prints from console write.
>>> for ex:
>>>       --> printk
>>>         --> uart_console_write
>>>           --> get_sync
>>>             --> printk from omap_device enable
>>>               --> uart_console write
>>
>> By this time, since the device's runtime PM hooks have been called, the
>> device's rutime PM state should be set to RPM_SUSPENDING (not yet
>> RPM_SUSPENDED).
>>
>> In addition to the console lock, you should be able to use that flag to
>> avoid console writes while the console is in the process of suspending.
>>
>
> Yes RPM_SUSPENDING check helps along with console lock

Great!

> << Changes as below >>
> ---------------
> diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
> index 59f548f..71964c3 100644
> --- a/drivers/tty/serial/omap-serial.c
> +++ b/drivers/tty/serial/omap-serial.c
> @@ -1040,6 +1040,18 @@ serial_omap_console_write(struct console *co,
> const char *s,
>         if (console_trylock())
>                 console_lock = 1;
>
> +       /*
> +        * If console_lock is not available and we are in suspending
> +        * state then we can avoid the console usage scenario
> +        * as this may introduce recursive prints.
> +        * Basically this scenario occurs during boot while
> +        * printing debug bootlogs.
> +        */
> +
> +       if (!console_lock &&
> +               up->pdev->dev.power.runtime_status == RPM_SUSPENDING)
> +               return;
> +
>         local_irq_save(flags);
>         if (up->port.sysrq)
>                 locked = 0;
>
> ------------
>
> Is it ok to check the RPM_SUSPENDING flag in driver ?
> I can't find any API currently available under runtime.h to use.

I would propose a new API in pm_runtime.h similar to
pm_runtime_suspended() that checks for this.

Kevin



More information about the linux-arm-kernel mailing list