linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] sunxi clock fixes
@ 2013-09-21  1:03 Emilio López
  2013-09-21  1:03 ` [PATCH 1/3] clk: sunxi: factors: fix off-by-one masks Emilio López
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Emilio López @ 2013-09-21  1:03 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

This small series contains two bug fixes and a patch to solve the issue
of accidental clock gating, as discussed earlier on my RFC patch, "of: 
add a basic memory driver".

I believe the two first patches should go into -rcN, although I have not
noticed any issues so far coming from the bugs themselves.

The third patch should be a no-op for now, and I'd like to have it
merged before these clocks actually appear on the driver; in this way
they will never be gated accidentally, and it remains bisectable. I will 
be sending PLL5/6 support patches in short order.

Cheers,

Emilio

Emilio L?pez (3):
  clk: sunxi: factors: fix off-by-one masks
  clk: sunxi: factors: clear variables before using them
  clk: sunxi: protect core clocks from accidental shutdown

 drivers/clk/sunxi/clk-factors.c |  4 ++--
 drivers/clk/sunxi/clk-sunxi.c   | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

-- 
1.8.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] clk: sunxi: factors: fix off-by-one masks
  2013-09-21  1:03 [PATCH 0/3] sunxi clock fixes Emilio López
@ 2013-09-21  1:03 ` Emilio López
  2013-09-23 16:56   ` Maxime Ripard
  2013-09-21  1:03 ` [PATCH 2/3] clk: sunxi: factors: clear variables before using them Emilio López
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Emilio López @ 2013-09-21  1:03 UTC (permalink / raw)
  To: linux-arm-kernel

The previous code would generate one bit too long masks, and was
needlessly complicated. This patch replaces it by simpler code that can
generate the masks correctly.

Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
 drivers/clk/sunxi/clk-factors.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 88523f9..5687ac9 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -40,7 +40,7 @@ struct clk_factors {
 
 #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
 
-#define SETMASK(len, pos)		(((-1U) >> (31-len))  << (pos))
+#define SETMASK(len, pos)		(((1U << (len)) - 1) << (pos))
 #define CLRMASK(len, pos)		(~(SETMASK(len, pos)))
 #define FACTOR_GET(bit, len, reg)	(((reg) & SETMASK(len, bit)) >> (bit))
 
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] clk: sunxi: factors: clear variables before using them
  2013-09-21  1:03 [PATCH 0/3] sunxi clock fixes Emilio López
  2013-09-21  1:03 ` [PATCH 1/3] clk: sunxi: factors: fix off-by-one masks Emilio López
@ 2013-09-21  1:03 ` Emilio López
  2013-09-23 16:57   ` Maxime Ripard
  2013-09-21  1:03 ` [PATCH 3/3] clk: sunxi: protect core clocks from accidental shutdown Emilio López
  2013-10-09 12:51 ` [PATCH 0/3] sunxi clock fixes Emilio López
  3 siblings, 1 reply; 9+ messages in thread
From: Emilio López @ 2013-09-21  1:03 UTC (permalink / raw)
  To: linux-arm-kernel

Random bits may get into our factors if we don't clear n, k, m and p.

Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
 drivers/clk/sunxi/clk-factors.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 5687ac9..f05207a 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -88,7 +88,7 @@ static long clk_factors_round_rate(struct clk_hw *hw, unsigned long rate,
 static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate,
 				unsigned long parent_rate)
 {
-	u8 n, k, m, p;
+	u8 n = 0, k = 0, m = 0, p = 0;
 	u32 reg;
 	struct clk_factors *factors = to_clk_factors(hw);
 	struct clk_factors_config *config = factors->config;
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] clk: sunxi: protect core clocks from accidental shutdown
  2013-09-21  1:03 [PATCH 0/3] sunxi clock fixes Emilio López
  2013-09-21  1:03 ` [PATCH 1/3] clk: sunxi: factors: fix off-by-one masks Emilio López
  2013-09-21  1:03 ` [PATCH 2/3] clk: sunxi: factors: clear variables before using them Emilio López
@ 2013-09-21  1:03 ` Emilio López
  2013-09-23 17:00   ` Maxime Ripard
  2013-10-09 12:51 ` [PATCH 0/3] sunxi clock fixes Emilio López
  3 siblings, 1 reply; 9+ messages in thread
From: Emilio López @ 2013-09-21  1:03 UTC (permalink / raw)
  To: linux-arm-kernel

Some important clocks may get disabled as a side effect of another clock
being disabled, because they have no consumers. This patch implements a
mechanism so those clocks can be claimed by the driver and therefore
remain enabled at all times.

Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
 drivers/clk/sunxi/clk-sunxi.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 34ee69f..83d3eac 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -617,6 +617,31 @@ static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat
 	}
 }
 
+/**
+ * System clock protection
+ *
+ * By enabling these critical clocks, we prevent their accidental gating
+ * by the framework
+ */
+static void __init sunxi_clock_protect(void)
+{
+	struct clk *clk;
+
+	/* memory bus clock - sun5i+ */
+	clk = clk_get(NULL, "mbus");
+	if (!IS_ERR(clk)) {
+		clk_prepare_enable(clk);
+		clk_put(clk);
+	}
+
+	/* DDR clock - sun4i+ */
+	clk = clk_get(NULL, "pll5_ddr");
+	if (!IS_ERR(clk)) {
+		clk_prepare_enable(clk);
+		clk_put(clk);
+	}
+}
+
 void __init sunxi_init_clocks(void)
 {
 	/* Register all the simple and basic clocks on DT */
@@ -633,4 +658,7 @@ void __init sunxi_init_clocks(void)
 
 	/* Register gate clocks */
 	of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup);
+
+	/* Enable core system clocks */
+	sunxi_clock_protect();
 }
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 1/3] clk: sunxi: factors: fix off-by-one masks
  2013-09-21  1:03 ` [PATCH 1/3] clk: sunxi: factors: fix off-by-one masks Emilio López
@ 2013-09-23 16:56   ` Maxime Ripard
  0 siblings, 0 replies; 9+ messages in thread
From: Maxime Ripard @ 2013-09-23 16:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 20, 2013 at 10:03:10PM -0300, Emilio L?pez wrote:
> The previous code would generate one bit too long masks, and was
> needlessly complicated. This patch replaces it by simpler code that can
> generate the masks correctly.
> 
> Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130923/73614c4b/attachment.sig>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/3] clk: sunxi: factors: clear variables before using them
  2013-09-21  1:03 ` [PATCH 2/3] clk: sunxi: factors: clear variables before using them Emilio López
@ 2013-09-23 16:57   ` Maxime Ripard
  0 siblings, 0 replies; 9+ messages in thread
From: Maxime Ripard @ 2013-09-23 16:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 20, 2013 at 10:03:11PM -0300, Emilio L?pez wrote:
> Random bits may get into our factors if we don't clear n, k, m and p.
> 
> Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130923/b34eb042/attachment.sig>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/3] clk: sunxi: protect core clocks from accidental shutdown
  2013-09-21  1:03 ` [PATCH 3/3] clk: sunxi: protect core clocks from accidental shutdown Emilio López
@ 2013-09-23 17:00   ` Maxime Ripard
  0 siblings, 0 replies; 9+ messages in thread
From: Maxime Ripard @ 2013-09-23 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 20, 2013 at 10:03:12PM -0300, Emilio L?pez wrote:
> Some important clocks may get disabled as a side effect of another clock
> being disabled, because they have no consumers. This patch implements a
> mechanism so those clocks can be claimed by the driver and therefore
> remain enabled at all times.
> 
> Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130923/878c7f57/attachment.sig>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 0/3] sunxi clock fixes
  2013-09-21  1:03 [PATCH 0/3] sunxi clock fixes Emilio López
                   ` (2 preceding siblings ...)
  2013-09-21  1:03 ` [PATCH 3/3] clk: sunxi: protect core clocks from accidental shutdown Emilio López
@ 2013-10-09 12:51 ` Emilio López
  2013-10-31 12:18   ` Emilio López
  3 siblings, 1 reply; 9+ messages in thread
From: Emilio López @ 2013-10-09 12:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mike,

El 20/09/13 22:03, Emilio L?pez escribi?:
> Hi,
>
> This small series contains two bug fixes and a patch to solve the issue
> of accidental clock gating, as discussed earlier on my RFC patch, "of:
> add a basic memory driver".
>
> I believe the two first patches should go into -rcN, although I have not
> noticed any issues so far coming from the bugs themselves.
>
> The third patch should be a no-op for now, and I'd like to have it
> merged before these clocks actually appear on the driver; in this way
> they will never be gated accidentally, and it remains bisectable. I will
> be sending PLL5/6 support patches in short order.
>
> Cheers,
>
> Emilio
>
> Emilio L?pez (3):
>    clk: sunxi: factors: fix off-by-one masks
>    clk: sunxi: factors: clear variables before using them
>    clk: sunxi: protect core clocks from accidental shutdown
>
>   drivers/clk/sunxi/clk-factors.c |  4 ++--
>   drivers/clk/sunxi/clk-sunxi.c   | 28 ++++++++++++++++++++++++++++
>   2 files changed, 30 insertions(+), 2 deletions(-)
>

Can you please take a look at this series and pick the patches if you 
are ok with them? It would be nice to see the first two fixes on -rcN by 
the way.

Thanks!

Emilio

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 0/3] sunxi clock fixes
  2013-10-09 12:51 ` [PATCH 0/3] sunxi clock fixes Emilio López
@ 2013-10-31 12:18   ` Emilio López
  0 siblings, 0 replies; 9+ messages in thread
From: Emilio López @ 2013-10-31 12:18 UTC (permalink / raw)
  To: linux-arm-kernel

El 09/10/13 09:51, Emilio L?pez escribi?:
> Hi Mike,
>
> El 20/09/13 22:03, Emilio L?pez escribi?:
>> Hi,
>>
>> This small series contains two bug fixes and a patch to solve the issue
>> of accidental clock gating, as discussed earlier on my RFC patch, "of:
>> add a basic memory driver".
>>
>> I believe the two first patches should go into -rcN, although I have not
>> noticed any issues so far coming from the bugs themselves.
>>
>> The third patch should be a no-op for now, and I'd like to have it
>> merged before these clocks actually appear on the driver; in this way
>> they will never be gated accidentally, and it remains bisectable. I will
>> be sending PLL5/6 support patches in short order.
>>
>> Cheers,
>>
>> Emilio
>>
>> Emilio L?pez (3):
>>    clk: sunxi: factors: fix off-by-one masks
>>    clk: sunxi: factors: clear variables before using them
>>    clk: sunxi: protect core clocks from accidental shutdown
>>
>>   drivers/clk/sunxi/clk-factors.c |  4 ++--
>>   drivers/clk/sunxi/clk-sunxi.c   | 28 ++++++++++++++++++++++++++++
>>   2 files changed, 30 insertions(+), 2 deletions(-)
>>
>
> Can you please take a look at this series and pick the patches if you
> are ok with them? It would be nice to see the first two fixes on -rcN by
> the way.

$ ping Mike

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-10-31 12:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-21  1:03 [PATCH 0/3] sunxi clock fixes Emilio López
2013-09-21  1:03 ` [PATCH 1/3] clk: sunxi: factors: fix off-by-one masks Emilio López
2013-09-23 16:56   ` Maxime Ripard
2013-09-21  1:03 ` [PATCH 2/3] clk: sunxi: factors: clear variables before using them Emilio López
2013-09-23 16:57   ` Maxime Ripard
2013-09-21  1:03 ` [PATCH 3/3] clk: sunxi: protect core clocks from accidental shutdown Emilio López
2013-09-23 17:00   ` Maxime Ripard
2013-10-09 12:51 ` [PATCH 0/3] sunxi clock fixes Emilio López
2013-10-31 12:18   ` Emilio López

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).