Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4459551rwb; Tue, 6 Sep 2022 07:51:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5g8Gddm+I6FgRmCIXy4v99yT/JGWCmlR30BKYzZSsoywVLXNDqOLnbU18KUXwob35YC3tj X-Received: by 2002:a17:906:eecb:b0:73c:5bcb:8eb3 with SMTP id wu11-20020a170906eecb00b0073c5bcb8eb3mr39768140ejb.284.1662475882700; Tue, 06 Sep 2022 07:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662475882; cv=none; d=google.com; s=arc-20160816; b=ZDlNez2QLDUGLqfNndgewOUCdgMfXH4Tp1JM+JOUJezRjJ49Z61fnx96UADDqkjRdr tHcgPx3E314KdVIE6inKf1i5DPvmAznLk/9I1tA0K9NDRckNNcb8abSIFE87LnQHjvYX Kt8uhmY3xUIU5Ph/lyQjYk5fZw357RsoQun8A1Dd8D+SAsRuZ/+ngobK5HviH0eFbPuP GWfRE8q3RqkZcCb0aEh9Btdtjicz4cLvAErP2F9rfhLC/6TWBGS8O+93zP+YT6nO5oUp YSu5wDvZdI68VKP4dLqQYhKR80frr7DUIz2BB6LBxbtHkR+8mJxlMrKH2BHY1NPKyMiz pvrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hDD33RQY8i9vNX6WDkNkh/S8HEOTP6VuQa69/DifeTI=; b=hoJmo/HdHmS+NeX401uzNHfPeqDEtFspC5Xfrxz1baplwbKNsVPFRqn3BsrQqNDyYw Vef8AgZgJP4a71QFe1bmKSuQr0ne+WXh9LOEU5BzSi6aJ/Xf2KK29ZNxIcbhXiBX/TVF B2mY/wm7kbCHoSlVz/GlJmffibardal++qF0rsVIpkrxZG53ppbFg3B8j92kQYmcOMRW jf8OIYL+Ou1LiFcU+c95Iqr9NFWF6oSwiqqw9J8XXm9vlxONnc6Ex2cQMLPUCBK6KuEp 3mtbIQbR5l35+utgEe+1gm3gGaEqKBBpL/izKeOFfzAW9/zK5Av80fQbBFrhNdcWMS+r rv8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PlYFI9MF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr4-20020a170907720400b00730aa3e3843si11013525ejc.131.2022.09.06.07.50.55; Tue, 06 Sep 2022 07:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PlYFI9MF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241262AbiIFOMT (ORCPT + 99 others); Tue, 6 Sep 2022 10:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241566AbiIFOKN (ORCPT ); Tue, 6 Sep 2022 10:10:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71C36870BF; Tue, 6 Sep 2022 06:47:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2843FB818D0; Tue, 6 Sep 2022 13:45:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 841D9C433D6; Tue, 6 Sep 2022 13:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471956; bh=B/g7M6eYXSuCJAoK0UhP9agxHOqqTFv8Ur6bBGZt7kI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PlYFI9MFfA0kbGBuy9ZKsaoOJfSsPANJA0r32nrwMhUfIN9TML4sF+pE/SlHnOsPK uR4j/zYhTMssEyYnCTtvs+FD/BHZsw3GbXyGDd+NXPjhvDFbivE5a2J6uqpM7NnjLC R3rRGEWuAwU5+K0hxigewv+lmSa3rTIR7INRe5xI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haibo Chen , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.19 096/155] gpio: pca953x: Add mutex_lock for regcache sync in PM Date: Tue, 6 Sep 2022 15:30:44 +0200 Message-Id: <20220906132833.536944372@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haibo Chen [ Upstream commit 518e26f11af2fe4f5bebf9a0351595d508c7077f ] The regcache sync will set the cache_bypass = true, at that time, when there is regmap write operation, it will bypass the regmap cache, then the regcache sync will write back the value from cache to register, which is not as our expectation. Though regmap already use its internal lock to avoid such issue, but this driver force disable the regmap internal lock in its regmap config: disable_locking = true To avoid this issue, use the driver's own lock to do the protect in system PM. Fixes: b76574300504 ("gpio: pca953x: Restore registers after suspend/resume cycle") Signed-off-by: Haibo Chen Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpio-pca953x.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index ecd7d169470b0..2925f4d8cef36 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -1175,7 +1175,9 @@ static int pca953x_suspend(struct device *dev) { struct pca953x_chip *chip = dev_get_drvdata(dev); + mutex_lock(&chip->i2c_lock); regcache_cache_only(chip->regmap, true); + mutex_unlock(&chip->i2c_lock); if (atomic_read(&chip->wakeup_path)) device_set_wakeup_path(dev); @@ -1198,13 +1200,17 @@ static int pca953x_resume(struct device *dev) } } + mutex_lock(&chip->i2c_lock); regcache_cache_only(chip->regmap, false); regcache_mark_dirty(chip->regmap); ret = pca953x_regcache_sync(dev); - if (ret) + if (ret) { + mutex_unlock(&chip->i2c_lock); return ret; + } ret = regcache_sync(chip->regmap); + mutex_unlock(&chip->i2c_lock); if (ret) { dev_err(dev, "Failed to restore register map: %d\n", ret); return ret; -- 2.35.1