Received: by 10.213.65.68 with SMTP id h4csp231871imn; Fri, 23 Mar 2018 03:29:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELs1vWgcwbHCoPwY09fBkcKmtaoIsmiu5QMOYhyARd5fSCSv9dOp0qFl11ocbaPIpQbUxohd X-Received: by 2002:a17:902:6103:: with SMTP id t3-v6mr28908715plj.76.1521800952709; Fri, 23 Mar 2018 03:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521800952; cv=none; d=google.com; s=arc-20160816; b=X9rIG0ibbSs9VDB5PtxCLhRE08n4fvGOQxaQ+vxyNYLU969dSNDKgack08tftLotwv ewqQBQvQCAK+ZSIySaBLBAaW3wgdbwJ4Fv80T1jCzEoa9rz2RlNjw1DulHNQCiLvPfAu 7Ss7qaU7FagjaOjabKKTwIQHkr9+j6O9pBC1NqusKgxoOomjlH/2Q4l0jKSrqGVKfVrT uClwq99n8tGhpgPTi3HnDDWuk4Sh8jYut3U7uPNv13aXOO1DfkaUDAYeuI97APDGPAuw ucUnz9DqYp7pQwBmpqq+EdqjxAm9sf8EFtH76V6yqgxho9G3HJseXL7mOaox9JtYP251 6h+A== 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=CTkUjcI5m2kSKLR/rqUR5fKhzCEL2Y/kjhRobGub6RU=; b=LC6kAPqZVozm9Ux5oZrH6GNBbGVhtZbgD6szyOdHJP4cxjsJEO886/zMygvUroXU+z PbB8qOiJ/YyzVxrWcUZ/x+I1HzCjdUG0sNTDd3a53flp0phvhrZhK+5+1gLHCrKvXF7O UdUueM2qpnG1NfDYVYmJEXwod8ziAGvVe+k8JR2K3SU12fZCUE23JAVB5sRJSrGKJq/o M6F6bIQ0bfRWew8CGRDxAJJwPBwdh7oBw2fEgisvmBULw3UhWtXZBl8vvi0jwDeHqZxS 11l5Yi6LQm1mvw1fysFiUL0iSkJx5k8/AmQlYvGCHxQBJfCk5eftX7i1YLahQ6FnRrL7 i91A== 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 q10si5883138pgr.126.2018.03.23.03.28.58; Fri, 23 Mar 2018 03:29:12 -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 S933859AbeCWKTm (ORCPT + 99 others); Fri, 23 Mar 2018 06:19:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48140 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933995AbeCWKTf (ORCPT ); Fri, 23 Mar 2018 06:19:35 -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 CB1F8F8E; Fri, 23 Mar 2018 10:19:34 +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 3.18 45/47] pinctrl: Really force states during suspend/resume Date: Fri, 23 Mar 2018 10:55:36 +0100 Message-Id: <20180323094250.047166988@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094248.117679641@linuxfoundation.org> References: <20180323094248.117679641@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 3.18-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 @@ -977,19 +977,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 @@ -1053,6 +1050,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) @@ -1221,7 +1231,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); @@ -1233,7 +1243,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);