From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 D1FEB29C328 for ; Wed, 20 May 2026 14:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779288145; cv=none; b=XL6i0QCRZWKVpb2FbH63WG2J0lwea/5ogNdBEN7PWeedhoLRJKIugN0u2m50t54QV/ANKdZBNMZPxBJ2304SKfa0nrYCB5KTT+CQoPaXPbk8DjqzBjQGQR32P4nJW9q1GEv0oYZYo32ZJ4mUQlkBuzWCMVbg46wCJf5iMLHQLj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779288145; c=relaxed/simple; bh=yWZvIL+ViufOig3Sc5+axdwyoyP4wX+AOeYG7YbHiyQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sJmaq97pkuF5gmSxEXlzqfiD8pMrLkCx1msz5JhBpHkwZhiBi611uj7HKD7LfjNYC+806pQCL0Y+J81lH8epfh5g4Mveyka0HBQ9IuWCzEoBNzzWGZ9jeoYdGXdYOZOIUTIsOCqPxKNmqZqA3nkT6VNmG54322uXZr5ac5KUaqA= 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=f98UF8sS; arc=none smtp.client-ip=209.85.128.51 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="f98UF8sS" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-488e1a8ac40so46370885e9.2 for ; Wed, 20 May 2026 07:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779288142; x=1779892942; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=usJ38430MjuWmc7xeBXCbfLGPtT8LL3NOyxym8359x0=; b=f98UF8sS/NyOE7uz2u6elAjnIqE3ckWT9gLOMSrLk98NGnyz1KAiZGa7HtpkZm/ta2 /rpxNaMnd+sHngf7kdsiDMHSaSxMUtul4vPxcQZn12yF2qcFz63Nry9Bz9emYXINuJkf mN2ZsSPCXiKf9IJCQi6CThQDPgyczLyK1r+HewXeLyZU5WVnfS0fULwbGqr9iQfJL0zG 8NzpaMFi1P0A7sgL6LGMk4b8vcGB0EIAkLzoiqQ8p40YVLMxvt+llheNBMKeLx6wym/z aOr2+DEADEMikEPuNY9zVOIP+kBQ/7ljMOtMfmw1sr972AgsSRQd8PZd4lGZNiApmvSr 7zBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779288142; x=1779892942; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=usJ38430MjuWmc7xeBXCbfLGPtT8LL3NOyxym8359x0=; b=g2cHMcmKJE28Xj4IOmnbuwA/Nc/ArAVUhaiM1E2fyNxpkzGJauHsddwK9zC7QWekuU nl8DT/sEICVG8mriS26/TNS7vkG8/L/if+2+jQdmQ5X8/J1HMY1xWCgw/pNxAKhdEf+Z 6Er8hdYmd6WfRxGtAS7eK2zuiKhZJWrOcbZSf2SCZ/QKaSC8AkdEyjJJR3B/feR0lTcn kYD/nJ4kODfIkh0p+u54bryrRIetL0WWbyXct/EwXFKc7TKyzSzSuQo9pnTCPjfd01MP ma/2h3whGefL4D7uYI6ssyt+CajP0kAfnjZ6J0e3h2x4t0n+9ztgcIDh0W3ONw4NJaw+ ZvAg== X-Gm-Message-State: AOJu0YzI7E7OIXciZOz+qyIf8zvKhK8VSU7kF1XOLW7ZdV7n/7X2vE+e yE5vDuuiz2d0zCgihXOHjisGBpyCT0EfdC0a1o2FMGqy+2jfwR04yL+c X-Gm-Gg: Acq92OGg+C3POqmfo2IIawCMrpsWa3KS8XlOWR4y9A90weHcm9b1U4POYlLdwaReyrP Lbu5mGjfIoqE99VQA6tlKtVspTvSev0je144XFX37Q8OR7DudKiwxuoaMKBKR8gHpbeu/c9P7kE irdF3Knynzxn4+ln6XQmG8d3Azs4iGDW/SqDGZ33VzzHJOYATwtlFUyDcjhPXu8aZk5cObxdXcp BFws89jSMfaSrn79dCy8E/jr8Zn5+8/PzYmXzO56CIXLGfnbr1e9dqdIwfhO/nu1FfA2Oefbb19 40k9LDkKvQqJ/ObVJxO255+e2rPJwBdjPk4ixVVMvvKO/t839V86Mm8gyN+QP0QNZlhXxqGIXz9 BocLMgTAW7Rd/L3+fiW9CMyrW+9SaWEKZhPjT9Kv9bHbPZTIQpOND2r6AGBh2O6n39yfXaVpcOa NgGtaV29N7b5fbmaqLB3NsWvv32kKpUeLaboO2/ujTbWNVXb4K+qQEWiowTFhi1r24 X-Received: by 2002:a05:600c:858d:b0:48a:66a8:9981 with SMTP id 5b1f17b1804b1-48fe66129efmr250763065e9.27.1779288141940; Wed, 20 May 2026 07:42:21 -0700 (PDT) Received: from [192.168.2.178] (109-252-156-195.dynamic.spd-mgts.ru. [109.252.156.195]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48feaa2949asm196145965e9.1.2026.05.20.07.42.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 May 2026 07:42:21 -0700 (PDT) Message-ID: Date: Wed, 20 May 2026 17:42:19 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mfd: max77620: Avoid regmap mutex deadlock in power-off handler To: Diogo Ivo , Lee Jones Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20260520-max77620_poweroff-v1-1-9186a3bcbe9e@tecnico.ulisboa.pt> Content-Language: en-US From: Dmitry Osipenko In-Reply-To: <20260520-max77620_poweroff-v1-1-9186a3bcbe9e@tecnico.ulisboa.pt> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 20.05.2026 17:28, Diogo Ivo пишет: > max77620_pm_power_off() is called via the sys-off framework as a > SYS_OFF_MODE_POWER_OFF handler, which runs in an atomic notifier chain > with IRQs disabled after smp_send_stop(). regmap_update_bits() acquires > the regmap mutex in this path; if another CPU held that mutex when it > was stopped, the power-off sequence deadlocks. > > Replace regmap_update_bits() with i2c_smbus_write_byte_data(), which > bypasses the regmap lock entirely. The I2C core detects the atomic > context via i2c_in_atomic_xfer_mode() and uses i2c_trylock_bus() rather > than a blocking acquisition, avoiding the deadlock. > > Tested on Pixel C, powers off correctly. > > Assisted-by: Claude:claude-sonnet-4-6 > Fixes: 744b13107d0d ("mfd: max77620: Provide system power-off functionality") > Cc: stable@vger.kernel.org > Signed-off-by: Diogo Ivo > --- > This patch was tested on a local branch that sets pm_power_off = > max77620_pm_power_off() unconditionally so that the function runs. > I haven't checked whether the other bits in ONOFFCNFG1 are safe to > discard at power-off time as I don't have access to the datasheet. > If someone with access to the datasheet confirms they're not I'll > respin the patch taking that into account. > --- > drivers/mfd/max77620.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c > index 3af2974b3023..8c768968a317 100644 > --- a/drivers/mfd/max77620.c > +++ b/drivers/mfd/max77620.c > @@ -487,10 +487,14 @@ static int max77620_read_es_version(struct max77620_chip *chip) > static void max77620_pm_power_off(void) > { > struct max77620_chip *chip = max77620_scratch; > + struct i2c_client *client = to_i2c_client(chip->dev); > > - regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG1, > - MAX77620_ONOFFCNFG1_SFT_RST, > - MAX77620_ONOFFCNFG1_SFT_RST); > + /* > + * Atomic context: IRQs disabled. Use raw I2C write, bypassing > + * regmap locking entirely. > + */ > + i2c_smbus_write_byte_data(client, MAX77620_REG_ONOFFCNFG1, > + MAX77620_ONOFFCNFG1_SFT_RST); > } > > static int max77620_probe(struct i2c_client *client) > > --- > base-commit: 27fa82620cbaa89a7fc11ac3057701d598813e87 > change-id: 20260520-max77620_poweroff-08e39429835f > > Best regards, > -- > Diogo Ivo Kernel parks secondary CPUs before powering off system, hence there shouldn't be a locking contention. Have you checked whether regmap_write_bits() works?