clk: x86: Do not gate clocks enabled by the firmware
PATCH 1/1 clk: x86: Do not gate clocks enabled by the firmware
From: Carlo Caione <[email protected]>
Read the enable register to determine if the clock is already in use by the firmware. In this case avoid gating the clock.
--- drivers/clk/x86/clk-pmc-atom.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/x86/clk-pmc-atom.c +3 -0
@@ -185,6 +185,9 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id, pclk->reg = base +PMC_CLK_CTL_OFFSET + id *PMC_CLK_CTL_SIZE ;spin_lock_init (&pclk->lock); +if (plt_clk_is_enabled (&pclk->hw)) + init.flags |=CLK_IGNORE_UNUSED ; + ret =devm_clk_hw_register (&pdev->dev, &pclk->hw);if (ret) { pclk =ERR_PTR (ret);
Signature · 1 line
2.13.2
Hi,
2017-07-10 22:38 GMT+02:00 Carlo Caione <[email protected]>:
Quoted 25 lines
From: Carlo Caione <[email protected]>
Read the enable register to determine if the clock is already in use by the firmware. In this case avoid gating the clock.
Signed-off-by Carlo Caione <[email protected]>--- drivers/clk/x86/clk-pmc-atom.c | 3 +++ 1 file changed, 3 insertions(+)drivers/clk/x86/clk-pmc-atom.c +3
-1@@ -185,6 +185,9 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id, pclk->reg = base +PMC_CLK_CTL_OFFSET + id *PMC_CLK_CTL_SIZE ;spin_lock_init (&pclk->lock); +if (plt_clk_is_enabled (&pclk->hw)) + init.flags |=CLK_IGNORE_UNUSED ; + ret =devm_clk_hw_register (&pdev->dev, &pclk->hw);if (ret) { pclk =ERR_PTR (ret); --
Quoted 2 lines
2.13.2
It also fixes the issue introduced in commit 282a4e4 ("platform/x86:
Enable Atom PMC platform clocks") that causes no audio on Baytrail.
Thanks Carlo to send this.
Quoted 34 lines · Enric Balletbo Serra
Hi,
2017-07-10 22:38 GMT+02:00 Carlo Caione <[email protected]>:
Quoted 25 lines
From: Carlo Caione <[email protected]>
Read the enable register to determine if the clock is already in use by the firmware. In this case avoid gating the clock.
Signed-off-by Carlo Caione <[email protected]>--- drivers/clk/x86/clk-pmc-atom.c | 3 +++ 1 file changed, 3 insertions(+)drivers/clk/x86/clk-pmc-atom.c +3
-1@@ -185,6 +185,9 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id, pclk->reg = base +PMC_CLK_CTL_OFFSET + id *PMC_CLK_CTL_SIZE ;spin_lock_init (&pclk->lock); +if (plt_clk_is_enabled (&pclk->hw)) + init.flags |=CLK_IGNORE_UNUSED ; + ret =devm_clk_hw_register (&pdev->dev, &pclk->hw);if (ret) { pclk =ERR_PTR (ret); --Quoted 2 lines
2.13.2
It also fixes the issue introduced in commit 282a4e4 ("platform/x86:
Enable Atom PMC platform clocks") that causes no audio on Baytrail.
Quoted 1 line
Excellent, thank you Enric. Pierre, any objections to this going in to 4.13 now and stable back to 4.12?
Signature · 2 lines
Darren Hart VMware Open Source Technology Center
Quoted 7 lines · Darren Hart
Quoted 6 lines · Enric Balletbo Serra
2017-07-10 22:38 GMT+02:00 Carlo Caione <[email protected]>:
Quoted 5 lines
pclk->reg = base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE; spin_lock_init(&pclk->lock);drivers/clk/x86/clk-pmc-atom.c +2
-0+if (plt_clk_is_enabled (&pclk->hw)) + init.flags |=CLK_IGNORE_UNUSED ;
Can you add a comment to the effect of why we're adding ignore unused here? That will make it clearer when reading the code a year from now why we're not turning these clks off by default and also allow us to recall why it isn't marked as a critical clk.
Probably, we want some sort of handoff mechanism here so that the clk is left on until a driver comes into the picture and acquires a handle to this clk?
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
+
ret = devm_clk_hw_register(&pdev->dev, &pclk->hw); if (ret) { pclk = ERR_PTR(ret);--
2.13.2
Quoted 8 lines
Quoted 4 lines
It also fixes the issue introduced in commit 282a4e4 ("platform/x86:
Enable Atom PMC platform clocks") that causes no audio on Baytrail.Excellent, thank you Enric. Pierre, any objections to this going in to 4.13 now and stable back to 4.12?
You mean v4.11? That's when commit 282a4e4 was released. Typically we punt these sorts of things to the next release because it isn't a regression in the release that's being worked on (i.e. it wasn't introduced in this merge window), but in this case it seems like a small enough patch plus it's a bother to keep it out of the release to make it alright to merge now.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 6 lines · Stephen Boyd
Quoted 5 lines · Darren Hart
Quoted 4 lines · Enric Balletbo Serra
2017-07-10 22:38 GMT+02:00 Carlo Caione <[email protected]>:
Quoted 3 lines
pclk->reg = base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE; spin_lock_init(&pclk->lock);
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
drivers/clk/x86/clk-pmc-atom.c static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id, · line 189
Quoted 2 lines
drivers/clk/x86/clk-pmc-atom.c +2
-0+if (plt_clk_is_enabled (&pclk->hw)) + init.flags |=CLK_IGNORE_UNUSED ;Can you add a comment to the effect of why we're adding ignore unused here? That will make it clearer when reading the code a year from now why we're not turning these clks off by default and also allow us to recall why it isn't marked as a critical clk.
Yes please, good point.
Quoted 4 lines
Probably, we want some sort of handoff mechanism here so that the clk is left on until a driver comes into the picture and acquires a handle to this clk?
Presumably optionally - it will stay on permanently if nothing claims it, as in the case where the firmware sets up for the platform, and nothing else touches it.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
+
ret = devm_clk_hw_register(&pdev->dev, &pclk->hw); if (ret) { pclk = ERR_PTR(ret);--
2.13.2It also fixes the issue introduced in commit 282a4e4 ("platform/x86:
Enable Atom PMC platform clocks") that causes no audio on Baytrail.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Excellent, thank you Enric. Pierre, any objections to this going in to 4.13 now and stable back to 4.12?
You mean v4.11? That's when commit 282a4e4 was released.
Yes indeed.
Quoted 10 lines
Typically we punt these sorts of things to the next release because it isn't a regression in the release that's being worked on (i.e. it wasn't introduced in this merge window), but in this case it seems like a small enough patch plus it's a bother to keep it out of the release to make it alright to merge now.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 2 lines
Darren Hart VMware Open Source Technology Center
Quoted 6 lines · Stephen Boyd
Quoted 5 lines · Darren Hart
Quoted 4 lines · Enric Balletbo Serra
2017-07-10 22:38 GMT+02:00 Carlo Caione <[email protected]>:
Quoted 3 lines
pclk->reg = base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE; spin_lock_init(&pclk->lock);
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
drivers/clk/x86/clk-pmc-atom.c static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id, · line 189
Quoted 2 lines
drivers/clk/x86/clk-pmc-atom.c +2
-0+if (plt_clk_is_enabled (&pclk->hw)) + init.flags |=CLK_IGNORE_UNUSED ;Can you add a comment to the effect of why we're adding ignore unused here? That will make it clearer when reading the code a year from now why we're not turning these clks off by default and also allow us to recall why it isn't marked as a critical clk.
This is actually a good point. Probably here we want to mark the clock as CLK_IS_CRITICAL instead of CLK_IGNORE_UNUSED.
Michael, any preference here?
Signature · 1 line
Carlo Caione | +39.340.80.30.096 | Endless
Quoted 35 lines · Darren Hart
Quoted 34 lines · Enric Balletbo Serra
Hi,
2017-07-10 22:38 GMT+02:00 Carlo Caione <[email protected]>:
Quoted 25 lines
From: Carlo Caione <[email protected]>
Read the enable register to determine if the clock is already in use by the firmware. In this case avoid gating the clock.
Signed-off-by Carlo Caione <[email protected]>--- drivers/clk/x86/clk-pmc-atom.c | 3 +++ 1 file changed, 3 insertions(+)drivers/clk/x86/clk-pmc-atom.c +3
-1@@ -185,6 +185,9 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id, pclk->reg = base +PMC_CLK_CTL_OFFSET + id *PMC_CLK_CTL_SIZE ;spin_lock_init (&pclk->lock); +if (plt_clk_is_enabled (&pclk->hw)) + init.flags |=CLK_IGNORE_UNUSED ; + ret =devm_clk_hw_register (&pdev->dev, &pclk->hw);if (ret) { pclk =ERR_PTR (ret); --Quoted 2 lines
2.13.2
It also fixes the issue introduced in commit 282a4e4 ("platform/x86:
Enable Atom PMC platform clocks") that causes no audio on Baytrail.
Quoted 4 lines
Quoted 1 line
Excellent, thank you Enric. Pierre, any objections to this going in to 4.13 now and stable back to 4.12?
I saw an update of this patch being merged while I was away on an extended summer break, but out of curiosity what was the problem with no audio on Baytrail? the code was added precisely to add support for 19.2 MHz on Baytrail and finally solve audio issues. I have no reports of broken functionality with this 282a4e4 commit... Enric, do you have a bugzilla or pointers?
Quoted 10 lines · Pierre-Louis Bossart
Quoted 8 lines · Darren Hart
Quoted 1 line · Enric Balletbo Serra
Excellent, thank you Enric. Pierre, any objections to this going in to
4.13 now and stable back to 4.12?
Quoted 8 lines
I saw an update of this patch being merged while I was away on an extended summer break, but out of curiosity what was the problem with no
audio on Baytrail? the code was added precisely to add support for 19.2
MHz on Baytrail and finally solve audio issues. I have no reports of broken functionality with this 282a4e4 commit... Enric, do you have a bugzilla or pointers?
TL;DR: We should respect firmware settings before blindly shut down "unused" resources. (We used to have similar stuff in GPIO/pinctrl driver for direct IRQ pins, where we shut up the pins which are used directly by IOAPIC)
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 20 lines · Andy Shevchenko
Quoted 10 lines · Pierre-Louis Bossart
Quoted 8 lines · Darren Hart
Quoted 1 line · Enric Balletbo Serra
Excellent, thank you Enric. Pierre, any objections to this going in to
4.13 now and stable back to 4.12?Quoted 8 lines
I saw an update of this patch being merged while I was away on an extended summer break, but out of curiosity what was the problem with no
audio on Baytrail? the code was added precisely to add support for 19.2
MHz on Baytrail and finally solve audio issues. I have no reports of broken functionality with this 282a4e4 commit... Enric, do you have a bugzilla or pointers?
Quoted 4 lines
TL;DR: We should respect firmware settings before blindly shut down "unused" resources. (We used to have similar stuff in GPIO/pinctrl driver for direct IRQ pins, where we shut up the pins which are used directly by IOAPIC)
I wasn't arguing against those patches, just curious as to which platforms were broken by setting pmc_plat_3 blindly in the driver.
2017-07-24 16:07 GMT+02:00 Pierre-Louis Bossart
<[email protected]>:
Quoted 28 lines · Andy Shevchenko
Quoted 27 lines · Pierre-Louis Bossart
Quoted 23 lines · Darren Hart
Quoted 11 lines
Quoted 1 line · Enric Balletbo Serra
Excellent, thank you Enric. Pierre, any objections to this going in to
4.13 now and stable back to 4.12?I saw an update of this patch being merged while I was away on an extended summer break, but out of curiosity what was the problem with no
audio on Baytrail? the code was added precisely to add support for 19.2
MHz on Baytrail and finally solve audio issues. I have no reports of broken functionality with this 282a4e4 commit... Enric, do you have a bugzilla or pointers?
Quoted 9 lines
Quoted 4 lines
TL;DR: We should respect firmware settings before blindly shut down "unused" resources. (We used to have similar stuff in GPIO/pinctrl driver for direct IRQ pins, where we shut up the pins which are used directly by IOAPIC)
I wasn't arguing against those patches, just curious as to which platforms were broken by setting
pmc_plat_3blindly in the driver.
After your patch the clock framework disables the required clocks because the driver does not request then and audio stopped to work.This is not the solution as is the codec who *must* request these clocks. We should implement this in the codec driver.. But now, at least, if firmware enables the clocks audio continues working on Baytrail.
Regards,
Enric
Quoted 40 lines · Enric Balletbo Serra
2017-07-24 16:07 GMT+02:00 Pierre-Louis Bossart
<[email protected]>:Quoted 28 lines · Andy Shevchenko
Quoted 27 lines · Pierre-Louis Bossart
Quoted 23 lines · Darren Hart
Quoted 11 lines
Quoted 1 line · Enric Balletbo Serra
Excellent, thank you Enric. Pierre, any objections to this going in to
4.13 now and stable back to 4.12?I saw an update of this patch being merged while I was away on an extended summer break, but out of curiosity what was the problem with no
audio on Baytrail? the code was added precisely to add support for 19.2
MHz on Baytrail and finally solve audio issues. I have no reports of broken functionality with this 282a4e4 commit... Enric, do you have a bugzilla or pointers?Quoted 9 lines
Quoted 4 lines
TL;DR: We should respect firmware settings before blindly shut down "unused" resources. (We used to have similar stuff in GPIO/pinctrl driver for direct IRQ pins, where we shut up the pins which are used directly by IOAPIC)
I wasn't arguing against those patches, just curious as to which platforms were broken by setting
pmc_plat_3blindly in the driver.
Quoted 6 lines
After your patch the clock framework disables the required clocks because the driver does not request then and audio stopped to work.This is not the solution as is the codec who *must* request these clocks. We should implement this in the codec driver.. But now, at least, if firmware enables the clocks audio continues working on Baytrail.
Clocks are not enabled/managed in any of the BIOSes I've seen for Baytrail, are you talking about a Chromebook by any chance with the legacy non-DPCM byt-max98080 driver?
Hi,
2017-07-24 18:26 GMT+02:00 Pierre-Louis Bossart
<[email protected]>:
Quoted 60 lines · Enric Balletbo Serra
Quoted 51 lines
2017-07-24 16:07 GMT+02:00 Pierre-Louis Bossart
<[email protected]>:Quoted 43 lines · Andy Shevchenko
Quoted 34 lines · Pierre-Louis Bossart
Quoted 20 lines · Darren Hart
Quoted 7 lines
On Tue, Jul 11, 2017 at 12:31:28AM +0200, Enric Balletbo Serra wrote:
Quoted 7 lines
Quoted 1 line
Excellent, thank you Enric. Pierre, any objections to this going in to
4.13 now and stable back to 4.12?Quoted 8 lines
I saw an update of this patch being merged while I was away on an extended summer break, but out of curiosity what was the problem with no
audio on Baytrail? the code was added precisely to add support for 19.2
MHz on Baytrail and finally solve audio issues. I have no reports of broken functionality with this 282a4e4 commit... Enric, do you have a bugzilla or pointers?Quoted 4 lines
TL;DR: We should respect firmware settings before blindly shut down "unused" resources. (We used to have similar stuff in GPIO/pinctrl driver for direct IRQ pins, where we shut up the pins which are used directly by IOAPIC)
Quoted 4 lines
I wasn't arguing against those patches, just curious as to which platforms
were broken by settingpmc_plat_3blindly in the driver.Quoted 6 lines
After your patch the clock framework disables the required clocks because the driver does not request then and audio stopped to work.This is not the solution as is the codec who *must* request these clocks. We should implement this in the codec driver.. But now, at least, if firmware enables the clocks audio continues working on Baytrail.
Quoted 4 lines
Clocks are not enabled/managed in any of the BIOSes I've seen for Baytrail, are you talking about a Chromebook by any chance with the legacy non-DPCM byt-max98080 driver?
Yes the issue is with a Chromebook with the legacy byt-max98080 driver.
Quoted 64 lines · Enric Balletbo Serra
Hi,
2017-07-24 18:26 GMT+02:00 Pierre-Louis Bossart
<[email protected]>:Quoted 60 lines · Enric Balletbo Serra
Quoted 57 lines
2017-07-24 16:07 GMT+02:00 Pierre-Louis Bossart
<[email protected]>:Quoted 43 lines · Andy Shevchenko
Quoted 34 lines · Pierre-Louis Bossart
Quoted 20 lines · Darren Hart
Quoted 7 lines
On Tue, Jul 11, 2017 at 12:31:28AM +0200, Enric Balletbo Serra wrote:
Quoted 7 lines
Quoted 1 line
Excellent, thank you Enric. Pierre, any objections to this going in to
4.13 now and stable back to 4.12?Quoted 8 lines
I saw an update of this patch being merged while I was away on an extended summer break, but out of curiosity what was the problem with no
audio on Baytrail? the code was added precisely to add support for 19.2
MHz on Baytrail and finally solve audio issues. I have no reports of broken functionality with this 282a4e4 commit... Enric, do you have a bugzilla or pointers?Quoted 4 lines
TL;DR: We should respect firmware settings before blindly shut down "unused" resources. (We used to have similar stuff in GPIO/pinctrl driver for direct IRQ pins, where we shut up the pins which are used directly by IOAPIC)
Quoted 4 lines
I wasn't arguing against those patches, just curious as to which platforms
were broken by settingpmc_plat_3blindly in the driver.After your patch the clock framework disables the required clocks because the driver does not request then and audio stopped to work.This is not the solution as is the codec who *must* request these clocks. We should implement this in the codec driver.. But now, at least, if firmware enables the clocks audio continues working on Baytrail.
Quoted 6 lines
Quoted 4 lines
Clocks are not enabled/managed in any of the BIOSes I've seen for Baytrail, are you talking about a Chromebook by any chance with the legacy non-DPCM byt-max98080 driver?
Yes the issue is with a Chromebook with the legacy byt-max98080 driver.
ah, yes I never tested on those (couldn't make the device boot).
We may be able to do more simplifications, in machine drivers I test for Baytrail vs. Cherrytrail to manage the clocks at the kernel level, but maybe I should just look at what the firmware does and use the kernel clock management as a fallback.