From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 97B4E34F49F for ; Thu, 16 Apr 2026 22:21:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776378104; cv=none; b=SQ+gSRSOuiJEX8h9t50sBhLbatITe9i8FjxAEzTSDOM468pGNS1vlYBDPKMjpAXQkHT2dG/zVpeWpySe81ZlwU4ohrtFwk1CUsnkmgCSgX0fvAo9O+0eNnhl+xvuD7G1M/RvxYcvx3+XlkfNnYw5uYIa/RH6BoiDHyprWSSQkzk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776378104; c=relaxed/simple; bh=whrgW5d5KlyW6bmlSZG7Qk7kFuFyfu4hmZkSYhcpyIg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lpWbHfo7LPhHmmXrXHkJO9F8VMEgN3BEKrOsF3JKBsY5csnZjbNIqxpUc+fK6K4TTeNSPQsLh1J+jchWkJ0+sxDv1nKjzqydlBD0mcJu8b3QOhlT7zlpH/khIK379JlgrOTwDgaaQtFmHb+bmeAKEcJXPJZjVxSzBcIy0zJoDYo= 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=LBE7788d; arc=none smtp.client-ip=209.85.128.49 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="LBE7788d" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4887f49ec5aso521905e9.1 for ; Thu, 16 Apr 2026 15:21:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776378101; x=1776982901; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding: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=sWp5CoFLY8d29IHfqc/3dRjNfeku6+UGKmZys1drG5k=; b=LBE7788dRwJO4vL4uvgBcPZXW2a6UyynHcfcaE2zyNBePVN1D/t1aqoajl6zFlOl6P 64J6VSUysHiNn0HlrwBC1lbtdsPQiMifAtwry+/M9TC38Vn5xQlG3SkCEYB34BKsIaWf 8u3Hk4r7iCMTdnPbn66uGMKgWbVb9Y40zCC5nIx05Q6Hk9bLB1Bf3t7BvW6BCERZSJOS dPYxmG1trC5rdfHGobQwetvAa5Xf5URyVuueyMbNqhx3rVU9C+KFoALZLpwkFdPnaf34 hEHsX/HO1lgLWfGcKrVNsPoeEh2AM6YYXpVvqFSguiqZ4c/8DYNbxZF+NBqomiWRBJON 61mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776378101; x=1776982901; h=in-reply-to:content-transfer-encoding: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=sWp5CoFLY8d29IHfqc/3dRjNfeku6+UGKmZys1drG5k=; b=EpMa+W2ARFl3vofl1ZQdhitIFF2zhPe+VrFaeT8RMKgxc9VJOp0VXl8Oe/dXgdXOMb Ae29ofkk7keHBLrLkIymUfzM6J4PZQ5JK1wgdn5Qg90v7x9qH8T6RCEL7w/edt8Q12Gm OOF7U+CH+/AyxNm62555v5SLwanO2KhPU3/j6h4mbonSfOj6L5i2yAeIjW8dYbAsE/MP PjFD2gKbIga0twXnEqT6PC5vXJBKq7Qbz/l7teYU2AAa8rdyAacCDcH6Yv/VWjE5BTKV Jxt3pNPD5RpWaM9u7uKQy14kWIJl5rErppSvNTblsF4NOibJkrFfN8OKnqT+tYDCleRc GqGw== X-Forwarded-Encrypted: i=1; AFNElJ/QJLsF6uzg+SZXdXxZCHAoXZhlZ7iai7jQfsOHo9fYnuX30fbQEqlolb4fs0KxWzlj4AvTNpkCJQ2+c7U=@vger.kernel.org X-Gm-Message-State: AOJu0YxuxaRpydzZtlYNM8jIC1mTTG90P9xPcv6NAo1LgKZAOa7/aFl4 W/hjdV6BfbqWqLL/nYD65FOlji7/XXwHENkslkH5rcnKgmM2keGYWjvO X-Gm-Gg: AeBDieu4M1l159TNy2/KkeUEAemC/Mi7MooAWUwxd5rOfco3sOqIX9s+jio+VmzULaS a1NWweI+xIcKfyS6zJL30U6Z3V0eoNlqvTR6o1yh7kSG02SumxtRD79JlIKA26AW494XRNzJrUD 2PVjylRIUWnhtX2WbKm3omK+dyHyjre4RjWU86/u0QClw8FXDiCNTRXM+HUIc8Rzztkb47Dw6Tx K1dnlk4JejZA1t5ZXrb3ZjGErPIjXjEl9yNBU8kWsG/JJPjHWXENFW7Lo9bA7w7AhKO910EqaKB FRQaoP55XJT85V8Se12/fuDXuOtr2o4Sk64JHo4z/UcVtqDxOy9iXIzl80/uEtnvCSuVS0xCcBH YmfpvRt9C4mNrptuNHo9d7/vujAyqCEqyxPKc+n8ZvMvnHikAXWYmaQidvXlScMfavV1EtAloxv Pk03Co3HYRa5Ihis6/O+G2KBIxLw6sCDZ1eVC0aA== X-Received: by 2002:a05:600c:4e4f:b0:488:a2ac:a34c with SMTP id 5b1f17b1804b1-488fb7433ddmr5186215e9.12.1776378100610; Thu, 16 Apr 2026 15:21:40 -0700 (PDT) Received: from localhost ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488f584e39dsm89464335e9.9.2026.04.16.15.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 15:21:40 -0700 (PDT) Date: Fri, 17 Apr 2026 01:21:39 +0300 From: Andrey Skvortsov To: Nuno =?utf-8?B?U8Oh?= Cc: Jean-Baptiste Maneyrol , Jonathan Cameron , 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 v2 3/3] iio: imu: inv_mpu6050: fix unbalanced regulator_disable calls, when probe fails Message-ID: Mail-Followup-To: Andrey Skvortsov , Nuno =?utf-8?B?U8Oh?= , Jean-Baptiste Maneyrol , Jonathan Cameron , 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: <20260401082737.781018-1-andrej.skvortzov@gmail.com> <20260401082737.781018-4-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-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi, On 26-04-11 14:22, Nuno Sá wrote: > On Wed, 2026-04-01 at 11:27 +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 > > > > 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. > > The above looks a bit hacky. We're playing with runtime status for things to work. > Also, setting the active state makes sense logically when the device is up and > running. > Thanks for the review. Approach with setting active state just before regulator is enabled was taken from recent commit in inv_icm4500 driver [1]. Another solution could be that pm_runtime_set_active(dev) is left, where it's now, where pm runtime is initialized. So there is no playing with runtime status. And just after that devm_add_action_or_reset(dev, inv_mpu_core_disable_regulator_action, st) is called. And if probe fails before inv_mpu_core_disable_regulator_action action is set, than regulators will be disabled explicitly in error paths (goto error_vddio_power_off). Is this approach ok? 1. https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/iio/imu/inv_icm45600?id=2617595538be8a2f270ad13fccb9f56007b292d7 > Maybe we should just move enabling runtime to the end of the probe > function? The problem is not that pm runtime is enabled so early during a probe, but that action to disable regulators has to be aware of changes made to regulators by runtime pm. Action is called, when probe fails (for example, before pm runtime is enabled) and when driver is unloaded. To work correctly action has to be set after pm_runtime_set_active. > > Also, fixes should come first in the series in case we want to backport them. Thanks, I'll fix that in the next version. -- Best regards, Andrey Skvortsov