Received: by 10.213.65.68 with SMTP id h4csp257692imn; Fri, 23 Mar 2018 04:06:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELti/i3Tmw3M5NJWfZwBD1EmrnXJnm737ahUEIuRgNqZ8t/AI1IW1hp10fAVvLmW7ppdCbaf X-Received: by 2002:a17:902:bc41:: with SMTP id t1-v6mr28623553plz.56.1521803160776; Fri, 23 Mar 2018 04:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521803160; cv=none; d=google.com; s=arc-20160816; b=AbQuNiEMhsFQDxRVeScBO+MKgdrytCeyRnug9BvAfweMSTvLpsD2494WszcTA9GCvI 4T+buBSF7/kwGP78yN4zXF5eNLbbG6wvC4YuVZMFpDTv6PT7BV5gpmEGIy3EbaZDVGRZ C4cwzFr/OojbN3de23nh9bt+OzOzyBujZTOowlhfr+c0SLAAJIWgJaefdt7C/XTrZabl GOg44hHaDcbYmoYKPIJZxQ7ZtaUru3+gsQgKs7FAlc9VL+uBO3CAyu/6Atm4plcuAh35 Q4Jqf0cWcJsX5g092cjPXOXZjnzQO4CBqCpc8lqSaAVGe4/jBFzqK/pbl0vzATPrLNiq sABA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VaEMctt9bYyKWOhd9DgY6Y21uLDWSbxlqmA14AM8lW8=; b=kUEpRfvZapvSo3CACjJgzfjQWpDdWzS/X+/FGz//xnhpfBHkoRsemi+uLbkbIIruw1 MK6eiGHxAKVHXk5tLHHm/nz9cMLK4M6Cu7zMsHfHXPJlY5dx6Dr+hNep5TPUWsfjp1Ag 5rgQP1xY7FJsCjgF80YvFbbRf2WWpEmnI0ifF8f65m3MRAoai5Xq5sKud2fEevIbozOH PKG0FNRHY684TYkgv6MsHeEQxgGMQgDa5LmibOplRE1vOr7Hk8wslxwGf7Z4qWGNekEt gRVY4DFz0d07IHQmjufjfYRSqcQOm1NkFKH0oEH67ENXDtCYw5QDAzBzCLwXP0ZA220X WfHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si7900276plk.295.2018.03.23.04.05.45; Fri, 23 Mar 2018 04:06:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933195AbeCWKM0 (ORCPT + 99 others); Fri, 23 Mar 2018 06:12:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44286 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933179AbeCWKMW (ORCPT ); Fri, 23 Mar 2018 06:12:22 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B78421066; Fri, 23 Mar 2018 10:12:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Andy Shevchenko , Linus Walleij , Sasha Levin Subject: [PATCH 4.9 161/177] pinctrl: Really force states during suspend/resume Date: Fri, 23 Mar 2018 10:54:49 +0100 Message-Id: <20180323094212.280968417@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Fainelli [ Upstream commit 981ed1bfbc6c4660b2ddaa8392893e20a6255048 ] 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 the actual state change from pinctrl_select_state() and move it pinctrl_commit_state(), while keeping the p->state == state check in pinctrl_select_state() not to change the caller assumptions. pinctrl_force_sleep() and pinctrl_force_default() are updated to bypass the state check by calling pinctrl_commit_state(). [Linus Walleij] The forced pin control states are currently only used in some pin controller drivers that grab their own reference to their own pins. This is equal to the pin control hogs: pins taken by pin control devices since there are no corresponding device in the Linux device hierarchy, such as memory controller lines or unused GPIO lines, or GPIO lines that are used orthogonally from the GPIO subsystem but pincontrol-wise managed as hogs (non-strict mode, allowing simultaneous use by GPIO and pin control). For this case forcing the state from the drivers' suspend()/resume() callbacks makes sense and should semantically match the name of the function. Fixes: 6e5e959dde0d ("pinctrl: API changes to support multiple states per device") Signed-off-by: Florian Fainelli Reviewed-by: Andy Shevchenko Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pinctrl/core.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -992,19 +992,16 @@ struct pinctrl_state *pinctrl_lookup_sta 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 */ -int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) +static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state) { struct pinctrl_setting *setting, *setting2; struct pinctrl_state *old_state = p->state; int ret; - if (p->state == state) - return 0; - if (p->state) { /* * For each pinmux setting in the old state, forget SW's record @@ -1068,6 +1065,19 @@ unapply_new_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) +{ + if (p->state == state) + return 0; + + return pinctrl_commit_state(p, state); +} EXPORT_SYMBOL_GPL(pinctrl_select_state); static void devm_pinctrl_release(struct device *dev, void *res) @@ -1236,7 +1246,7 @@ void pinctrl_unregister_map(struct pinct 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); return 0; } EXPORT_SYMBOL_GPL(pinctrl_force_sleep); @@ -1248,7 +1258,7 @@ 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); return 0; } EXPORT_SYMBOL_GPL(pinctrl_force_default);