From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 E516D342146 for ; Fri, 29 May 2026 19:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780083363; cv=none; b=BW0m/ZPXTXttGzcby1rZjbwwA35AhFG5MYl/eaO65zbdsht0Z5hL8/gmegFX7+NDSzzzBI4xZzL0nNIa5aEFZbR621RqXsJDr0VoeT2aEYFmX6YMbSG04w5sCPc3Gcv1063K1TDZUi0NuU2sjXmNuz2FINkCQC7LUsDyE4mNRJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780083363; c=relaxed/simple; bh=n9h0MjhuSTHJx0ps9EQSx+ZsByKpqYFFUGQ2CiW+e4I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sHjG0ebkQ6KhXOKfVj64v3Yl7FXVTmhVXRBUBzL0zRKZmXH9AOfzrnlAeuF45uIZxWjCNVLifNSV1DEa14QW8LZA/7zwDLflsOtkAhrzb2AOmT2QrzcBAyaaPlVogPyYGC0aH3pOw+QIAdGMMcdBEZDiyoKaHw/c0djVg2BLNvs= 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=Sp/Yv47v; arc=none smtp.client-ip=209.85.208.46 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="Sp/Yv47v" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-68bd9fce347so2128408a12.2 for ; Fri, 29 May 2026 12:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780083360; x=1780688160; 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=C4KTjjREkFr8HWH1QHpFZ/ConaYsx8lnYSzAqiNOAtQ=; b=Sp/Yv47vdtQoBsi8OShahiTwd8gMmCK1iTi1PnTwQxm9c67RILnujnD1k/kpA9a+Yd 0S28q2pvJGsc9FzI9nHsmx7EGhbaU3i5+hyfvAb0Oj2uAkEaMjn60c55MKhUDRPiOeGZ 3XxaJIcxhSo7/d+IVem8u2RqO92lZGg9yQkXaYEoCefs6fFo8jto3MPiTLMdbjQPjWLQ KFkG0QUqkNjn8BIpJ42Is8tDCwoat+p8Kcw1RH75+H5ts/iywk9gG9k2v+BETQtdg9E6 DFGFcKpk+IHX9PCp3eM3v06Rw+UXrc6HrBDo1U8/WApMB2XKiQeNYsKH4LbbVe2+slcx xd+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780083360; x=1780688160; 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=C4KTjjREkFr8HWH1QHpFZ/ConaYsx8lnYSzAqiNOAtQ=; b=SeQIhMc1SfwLAvt1i9ItN2QH5UPkN5g8+sM8Sh2rt+ROzanWn9fYQUmXoXcgIADxpv Hh13KLuw+T9YWSsEAHLOSC4CqIhDw1No7rm73bXyzvaOgIPOsTK5DBPYUbMTERI6CPcS ghJxlvMFPK8WA6NAyaqUA0n5hFLIJ39f5OW734364aknRozGZdOr5mYmeL4dNm0HZhMs rSusKfgNvbCS/JgU12Xp6OecKTonmFI5YnhVb/Xfms8ZGW8l3RitdsIGGYxQ9ma3Pl/D j5UBGzxIqMgO0tl8Fjafd7mD89B4Y6fWPZpHZtkIO8EAkNH9y3h4jdpS2WzFq5k/pDgD Y3aQ== X-Forwarded-Encrypted: i=1; AFNElJ8hdZL7VjJDpqpFa5Q6MSBhITFJJcXO8pra3Y23dSsiwISebNbBFlZDGHiM1zxgr36j7MYsVyfY1rVJuXQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxi+TN0ftwGRjn+GGWyBcqCjTgI1eMxOyGvf/q+XSh2wrcFbfHy TvtCx3H/OImp/JGWCDHBH6GYLMtL23vaW+4/3gHvkrKz93j5+oMO10Ox X-Gm-Gg: Acq92OGqpc7ZCstL/Gf0OlJSRgR2l7bw8jkiKdTtilPJkCk4Jg3nGpvfsZX1bXleXQ1 KDtuALUyWMKWr9R+XdTq17xamCgJHrbhxtH7pQirx3QUFwAFOS0vIuiKsbpJlN5EtmI27FI8lCp LT493uk+0k53FOM7p2efyRicxtB9YoO27G9WmX4RkiQjzcD78qZAohgLaNCK4v/PH5UQKq/lcQo ZPZHyUZTzYjlW4K+wEmY6i7MaxF5R00VxuINn8LTxt0dmPHnt0SlgfGVXR9yYyBnDasL2K2EXYi odq7uCdj3+hmaGK/KBk5EUDkC4uU6jytHhhyF6RmaPirn9Rx2RsGqkIBZHp9yY2ncspsTZe/hjw J3bwl0ggNquR2p0/OZYUTpG3XokfXXXMufxPXmIkKLAbj0VOUaphb8mDbxUM2cg9dKroMS/SCMa wIxp1/XbG2y/iae37prMNkAl2xKjxpvZc6Qgt12z4aPmJa X-Received: by 2002:a17:907:9495:b0:bd9:a6ab:a245 with SMTP id a640c23a62f3a-beab344183dmr50261466b.41.1780083359132; Fri, 29 May 2026 12:35:59 -0700 (PDT) Received: from localhost ([2a05:3580:f312:6c00:1b49:dfce:283c:7307]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-be9d27f4782sm95518766b.5.2026.05.29.12.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 12:35:58 -0700 (PDT) Date: Fri, 29 May 2026 22:35:57 +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> <20260427100441.68b6a986@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: <20260427100441.68b6a986@jic23-huawei> On 26-04-27 10:04, Jonathan Cameron wrote: > On Sun, 26 Apr 2026 23:25:42 +0300 > Andrey Skvortsov wrote: > > > 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 > Ah yes. Sorry, I missed that discussion. > > To me moving this earlier is less hacky. We are brining the runtime > state inline with what we have set the power to at the point of doing > so. For me moving pm_runtime_set_active earlier looks better as well. Then I'll change this back to the previous version in the next patchset version, if nobody has something against that. > > Nuno, having seen the complexity that moving that state change late > causes, I don't suppose you are convinced that v2 solution is the way > to go? > > Thanks, > > Jonathan -- Best regards, Andrey Skvortsov