linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Govindraj <govindraj.ti@gmail.com>
To: Kevin Hilman <khilman@ti.com>
Cc: Tony Lindgren <tony@atomide.com>, Rajendra Nayak <rnayak@ti.com>,
	Partha Basak <p-basak2@ti.com>,
	"Govindraj.R" <govindraj.raja@ti.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	linux-serial@vger.kernel.org,
	Vishwanath Sripathy <vishwanath.bs@ti.com>,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v6 09/16] OMAP2+: UART: Add runtime pm support for omap-serial driver
Date: Fri, 14 Oct 2011 23:59:53 +0530	[thread overview]
Message-ID: <CAAL8m4zt1aA2ysRTRazQgn=1QGJkzcYLMCi2m_dUqNKf+0Sh7w@mail.gmail.com> (raw)
In-Reply-To: <87ehyfec7t.fsf@ti.com>

On Fri, Oct 14, 2011 at 10:34 PM, Kevin Hilman <khilman@ti.com> wrote:
> Govindraj <govindraj.ti@gmail.com> writes:
>
>> On Fri, Oct 14, 2011 at 2:52 AM, Kevin Hilman <khilman@ti.com> wrote:
>>> Govindraj <govindraj.ti@gmail.com> writes:
>>>
>>>> On Thu, Oct 13, 2011 at 5:36 AM, Kevin Hilman <khilman@ti.com> wrote:
>>>>> "Govindraj.R" <govindraj.raja@ti.com> writes:
>>>>>
>>>>> [...]
>>>>>
>>>>>> Use device_may_wakeup to check whether uart has wakeup capabilities
>>>>>> and then enable uart runtime usage for the uart.
>>>>>
>>>>> Curious about what happens when device_may_wakeup() is not set during
>>>>> device init.
>>>>>
>>>>> [...]
>>>>>
>>>>>> @@ -1305,6 +1363,16 @@ static int serial_omap_probe(struct platform_device *pdev)
>>>>>>               up->uart_dma.rx_dma_channel = OMAP_UART_DMA_CH_FREE;
>>>>>>       }
>>>>>>
>>>>>> +     pm_runtime_use_autosuspend(&pdev->dev);
>>>>>> +     pm_runtime_set_autosuspend_delay(&pdev->dev,
>>>>>> +                     OMAP_UART_AUTOSUSPEND_DELAY);
>>>>>> +
>>>>>> +     pm_runtime_irq_safe(&pdev->dev);
>>>>>> +     if (device_may_wakeup(&pdev->dev)) {
>>>>>> +             pm_runtime_enable(&pdev->dev);
>>>>>
>>>>> So if device_may_wakeup() is false, runtime PM is not enabled, then...
>>>>>
>>>>>> +             pm_runtime_get_sync(&pdev->dev);
>>>>>
>>>>> ...this get doesn't happen, and the first register access causes a crash.
>>>>
>>>> Actually no crash, clocks will left enabled from boot up (hwmod_no_reset/idle)
>>>> that are idled and enabled back here.
>>>>
>>>> Since hwmod_idle is binded here later ([PATCH v6 15/16]),
>>>
>>> IMO, That's not a very maintainable solution.
>>>
>>> What happens when when someone fixes serial.c to only set
>>> HWMOD_INIT_NO_IDLE on the console UART?  or if we fix things so we don't
>>> need INIT_NO_IDLE anymore?  Then this will crash.
>>>
>>> Driver code should not make assumptions like this about what device init
>>> code is or isn't doing.
>>>
>>
>> Okay, How about doing as below ensuring get_sync always
>> and forbid runtime to avoid clock_gating if wakeup is not set.
>>
>
> This is better, I'm not crazy about that either.
>
> Consider a platform that doesn't have wakeups, but the UARTs are not
> used (at least initially.)   That means on power up, all the UARTs are
> left enabled to consume power even when they're not used.
>

okay, the right place would be serial_omap_pm
to do add runtime forbid.

whenever the uart port is used it will call serial_omap_pm
with state param assigned value zero from serial_core layer
for open system call from user space.

Also when uart port is closed it will shutdown where we can add runtime_allow.
So for uart ports not wakeup capable keep uart clocks on until
used and once port is shutdown cut uart clocks.


diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 8a955fc..2c43744 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -608,6 +608,10 @@ static void serial_omap_shutdown(struct uart_port *port)
                        up->uart_dma.rx_buf_dma_phys);
                up->uart_dma.rx_buf = NULL;
        }
+
+       if (!device_may_wakeup(&up->pdev->dev))
+               pm_runtime_allow(&up->pdev->dev);
+
        pm_runtime_put(&up->pdev->dev);
        free_irq(up->port.irq, up);
 }
@@ -893,6 +897,10 @@ serial_omap_pm(struct uart_port *port, unsigned int state,
        serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
        serial_out(up, UART_EFR, efr);
        serial_out(up, UART_LCR, 0);
+
+       if (!state && !device_may_wakeup(&up->pdev->dev))
+               pm_runtime_forbid(&up->pdev->dev);
+
        pm_runtime_put(&up->pdev->dev);
 }


--
Thanks,
Govindraj.R
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-10-14 18:30 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-30 11:01 [PATCH v6 01/16] OMAP2+: hwmod: Add API to enable IO ring wakeup Govindraj.R
2011-09-30 11:01 ` [PATCH v6 02/16] OMAP2+: hwmod: Add API to check IO PAD wakeup status Govindraj.R
2011-10-01 14:33   ` Rajendra Nayak
2011-10-03  5:00     ` Govindraj
2011-10-03  5:23       ` Rajendra Nayak
2011-10-03  5:56         ` Govindraj
2011-10-10 22:24           ` Kevin Hilman
2011-10-11  6:17             ` Govindraj
2011-09-30 11:01 ` [PATCH v6 03/16] OMAP2+: UART: cleanup + remove uart pm specific API Govindraj.R
2011-09-30 11:01 ` [PATCH v6 04/16] OMAP2+: UART: cleanup 8250 console driver support Govindraj.R
2011-10-04 21:42   ` Kevin Hilman
2011-10-05  6:54     ` Govindraj
2011-10-05 18:42       ` Kevin Hilman
2011-10-06  8:16         ` Govindraj
2011-09-30 11:01 ` [PATCH v6 05/16] OMAP2+: UART: Cleanup part of clock gating mechanism for uart Govindraj.R
2011-10-10 22:30   ` Kevin Hilman
2011-10-11  6:45     ` Govindraj
2011-09-30 11:01 ` [PATCH v6 06/16] OMAP2+: UART: Remove certain feilds from omap_uart_state struct Govindraj.R
2011-10-10 23:31   ` Kevin Hilman
2011-10-12 10:25     ` Govindraj
2011-09-30 11:01 ` [PATCH v6 07/16] OMAP2+: UART: Add default mux for all uarts Govindraj.R
2011-10-05 19:04   ` Kevin Hilman
2011-10-06  8:21     ` Govindraj
2011-09-30 11:01 ` [PATCH v6 08/16] OMAP2+: UART: Store certain reg values to port structure Govindraj.R
2011-10-10 23:58   ` Kevin Hilman
2011-10-11 13:21     ` Govindraj
2011-09-30 11:01 ` [PATCH v6 09/16] OMAP2+: UART: Add runtime pm support for omap-serial driver Govindraj.R
2011-10-10 23:42   ` Kevin Hilman
2011-10-12 10:37     ` Govindraj
2011-10-10 23:56   ` Kevin Hilman
2011-10-12 10:35     ` Govindraj
2011-10-13  0:06   ` Kevin Hilman
2011-10-13  1:28     ` Govindraj
2011-10-13 21:22       ` Kevin Hilman
2011-10-14 12:32         ` Govindraj
2011-10-14 17:04           ` Kevin Hilman
2011-10-14 18:29             ` Govindraj [this message]
2011-10-01 13:41 ` [PATCH v6 01/16] OMAP2+: hwmod: Add API to enable IO ring wakeup Rajendra Nayak
2011-10-03 15:10   ` Vishwanath Sripathy
2011-10-04 21:03   ` Kevin Hilman
2011-10-05 11:57     ` Rajendra Nayak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAL8m4zt1aA2ysRTRazQgn=1QGJkzcYLMCi2m_dUqNKf+0Sh7w@mail.gmail.com' \
    --to=govindraj.ti@gmail.com \
    --cc=govindraj.raja@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=p-basak2@ti.com \
    --cc=rnayak@ti.com \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.com \
    --cc=vishwanath.bs@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).