Received: by 10.213.65.68 with SMTP id h4csp304654imn; Fri, 23 Mar 2018 05:09:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELtrRPWhV1WXAmXpyi+A6kTGiZNcezMj0eilB0bnvsh3e+Bct8FBzALSSfQVSWpNqYfxtW0H X-Received: by 10.101.76.10 with SMTP id u10mr8765974pgq.445.1521806988863; Fri, 23 Mar 2018 05:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521806988; cv=none; d=google.com; s=arc-20160816; b=i+S8AF/55SqxF4nQT4JhIIxVB6ce3/x4qJjVOfMrjkO3nkRg61+LsEBq3UUjCP+6eI FUazhKok+KSDtmDbJNO13ArjGjGZ2Za66u8WviIbMM+lyB6DyX7qD4FFx6nnS2RgAG49 yOeILO1r+0mzVJHFdOZtgpV2POV10jdOxDs93P5E1HykSXiFQW1alkE4si9hFrpYY3Pb 8+EecPfR0vKJJWA5RT+/Qs/IY7ZunKZOW3vF3tyY6ZcZlfuDjUpxNehJV56H/rrIKnMl 4ls1gvQzlmDXhy9sjcvse0Z/JLRerbTXhdvBvE3e14GTMj5n6FVIYP0pqR0HG+w9Krac Xk/g== 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=reqJ0xM02M2lcVogkjF8xdx2QoSW6GynVza/9QWI/lY=; b=cX2TwynyS0ZDjOD+fwrewrieiGSxSHe4SkwJ4KPNfi19vTOKK0t58D2QoHCEe1hw3q qbZ4wVFfUAmSVVq6fAKcihDemIXzGz+ez+WNt91ir6QMuu6AtpivjjPZFJOYM2xwcGhK smHzf0IkGTNEpO/behDD59zGP8Prdf9dq1jkj/A9SXUv2bWMZqB286Oz9CmaTEk8qy06 39EzQnD4LWQ1TKNpRWjdiNzlmt96qlNEV5gTcVHCmWURS0ilzgtNQ0cFLMyIZ95ORmIm fSVqQaue1OVHmXCEf+aIFtkhBxgh+A8srB/7UhsM5I/BizZxj4o4c+Z0GMKoWH3sJdJZ xT1w== 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 x27si5916023pgc.4.2018.03.23.05.09.33; Fri, 23 Mar 2018 05:09:48 -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 S1753142AbeCWJ6d (ORCPT + 99 others); Fri, 23 Mar 2018 05:58:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35706 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753113AbeCWJ61 (ORCPT ); Fri, 23 Mar 2018 05:58:27 -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 9B7AA1016; Fri, 23 Mar 2018 09:58:26 +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.15 58/84] pinctrl: Really force states during suspend/resume Date: Fri, 23 Mar 2018 10:54:12 +0100 Message-Id: <20180323095420.776620158@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323095411.913234798@linuxfoundation.org> References: <20180323095411.913234798@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.15-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 @@ -1189,19 +1189,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 @@ -1265,6 +1262,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) @@ -1430,7 +1440,7 @@ void pinctrl_unregister_map(const struct 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); @@ -1442,7 +1452,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);