lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b201355c-0c0f-4146-8574-669e77aabec5@lunn.ch>
Date: Thu, 19 Dec 2024 17:21:19 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Wei Fang <wei.fang@....com>
Cc: hkallweit1@...il.com, linux@...linux.org.uk, davem@...emloft.net,
	edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
	florian.fainelli@...adcom.com, heiko.stuebner@...rry.de,
	frank.li@....com, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org, imx@...ts.linux.dev
Subject: Re: [PATCH v5 net] net: phy: micrel: Dynamically control external
 clock of KSZ PHY

On Tue, Dec 17, 2024 at 02:35:00PM +0800, Wei Fang wrote:
> On the i.MX6ULL-14x14-EVK board, enet1_ref and enet2_ref are used as the
> clock sources for two external KSZ PHYs. However, after closing the two
> FEC ports, the clk_enable_count of the enet1_ref and enet2_ref clocks is
> not 0. The root cause is that since the commit 985329462723 ("net: phy:
> micrel: use devm_clk_get_optional_enabled for the rmii-ref clock"), the
> external clock of KSZ PHY has been enabled when the PHY driver probes,
> and it can only be disabled when the PHY driver is removed. This causes
> the clock to continue working when the system is suspended or the network
> port is down.
> 
> Although Heiko explained in the commit message that the patch was because
> some clock suppliers need to enable the clock to get the valid clock rate
> , it seems that the simple fix is to disable the clock after getting the
> clock rate to solve the current problem. This is indeed true, but we need
> to admit that Heiko's patch has been applied for more than a year, and we
> cannot guarantee whether there are platforms that only enable rmii-ref in
> the KSZ PHY driver during this period. If this is the case, disabling
> rmii-ref will cause RMII on these platforms to not work.
> 
> Secondly, commit 99ac4cbcc2a5 ("net: phy: micrel: allow usage of generic
> ethernet-phy clock") just simply enables the generic clock permanently,
> which seems like the generic clock may only be enabled in the PHY driver.
> If we simply disable the generic clock, RMII may not work. If we keep it
> as it is, the platform using the generic clock will have the same problem
> as the i.MX6ULL platform.
> 
> To solve this problem, the clock is enabled when phy_driver::resume() is
> called, and the clock is disabled when phy_driver::suspend() is called.
> Since phy_driver::resume() and phy_driver::suspend() are not called in
> pairs, an additional clk_enable flag is added. When phy_driver::suspend()
> is called, the clock is disabled only if clk_enable is true. Conversely,
> when phy_driver::resume() is called, the clock is enabled if clk_enable
> is false.
> 
> The changes that introduced the problem were only a few lines, while the
> current fix is about a hundred lines, which seems out of proportion, but
> it is necessary because kszphy_probe() is used by multiple KSZ PHYs and
> we need to fix all of them.
> 
> Fixes: 985329462723 ("net: phy: micrel: use devm_clk_get_optional_enabled for the rmii-ref clock")
> Fixes: 99ac4cbcc2a5 ("net: phy: micrel: allow usage of generic ethernet-phy clock")
> Signed-off-by: Wei Fang <wei.fang@....com>

Reviewed-by: Andrew Lunn <andrew@...n.ch>

    Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ