clk: core: Force setting the phase delay when no change
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · Jean-Francois Moine
The hardware phase delay may depend on some other settings as clock reparenting, so, it has to be set each time.
Also, when the delay was the same as previously, an error was returned.Signed-off-by Jean-Francois Moine <[email protected]>---
This effectively reverts commit 023bd7166be0 (clk: skip unnecessary set_phase if nothing to do, 2016-02-26), so I'd like to see if Shawn has any comments or if that patch was just a broken optimization.
We may want to go another route and get the phase from the hardware and compare that to what's requested. That way we don't set the phase again unnecessarily.
Quoted 18 lines
drivers/clk/clk.c | 4 ---- 1 file changed, 4 deletions(-)drivers/clk/clk.c +0
-4@@ -1908,10 +1908,6 @@ int clk_set_phase(struct clk *clk, int degrees)clk_prepare_lock (); -/* bail early if nothing to do */ -if (degrees == clk->core->phase) - goto out; -trace_clk_set_phase (clk->core, degrees);if (clk->core->ops->set_phase)
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 8 lines · Stephen Boyd
Quoted 6 lines · Jean-Francois Moine
The hardware phase delay may depend on some other settings as clock reparenting, so, it has to be set each time.
Also, when the delay was the same as previously, an error was returned.Signed-off-by Jean-Francois Moine <[email protected]>---
Quoted 9 lines
This effectively reverts commit
023bd7166be0(clk: skip unnecessaryset_phaseif nothing to do, 2016-02-26), so I'd like to see if Shawn has any comments or if that patch was just a broken optimization.We may want to go another route and get the phase from the hardware and compare that to what's requested. That way we don't set the phase again unnecessarily.
Sorry for late response.
If the client calls clk_set_phase to set the same phase , why it needs to reparent as *this* parent already support this phase and we don't need to do it again?
For some reasons we have to reparent the clock, it should be sub clock drivers' responsibility to guarantee that we can maintain/restore the topology structure no matter for rate or for phase. But it shouldn't make the callers/users be aware of what was happening.
How do you nofify them that "Oh, reparent now, please call clk_set_phase again" ? :)
Plz correct me if my understanding is wrong.
Quoted 19 lines
Quoted 18 lines
drivers/clk/clk.c | 4 ---- 1 file changed, 4 deletions(-)drivers/clk/clk.c +0
-4@@ -1908,10 +1908,6 @@ int clk_set_phase(struct clk *clk, int degrees)clk_prepare_lock (); -/* bail early if nothing to do */ -if (degrees == clk->core->phase) - goto out; -trace_clk_set_phase (clk->core, degrees);if (clk->core->ops->set_phase)
Signature · 2 lines
Best Regards Shawn Lin
Quoted 18 lines · On Wed, 17 Aug 2016 09:00:05 +0800 Shawn Lin <[email protected]> wrote:
Quoted 8 lines · Stephen Boyd
Quoted 6 lines · Jean-Francois Moine
The hardware phase delay may depend on some other settings as clock reparenting, so, it has to be set each time.
Also, when the delay was the same as previously, an error was returned.Signed-off-by Jean-Francois Moine <[email protected]>---
Quoted 9 lines
This effectively reverts commit
023bd7166be0(clk: skip unnecessaryset_phaseif nothing to do, 2016-02-26), so I'd like to see if Shawn has any comments or if that patch was just a broken optimization.We may want to go another route and get the phase from the hardware and compare that to what's requested. That way we don't set the phase again unnecessarily.
Quoted 16 lines
=20
Sorry for late response.
=20
If the client callsclk_set_phaseto set the same phase , why it needs to reparent as *this* parent already support this phase and we don't need to do it again?
=20
For some reasons we have to reparent the clock, it should be sub clock drivers' responsibility to guarantee that we can maintain/restore the topology structure no matter for rate or for phase. But it shouldn't make the callers/users be aware of what was happening.
=20
How do you nofify them that "Oh, reparent now, please callclk_set_phaseagain" ? :)
=20
Plz correct me if my understanding is wrong.
Shawn,
Maybe this problem is Allwinner specific.
In their SoCs, the phase delays 0..360=B0 must be translated to a hardware shift 0..7 which depends on the ratio of of the rates of the clock and its father. When reparenting the clock, the ratio may change and, with a same phase delay, the hardware shift may have to be changed. As the phase delay is always set after setting the clock, setting the clock hardware in all cases solves the possible mismatch.
Now, the problem I had is a bit different: in some devices (MMCs) of some Allwinner SoCs, and under some conditions, the hardware phase delay may be set directly in the client instead of in the clock. Only the clock knows when this capability is used, so the clock must alert the client that this one has to set the phase delay or not. I solved this required synchronization by returning a specific error code when the clock does not set the phase delay on its side. This mechanism works fine when the set_phase() callback function of the clock is always called, even with a same delay.
In the Allwinner's SoCs, setting the hardware phase delay asks for only a few machine instructions, so, the overhead is very small. If this is not the case for other machines, it could be simple enough to move the test of same delay to the clock drivers of these machines...
--=20
Ken ar c'henta=F1 | ** Breizh ha Linux atav! **
Jef | http://moinejf.free.fr/
+ Heiko
Quoted 38 lines · Jean-Francois Moine
Quoted 30 lines · On Wed, 17 Aug 2016 09:00:05 +0800 Shawn Lin <[email protected]> wrote:
Quoted 8 lines · Stephen Boyd
Quoted 6 lines · Jean-Francois Moine
The hardware phase delay may depend on some other settings as clock reparenting, so, it has to be set each time.
Also, when the delay was the same as previously, an error was returned.Signed-off-by Jean-Francois Moine <[email protected]>---
Quoted 9 lines
This effectively reverts commit
023bd7166be0(clk: skip unnecessaryset_phaseif nothing to do, 2016-02-26), so I'd like to see if Shawn has any comments or if that patch was just a broken optimization.We may want to go another route and get the phase from the hardware and compare that to what's requested. That way we don't set the phase again unnecessarily.
Sorry for late response.
If the client calls
clk_set_phaseto set the same phase , why it needs to reparent as *this* parent already support this phase and we don't need to do it again?For some reasons we have to reparent the clock, it should be sub clock drivers' responsibility to guarantee that we can maintain/restore the topology structure no matter for rate or for phase. But it shouldn't make the callers/users be aware of what was happening.
Quoted 4 lines
How do you nofify them that "Oh, reparent now, please call
clk_set_phaseagain" ? :)Plz correct me if my understanding is wrong.
Quoted 8 lines
Shawn,
Maybe this problem is Allwinner specific.
In their SoCs, the phase delays 0..360° must be translated to a hardware shift 0..7 which depends on the ratio of of the rates of the clock and its father. When reparenting the clock, the ratio may change and, with a same phase delay, the hardware shift may have to be
So when reparenting the clock, could you update the clk->core->phase as well to match the real phase using?
Quoted 6 lines
changed. As the phase delay is always set after setting the clock, setting the clock hardware in all cases solves the possible mismatch.
Now, the problem I had is a bit different: in some devices (MMCs) of some Allwinner SoCs, and under some conditions, the hardware phase delay may be set directly in the client instead of in the clock.
You mean Allwinner mmc driver hardcode the setting of clk phasse instead of calling clk API? Looks strange to me...
Quoted 11 lines
Only the clock knows when this capability is used, so the clock must alert the client that this one has to set the phase delay or not. I solved this required synchronization by returning a specific error code when the clock does not set the phase delay on its side. This mechanism works fine when the
set_phase()callback function of the clock is always called, even with a same delay.In the Allwinner's SoCs, setting the hardware phase delay asks for only a few machine instructions, so, the overhead is very small. If this is not the case for other machines, it could be simple enough to move the test of same delay to the clock drivers of these machines...
I understand it now but it's a trick but not a legit way to solve your problem from my view.
Quoted 1 line
Signature · 2 lines
Best Regards Shawn Lin
+ Heiko
Quoted 38 lines · Jean-Francois Moine
Quoted 30 lines · On Wed, 17 Aug 2016 09:00:05 +0800 Shawn Lin <[email protected]> wrote:
Quoted 8 lines · Stephen Boyd
Quoted 6 lines · Jean-Francois Moine
The hardware phase delay may depend on some other settings as clock reparenting, so, it has to be set each time.
Also, when the delay was the same as previously, an error was returned.Signed-off-by Jean-Francois Moine <[email protected]>---
Quoted 9 lines
This effectively reverts commit
023bd7166be0(clk: skip unnecessaryset_phaseif nothing to do, 2016-02-26), so I'd like to see if Shawn has any comments or if that patch was just a broken optimization.We may want to go another route and get the phase from the hardware and compare that to what's requested. That way we don't set the phase again unnecessarily.
Sorry for late response.
If the client calls
clk_set_phaseto set the same phase , why it needs to reparent as *this* parent already support this phase and we don't need to do it again?For some reasons we have to reparent the clock, it should be sub clock drivers' responsibility to guarantee that we can maintain/restore the topology structure no matter for rate or for phase. But it shouldn't make the callers/users be aware of what was happening.
Quoted 4 lines
How do you nofify them that "Oh, reparent now, please call
clk_set_phaseagain" ? :)Plz correct me if my understanding is wrong.
Quoted 8 lines
Shawn,
Maybe this problem is Allwinner specific.
In their SoCs, the phase delays 0..360° must be translated to a hardware shift 0..7 which depends on the ratio of of the rates of the clock and its father. When reparenting the clock, the ratio may change and, with a same phase delay, the hardware shift may have to be
So when reparenting the clock, could you update the clk->core->phase as well to match the real phase using?
Quoted 6 lines
changed. As the phase delay is always set after setting the clock, setting the clock hardware in all cases solves the possible mismatch.
Now, the problem I had is a bit different: in some devices (MMCs) of some Allwinner SoCs, and under some conditions, the hardware phase delay may be set directly in the client instead of in the clock.
You mean Allwinner mmc driver hardcode the setting of clk phasse instead of calling clk API? Looks strange to me...
Quoted 11 lines
Only the clock knows when this capability is used, so the clock must alert the client that this one has to set the phase delay or not. I solved this required synchronization by returning a specific error code when the clock does not set the phase delay on its side. This mechanism works fine when the
set_phase()callback function of the clock is always called, even with a same delay.In the Allwinner's SoCs, setting the hardware phase delay asks for only a few machine instructions, so, the overhead is very small. If this is not the case for other machines, it could be simple enough to move the test of same delay to the clock drivers of these machines...
I understand it now but it's a trick but not a legit way to solve your problem from my view.
Quoted 1 line
Signature · 2 lines
Best Regards Shawn Lin
Quoted 11 lines · On Wed, 17 Aug 2016 16:15:57 +0800 Shawn Lin <[email protected]> wrote:
+ Heiko
=20Quoted 8 lines · Jean-Francois Moine
Quoted 5 lines · On Wed, 17 Aug 2016 09:00:05 +0800 Shawn Lin <[email protected]> wrote:
Quoted 4 lines · Stephen Boyd
Quoted 3 lines · Jean-Francois Moine
The hardware phase delay may depend on some other settings as clock reparenting, so, it has to be set each time.
Also, when the delay was the same as previously, an error was return=
ed.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Signed-off-by Jean-Francois Moine <[email protected]>---
This effectively reverts commit
023bd7166be0(clk: skip unnecessaryset_phaseif nothing to do, 2016-02-26), so I'd like to see if Shawn has any comments or if that patch was just a broken optimization.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
We may want to go another route and get the phase from the hardware and compare that to what's requested. That way we don't set the phase again unnecessarily.
Sorry for late response.
If the client calls
clk_set_phaseto set the same phase , why it needs to reparent as *this* parent already support this phase a=
nd
Quoted 16 lines
Quoted 16 lines
Quoted 11 lines
we don't need to do it again?
For some reasons we have to reparent the clock, it should be sub clock drivers' responsibility to guarantee that we can maintain/restore the topology structure no matter for rate or for phase. But it shouldn't make the callers/users be aware of what was happening.
How do you nofify them that "Oh, reparent now, please call
clk_set_phaseagain" ? :)Plz correct me if my understanding is wrong.
Shawn,
Maybe this problem is Allwinner specific.
Quoted 7 lines
Quoted 4 lines
In their SoCs, the phase delays 0..360=B0 must be translated to a hardware shift 0..7 which depends on the ratio of of the rates of the clock and its father. When reparenting the clock, the ratio may change and, with a same phase delay, the hardware shift may have to be
=20
So when reparenting the clock, could you update theclk->core->phaseas well to match the real phase using?
No so easy: from the old ratio, we should translate back the hardware shifts (sample and output) to degrees, and, after reparenting, explicitly call the set_phase function of both the sample and output clocks and update the hardware.
While we are sure that the client will call set_phase after reparenting.
Quoted 9 lines
Quoted 6 lines
changed. As the phase delay is always set after setting the clock, setting the clock hardware in all cases solves the possible mismatch.
Now, the problem I had is a bit different: in some devices (MMCs) of some Allwinner SoCs, and under some conditions, the hardware phase delay may be set directly in the client instead of in the clock.
=20
You mean Allwinner mmc driver hardcode the setting of clk phasse instead of calling clk API? Looks strange to me...
But not so stupid. In the Allwinner's SoCs, the MMC hardware asks for 2 clocks, 'sample' and 'output', which have a same rate but different phase delays. The phase shift is implemented in the clock hardware. So, by software, after setting the (main) clock rate, the MMC driver must call the clock driver to update the delays of the clock children.
In newer SoCs, Allwinner developped a 'new timing' mode.
The hardware phase shift still exists in the clock, but they added the same shifting mechanism in the MMC hardware. In this 'new timing' mode, there is only one clock, and the MMC driver sets itself the phase delays without having to call twice more the clock driver.
(but this would be too simple, in fact, the old timing must still be used for rates < 50MHz, and some devices - eMMC - don't work without the new timing)
Quoted 7 lines
Quoted 7 lines
Only the clock knows when this capability is used, so the clock must alert the client that this one has to set the phase delay or not. I solved this required synchronization by returning a specific error code when the clock does not set the phase delay on its side. This mechanism works fine when the
set_phase()callback function of the clock is always called, even with a same delay.
Quoted 7 lines
Quoted 4 lines
In the Allwinner's SoCs, setting the hardware phase delay asks for only a few machine instructions, so, the overhead is very small. If this is not the case for other machines, it could be simple enough to move the test of same delay to the clock drivers of these machines...
=20
I understand it now but it's a trick but not a legit way to solve your problem from my view.
Have you arguments about keeping the test of same delay and not calling the clock driver?
--=20
Ken ar c'henta=F1 | ** Breizh ha Linux atav! **
Jef | http://moinejf.free.fr/