Received: by 10.213.65.68 with SMTP id h4csp237379imn; Fri, 23 Mar 2018 03:36:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELvX5nj16rnNuHPsvUEQ2lM7A95LY4J2PM8wr4A9tN+GhDBt3O+ITwySATWjq5MyYeQYInRV X-Received: by 2002:a17:902:684:: with SMTP id 4-v6mr29373915plh.262.1521801413372; Fri, 23 Mar 2018 03:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521801413; cv=none; d=google.com; s=arc-20160816; b=whb74jAfEfjzqzlGU/qeMtKF+n2lLzfGk1Fhu8qihaPNchEbbr0bP9lq9IZkbonNuO wMzXIip7Y7g3aGmZVOQoMM5ejZ8hn4Z5AIakRLlVEaYoW8vNCLmMaXwDR8xYcyXWpLwd GBF2/FD7ecc72QzwKnYptZqFvYZhaBvDPWwMr63vlrtDhFgkiBKttS/7ScuAHc6jf7WK xtVK1mGsxBJAYtLB62MyQ1EH+eq+1xFTav4fOOU/osXuQ5saNetiU2tG8L9odNk5J45C ksWPs5/Mmj5mR66OONaj/etBgJ2QhCWLZSRzclMHEsJLgjasELl5sw9Qwx46W6BV185z IlJQ== 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=vac8CuDenUL8je0QDjwc0QQHoOUnCEozdPoyzlrFeHA=; b=dib95ONVIh1gRoXug0ElHCbsvjtCFql1ZNbztGOklkiEPx0e1ibVmfMnamGALIklWS lhRpl+SpLgEYH+DzoXrP/9NZeuVsUM31mEGFLfobEOrL4vfRyZtf62TCjGuP5MmQ2hzK W8WZTf+CYxPUatjNAy3T1vdC9Vs0mEBEuKiEHeaUboevfsQRgHothwzscmiOkAx+BGkl 3O+6GPLGzLPWvcLAKsmnizBZNK68DnsdMeZch0r2cyDs1mLDCTK2hRFsMzaqGbiPYmKf z4KOiJ2BAE4LLvRRxE/z8TyH+ZfOuIblqN9l7jhCz2+PEbyJtOQIsja/oqVBWZWBYOfc 7UPw== 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 t9si5842166pgq.271.2018.03.23.03.36.38; Fri, 23 Mar 2018 03:36:53 -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 S1755933AbeCWKRp (ORCPT + 99 others); Fri, 23 Mar 2018 06:17:45 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47302 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933560AbeCWKRk (ORCPT ); Fri, 23 Mar 2018 06:17:40 -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 79A65EF1; Fri, 23 Mar 2018 10:17:39 +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.4 90/97] pinctrl: Really force states during suspend/resume Date: Fri, 23 Mar 2018 10:55:17 +0100 Message-Id: <20180323094202.520488518@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@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.4-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 @@ -979,19 +979,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 @@ -1055,6 +1052,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) @@ -1223,7 +1233,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); @@ -1235,7 +1245,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);