pinctrl: add params in disable_setting for different usage
PATCH v2 1/1 pinctrl: add params in disable_setting for different usage
From: Fan Wu <[email protected]>
What the patch did:
1.To call pinmux_disable_setting ahead of pinmux_enable_setting in each time of
calling pinctrl_select_state
2.Remove the HW disable operation in in pinmux_disable_setting function.
The reason why to do this is that:
1.To avoid duplicated enable_setting operation without disabling operation
which will let Pin's desc->mux_usecount keep being added.
2.The HW pin disable operation is not useful for most of the vendors' platform.
And this avoid the HW glitch after using the item 1# modification.
In the following case, the issue can be reproduced:
1)There is a driver need to switch Pin state dynamicly, E.g. b/t "sleep" and "default" state
2)The Pin setting configuration in DTS node may be like the following one:
component a {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&a_grp_setting &c_grp_setting>;
pinctrl-1 = <&b_grp_setting &c_grp_setting>;
}
The "c_grp_setting" config node is totaly same, maybe like following one:
c_grp_setting: c_grp_setting {
pinctrl-single,pins = <GPIO48 AF6>;
MFP_DEFAULT;
}
3)When switching the Pin state in the following official Pinctrl sequence:
pin = pinctrl_get();
state = pinctrl_lookup_state(wanted_state);
pinctrl_select_state(state);
pinctrl_put();Test Result:
1)The switch is completed as expectation, that is: component's
Pins configuration are changed according to the description in the "wanted_state" group setting
2)The "desc->mux_usecount" of corresponding Pins in "c_group" is added without being decreased, because the "desc" is for each physical pin while the "setting" is for each setting node in the DTS.
Thus, if the "c_grp_setting" in pinctrl-0 is not disabled ahead of enabling "c_grp_setting" in pinctrl-1, the desc->mux_usecount will be kept added without any chance to be decreased.
According to the comments in the original code, only the setting, in old state but not in new state, will be "disable"(calling pinmux_disable_setting), which is correct logic but not intact. We still need consider case that the setting is in both old state and new state.
We can do this in the following two ways:
1) Avoid "enable"(calling pinmux_enable_setting) the Same Pins setting repeatedly.
2) "Disable"(calling pinmux_disable_setting) the "Same Pins setting", actually two setting instance, ahead of enabling them.
Analysis:
1.The solution 2# is better because it can avoid too much iteration.
2.If we disable all of the setting in the old state and one/ones of the setting(s) is/are existed in the new state, the Pin's mux function change may happen when
some SoC vendors defined the "pinctrl-single,function-off" in their DTS file. old_setting=>disabled_setting=>new_setting.
3.In the pinmux framework, when Pin state is switched, the setting in the old state should be marked as "disabled".
Conclusion:
1.To Remove the HW disabling operation to above the glitch mentioned above. 2.Handle the issue mentioned above by disabling all of the setting in old state and then enable the new setting in new state.
--- drivers/pinctrl/core.c | 18 +++--------------- drivers/pinctrl/pinmux.c | 4 ---- 2 files changed, 3 insertions(+), 19 deletions(-)
drivers/pinctrl/core.c +3 -15
@@ -993,25 +993,13 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)* may not be identical to the set of groups with a mux setting * in the new state. While this might be unusual, it's entirely * possible for the "user"-supplied mapping table to be written -* that way. For each group that was configured in the old state -* but not in the new state, this code puts that group into a -* safe/disabled state. +* that way. This code is used for each group that was +* configured in the old state but not in the new state */ list_for_each_entry (setting, &p->state->settings, node) { -bool found = false;if (setting->type !=PIN_MAP_TYPE_MUX_GROUP )continue ; -list_for_each_entry (setting2, &state->settings, node) { -if (setting2->type !=PIN_MAP_TYPE_MUX_GROUP ) -continue ; -if (setting2->data.mux.group == - setting->data.mux.group) { - found = true; -break ; - } - } -if (!found) -pinmux_disable_setting (setting); +pinmux_disable_setting (setting); } }
drivers/pinctrl/pinmux.c +0 -4
@@ -469,7 +469,6 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) {struct pinctrl_dev *pctldev = setting->pctldev;const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; -const struct pinmux_ops *ops = pctldev->desc->pmxops;int ret;const unsigned *pins;unsigned num_pins;
@@ -515,9 +514,6 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) pins[i], desc->name, gname); } } - -if (ops->disable) - ops->disable (pctldev, setting->data.mux.func, setting->data.mux.group); }#ifdef CONFIG_DEBUG_FS
Signature · 1 line
1.7.9.5
Quoted 120 lines · On 05/22/2014 11:10 AM, [email protected] wrote:
From: Fan Wu <[email protected]>
What the patch did:
1.To callpinmux_disable_settingahead ofpinmux_enable_settingin each time of
callingpinctrl_select_state
2.Remove the HW disable operation in inpinmux_disable_settingfunction.The reason why to do this is that:
1.To avoid duplicatedenable_settingoperation without disabling operation
which will let Pin'sdesc->mux_usecountkeep being added.
2.The HW pin disable operation is not useful for most of the vendors' platform.
And this avoid the HW glitch after using the item 1# modification.In the following case, the issue can be reproduced:
1)There is a driver need to switch Pin state dynamicly, E.g. b/t "sleep" and "default" state
2)The Pin setting configuration in DTS node may be like the following one:component a { pinctrl-names = "default", "sleep"; pinctrl-0 = <&a_grp_setting &c_grp_setting>; pinctrl-1 = <&b_grp_setting &c_grp_setting>; } The "c_grp_setting" config node is totaly same, maybe like following one: c_grp_setting: c_grp_setting { pinctrl-single,pins = <GPIO48 AF6>; MFP_DEFAULT; } 3)When switching the Pin state in the following official Pinctrl sequence: pin = pinctrl_get(); state = pinctrl_lookup_state(wanted_state); pinctrl_select_state(state); pinctrl_put();Test Result:
1)The switch is completed as expectation, that is: component's
Pins configuration are changed according to the description in the "wanted_state" group setting
2)The "desc->mux_usecount" of corresponding Pins in "c_group" is added without being decreased, because the "desc" is for each physical pin while the "setting" is for each setting node in the DTS.
Thus, if the "c_grp_setting" in pinctrl-0 is not disabled ahead of enabling "c_grp_setting" in pinctrl-1, thedesc->mux_usecountwill be kept added without any chance to be decreased.According to the comments in the original code, only the setting, in old state but not in new state, will be "disable"(calling
pinmux_disable_setting), which is correct logic but not intact. We still need consider case that the setting is in both old state and new state.
We can do this in the following two ways:
1) Avoid "enable"(callingpinmux_enable_setting) the Same Pins setting repeatedly.
2) "Disable"(callingpinmux_disable_setting) the "Same Pins setting", actually two setting instance, ahead of enabling them.Analysis:
1.The solution 2# is better because it can avoid too much iteration.
2.If we disable all of the setting in the old state and one/ones of the setting(s) is/are existed in the new state, the Pin's mux function change may happen when
some SoC vendors defined the "pinctrl-single,function-off" in their DTS file. old_setting=>disabled_setting=>new_setting.
3.In the pinmux framework, when Pin state is switched, the setting in the old state should be marked as "disabled".Conclusion:
1.To Remove the HW disabling operation to above the glitch mentioned above. 2.Handle the issue mentioned above by disabling all of the setting in old state and then enable the new setting in new state.Signed-off-by Fan Wu <[email protected]>--- drivers/pinctrl/core.c | 18 +++--------------- drivers/pinctrl/pinmux.c | 4 ---- 2 files changed, 3 insertions(+), 19 deletions(-)drivers/pinctrl/core.c +3
-15@@ -993,25 +993,13 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)* may not be identical to the set of groups with a mux setting * in the new state. While this might be unusual, it's entirely * possible for the "user"-supplied mapping table to be written -* that way. For each group that was configured in the old state -* but not in the new state, this code puts that group into a -* safe/disabled state. +* that way. This code is used for each group that was +* configured in the old state but not in the new state */ list_for_each_entry (setting, &p->state->settings, node) { -bool found = false;if (setting->type !=PIN_MAP_TYPE_MUX_GROUP )continue ; -list_for_each_entry (setting2, &state->settings, node) { -if (setting2->type !=PIN_MAP_TYPE_MUX_GROUP ) -continue ; -if (setting2->data.mux.group == - setting->data.mux.group) { - found = true; -break ; - } - } -if (!found) -pinmux_disable_setting (setting); +pinmux_disable_setting (setting); } }drivers/pinctrl/pinmux.c +0
-1@@ -469,7 +469,6 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) {struct pinctrl_dev *pctldev = setting->pctldev;const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; -const struct pinmux_ops *ops = pctldev->desc->pmxops;int ret;const unsigned *pins;unsigned num_pins;
drivers/pinctrl/pinmux.c void pinmux_disable_setting(struct pinctrl_setting const *setting) · line 519
Quoted 9 lines
drivers/pinctrl/pinmux.c +0
-3@@ -515,9 +514,6 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) pins[i], desc->name, gname); } } - -if (ops->disable) - ops->disable (pctldev, setting->data.mux.func, setting->data.mux.group); }#ifdef CONFIG_DEBUG_FS
Dear Guys,
Just as we talked, for my platform, I have no concern about removing the HW disabling operation in the pinmux_disable_setting.
Thus, I filed a new version of the patch we discussed before.
Just as the patch comments said, the patch did:
What the patch did:
1.To call pinmux_disable_setting ahead of pinmux_enable_setting in each time of calling pinctrl_select_state 2.Remove the HW disable operation in in pinmux_disable_setting function.
Could you please help to review the above patch?
If there is no concern about the above solution from you Guys, I think I will try to do the other two patches:
1. To remove the disable ops registration when defining the "include/linux/pinctrl/pinmux.h" in inctrl-single driver. Meanwhile, the related things, like "pinctrl-single,function-off" property and corresponding flag in "pcs_device", will be also removed.
2. To remove the disable ops in "pinmux_ops"(include/linux/pinctrl/pinmux.h)
Is that OK for you about my plan ?
Quoted 7 lines · On 05/21/2014 09:10 PM, [email protected] wrote:
From: Fan Wu <[email protected]>
What the patch did:
1.To callpinmux_disable_settingahead ofpinmux_enable_settingin each time of
callingpinctrl_select_state
2.Remove the HW disable operation in inpinmux_disable_settingfunction.
...
drivers/pinctrl/core.c int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) · line 997
Quoted 13 lines
drivers/pinctrl/core.c +2
-3@@ -993,25 +993,13 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)* may not be identical to the set of groups with a mux setting * in the new state. While this might be unusual, it's entirely * possible for the "user"-supplied mapping table to be written -* that way. For each group that was configured in the old state -* but not in the new state, this code puts that group into a -* safe/disabled state. +* that way. This code is used for each group that was +* configured in the old state but not in the new state
Looking at the code, it's run for every group in the state, not "each group that was configured in the old state but not in the new state"
drivers/pinctrl/core.c void pinmux_disable_setting(struct pinctrl_setting const *setting) · line 517
Quoted 8 lines
drivers/pinctrl/core.c +0
-3@@ -515,9 +514,6 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) pins[i], desc->name, gname); } } - -if (ops->disable) - ops->disable (pctldev, setting->data.mux.func, setting->data.mux.group); }
Should that op be removed from the header file and all drivers too?
Quoted 27 lines · Stephen Warren
Quoted 7 lines · On 05/21/2014 09:10 PM, [email protected] wrote:
From: Fan Wu <[email protected]>
What the patch did:
1.To callpinmux_disable_settingahead ofpinmux_enable_settingin each time of
callingpinctrl_select_state
2.Remove the HW disable operation in inpinmux_disable_settingfunction....
drivers/pinctrl/core.c int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) · line 997
Quoted 13 lines
drivers/pinctrl/core.c +2
-3@@ -993,25 +993,13 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)* may not be identical to the set of groups with a mux setting * in the new state. While this might be unusual, it's entirely * possible for the "user"-supplied mapping table to be written -* that way. For each group that was configured in the old state -* but not in the new state, this code puts that group into a -* safe/disabled state. +* that way. This code is used for each group that was +* configured in the old state but not in the new state Looking at the code, it's run for every group in the state, not "each group that was configured in the old state but not in the new state"
Quoted 11 lines
drivers/pinctrl/core.c void pinmux_disable_setting(struct pinctrl_setting const *setting) · line 517
Quoted 8 lines
drivers/pinctrl/core.c +0
-3@@ -515,9 +514,6 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) pins[i], desc->name, gname); } } - -if (ops->disable) - ops->disable (pctldev, setting->data.mux.func, setting->data.mux.group); }Should that op be removed from the header file and all drivers too?
Dear Stephen,
For you question 1:
The disable_pinmux_setting is for the all of the setting in old state. This is what we really need to do, ahead of enable setting in new state.
In the first patch I filed, which still includes the HW ops in disable_pinmux_setting, to disable each setting in old state and then to enable the setting in new state will introduce HW glitch. But in the current solution, the glitch will not be there, because there is no HW ops in disable_pinmux_setting.
And please notice the patch is mainly used to avoid the duplicated enable operation for the same pin.
For your question 2:
the pinctrl-single driver is still using ops->disable, if I remove the "disable" in ops, there will be build error in the vendor's code base who is using pinctrl-single driver.
Just as I said in the last mail,
the next plan for this topic:
1. To remove the disable ops registration when defining the "include/linux/pinctrl/pinmux.h" in inctrl-single driver. Meanwhile, the related things, like "pinctrl-single,function-off" property and corresponding flag in "pcs_device", will be also removed.
2. To remove the disable ops in "pinmux_ops" in the file of include/linux/pinctrl/pinmux.h
Are you OK for this ?
Quoted 30 lines · FanWu
Quoted 20 lines · Stephen Warren
Quoted 8 lines · On 05/21/2014 09:10 PM, [email protected] wrote:
From: Fan Wu <[email protected]>
What the patch did:
1.To callpinmux_disable_settingahead ofpinmux_enable_settingin each time of
callingpinctrl_select_state
2.Remove the HW disable operation in inpinmux_disable_settingfunction....
Quoted 10 lines
drivers/pinctrl/core.c +0
-1@@ -993,25 +993,13 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) * may not be identical to the set of groups with a mux setting * in the new state. While this might be unusual, it's entirely * possible for the "user"-supplied mapping table to be written - * that way. For each group that was configured in the old stateQuoted 8 lines
drivers/pinctrl/core.c int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) · line 997
Quoted 4 lines
drivers/pinctrl/core.c +2
-2-* but not in the new state, this code puts that group into a -* safe/disabled state. +* that way. This code is used for each group that was +* configured in the old state but not in the new state Looking at the code, it's run for every group in the state, not "each group that was configured in the old state but not in the new state"
Quoted 10 lines
For you question 1:
Thedisable_pinmux_settingis for the all of the setting in old state. This is what we really need to do, ahead of enable setting in new state. In the first patch I filed, which still includes the HW ops indisable_pinmux_setting, to disable each setting in old state and then to enable the setting in new state will introduce HW glitch. But in the current solution, the glitch will not be there, because there is no HW ops indisable_pinmux_setting.
And please notice the patch is mainly used to avoid the duplicated enable operation for the same pin.
I think you missed the point of my comment. I think the new comment text is incorrect. Instead, how about replacing the entire comment with:
/*
* For each pinmux setting in the old state, forget SW's record of mux
* owner for that pingroup. Any pingroups which are still owned by the
* new state will be re-acquired by the call to pinmux_enable_setting()
* in the loop below.
*/
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
drivers/pinctrl/core.c +0
-0@@ -515,9 +514,6 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) pins[i], desc->name, gname); }Quoted 8 lines
drivers/pinctrl/core.c void pinmux_disable_setting(struct · line 519
Quoted 6 lines
drivers/pinctrl/core.c +0
-3} - -if (ops->disable) - ops->disable (pctldev, setting->data.mux.func, setting->data.mux.group); }Should that op be removed from the header file and all drivers too?
Quoted 4 lines
For your question 2:
the pinctrl-single driver is still usingops->disable, if I remove the "disable" in ops, there will be build error in the vendor's code base who is using pinctrl-single driver.
I thought Tony said it was fine to simply remove pinctrl-single's ops->disable code completeley.
Quoted 8 lines
Just as I said in the last mail,
the next plan for this topic:1. To remove the disable ops registration when defining the "
include/linux/pinctrl/pinmux.h" in inctrl-single driver. Meanwhile, the related things, like "pinctrl-single,function-off" property and corresponding flag in "pcs_device", will be also removed.
Quoted 4 lines
2. To remove the disable ops in "
pinmux_ops" in the file ofinclude/linux/pinctrl/pinmux.hAre you OK for this ?
I guess splitting that into separate patches is fine.
Quoted 7 lines · Stephen Warren
Quoted 3 lines · FanWu
the pinctrl-single driver is still using
ops->disable, if I remove the "disable" in ops, there will be build error in the vendor's code base who is using pinctrl-single driver.I thought Tony said it was fine to simply remove pinctrl-single's
ops->disablecode completeley.
AFAIK nobody is using it. At least we don't have any references to pinctrl-single,function-off property in the .dts files.
So removing pcs_disable seems safe to do, the property we probably want to parse and produce a warning in case somebody is using it out of tree.
Regards,
Tony