Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4518991rwb; Tue, 6 Sep 2022 08:36:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR7CJ4cC3n8ZPwvskeTAz1wERuUAodsvjX3JtjR43lsOilTr++WczM1+aaxj1lEoojm814e9 X-Received: by 2002:a17:90b:4a51:b0:1f5:8308:6ed7 with SMTP id lb17-20020a17090b4a5100b001f583086ed7mr25390195pjb.177.1662478564036; Tue, 06 Sep 2022 08:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662478564; cv=none; d=google.com; s=arc-20160816; b=Yygl0P9kdgGRn7wBtlK8V1ibSxQVpMImFWM4kJu5yZbzFTRpOJ8ScNs672TwqKPh0m wsiQuEO7FHrqgabGmcqiR/mOleNoWMHksRegQTJQH30qa7qfd3W4czr8wrPX3Z8xlnYy bPtXQg4LEpFVIqoep662Az25ioHCYsMsndLWTkBdfR4OJFu3QTG77nBj3gIra3lkccLN WfbJw7m7oQveNDKjb0IdAr1VyRn/qtvRC2/ggo5O86bg87sSmvNk4iyHaH7uWhKnggWD s1IRaSKdc7tS77yE2HvdjH/jVO0nSUVRpVbzeWQx1BvPZ5ciKOM/ShZ2L04CH0j8nmtp YVnw== 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=5Q6gpprdhXjPTOgM2RZZ+D5jirDWLF3T2NfWFaNyAPU=; b=zW96qOZBvb0ajvzszt7kW0mRhycLVuh3Cr0Fhvb6phRLJinIcKQudqbV+5T5wKi6AK oXCJm5zAfI2FNL339YS2ru9POxVNPylzQdLT5UsCvEOuYHwMtsXq9Q/gjQIRbveLmnqm bDtwPRfK/r7dwZQJ9BKqutpnJe0RZO/ePOmK/OOBg2Tic8ZpMYMgsfWFBFUTTPGpL9E6 FCbg4/H3JV72AInRkEPb7kV+aJZo4tUah4+KcA+t+Qf9JQ0Pk8N6FmM22n2nSCQ6eYkR 8IETVkXH8E/Ty2SUzsV9QLe6d6zknxluNS5MBAkGIGT3sev+RvpkTy0VVUzM5lZvhA6G /ZNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q9DbzcK5; 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 z65-20020a623344000000b0052abccd715csi13279715pfz.118.2022.09.06.08.35.49; Tue, 06 Sep 2022 08:36:04 -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=Q9DbzcK5; 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 S240775AbiIFNgV (ORCPT + 99 others); Tue, 6 Sep 2022 09:36:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240692AbiIFNf0 (ORCPT ); Tue, 6 Sep 2022 09:35:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563087AC22; Tue, 6 Sep 2022 06:33:58 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C6F1D61549; Tue, 6 Sep 2022 13:33:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFDC7C433D6; Tue, 6 Sep 2022 13:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471237; bh=2U7iI0nmhUphuAQOvU5vkJ0Ft2zgRmZO5Dr6eh1Hc7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q9DbzcK5WMb60WBsHidxsIwhlEc+w4WfrcYoWuIoyztHrBOdvEI/1vGA1BBTAnPU0 dRbYJsxeRdXLQuL6/MyA1WokSrhMpC5+zXTk+2lNfvCZruMQaQadHwr546tRv7X6LO 77g+hGNHHhY0IDi9go1/hclC2Ofw4uTrdN6W7Fl8= 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.10 43/80] gpio: pca953x: Add mutex_lock for regcache sync in PM Date: Tue, 6 Sep 2022 15:30:40 +0200 Message-Id: <20220906132818.811111055@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@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 957be5f69406a..3ad1a9e432c8a 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -1162,7 +1162,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); @@ -1185,13 +1187,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