From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 00AEA2116F4 for ; Sun, 26 Apr 2026 20:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777235147; cv=none; b=TrZV4n+ulTjVh6h4C2J7+82wOYpvPDHQoBgPmMZWplH9+GRGLD17UftqbcmZYoFJz5NYNazwTQGbtMXjEJ8W7OpdemwZhOzfe+4WD9L4P6fwSMTU1qrj1AAJuqy99whc5ZOfPAHbxjxfV3ZkiHI+oEU1eUA7LxgtyOIlM6zYL94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777235147; c=relaxed/simple; bh=yr2DHkpYu2/Xu8RHkP9LXjK2VZnznGUp5EnqqaF+/jE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AmSas1hG9RC0BTfBfefCrVDZ1NCT59qLpq2F/HoQ9PhKprlltlzo5aI0nWgcRd8l8QvCSqmO2oDeXoIMqaUkiMT59PAiASR02owugRqcoMWeTH9GQmgih3ugTwwNE8w/imWwO76a5XzstJe1NPKh9mc+ZU1HTxe3PhzF3Wb2gnk= 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=VDbxKH8B; arc=none smtp.client-ip=209.85.208.54 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="VDbxKH8B" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-65c0891f4e9so15718017a12.1 for ; Sun, 26 Apr 2026 13:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777235144; x=1777839944; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=8oQhRQaCh7wTVDtW5X/ov7P7WhvzMH+Ofkf86HNNbro=; b=VDbxKH8BVMRRK+PJB3RuS1/UeRUArmCgZPRnPL1Wrdv+ZvCNpLMW3B9JT06iSFxv/B X0LXaLc847Y5CCUBHQbRRkFpndpvNavuVHbAhw8uaijuVC6AYSp0NgIlzCuJK0lSa2X4 oO0zp6ctMB60E2rpbAihxavSFAvfAAY/99DtIjgQ3qSvrQ5PgHHW7lTJvnYM6x5we96F RXran58VznsQqlvyjogilJYICZ34LgmNTFDrSPWbkkk9oDrmwFFtYFlYulLBjdqSqoDl +blHJPtOn3Y2xIJMbbwyLET2jokNZE21Lsm785tJaKB0VNJEQxA263OSpm452cgV7GTd CVOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777235144; x=1777839944; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8oQhRQaCh7wTVDtW5X/ov7P7WhvzMH+Ofkf86HNNbro=; b=KMTTGMmvvO3WNt0b53Nyi8JFVnUNws1Dte5criQ/FiKrH12EtiMCSrSMNLrfV6xmBu 9KZ1l6Ch9J28mSfuNMcRd3iWor0RCi8j+XTxkQol2dgnqkhdOquuL7BX/5maWAcN3+mm 6CutAumeSF98Bt1UnUBOHKTpkC5Br5Y2OPa3irZyXpo9zSbCnbGc5Aud2fTvnnCrEqG8 442StTlWCxRRys/8Jdnm/jWfeBx5g136JvOJvi/hzHjinrRIKn3+JiRG1OaXxnuxRrU+ VzBEN28KpFkaRAppAP/ji3EtX6gTGx+8R42oJeih2DGb9PLZzHtr0R78PE0DX+EQWY2O aaKA== X-Forwarded-Encrypted: i=1; AFNElJ8Ksl+ciUdqM4v/flInpI0TeYKLtlM6S8lh6u7riW/aKYqtS575n6KLU0Cf7ZtDJzaDR/F+MASpTK4DdUM=@vger.kernel.org X-Gm-Message-State: AOJu0YySDp8ogEDmXRZujrpMr3g4owAXB1DOJhGWcnK0KB9QUGFrErDN dm3zgZcXRXeJPQoG1OLhHBWyCxAydjcYIEQjRtfNSQBvz7Yl00qGRCdT X-Gm-Gg: AeBDiesxf2BdH/9IKqHHRY3QtyTdympRyL+nUsp9T/M6oOkZRnO5EzMYdK+QQtqCfoW ZfwNRxbUmUcQD0NJlMAoc/fEHHJjlkcBN7pHlFhJKV0EEKYzJU899V1nKanKN15bP0QU7splVc5 YJsZuNwa1DZH/wytynzpjYZwQ55bxtSWMD8Kpml2CoBRif4WpqRQ2njBlOcRuKO8mzvyt3qsQBJ FW+N8c6uqCyO4AQfjHsH5LEkA2I5Tdggnf1Kt6IGOalMHti2vsuicMKdTg+jCbcoUqXB5GwmZ5r V84xrQfwvbFQ791gCRVXeZELG31uLUJLDphEYkGoWj9ZPR0PEdgS9f4hZZSQ99+KX7P/ZsEzGlE B45M2ji8sg7S/n5IKuAk2q62WCqV+lyPUcL5vtWp6KvzjOs2OdJqYOImXYOxU1c56ag79m41lyR rJdvGjG1uxlRYsuEbdxG5vRkA2XVHHd9OXLkpOz1NNxJxrITyDqw== X-Received: by 2002:a17:907:c302:b0:b96:e593:fd24 with SMTP id a640c23a62f3a-ba419658d6fmr2389436466b.15.1777235144005; Sun, 26 Apr 2026 13:25:44 -0700 (PDT) Received: from localhost ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ba455043cdbsm1029590366b.46.2026.04.26.13.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 13:25:43 -0700 (PDT) Date: Sun, 26 Apr 2026 23:25:42 +0300 From: Andrey Skvortsov To: Jonathan Cameron Cc: Jean-Baptiste Maneyrol , David Lechner , Nuno =?utf-8?B?U8Oh?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Marek , Brian Masney , Rob Herring Subject: Re: [PATCH v3 1/3] iio: imu: inv_mpu6050: fix unbalanced regulator_disable calls, when probe fails Message-ID: Mail-Followup-To: Andrey Skvortsov , Jonathan Cameron , Jean-Baptiste Maneyrol , David Lechner , Nuno =?utf-8?B?U8Oh?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Marek , Brian Masney , Rob Herring References: <20260426112334.3938774-1-andrej.skvortzov@gmail.com> <20260426112334.3938774-2-andrej.skvortzov@gmail.com> <20260426154330.0a29236e@jic23-huawei> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260426154330.0a29236e@jic23-huawei> On 26-04-26 15:43, Jonathan Cameron wrote: > On Sun, 26 Apr 2026 14:23:32 +0300 > Andrey Skvortsov wrote: > > > During a probe functions after all regulators are enabled, runtime pm > > is enabled. Before probe function finishes, runtime pm triggers and > > disables vddio regulator. When probe function fails after that, > > inv_mpu_core_disable_regulator_action tries to disable already > > disabled by runtime pm vddio regulator causing following backtrace: > > > > inv-mpu6050-i2c 1-0068: trigger probe fail -19 > > WARNING: drivers/regulator/core.c:3244 at _regulator_disable+0x2ac/0x600 > > Call trace: > > _regulator_disable+0x2ac/0x600 (P) > > regulator_disable+0xac/0x148 > > inv_mpu_core_disable_regulator_vddio_action+0x3c/0xb0 [inv_mpu6050] > > devm_action_release+0x4c/0x88 > > release_nodes+0xd8/0x178 > > devres_release_group+0x214/0x3c8 > > i2c_device_probe+0x6fc/0x9b0 > > ... > > inv-mpu6050-i2c 1-0068: Failed to disable vddio regulator: -5 > > > > vddio state is handled in two places: pm_runtime and > > inv_mpu_core_disable_regulator_vddio_action devm action. > > inv_mpu_core_disable_regulator_vddio_action has to check, whether > > regulator is disabled by pm_runtime already. But this information is > > available only after pm_runtime state is initialized by > > pm_runtime_set_active during a probe. So > > inv_mpu_core_disable_regulator_vddio_action has to be called only > > after pm_runtime is properly initialized. To handle cases, when probe > > fails before pm_runtime is enabled, explicitly disable regulators > > in error paths. > Why not drag pm_runtime_set_active() earlier? Do you mean something like proposed in v2? [1] 1. https://lore.kernel.org/linux-iio/20260401082737.781018-4-andrej.skvortzov@gmail.com/#t > Whilst we currently > check for an error on that call I'm not sure there is any reason > to do so. It's a narrow set of conditions than can cause such an > error. > > If you have that between the regulator enable and registering the > devm action I think that would mean you don't need to manually clean > up the regulators. > > Maybe I'm missing something. > > J > > > > > Signed-off-by: Andrey Skvortsov > > Fixes: 07c12b1c007c ("iio: imu: mpu6050: add support for regulator framework") > > --- > > > > Changes in v3: > > - make patch to be the first patch of the patchset for easier backporting > > - update commit message to fix Andy's comment > > - don't move pm_runtime_set_active from pm_runtime initialization, > > move activation of inv_mpu_core_disable_regulator_action instead > > > > Changes in v2: > > - minimize call trace in commit message > > - include specific driver name in patch subject > > -- Best regards, Andrey Skvortsov