From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2349A3DEFFB for ; Mon, 27 Jul 2026 08:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785139340; cv=none; b=kJQ2/kdAko7G3FIwxWDAEUi9qvKNXy0M0KdFNnQbcniR7NtJP8pVptmu505ez6wPDO1wLdtsqlagT9mqbgY+w/RL1eH/ztYWQ/8FL3+6ceeNRx1kziaEdPtYmECPFPQ9P2tcY2RbUBhue6wfIulGRM4OUhwTwZJmZXpXDcVXsio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785139340; c=relaxed/simple; bh=pGRRkLOovQKXGIVL46U0Bymbr48B32n4icpDQJ4H2Ig=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=U4pUNbx9EWnewaNfccC7/YjAsUp5WGSb1c9XxWBvSMOrrmOFAfbVX4lWancj+iVTQlmsYCD7eU5YuyY8LafWt998FfR+WI32MqKPwv6oK0Y5vzhTeZQSkoIvBoQgU3VFVqaWc7GQKdJ/dnZQxyT3NAOop/nJeAJh0cBYhqP3q2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kX2b36h+; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kX2b36h+" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c9d1fff21edso1440191a12.1 for ; Mon, 27 Jul 2026 01:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785139338; x=1785744138; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=QaLoWGkEcB7GzSZ0TXQ17OSV0J1XYO8dorJLUXwgL5k=; b=kX2b36h+EDxNVOu2jAubOtSeBlpSXMI226b3MRICXr5GlztshI3vwa6ci6I+TdaZ7F Q3Lfi0pklkQePGPnPnK5pv33oK4ZhhAb2UgGrbPBVwqugPiCNj9dtoHVDHBwEC4sufxO Ln/3c0XKXo2elN43qe9ff1vpYvnSkw+uRS07ZokkucH63Gp8+IonYXyICPsBNfSgPGWi CQcjm9oMPEMrp4XoDAX2JOw5jIF4RYpy/fcNntmZVhJHK/Zf+F+DcW1IKoB24zu89PkP 31yfn7QlpiCjYiycipzSdnZwdmn+BdMQEz6wnr59eIutIJUFpP64OUXmSAGn4d789oPB kjIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785139338; x=1785744138; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QaLoWGkEcB7GzSZ0TXQ17OSV0J1XYO8dorJLUXwgL5k=; b=NFvHLJjxTRbXzwS/3E1ybT27UwFu0husfo7dcExGIi7sQM7zMOli1tdrGrN/VqIRrN xQUyyKmkvyZxqelIohKdsp6H2jkWxD/B690xnrMxRjjgzAjvIuuoEYsXK8ztiv5PU/zf H8fSw30g4QZSFo903LmBLDCMBKqtM3+GVNv2mFGAg1VVIMWf0q5Sc54VhKleUjycHbYN pO1za54/pQPvN1UihvCS6/1+GSc5Y+h11iDsGwW3UBH+Iwyonqn+qQVOed37ZkFFGZ0v 76p7THH1ZFt+0pVqEIwZJFpvZxtLYTJBDkTKPbBf/9eKcDDKLf2EDSz7G5FJ3pLabOc6 n12Q== X-Gm-Message-State: AOJu0YwUnSA9dCgnyKXCWPiZn1KMYgRK1pExmI6f8wGWtAOGxq+ZVGYB +UrgZ7XFlYr9PanTPXKwipPelDdu0Ptk2oyTw1XnEs47wnRzwmw6pLXv X-Gm-Gg: AR+sD10P53yuG/wu2a6mBcjPL6NCBj2NakiNkKy6JOjVjo5ZayeJyYHDUTguJSNLo8H 4VF8zKzsot5mzCwqUjffSGu6DMq6p7fqblAE3t+QuvHOkrqiAWm7BFEH1IxuwyYpoqb/Wz1K9PU yfEIubld5BEYGIuETx2A1zsD/ryRR8QE6bH9D4NrbwrIZuqwePk9wr95loL1ZfB9VMKgGwEVAM1 evEUBXtvGKYkdaE6UBBVavJBlSqE8cPzR3CVsz7ShonZANceiEpcp9ZT+Dc1R+WZOdprqLP/fJd onC8t9Vb8mcuc29gAN9JtP64zmD65V6i6NyIYKlOvSiyXyBkTX+7YPNiCMNSi2hzM/C7yhXqZ6G jcjCbqjHgMbL9hQkd184LTF8kP+OytHsa50GSJGVjgnvNH7AK4Bv/Z8MjWRhSs3WFRAwVKT56JI szaVWiAJx2TciKmaVNX5K2HnJFueTK81jg1MQKqFRMifeG79QgKAFtVxp6W0/eoXf7JmsGZIudl wwNC+XGOgy6kon+YxxmQjHtg/HNbz8S X-Received: by 2002:a05:6a21:139a:b0:3bd:3591:2457 with SMTP id adf61e73a8af0-3c67dab46a2mr7637709637.4.1785139338288; Mon, 27 Jul 2026 01:02:18 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cbbb6623294sm2814443a12.10.2026.07.27.01.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2026 01:02:17 -0700 (PDT) From: phucduc.bui@gmail.com To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, bui duc phuc , stable@vger.kernel.org Subject: [PATCH v2] gpio: pca953x: fix cache_only and IRQ state on restore_context() failure Date: Mon, 27 Jul 2026 15:02:05 +0700 Message-ID: <20260727080205.16353-1-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: bui duc phuc When pca953x_restore_context() fails, cache_only is left disabled and the IRQ left enabled, even though register synchronization may not have completed successfully. Restore cache_only and disable the IRQ again on failure, matching the state set by pca953x_save_context(). Fixes: ec5bde62019b ("gpio: pca953x: Split pca953x_restore_context() and pca953x_save_context()") Fixes: 3e38f946062b ("gpio: pca953x: fix IRQ storm on system wake up") Cc: stable@vger.kernel.org Reviewed-by: Linus Walleij Signed-off-by: bui duc phuc --- Changes in v2: - Add Fixes tag and Cc: stable (Bart). - Add Reviewed-by tag from Linus Walleij. - Update the patch subject to better reflect the patch content. drivers/gpio/gpio-pca953x.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index f6b870b7b352..0c94630f3160 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -1369,9 +1369,20 @@ static int pca953x_restore_context(struct pca953x_chip *chip) regcache_mark_dirty(chip->regmap); ret = pca953x_regcache_sync(chip); if (ret) - return ret; + goto err; + + ret = regcache_sync(chip->regmap); + if (ret) + goto err; + + return 0; - return regcache_sync(chip->regmap); +err: + if (chip->client->irq > 0) + disable_irq(chip->client->irq); + regcache_cache_only(chip->regmap, true); + + return ret; } static void pca953x_save_context(struct pca953x_chip *chip) -- 2.43.0