From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 4A1A13C8700 for ; Wed, 27 May 2026 07:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779867184; cv=none; b=rHHuauFmaYRiYJBmzMYcbB1oq8rJKno4A1TvfQsgl8xW/ouStx2uZowJoswOEGb22neN3RAZp1iku+cvRar3wSiOxSEezoS8XZ4wtAhf3cWPzYmKdohAPrV3UsG+Uk+Ls3YScBJl03UnR4jSYfYYARvSQZzWddwm+udcQ/yQ71M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779867184; c=relaxed/simple; bh=5Tee8Ss7lVikSWcDsjK7FCkoxIfVoi67SVTOwAWY7Gc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tri3Wh99/IngEFcCDv4xyGUYHype5nRDYVqdqfC1EoJYqb29Hu/Ujq7QwjUZ4u98FBQu+pU7/yWWmpJmJ4IoKoH+keHyhn4XZZ5Iws8rsQMIpTaNYy544vC82XnotA+VnbKNF4sFt8N0gvr1Fvvv/9WTm8l7igz9rw3Z/SosxtM= 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=asya3E9u; arc=none smtp.client-ip=209.85.128.47 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="asya3E9u" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49040362e4aso57880855e9.0 for ; Wed, 27 May 2026 00:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779867181; x=1780471981; 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=RvVoq60kjeElEbHQ7jSTrbLPRosQJq300xgMTu6D2Ng=; b=asya3E9uIBlKxnX/WogiX7wqViawfz3VsBzW7uq2HQPqgNJH044tBgwQWvy6UPkZAZ tyhsfZEIipnc5JBQSCs66GW9V+/oJQVSxVZoGm9ifIjEnukvhDkfShUO1ARGDL2j9A0w lem5/MO7DgRWT8DqUhyBOY5uQ/73fMt1YjMuUVk1W1TBs1qQ6o1hopuMM5v3cvWk9bvl 4A9sNcV4ChLvTrIfTiBX/6/lJeE5C4709PHHbnCSyxaYM7hC5qs5UYLRjfazyGYYOHni emlGe10TXYNo2PxxX4cihUn2jXot7vy9u46r4h98bNsjTdSjWdCwivtsZmM4gAUn9a4a X7fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779867181; x=1780471981; 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=RvVoq60kjeElEbHQ7jSTrbLPRosQJq300xgMTu6D2Ng=; b=UcUEG/VMnwbUkDJPubHaGvRCTG4Usj3rWC6U7OWaCIwHqsGlyoBeLI6EsM8fxYyPIY MqPpvSCy/vRJAr+DXthvAdQBstlqxTklTPXjj3xi29rhNrc95rhG5iIbAjTroLq5m8uc tE/OjaPpacIosDUaQGGbjE6B/MJJvUTFFf4cRLhKsLDDQtG2gTbNy2AtqYtsHrfxRTPh +4tH5zcK0OBcjozYWiLLmNNet9l9dtvEOTCER9lC84nAN0MdL5530Qjz0dWCNUG0htVk 1cKCKTpsiz4Hw3uUVIZcp9HftjKByzSXeF/ltCU2eq4VW2g48M0/T1UpQBUbTYZnJ3Fh nBSQ== X-Gm-Message-State: AOJu0YxOPLYJvlQmKs75k2Wts6j1neZEj74kZ+204gZ82fh9OJU3GzKT QJkWAAN1npiycZKK3pxkm6rctu5lLFqbykxSNVS0EUQILEYpCqWCOUfi X-Gm-Gg: Acq92OH9lPZ8RIk0RcFL2FrPxSKOPjkQkFKbhGUXBOEOW8SgwJX7Wjioe9PgzELFzeU LGBVCk+tvHd1/EkJ/O0jk2IkWzoZoRfYfaB2dbOuC3H6C03xEgMfBYxY9eQcqL7HtwjAxMq8X72 tShGutGLumwxiIeFPNsumLSKHqL8LgmuCvq6CRRi0CpQ0Jtq+NETuVgUoKkQ3+/VmEmyX84XWGK PVZKGSthp0uWWMVu7g/SQdipPEwfsrnIXZNLEf/fX21tqh9n9ySgdDvJ9aL3EmxGHxzAnGWrLf7 1vT1RK+gMvV4EZ8sbv/T1leKUHMy6ynYNlT59UhEZNk1YTW/a+OcBBQRgWyjHpq1YlKR+GoQLhQ zu2DP5DBqcQx3pPy9zNQts8mTeDd7CYk2Qrum33FAHhbl0+Z+pQW9jvwbAbPwuX7IPWCYR1z2a9 GNm9i6Rt2pj2Mf9puAj/8pl6zkaebtAyDBiSxVV656VmMauC4KxwUObOKg6LbhE0x7 X-Received: by 2002:a05:600c:3e12:b0:490:40f1:5314 with SMTP id 5b1f17b1804b1-49042482845mr388648385e9.1.1779867181120; Wed, 27 May 2026 00:33:01 -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 ffacd0b85a97d-45edb5a2a07sm3619977f8f.19.2026.05.27.00.32.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 May 2026 00:33:00 -0700 (PDT) Message-ID: <7cc7626a-ba83-46bb-9a52-325d84bcdfb1@gmail.com> Date: Wed, 27 May 2026 10:32:58 +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 , Mark Brown , Lee Jones Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20260520-max77620_poweroff-v1-1-9186a3bcbe9e@tecnico.ulisboa.pt> <38f5201a-6b52-4f18-bbbe-775171a3f147@tecnico.ulisboa.pt> <20260520161900.GM2767592@google.com> <3b2b25f9-3ab5-4811-9945-f317b8788484@sirena.org.uk> <286ebc23-944a-4374-8128-3511c68cd1bf@gmail.com> <6017863a-6587-4b6d-8c10-ade27fbafc2c@tecnico.ulisboa.pt> Content-Language: en-US From: Dmitry Osipenko In-Reply-To: <6017863a-6587-4b6d-8c10-ade27fbafc2c@tecnico.ulisboa.pt> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 21.05.2026 12:19, Diogo Ivo пишет: > > > On 5/20/26 18:44, Dmitry Osipenko wrote: >> 20.05.2026 19:23, Mark Brown пишет: >>> On Wed, May 20, 2026 at 05:19:00PM +0100, Lee Jones wrote: >>>> On Wed, 20 May 2026, Diogo Ivo wrote: >>> >>>>> This patch was motivated by the Sashiko review I got in [1]. Its point >>>>> here is that there is a possibility for a deadlock scenario in which >>>>> a secondary CPU obtains the mutex for the regmap and then >>>>> smp_send_stop() >>>>> is called before this secondary CPU gets a chance to release the >>>>> mutex, >>>>> making it so that when the primary CPU tries to acquire it to issue >>>>> the >>>>> write it hangs. Is there something that I am misunderstanding here? >>>>> >>> >>>> It's my understanding that using the Regmap wrappers _prevents_ locking >>>> issues, rather than causes them. >>> >>> In the case where the CPU is being powered off during a regmap write >>> there is a potential issue - as Diogo says if we're in the middle of >>> holding the lock and we power off the CPU that owns the lock then it >>> will never be able to release the lock.  I would expect the same issue >>> to apply to a bus like I2C or SPI though, they'll hold a lock while >>> they're in the middle of doing bus I/O unless you use some special API. >> >> Sounds bad >> >> Diogo, check if shutdown works with added nosmp to kernel's cmdline. > > So to be clear shutdown already works with regmap_update_bits() and I > have never encountered this deadlock in my testing as the write to power > off the PMIC needs to happen at a very specific timing. I imagine adding > nosmp will just guarantee that the deadlock can never happen. > >> BTW, you can use i2c_smbus_read_byte_data+i2c_smbus_write_byte_data to >> keep the old regmap_update_bits behaviour. > > My question here is more if this is actually needed or we can skip the > read. In any case the patch that Lee merged is with regmap_update_bits() > so for the time being this is not a problem. I'd suggest not to change anything if there is no real problem. Otherwise you pleasing ai bot without understanding the problem, maybe problem doesn't exist in practice.