* [PATCH fixes v2] pinctrl: Really force states during suspend/resume
@ 2017-02-27 23:06 Florian Fainelli
2017-03-01 18:29 ` Florian Fainelli
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2017-02-27 23:06 UTC (permalink / raw)
To: linux-kernel
Cc: swarren, andy.shevchenko, alcooperx, Florian Fainelli,
Linus Walleij, open list:PIN CONTROL SUBSYSTEM
In case a platform only defaults a "default" set of pins, but not a
"sleep" set of pins, and this particular platform suspends and resumes
in a way that the pin states are not preserved by the hardware, when we
resume, we would call pinctrl_single_resume() -> pinctrl_force_default()
-> pinctrl_select_state() and the first thing we do is check that the
pins state is the same as before, and do nothing.
In order to fix this, decouple pinctrl_select_state and make it become
pinctrl_commit_state(), taking an additional ignore_state_check boolean
which allows us to bypass the state check during suspend/resume, since
we really want to re-apply the previous pin states in these case.
Fixes: 6e5e959dde0d ("pinctrl: API changes to support multiple states per device")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- rename __pinctrl_select_state to pinctrl_commit_state
drivers/pinctrl/core.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index fb38e208f32d..36bb329c13e2 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -992,17 +992,21 @@ struct pinctrl_state *pinctrl_lookup_state(struct pinctrl *p,
EXPORT_SYMBOL_GPL(pinctrl_lookup_state);
/**
- * pinctrl_select_state() - select/activate/program a pinctrl state to HW
+ * pinctrl_commit_state() - select/activate/program a pinctrl state to HW
* @p: the pinctrl handle for the device that requests configuration
* @state: the state handle to select/activate/program
+ * @force: ignore the state check (e.g: to re-apply default state during
+ * suspend/resume)
*/
-int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)
+static int pinctrl_commit_state(struct pinctrl *p,
+ struct pinctrl_state *state,
+ bool ignore_state_check)
{
struct pinctrl_setting *setting, *setting2;
struct pinctrl_state *old_state = p->state;
int ret;
- if (p->state == state)
+ if (p->state == state && !ignore_state_check)
return 0;
if (p->state) {
@@ -1068,6 +1072,16 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)
return ret;
}
+
+/**
+ * pinctrl_select_state() - select/activate/program a pinctrl state to HW
+ * @p: the pinctrl handle for the device that requests configuration
+ * @state: the state handle to select/activate/program
+ */
+int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state)
+{
+ return pinctrl_commit_state(p, state, false);
+}
EXPORT_SYMBOL_GPL(pinctrl_select_state);
static void devm_pinctrl_release(struct device *dev, void *res)
@@ -1236,7 +1250,8 @@ void pinctrl_unregister_map(struct pinctrl_map const *map)
int pinctrl_force_sleep(struct pinctrl_dev *pctldev)
{
if (!IS_ERR(pctldev->p) && !IS_ERR(pctldev->hog_sleep))
- return pinctrl_select_state(pctldev->p, pctldev->hog_sleep);
+ return pinctrl_commit_state(pctldev->p,
+ pctldev->hog_sleep, true);
return 0;
}
EXPORT_SYMBOL_GPL(pinctrl_force_sleep);
@@ -1248,7 +1263,8 @@ EXPORT_SYMBOL_GPL(pinctrl_force_sleep);
int pinctrl_force_default(struct pinctrl_dev *pctldev)
{
if (!IS_ERR(pctldev->p) && !IS_ERR(pctldev->hog_default))
- return pinctrl_select_state(pctldev->p, pctldev->hog_default);
+ return pinctrl_commit_state(pctldev->p,
+ pctldev->hog_default, true);
return 0;
}
EXPORT_SYMBOL_GPL(pinctrl_force_default);
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH fixes v2] pinctrl: Really force states during suspend/resume
2017-02-27 23:06 [PATCH fixes v2] pinctrl: Really force states during suspend/resume Florian Fainelli
@ 2017-03-01 18:29 ` Florian Fainelli
0 siblings, 0 replies; 2+ messages in thread
From: Florian Fainelli @ 2017-03-01 18:29 UTC (permalink / raw)
To: linux-kernel, Linus Walleij
Cc: swarren, andy.shevchenko, alcooperx, open list:PIN CONTROL SUBSYSTEM
On 02/27/2017 03:06 PM, Florian Fainelli wrote:
> In case a platform only defaults a "default" set of pins, but not a
> "sleep" set of pins, and this particular platform suspends and resumes
> in a way that the pin states are not preserved by the hardware, when we
> resume, we would call pinctrl_single_resume() -> pinctrl_force_default()
> -> pinctrl_select_state() and the first thing we do is check that the
> pins state is the same as before, and do nothing.
>
> In order to fix this, decouple pinctrl_select_state and make it become
> pinctrl_commit_state(), taking an additional ignore_state_check boolean
> which allows us to bypass the state check during suspend/resume, since
> we really want to re-apply the previous pin states in these case.
>
> Fixes: 6e5e959dde0d ("pinctrl: API changes to support multiple states per device")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Linus, I have a better version of this coming where the p->state ==
state check is just moved into pinctrl_select_state() instead.
--
Florian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-01 18:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-27 23:06 [PATCH fixes v2] pinctrl: Really force states during suspend/resume Florian Fainelli
2017-03-01 18:29 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).