From nobody Wed Apr 1 23:53:41 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 D00EC3803D3 for ; Wed, 1 Apr 2026 08:29:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775032145; cv=none; b=u17Lgp5o3yYTKlz38WUbLnp823KRH4wJhgTQ2rTX7Syj20pFBHV5gKpjfaymbBgJGtxg8Gn4OUF1QOW1VBXFS66Xh8umnJMZ76o9R4LOhB8L3xWM/aPnlQA4LYfGw8mtc3yqn54a8ahcptSIjqMLPLdcWiwCXAMG96JrNSrJQms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775032145; c=relaxed/simple; bh=QOMIzjNoG38g04AnGIDm8S21dxdqXer8FkrYDdTsXgk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RiNrl7MSQEokDigx/s+phoM00cqQOVPPd5bYNiGaioTts58wlGKObAZCJeHYBNz+9J0AUgbW8A/E4X2V1m5AQCXPhPxu83UGSJBCvaYox4+LQDAEcFjWTmmJ53OBuAqmOLAshUNOaX+82uAI+yfo2QFAtIsXHd2otcFWEgKFQlI= 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=sbkF0jtz; arc=none smtp.client-ip=209.85.216.41 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="sbkF0jtz" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-35c206f0481so6185304a91.0 for ; Wed, 01 Apr 2026 01:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775032143; x=1775636943; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3tYVObevDqBuONwH6QGIZanP6IjHHjbyhFuTpehaXTI=; b=sbkF0jtzg9draY/4TAGdHQJbH7lQ0pN8CINp1s4CJYYFdur2/J51w7lVtfJ9JO6zrt mv4hUSQuxG/FEGqIcDgDsElq0G/6J0mi3u4bf0zRQhU7b8xr8VayYJZunKD5Uhl5JPzG rkXnwp3gpKFp9bY+/695zMOhoRVZ3Pwd+otCKL0DPlHJ9BnW/E+RKP+/UMaNXzqaBrp/ roASOaRfwEFkCXdWNlRPam/W7MGO00nTSode8jvngaqJPvtKiWN0/Dl0MHxAwqFEGAGx 189OINnHZzpyoePC0JD9DSpU5v9t8Rgy6Amf7PE0fU8I+eLO/EVhClsD+ANM147x49eU lkRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775032143; x=1775636943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3tYVObevDqBuONwH6QGIZanP6IjHHjbyhFuTpehaXTI=; b=CQdc0EBpLWZdUdE4zhxaPd+2Tj3xmzP7nxgquDgPUmtdNWQ94QuygZ8j10LrfwY7Zb 0gv31S5uPHKsssuDd0Kb5D0DgRzUSPuFkBqy2YfIdnX5CIC0vHQUBvQqjUczH5SV1wsK oUoLgNN4+gU9A4qPMkPJMzIeImWGfqYTW0AlGbp6+iJWHDEooIPUvAvT3p+D2MgIAJFh X3TVv1QrkJyS7g2QZkQ1MlJitmvQYuCFogwr17Qo4umvAIwn+S9kM+5f3ckfFtTPMGEz P994atDw3QW/02wJ+494jThPYYRq0PYGFwr4xYYoCTZYi8veJLfrMLNhEOPSbijdHf8d eRCQ== X-Forwarded-Encrypted: i=1; AJvYcCWEe8f80fAm97FeDB5eFRXQQRfHk2FbozbuvuwqNiz0A3j9kPfJdoMWkCIC0StKMeyV58QbbE8izhJv8bw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5ojSJ433Kz9jFSiBuhREr993L+qXR5ZoDSJN5odRVEq6Tnctw 6YnDtQoMnR8DsU3nnc4Pia8WYfeFDYRv0BOQZe2YYeH6pc/WMlD/dlWw X-Gm-Gg: ATEYQzyK3LozYZjre+QSKlsQEZdjQhVkD3+hgX2rmaaluZd7Dqz26nzWbXtgYukhpYo +BTy0HB2mBkF7rT5N5h8aaGkmPNPbk4CLc++zv9/5B6mTXp4EFC449tmwK/yaSg31CHpS6iQbe9 1ciM3gwWnSss4TPSeVAMTiOoLEtpm1bJiwNqKF1uzUTJO5BNsYE4sabx5KBUl2F0kaAvQ288JYj XtXKmGjmEUULTMqK2oR93meRfzTFllwstudddGoizjbVsZecb6JoEh8s1CGN3KiK1XLjDr75PkR J5ChL0OQs3PA8prwEHICtJX8DxAFAE2tIxhgjH2HUoqPvtRQnhu5f2QIUBRRluyzwcNhEr9CXXj 7IG0RdDsLRaOK1md+g3eSYWrHnXVhgdBrVR0kdMt2w0uwwTmJZsg9dh0OQWHd/i0+3LruIAU8bP 6mepUk6Y9dfHFr5nIi/2W6mQ/jDPs= X-Received: by 2002:a17:90b:4ccc:b0:35c:30a8:319 with SMTP id 98e67ed59e1d1-35dc6d2edfemr2859424a91.0.1775032143178; Wed, 01 Apr 2026 01:29:03 -0700 (PDT) Received: from new-nest ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35dbe5e519dsm4118561a91.2.2026.04.01.01.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 01:29:02 -0700 (PDT) From: Andrey Skvortsov To: Jean-Baptiste Maneyrol , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Marek , Brian Masney , Rob Herring Cc: Andrey Skvortsov Subject: [PATCH v2 3/3] iio: imu: inv_mpu6050: fix unbalanced regulator_disable calls, when probe fails Date: Wed, 1 Apr 2026 11:27:37 +0300 Message-ID: <20260401082737.781018-4-andrej.skvortzov@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260401082737.781018-1-andrej.skvortzov@gmail.com> References: <20260401082737.781018-1-andrej.skvortzov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Fix the issue by checking runtime suspend status, when vddio regulator is disabled. To handle this correctly pm_runtime active status has to be set early before vddio regulator setup. Signed-off-by: Andrey Skvortsov Fixes: 07c12b1c007c ("iio: imu: mpu6050: add support for regulator framewor= k") --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/i= nv_mpu6050/inv_mpu_core.c index 3a57a3f440526..86e4d42c4d3d1 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -1862,8 +1862,10 @@ static int inv_mpu_core_disable_regulator_vddio(stru= ct inv_mpu6050_state *st) static void inv_mpu_core_disable_regulator_vddio_action(void *_data) { struct inv_mpu6050_state *st =3D _data; + struct device *dev =3D regmap_get_device(st->map); =20 - inv_mpu_core_disable_regulator_vddio(st); + if (!pm_runtime_status_suspended(dev)) + inv_mpu_core_disable_regulator_vddio(st); } =20 =20 @@ -1953,6 +1955,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int ir= q, const char *name, =20 msleep(INV_MPU6050_POWER_UP_TIME); =20 + /* set pm_runtime active early for disable vddio resource cleanup */ + result =3D pm_runtime_set_active(dev); + if (result) + return result; + result =3D inv_mpu_core_enable_regulator_vddio(st); if (result) return result; @@ -1996,9 +2003,6 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq= , const char *name, } =20 /* chip init is done, turning on runtime power management */ - result =3D pm_runtime_set_active(dev); - if (result) - goto error_power_off; pm_runtime_get_noresume(dev); result =3D devm_pm_runtime_enable(dev); if (result) --=20 2.51.0