diff mbox series

[v2,3/3] clk: x86: Stop marking clocks as CLK_IS_CRITICAL

Message ID 20180912093456.23400-4-hdegoede@redhat.com (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show
Series r8169 (x86) clk fixes to fix S0ix not being reached | expand

Commit Message

Hans de Goede Sept. 12, 2018, 9:34 a.m. UTC
Commit d31fd43c0f9a ("clk: x86: Do not gate clocks enabled by the
firmware"), which added the code to mark clocks as CLK_IS_CRITICAL, causes
all unclaimed PMC clocks on Cherry Trail devices to be on all the time,
resulting on the device not being able to reach S0i3 when suspended.

The reason for this commit is that on some Bay Trail / Cherry Trail devices
the r8169 ethernet controller uses pmc_plt_clk_4. Now that the clk-pmc-atom
driver exports an "ether_clk" alias for pmc_plt_clk_4 and the r8169 driver
has been modified to get and enable this clock (if present) the marking of
the clocks as CLK_IS_CRITICAL is no longer necessary.

This commit removes the CLK_IS_CRITICAL marking, fixing Cherry Trail
devices not being able to reach S0i3 greatly decreasing their battery
drain when suspended.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=193891#c102
Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=196861
Cc: Johannes Stezenbach <js@sig21.net>
Cc: Carlo Caione <carlo@endlessm.com>
Reported-by: Johannes Stezenbach <js@sig21.net>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Tweaked the commit msg a bit
-Added: Stephen's Acked-by, Andy's Reviewed-by
---
 drivers/clk/x86/clk-pmc-atom.c | 7 -------
 1 file changed, 7 deletions(-)

Comments

Matwey V. Kornilov July 24, 2022, 9 p.m. UTC | #1
Hello,

I've just found that the following commit

    648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")

breaks the ethernet on my Lex 3I380CW (Atom E3845) motherboard. The board is
equipped with dual Intel I211 based 1Gbps copper ethernet.

Before the commit I see the following:

     igb 0000:01:00.0: added PHC on eth0
     igb 0000:01:00.0: Intel(R) Gigabit Ethernet Network Connection
     igb 0000:01:00.0: eth0: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e4
     igb 0000:01:00.0: eth0: PBA No: FFFFFF-0FF
     igb 0000:01:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
     igb 0000:02:00.0: added PHC on eth1
     igb 0000:02:00.0: Intel(R) Gigabit Ethernet Network Connection
     igb 0000:02:00.0: eth1: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e5
     igb 0000:02:00.0: eth1: PBA No: FFFFFF-0FF
     igb 0000:02:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)

while when the commit is applied I see the following:

     igb 0000:01:00.0: added PHC on eth0
     igb 0000:01:00.0: Intel(R) Gigabit Ethernet Network Connection
     igb 0000:01:00.0: eth0: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e4
     igb 0000:01:00.0: eth0: PBA No: FFFFFF-0FF
     igb 0000:01:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
     igb: probe of 0000:02:00.0 failed with error -2

Please note, that the second ethernet initialization is failed.


See also: http://www.lex.com.tw/products/pdf/3I380A&3I380CW.pdf
Pierre-Louis Bossart July 25, 2022, 3:32 p.m. UTC | #2
On 7/24/22 16:00, Matwey V. Kornilov wrote:
> Hello,
> 
> I've just found that the following commit
> 
>     648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
> 
> breaks the ethernet on my Lex 3I380CW (Atom E3845) motherboard. The board is
> equipped with dual Intel I211 based 1Gbps copper ethernet.

It's not going to be simple, it's 4 yr old commit that fixes other
issues with S0i3...

> 
> Before the commit I see the following:
> 
>      igb 0000:01:00.0: added PHC on eth0
>      igb 0000:01:00.0: Intel(R) Gigabit Ethernet Network Connection
>      igb 0000:01:00.0: eth0: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e4
>      igb 0000:01:00.0: eth0: PBA No: FFFFFF-0FF
>      igb 0000:01:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
>      igb 0000:02:00.0: added PHC on eth1
>      igb 0000:02:00.0: Intel(R) Gigabit Ethernet Network Connection
>      igb 0000:02:00.0: eth1: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e5
>      igb 0000:02:00.0: eth1: PBA No: FFFFFF-0FF
>      igb 0000:02:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
> 
> while when the commit is applied I see the following:
> 
>      igb 0000:01:00.0: added PHC on eth0
>      igb 0000:01:00.0: Intel(R) Gigabit Ethernet Network Connection
>      igb 0000:01:00.0: eth0: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e4
>      igb 0000:01:00.0: eth0: PBA No: FFFFFF-0FF
>      igb 0000:01:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
>      igb: probe of 0000:02:00.0 failed with error -2
> 
> Please note, that the second ethernet initialization is failed.
> 
> 
> See also: http://www.lex.com.tw/products/pdf/3I380A&3I380CW.pdf
Matwey V. Kornilov July 26, 2022, 9:15 a.m. UTC | #3
пн, 25 июл. 2022 г. в 20:08, Pierre-Louis Bossart
<pierre-louis.bossart@linux.intel.com>:
>
>
>
> On 7/24/22 16:00, Matwey V. Kornilov wrote:
> > Hello,
> >
> > I've just found that the following commit
> >
> >     648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
> >
> > breaks the ethernet on my Lex 3I380CW (Atom E3845) motherboard. The board is
> > equipped with dual Intel I211 based 1Gbps copper ethernet.
>
> It's not going to be simple, it's 4 yr old commit that fixes other
> issues with S0i3...

Additionally, it seems that the issue appears only when CONFIG_IGB=m
is used. When CONFIG_IGB=y then both ethernets are initialized
correctly.
However, most (if not all) kernel configs in Linux distros use CONFIG_IGB=m

>
> >
> > Before the commit I see the following:
> >
> >      igb 0000:01:00.0: added PHC on eth0
> >      igb 0000:01:00.0: Intel(R) Gigabit Ethernet Network Connection
> >      igb 0000:01:00.0: eth0: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e4
> >      igb 0000:01:00.0: eth0: PBA No: FFFFFF-0FF
> >      igb 0000:01:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
> >      igb 0000:02:00.0: added PHC on eth1
> >      igb 0000:02:00.0: Intel(R) Gigabit Ethernet Network Connection
> >      igb 0000:02:00.0: eth1: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e5
> >      igb 0000:02:00.0: eth1: PBA No: FFFFFF-0FF
> >      igb 0000:02:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
> >
> > while when the commit is applied I see the following:
> >
> >      igb 0000:01:00.0: added PHC on eth0
> >      igb 0000:01:00.0: Intel(R) Gigabit Ethernet Network Connection
> >      igb 0000:01:00.0: eth0: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e4
> >      igb 0000:01:00.0: eth0: PBA No: FFFFFF-0FF
> >      igb 0000:01:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
> >      igb: probe of 0000:02:00.0 failed with error -2
> >
> > Please note, that the second ethernet initialization is failed.
> >
> >
> > See also: http://www.lex.com.tw/products/pdf/3I380A&3I380CW.pdf
Hans de Goede July 27, 2022, 12:18 p.m. UTC | #4
Hi Paul,

On 7/24/22 23:00, Matwey V. Kornilov wrote:
> Hello,
> 
> I've just found that the following commit
> 
>     648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
> 
> breaks the ethernet on my Lex 3I380CW (Atom E3845) motherboard. The board is
> equipped with dual Intel I211 based 1Gbps copper ethernet.
> 
> Before the commit I see the following:
> 
>      igb 0000:01:00.0: added PHC on eth0
>      igb 0000:01:00.0: Intel(R) Gigabit Ethernet Network Connection
>      igb 0000:01:00.0: eth0: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e4
>      igb 0000:01:00.0: eth0: PBA No: FFFFFF-0FF
>      igb 0000:01:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
>      igb 0000:02:00.0: added PHC on eth1
>      igb 0000:02:00.0: Intel(R) Gigabit Ethernet Network Connection
>      igb 0000:02:00.0: eth1: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e5
>      igb 0000:02:00.0: eth1: PBA No: FFFFFF-0FF
>      igb 0000:02:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
> 
> while when the commit is applied I see the following:
> 
>      igb 0000:01:00.0: added PHC on eth0
>      igb 0000:01:00.0: Intel(R) Gigabit Ethernet Network Connection
>      igb 0000:01:00.0: eth0: (PCIe:2.5Gb/s:Width x1) 4c:02:89:10:02:e4
>      igb 0000:01:00.0: eth0: PBA No: FFFFFF-0FF
>      igb 0000:01:00.0: Using MSI-X interrupts. 2 rx queue(s), 2 tx queue(s)
>      igb: probe of 0000:02:00.0 failed with error -2
> 
> Please note, that the second ethernet initialization is failed.
> 
> 
> See also: http://www.lex.com.tw/products/pdf/3I380A&3I380CW.pdf

Yes some boards use more then 1 clk for the ethernet and do not take
care of enabling/disabling the clk in their ACPI.

As Pierre-Louis mentioned already the disabling of the clocks is necessary
to make 100-s of different (tablet) models suspend properly.

Unfortunately this is known to break ethernet on some boards. As a workaround
we use DMI quirks on those few boards to keep the clocks enabled there, see:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/platform/x86/pmc_atom.c#n381

If you can submit a patch adding your board to this DMI table, then I will
merge it and get it on its way to Linus Torvalds asap.

If you instead want me to write the patch for you, please run:

sudo dmidecode > dmidecode.txt

And attach the generated dmidecode.txt file to your next email.

Regards,

Hans
diff mbox series

Patch

diff --git a/drivers/clk/x86/clk-pmc-atom.c b/drivers/clk/x86/clk-pmc-atom.c
index 75151901ff7d..d977193842df 100644
--- a/drivers/clk/x86/clk-pmc-atom.c
+++ b/drivers/clk/x86/clk-pmc-atom.c
@@ -187,13 +187,6 @@  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 the clock was already enabled by the firmware mark it as critical
-	 * to avoid it being gated by the clock framework if no driver owns it.
-	 */
-	if (plt_clk_is_enabled(&pclk->hw))
-		init.flags |= CLK_IS_CRITICAL;
-
 	ret = devm_clk_hw_register(&pdev->dev, &pclk->hw);
 	if (ret) {
 		pclk = ERR_PTR(ret);