From nobody Thu Apr 9 13:27:32 2026 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (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 215031A23AC for ; Sun, 8 Mar 2026 11:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772967837; cv=none; b=qqmxM42z3bneimi3eFwdsHa1y5nu34j7gZB2C3DfX4pH+dpTj9trSG5l8rVOEwCM6HrijvbxDPa5txlugvB7rSsbz8SLkivBFPZT/+n8Y4lrqF+SjGu01uhS8mwHZcytVBMOQA58ucFoWQuyeccESYaHckpHtmGheuMN33CPJgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772967837; c=relaxed/simple; bh=ZR2qFgJfdC2GjW4dyKZjOf8PqW0v0MbDkbDRSr8lLHQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QrJ/ZcRMhq8mXDWPt5K/4yDzrGG4KbOn2OvDQDM9VMyf5s74KBik9tsK1cOdYNQ3fiCKHZrCvjvNQVcS/w5ncCehQLmngDYJkIYy8DpVOgy+0UWB8X3+gds+zx7kDQ+s+QZgZbkqHrntgxlN6SLa4HM+jVJ6tPlhIzlSvhCYOdU= 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=QW0VtTwz; arc=none smtp.client-ip=209.85.160.182 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="QW0VtTwz" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-5033387c80aso139498101cf.0 for ; Sun, 08 Mar 2026 04:03:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772967835; x=1773572635; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Nq7xBQecNCcWqMyaqx5bcThSviNyfnXB225YIziDf9g=; b=QW0VtTwz6FAY3N2/AWNiHHfisZKCVXLvImrzKK8cAURqThgQogQYYrpeM+kwBrGybu GONKq1+K7FRswkTcUgFx+KAV4pajsI+oLYF7f8nTROlTekm4AM1EQrUSdKBjspADcwBA VtgOmwS+WG18k79jiSf+Q+EOTmpt93nxYE0+pCifYVTgJxTrmPlQy0W3/SZmmnTk1A7/ hD1kxashcNMS+z0arz1gwKty9bgSPTBbHK5hlkcap/EltIC/0jV/yRsBZhhq7rM7v90E zfULukuuCqMsA032EHSb48ovO7awi5RKH8zn+WwP99WBv5+o7WPmPVZk/+tcxl6scNrp ifFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772967835; x=1773572635; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Nq7xBQecNCcWqMyaqx5bcThSviNyfnXB225YIziDf9g=; b=UGjJEoFBiB0ml8aX3uLow8EGVfQRrIFl+xEY9bdpupwPHelTthcfS2umWhivmBfo2b bDnZ8VGaKXThInjnQsigNsCkZj2Ok++Q9dYUkqmA9Zguinl5OaxbGJMovWkJlTFIahJW nqGXjSPKd64DwJ/d91BT7V8r8PepN2w5XL2NawYWQTrganMeVINzTFpRzPuzrU7u81Ye ND3Tj4aFtfMspcSZ8+z4TbiY47YjNVPBECFObzyWdMN4V83MZy5FayR8pNIJFDzHnjx6 7clbUufM7pw1rtc7y5RQTReCiqPzB7hluXRpiUiTkqLvk2ulAbnvens3/O89xamzuHh9 P/0g== X-Forwarded-Encrypted: i=1; AJvYcCVd4uwzSj3Kf3fJBSBm8jKOtgFNSartRFT16OnAd4MGSwdQUl4UVMXqvt1vwL+nKL6sU1z8lERf2EksKxA=@vger.kernel.org X-Gm-Message-State: AOJu0Yyucyi6bAwJ6itkwR0mtji0AmhI4pMMc/JBwXTvc42dOXeGiXl1 3XvVBkVLCL9s0j1DOo2JTWLjDXagXd5PuGw8jR3dszJIeZ7nDR4o4iYS X-Gm-Gg: ATEYQzzTYmvtc9GP4s8cqs6eklufrhFigsF1S4TmDq9A4+KAwOBf1OZnqQa44GTj1PR W6xWAmFODuHprBayMTAJd2mJVjo3ybdXCr5wItesNPGjKh8bMvnilUar/l66WArexvxB/ubz9CP dwp2HgDBBmyrScDBThfgqXURDWy5AC/xAjadFockNCYGusNC3zeFDR9pYYMOVYYMmT0hgh3Sgdv hri7NUgk51VFpSuRsnSA0XTTnVJPhs6PZSN5y52JY6ZRsIhu8UitqQlV8HGEI5VgNItzTWq6/RK NcZSFdV/gZb18CrS/9xpD+T9xFvw5/zrtOxWzvGYXB3LM4nI7nA59bXL0bD4eKIJGN6fokPYl9M tFeMwrBnFWi9nUqJulGyPHRjvdC0+RNdovoNYD2ga0isa2KdMLvQy01rKbK3dGCZXHW6/cMp0Q1 ex82Riej4NlL4bbmmzuqG6MDDge35JT8RWOb+npQ== X-Received: by 2002:a05:622a:10:b0:506:7049:c768 with SMTP id d75a77b69052e-508e67f5f64mr148242761cf.9.1772967834819; Sun, 08 Mar 2026 04:03:54 -0700 (PDT) Received: from new-nest ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-509101c6a55sm13521381cf.23.2026.03.08.04.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2026 04:03:54 -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 Cc: Andrey Skvortsov Subject: [PATCH] iio: imu: fix unbalanced regulator_disable calls, when probe fails Date: Sun, 8 Mar 2026 14:03:28 +0300 Message-ID: <20260308110328.2859831-1-andrej.skvortzov@gmail.com> X-Mailer: git-send-email 2.51.0 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 ------------[ cut here ]------------ unbalanced disables a for vcc-dsi-sensor WARNING: drivers/regulator/core.c:3244 at _regulator_disable+0x118/0x260, = CPU#3: (udev-worker)/357 Call trace: _regulator_disable+0x118/0x260 (P) regulator_disable+0x50/0xa0 inv_mpu_core_disable_regulator_action+0x30/0xa0 [inv_mpu6050] devm_action_release+0x1c/0x30 release_nodes+0x6c/0xa8 devres_release_group+0x158/0x1a0 i2c_device_probe+0x33c/0x3a0 really_probe+0xc8/0x3f0 __driver_probe_device+0x88/0x170 driver_probe_device+0x48/0x130 __driver_attach+0x10c/0x260 bus_for_each_dev+0x84/0xf0 driver_attach+0x2c/0x40 bus_add_driver+0x124/0x258 driver_register+0x70/0x138 i2c_register_driver+0x50/0xe8 inv_mpu_driver_init+0x28/0xfb8 [inv_mpu6050_i2c] do_one_initcall+0x5c/0x478 do_init_module+0x5c/0x268 load_module+0x1d04/0x2558 init_module_from_file+0xe8/0x158 __arm64_sys_finit_module+0x1f8/0x388 invoke_syscall.constprop.0+0x64/0xe8 el0_svc_common.constprop.0+0xc0/0xe8 do_el0_svc+0x24/0x38 el0_svc+0x3c/0x198 el0t_64_sync_handler+0xa0/0xe8 el0t_64_sync+0x198/0x1a0 ---[ end trace 0000000000000000 ]--- inv-mpu6050-i2c 1-0068: Failed to disable vddio regulator: -5 This change introduces variable to track state of vddio regulator and whether it's needed to disable it or not. Signed-off-by: Andrey Skvortsov --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 +++++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/i= nv_mpu6050/inv_mpu_core.c index 5796896d54cd8..7dd09963d5a39 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -1843,6 +1843,7 @@ static int inv_mpu_core_enable_regulator_vddio(struct= inv_mpu6050_state *st) /* Give the device a little bit of time to start up. */ usleep_range(3000, 5000); } + st->vddio_supply_en =3D !result; =20 return result; } @@ -1851,10 +1852,14 @@ static int inv_mpu_core_disable_regulator_vddio(str= uct inv_mpu6050_state *st) { int result; =20 + if (!st->vddio_supply_en) + return 0; + result =3D regulator_disable(st->vddio_supply); if (result) dev_err(regmap_get_device(st->map), "Failed to disable vddio regulator: %d\n", result); + st->vddio_supply_en =3D false; =20 return result; } diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/in= v_mpu6050/inv_mpu_iio.h index 6239b1a803f77..1a2fb857f022d 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -208,6 +208,7 @@ struct inv_mpu6050_state { struct inv_sensors_timestamp timestamp; struct regulator *vdd_supply; struct regulator *vddio_supply; + bool vddio_supply_en; bool magn_disabled; s32 magn_raw_to_gauss[3]; struct iio_mount_matrix magn_orient; --=20 2.51.0