Re: [PATCH v1] clk: Export __clk_lookup()

From: elaine.zhang
Date: Wed Jul 22 2020 - 21:49:40 EST



å 2020/7/23 äå9:42, elaine.zhang åé:

å 2020/7/23 äå8:51, Stephen Boyd åé:
Quoting Heiko Stuebner (2020-07-22 11:26:50)
Hi Elaine,

Am Mittwoch, 22. Juli 2020, 04:32:30 CEST schrieb Elaine Zhang:
Export __clk_lookup() to support user built as module.

ERROR:
drivers/clk/rockchip/clk.ko: In function
`rockchip_clk_protect_critical':
drivers/clk/rockchip/clk.c:741:
undefined reference to `__clk_lookup'
can you elaborate a bit more on why this would be needed?

Because right now the Rockchip clocks are of course built into
the main kernel image (especially due to them being needed during early
boot) and __clk_lookup actually is a pretty deep part of the clock-
framework itself, as probably also denoted by the "__" in the function
name.

Can you stop using __clk_lookup()? The plan is to remove it.

Rk use __clk_lookup() as:

drivers/clk/rockchip/clk.c

void __init rockchip_clk_protect_critical(const char *const clocks[],
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ int nclocks)
{
ÂÂÂÂÂÂÂ int i;

ÂÂÂÂÂÂÂ /* Protect the clocks that needs to stay on */
ÂÂÂÂÂÂÂ for (i = 0; i < nclocks; i++) {
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct clk *clk = __clk_lookup(clocks[i]);

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (clk)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ clk_prepare_enable(clk);
ÂÂÂÂÂÂÂ }
}
e.g:

drivers/clk/rockchip/clk-rk3328.c

static const char *const rk3328_critical_clocks[] __initconst = {
ÂÂÂÂÂÂÂ "aclk_bus",
ÂÂÂÂÂÂÂ "aclk_bus_niu",
ÂÂÂÂÂÂÂ "pclk_bus",
ÂÂÂÂÂÂÂ "pclk_bus_niu",
ÂÂÂÂÂÂÂ "hclk_bus",
ÂÂÂÂÂÂÂ "hclk_bus_niu",
ÂÂÂÂÂÂÂ "aclk_peri",
............

};

If have plan to remove the __clk_lookup, I need to replace the rockchip_clk_protect_critical, and use the flag CLK_IS_CRITICAL.(but use flag CLK_IS_CRITICAL, the enable count is always "0")
Use the CLK_IS_CRITICAL, there is no guarantee that the parent clk is enabled, So the flag CLK_IS_CRITICAL need to be added to all special clks according to the clk tree.