All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saravana Kannan <skannan@codeaurora.org>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: Locking in the clk API
Date: Thu, 27 Jan 2011 04:34:20 +0000	[thread overview]
Message-ID: <4D40F5CC.6080809@codeaurora.org> (raw)
In-Reply-To: <20110121094042.GD13235@n2100.arm.linux.org.uk>

On 01/21/2011 01:40 AM, Russell King - ARM Linux wrote:
> On Thu, Jan 20, 2011 at 11:16:04PM -0800, Saravana Kannan wrote:
>> This suggestion looked promising till I realized that clk_set_rate()
>> will still be atomic. clk_set_rate() will need to enable/disable the
>> PLLs depending on which PLLs the rates are derived from. So, the locking
>> in clk_prepare/unprepare() still has to be atomic since the "slow stuff"
>> is shared with clk_set_rate().
>
> Who calls clk_set_rate() from an atomic context?  Do we know whether
> anyone does?

As promised I looked into this in the upstream kernel and with the 
internal teams.

In the upstream (torvalds/master) kernel, I found at least one example 
of calling clk_set_rate() from atomic context (spinlock in this case):
cpm_uart/cpm_uart_core.c

I'm not too familiar with serial/tty, does anyone know if the 
.set_termios needs to be atmoic? If not, we could just change 
cpm_uart/cpm_uart_core.c to use mutex instead of spinlock.

In our internal tree (which we upstream), we have UART HS driver that 
needs to do the same stuff as cpm_uart_core.c. The problem is 
essentially the UART baud rate range being too high to be controllable 
by just the dividers in the UART core. So, the clock rate has to be 
changed in the .set_termios function.

Another concern (not present in MSM) for upstream kernel is that some 
arch/mach might use the clock driver to control the CPU frequency and 
might want to drop it to a low freq in the final stages of an idle 
suspend. In that case, the call would be from atomic context. Similar 
issue during normal suspend.

Except UART, looks like internal teams don't care much for atomic 
clk_set_rate(). So, if .set_termios can use mutex, MSM is good to go for 
prepare/unprepare.

Russell,

If UART does not need clk_set_rate() to be atomic, would you be 
comfortable marking clk_set_rate() as sleepable in the clk.h comments?

Thanks,
Saravana

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

WARNING: multiple messages have this Message-ID (diff)
From: Saravana Kannan <skannan@codeaurora.org>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Colin Cross <ccross@google.com>
Cc: "Lorenzo Pieralisi" <Lorenzo.Pieralisi@arm.com>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	linux-sh <linux-sh@vger.kernel.org>,
	"Ben Herrenschmidt" <benh@kernel.crashing.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"Ben Dooks" <ben-linux@fluff.org>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Jeremy Kerr" <jeremy.kerr@canonical.com>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	"Richard Zhao" <linuxzsc@gmail.com>
Subject: Re: Locking in the clk API
Date: Wed, 26 Jan 2011 20:34:20 -0800	[thread overview]
Message-ID: <4D40F5CC.6080809@codeaurora.org> (raw)
In-Reply-To: <20110121094042.GD13235@n2100.arm.linux.org.uk>

On 01/21/2011 01:40 AM, Russell King - ARM Linux wrote:
> On Thu, Jan 20, 2011 at 11:16:04PM -0800, Saravana Kannan wrote:
>> This suggestion looked promising till I realized that clk_set_rate()
>> will still be atomic. clk_set_rate() will need to enable/disable the
>> PLLs depending on which PLLs the rates are derived from. So, the locking
>> in clk_prepare/unprepare() still has to be atomic since the "slow stuff"
>> is shared with clk_set_rate().
>
> Who calls clk_set_rate() from an atomic context?  Do we know whether
> anyone does?

As promised I looked into this in the upstream kernel and with the 
internal teams.

In the upstream (torvalds/master) kernel, I found at least one example 
of calling clk_set_rate() from atomic context (spinlock in this case):
cpm_uart/cpm_uart_core.c

I'm not too familiar with serial/tty, does anyone know if the 
.set_termios needs to be atmoic? If not, we could just change 
cpm_uart/cpm_uart_core.c to use mutex instead of spinlock.

In our internal tree (which we upstream), we have UART HS driver that 
needs to do the same stuff as cpm_uart_core.c. The problem is 
essentially the UART baud rate range being too high to be controllable 
by just the dividers in the UART core. So, the clock rate has to be 
changed in the .set_termios function.

Another concern (not present in MSM) for upstream kernel is that some 
arch/mach might use the clock driver to control the CPU frequency and 
might want to drop it to a low freq in the final stages of an idle 
suspend. In that case, the call would be from atomic context. Similar 
issue during normal suspend.

Except UART, looks like internal teams don't care much for atomic 
clk_set_rate(). So, if .set_termios can use mutex, MSM is good to go for 
prepare/unprepare.

Russell,

If UART does not need clk_set_rate() to be atomic, would you be 
comfortable marking clk_set_rate() as sleepable in the clk.h comments?

Thanks,
Saravana

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

WARNING: multiple messages have this Message-ID (diff)
From: skannan@codeaurora.org (Saravana Kannan)
To: linux-arm-kernel@lists.infradead.org
Subject: Locking in the clk API
Date: Wed, 26 Jan 2011 20:34:20 -0800	[thread overview]
Message-ID: <4D40F5CC.6080809@codeaurora.org> (raw)
In-Reply-To: <20110121094042.GD13235@n2100.arm.linux.org.uk>

On 01/21/2011 01:40 AM, Russell King - ARM Linux wrote:
> On Thu, Jan 20, 2011 at 11:16:04PM -0800, Saravana Kannan wrote:
>> This suggestion looked promising till I realized that clk_set_rate()
>> will still be atomic. clk_set_rate() will need to enable/disable the
>> PLLs depending on which PLLs the rates are derived from. So, the locking
>> in clk_prepare/unprepare() still has to be atomic since the "slow stuff"
>> is shared with clk_set_rate().
>
> Who calls clk_set_rate() from an atomic context?  Do we know whether
> anyone does?

As promised I looked into this in the upstream kernel and with the 
internal teams.

In the upstream (torvalds/master) kernel, I found at least one example 
of calling clk_set_rate() from atomic context (spinlock in this case):
cpm_uart/cpm_uart_core.c

I'm not too familiar with serial/tty, does anyone know if the 
.set_termios needs to be atmoic? If not, we could just change 
cpm_uart/cpm_uart_core.c to use mutex instead of spinlock.

In our internal tree (which we upstream), we have UART HS driver that 
needs to do the same stuff as cpm_uart_core.c. The problem is 
essentially the UART baud rate range being too high to be controllable 
by just the dividers in the UART core. So, the clock rate has to be 
changed in the .set_termios function.

Another concern (not present in MSM) for upstream kernel is that some 
arch/mach might use the clock driver to control the CPU frequency and 
might want to drop it to a low freq in the final stages of an idle 
suspend. In that case, the call would be from atomic context. Similar 
issue during normal suspend.

Except UART, looks like internal teams don't care much for atomic 
clk_set_rate(). So, if .set_termios can use mutex, MSM is good to go for 
prepare/unprepare.

Russell,

If UART does not need clk_set_rate() to be atomic, would you be 
comfortable marking clk_set_rate() as sleepable in the clk.h comments?

Thanks,
Saravana

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  parent reply	other threads:[~2011-01-27  4:34 UTC|newest]

Thread overview: 248+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11  2:16 Locking in the clk API Jeremy Kerr
2011-01-11  2:16 ` Jeremy Kerr
2011-01-11  2:16 ` Jeremy Kerr
2011-01-11  3:15 ` Paul Mundt
2011-01-11  3:15   ` Paul Mundt
2011-01-11  3:15   ` Paul Mundt
2011-01-11  4:11   ` Jeremy Kerr
2011-01-11  4:11     ` Jeremy Kerr
2011-01-11  4:11     ` Jeremy Kerr
2011-01-11  4:54     ` Paul Mundt
2011-01-11  4:54       ` Paul Mundt
2011-01-11  4:54       ` Paul Mundt
2011-01-20 16:32       ` Ben Dooks
2011-01-20 16:32         ` Ben Dooks
2011-01-20 16:32         ` Ben Dooks
2011-01-20 18:57         ` Russell King - ARM Linux
2011-01-20 18:57           ` Russell King - ARM Linux
2011-01-20 18:57           ` Russell King - ARM Linux
2011-01-21  3:43           ` Saravana Kannan
2011-01-21  3:43             ` Saravana Kannan
2011-01-21  3:43             ` Saravana Kannan
2011-01-21  9:31             ` Russell King - ARM Linux
2011-01-21  9:31               ` Russell King - ARM Linux
2011-01-21  9:31               ` Russell King - ARM Linux
2011-01-11  9:03     ` Sascha Hauer
2011-01-11  9:03       ` Sascha Hauer
2011-01-11  9:03       ` Sascha Hauer
2011-01-11  9:28       ` Russell King - ARM Linux
2011-01-11  9:28         ` Russell King - ARM Linux
2011-01-11  9:28         ` Russell King - ARM Linux
2011-01-11 14:34         ` Pavel Machek
2011-01-11 14:34           ` Pavel Machek
2011-01-11 14:34           ` Pavel Machek
2011-01-20 16:29   ` Ben Dooks
2011-01-20 16:29     ` Ben Dooks
2011-01-20 16:29     ` Ben Dooks
2011-01-20 18:56     ` Russell King - ARM Linux
2011-01-20 18:56       ` Russell King - ARM Linux
2011-01-20 18:56       ` Russell King - ARM Linux
2011-01-20 21:30       ` Nicolas Pitre
2011-01-20 21:30         ` Nicolas Pitre
2011-01-20 21:30         ` Nicolas Pitre
2011-01-21  2:06         ` Dima Zavin
2011-01-21  2:06           ` Dima Zavin
2011-01-21  2:06           ` Dima Zavin
2011-01-21  4:12           ` Saravana Kannan
2011-01-21  4:12             ` Saravana Kannan
2011-01-21  4:12             ` Saravana Kannan
2011-01-21  9:32             ` Russell King - ARM Linux
2011-01-21  9:32               ` Russell King - ARM Linux
2011-01-21  9:32               ` Russell King - ARM Linux
2011-01-22  1:53               ` Saravana Kannan
2011-01-22  2:24                 ` Colin Cross
2011-01-22  2:56                   ` Saravana Kannan
2011-01-22  9:15                 ` Russell King - ARM Linux
2011-01-24 19:31                   ` Saravana Kannan
2011-01-21 21:03             ` Dima Zavin
2011-01-21 21:03               ` Dima Zavin
2011-01-21 21:03               ` Dima Zavin
2011-01-21 21:53               ` Nicolas Pitre
2011-01-21 21:53                 ` Nicolas Pitre
2011-01-21 21:53                 ` Nicolas Pitre
2011-01-21 22:02                 ` Russell King - ARM Linux
2011-01-21 22:02                   ` Russell King - ARM Linux
2011-01-21 22:02                   ` Russell King - ARM Linux
2011-01-21 22:28                   ` Colin Cross
2011-01-21 22:28                     ` Colin Cross
2011-01-21 22:28                     ` Colin Cross
2011-01-21 23:21                     ` Benjamin Herrenschmidt
2011-01-21 23:21                       ` Benjamin Herrenschmidt
2011-01-21 23:21                       ` Benjamin Herrenschmidt
2011-01-21 23:50                     ` Nicolas Pitre
2011-01-21 23:50                       ` Nicolas Pitre
2011-01-21 23:50                       ` Nicolas Pitre
2011-01-22  1:35                     ` Saravana Kannan
2011-01-22  1:35                       ` Saravana Kannan
2011-01-22  1:35                       ` Saravana Kannan
2011-01-22  2:22                       ` Colin Cross
2011-01-22  2:22                         ` Colin Cross
2011-01-22  2:22                         ` Colin Cross
2011-01-21 22:29                   ` Nicolas Pitre
2011-01-21 22:29                     ` Nicolas Pitre
2011-01-21 22:29                     ` Nicolas Pitre
2011-01-21 23:28                 ` Bryan Huntsman
2011-01-21 23:28                   ` Bryan Huntsman
2011-01-21 23:28                   ` Bryan Huntsman
2011-01-11  9:16 ` Russell King - ARM Linux
2011-01-11  9:16   ` Russell King - ARM Linux
2011-01-11  9:16   ` Russell King - ARM Linux
2011-01-11  9:44   ` Jeremy Kerr
2011-01-11  9:44     ` Jeremy Kerr
2011-01-11  9:44     ` Jeremy Kerr
2011-01-11 10:13     ` Paul Mundt
2011-01-11 10:13       ` Paul Mundt
2011-01-11 10:13       ` Paul Mundt
2011-01-11 10:30       ` Jeremy Kerr
2011-01-11 10:30         ` Jeremy Kerr
2011-01-11 10:30         ` Jeremy Kerr
2011-01-11 12:18         ` Paul Mundt
2011-01-11 12:18           ` Paul Mundt
2011-01-11 12:18           ` Paul Mundt
2011-01-11 13:52           ` 
2011-01-11 13:52             ` Uwe Kleine-König
2011-01-11 13:52             ` Uwe Kleine-König
2011-01-11 14:35           ` Jeremy Kerr
2011-01-11 14:35             ` Jeremy Kerr
2011-01-11 14:35             ` Jeremy Kerr
2011-01-12  3:25             ` Saravana Kannan
2011-01-12  3:25               ` Saravana Kannan
2011-01-12  3:25               ` Saravana Kannan
2011-01-12  7:40               ` 
2011-01-12  7:40                 ` Uwe Kleine-König
2011-01-12  7:40                 ` Uwe Kleine-König
2011-01-12  1:54           ` Saravana Kannan
2011-01-12  1:54             ` Saravana Kannan
2011-01-12  1:54             ` Saravana Kannan
2011-01-12  2:25             ` Paul Mundt
2011-01-12  2:25               ` Paul Mundt
2011-01-12  2:25               ` Paul Mundt
2011-01-20 16:57               ` Ben Dooks
2011-01-20 16:57                 ` Ben Dooks
2011-01-20 16:57                 ` Ben Dooks
2011-01-20 16:53           ` Ben Dooks
2011-01-20 16:53             ` Ben Dooks
2011-01-20 16:53             ` Ben Dooks
2011-01-20 16:40       ` Ben Dooks
2011-01-20 16:40         ` Ben Dooks
2011-01-20 16:40         ` Ben Dooks
2011-01-11 10:39     ` 
2011-01-11 10:39       ` Uwe Kleine-König
2011-01-11 10:39       ` Uwe Kleine-König
2011-01-11 10:47       ` Russell King - ARM Linux
2011-01-11 10:47         ` Russell King - ARM Linux
2011-01-11 10:47         ` Russell King - ARM Linux
2011-01-11 10:56         ` 
2011-01-11 10:56           ` Uwe Kleine-König
2011-01-11 10:56           ` Uwe Kleine-König
2011-01-11 11:15       ` Richard Zhao
2011-01-11 11:15         ` Richard Zhao
2011-01-11 11:15         ` Richard Zhao
2011-01-20 17:02         ` Ben Dooks
2011-01-20 17:02           ` Ben Dooks
2011-01-20 17:02           ` Ben Dooks
2011-01-20 19:08           ` Russell King - ARM Linux
2011-01-20 19:08             ` Russell King - ARM Linux
2011-01-20 19:08             ` Russell King - ARM Linux
2011-01-21  0:09             ` Jassi Brar
2011-01-21  0:09               ` Jassi Brar
2011-01-21  0:09               ` Jassi Brar
2011-01-21  4:47               ` Jassi Brar
2011-01-21  4:47                 ` Jassi Brar
2011-01-21  4:47                 ` Jassi Brar
2011-01-21  9:39                 ` Russell King - ARM Linux
2011-01-21  9:39                   ` Russell King - ARM Linux
2011-01-21  9:39                   ` Russell King - ARM Linux
2011-01-21 10:11                   ` Jassi Brar
2011-01-21 10:11                     ` Jassi Brar
2011-01-21 10:11                     ` Jassi Brar
2011-01-22  4:08                 ` Richard Zhao
2011-01-22  4:08                   ` Richard Zhao
2011-01-22  4:08                   ` Richard Zhao
2011-01-22  5:30                   ` Jassi Brar
2011-01-22  5:30                     ` Jassi Brar
2011-01-22  5:30                     ` Jassi Brar
2011-01-21  7:16             ` Saravana Kannan
2011-01-21  7:16               ` Saravana Kannan
2011-01-21  7:16               ` Saravana Kannan
2011-01-21  9:40               ` Russell King - ARM Linux
2011-01-21  9:40                 ` Russell King - ARM Linux
2011-01-21  9:40                 ` Russell King - ARM Linux
2011-01-22  1:47                 ` Saravana Kannan
2011-01-27  4:34                 ` Saravana Kannan [this message]
2011-01-27  4:34                   ` Saravana Kannan
2011-01-27  4:34                   ` Saravana Kannan
2011-01-27  8:54                   ` Russell King - ARM Linux
2011-01-27  8:54                     ` Russell King - ARM Linux
2011-01-27  8:54                     ` Russell King - ARM Linux
2011-01-27 20:30                     ` Saravana Kannan
2011-01-27 20:30                       ` Saravana Kannan
2011-01-27 20:30                       ` Saravana Kannan
2011-01-27 20:43                       ` Russell King - ARM Linux
2011-01-27 20:43                         ` Russell King - ARM Linux
2011-01-27 20:43                         ` Russell King - ARM Linux
2011-01-27 21:07                         ` Alan Cox
2011-01-27 21:07                           ` Alan Cox
2011-01-27 21:07                           ` Alan Cox
2011-01-27 21:11                           ` Russell King - ARM Linux
2011-01-27 21:11                             ` Russell King - ARM Linux
2011-01-27 21:11                             ` Russell King - ARM Linux
2011-01-27 21:15                           ` Russell King - ARM Linux
2011-01-27 21:15                             ` Russell King - ARM Linux
2011-01-27 21:15                             ` Russell King - ARM Linux
2011-01-28  3:29                           ` Saravana Kannan
2011-01-28  3:29                             ` Saravana Kannan
2011-01-28  3:29                             ` Saravana Kannan
2011-01-28  3:27                         ` Saravana Kannan
2011-01-28  3:27                           ` Saravana Kannan
2011-01-28  3:27                           ` Saravana Kannan
2011-01-11 12:11   ` Jassi Brar
2011-01-11 12:23     ` Jassi Brar
2011-01-11 12:11     ` Jassi Brar
2011-01-12  2:56   ` Saravana Kannan
2011-01-12  2:56     ` Saravana Kannan
2011-01-12  2:56     ` Saravana Kannan
2011-01-12  9:03     ` Russell King - ARM Linux
2011-01-12  9:03       ` Russell King - ARM Linux
2011-01-12  9:03       ` Russell King - ARM Linux
2011-01-15 14:02       ` Christer Weinigel
2011-01-15 14:02         ` Christer Weinigel
2011-01-15 14:02         ` Christer Weinigel
2011-01-15 14:53         ` Russell King - ARM Linux
2011-01-15 14:53           ` Russell King - ARM Linux
2011-01-15 14:53           ` Russell King - ARM Linux
2011-01-15 15:03           ` 
2011-01-15 15:03             ` Uwe Kleine-König
2011-01-15 15:03             ` Uwe Kleine-König
2011-01-15 15:15             ` Russell King - ARM Linux
2011-01-15 15:15               ` Russell King - ARM Linux
2011-01-15 15:15               ` Russell King - ARM Linux
2011-01-15 16:03               ` 
2011-01-15 16:03                 ` Uwe Kleine-König
2011-01-15 16:03                 ` Uwe Kleine-König
2011-01-15 16:21                 ` Russell King - ARM Linux
2011-01-15 16:21                   ` Russell King - ARM Linux
2011-01-15 16:21                   ` Russell King - ARM Linux
2011-01-15 16:31                   ` 
2011-01-15 16:31                     ` Uwe Kleine-König
2011-01-15 16:31                     ` Uwe Kleine-König
2011-01-16  6:59               ` Grant Likely
2011-01-16  6:59                 ` Grant Likely
2011-01-16  6:59                 ` Grant Likely
2011-01-15 17:07           ` Christer Weinigel
2011-01-15 17:07             ` Christer Weinigel
2011-01-15 17:07             ` Christer Weinigel
2011-01-15 17:20             ` Russell King - ARM Linux
2011-01-15 17:20               ` Russell King - ARM Linux
2011-01-15 17:20               ` Russell King - ARM Linux
2011-01-15 17:44               ` Christer Weinigel
2011-01-15 17:44                 ` Christer Weinigel
2011-01-15 17:44                 ` Christer Weinigel
2011-01-15 20:30                 ` Russell King - ARM Linux
2011-01-15 20:30                   ` Russell King - ARM Linux
2011-01-15 20:30                   ` Russell King - ARM Linux
2011-01-17  1:19 ` Jeremy Kerr
2011-01-17  1:19   ` Jeremy Kerr
2011-01-17  1:19   ` Jeremy Kerr
2011-01-17  1:27 ` Jeremy Kerr
2011-01-17  1:27   ` Jeremy Kerr

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=4D40F5CC.6080809@codeaurora.org \
    --to=skannan@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 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.