From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 527C23DCD95; Mon, 4 May 2026 13:57:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903038; cv=none; b=PTjl++DDBFvxl48Fon+xgbAPtG1l8axDWLrUd8BuRK8BYZ2fHAm87yZ/HUzbn0UVhuF80JXv4zSaEELRr3SWOPGLhStHUwC0h+J5CrsspkPZVc2cJmJknw+CuIikAWhcJw83R265KKkfS8Dh6CHZSWtClOskuftEzJvA0NnW5wI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903038; c=relaxed/simple; bh=HeYFmKrV2q9qk6Et/PvJA8xOx/Di3cQNN2NTUZdm4gk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jpfEBC03i0MPg0JuGa5/sZF0Kb/D/IvoG1ciD4ZDGoprqbwzNhLal9etoHAVHs2YtPhAlHPB4M8kFKD9v6L/p9aFTDtJROZzmKfBOxe144s7kk4wO6Wrehst/66FnQb0j12nuLsf0wg1Kt4xkm/TeiljFAKJZ1yOY+hIYo55d4I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k55SnBLt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="k55SnBLt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC521C2BCB8; Mon, 4 May 2026 13:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777903038; bh=HeYFmKrV2q9qk6Et/PvJA8xOx/Di3cQNN2NTUZdm4gk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k55SnBLtVZLrGyKlrLazvXWxq0TW+oRcHm3HZIYPkMoUvJLh7hUsYxk28rQ19rp3s dlWfQ+4LF/EL4doSJPbKlNP1TcezJzirZsrjp15B0r28E4mwVGmOMxwSN3KraPwis5 2i9aOCfkZJytkLDtzbErfTcZ6ZvKatr9ni5F+QRQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Vasut , Lee Jones Subject: [PATCH 7.0 080/307] mfd: stpmic1: Attempt system shutdown twice in case PMIC is confused Date: Mon, 4 May 2026 15:49:25 +0200 Message-ID: <20260504135145.822091629@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135142.814938198@linuxfoundation.org> References: <20260504135142.814938198@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marek Vasut commit ffdc5c51f8bcd0e5e8255ca275a0a3b958475d99 upstream. Attempt to shut down again, in case the first attempt failed. The STPMIC1 might get confused and the first regmap_update_bits() returns with -ETIMEDOUT / -110 . If that or similar transient failure occurs, try to shut down again. If the second attempt fails, there is some bigger problem, report it to user. Cc: stable@vger.kernel.org Fixes: 6e9df38f359a ("mfd: stpmic1: Add PMIC poweroff via sys-off handler") Signed-off-by: Marek Vasut Link: https://patch.msgid.link/20260122111423.62591-1-marex@nabladev.com Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- drivers/mfd/stpmic1.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) --- a/drivers/mfd/stpmic1.c +++ b/drivers/mfd/stpmic1.c @@ -16,6 +16,8 @@ #include +#define STPMIC1_MAX_RETRIES 2 + #define STPMIC1_MAIN_IRQ 0 static const struct regmap_range stpmic1_readable_ranges[] = { @@ -121,9 +123,23 @@ static const struct regmap_irq_chip stpm static int stpmic1_power_off(struct sys_off_data *data) { struct stpmic1 *ddata = data->cb_data; + int ret; + + /* + * Attempt to shut down again, in case the first attempt failed. + * The STPMIC1 might get confused and the first regmap_update_bits() + * returns with -ETIMEDOUT / -110 . If that or similar transient + * failure occurs, try to shut down again. If the second attempt + * fails, there is some bigger problem, report it to user. + */ + for (int retries = 0; retries < STPMIC1_MAX_RETRIES; retries++) { + ret = regmap_update_bits(ddata->regmap, MAIN_CR, SOFTWARE_SWITCH_OFF, + SOFTWARE_SWITCH_OFF); + if (!ret) + return NOTIFY_DONE; + } - regmap_update_bits(ddata->regmap, MAIN_CR, - SOFTWARE_SWITCH_OFF, SOFTWARE_SWITCH_OFF); + dev_err(ddata->dev, "Failed to access PMIC I2C bus (%d)\n", ret); return NOTIFY_DONE; }