From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80B66303C8A for ; Sat, 18 Jul 2026 22:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784412875; cv=none; b=GZcg+1oqYGxXlX8c/XdbcoxUW2htIVFQcm22xtXK7Ekt3G3AQFCpR0BnlpEn3Ml8KQKrIH54sZ9PUuI2mb2pyBjGB2hV7sHwYT2zuCm8sDFlw4Pf1UxmAusf1U74Dv1hytA42trm0TF4C6hUKWp9p6eWjWp7GRU2GIK9wRuw518= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784412875; c=relaxed/simple; bh=v7LJnAu7y9CSe8I/im2BxF/SRbA91FcQWcmoQfZdh3o=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tYvxov7FSQu9PMBz85kc+l03XERw04Pdk8B9KpHJ3DGFDZ1L9/FW3ZiGOXjzWBAaQbEn6ZYiaHU3eR8pLb0PydZg2J3KqoUcik58JQN92mvVvcdw+ZrZabjOVbIf6oRwlupZmIYmanVwTzJgF3ZUE0Dw19NtrHc5n73oE/XGmQ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=faft+BtX; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Zf+hB9+Q; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="faft+BtX"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Zf+hB9+Q" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66IJrdDa1206711 for ; Sat, 18 Jul 2026 22:14:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 0Idzlhue3W/MiDudz36WGyiI7d1evH1tZrrwWXspMl0=; b=faft+BtX2HE/IeW4 lleeIq2SwP4EnIFne5+PZmNGRnOHhRqHrC7RY7FJ3YI67oy47EnFmq2SHVOFqNB5 6Byqq8vXYBU5wXonHfdtl+XOkY/brzT4HJNtnhlw9llsCKKVyJfTen0UBAdOxs2J dxu7IGnhB9aOX5QIWW43Y0yiz5PX0tzaiXtVRZiCDm1VCX9GKgZqiArQkBMmRCK4 B8zbK6U4AahzxT9Mnph5H9wnNPE5bfpaLp6Hfbx5lVKBP7igYEemW07KY3Jnyb+L LR+XxH2zuGKW4scv4TpxaTGNWZ6Gp8NYvWFNiJEU7IKR739ZOYOpbIFv1M2PktaW EYjoIQ== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fg2nhhmqy-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 18 Jul 2026 22:14:33 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-8483e038efeso6260205b3a.2 for ; Sat, 18 Jul 2026 15:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784412873; x=1785017673; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=0Idzlhue3W/MiDudz36WGyiI7d1evH1tZrrwWXspMl0=; b=Zf+hB9+QVOL3njqcRRqsHqTsbb0iCNlB41zPtWpiodMKTwhwUiQfhC3MkN0qWxbXNr c7Y7F3kECEGNjmD0qdkmj4AR0pnwXswOsQOgPaOJs5S8SdGKYOSy80rEBmvOmrVNoevR MhBVqmO1qhfwvxSZo6PzDUCpke4jBH1mJ7g2LNmPHs+T+FQMxFxLUcylhMXXYvFmRkem 2vlOD9bNfMTZM/V4cKpF0jlmxxv4Qiu/ykWGYLONDug9cCrsBrtdj6DiECXK9OXaPnYp i8lmtNMC00uO7B9CtK4IDOBqDq0ILiQuzlIjbbl2IOdxK0zUpHDR7cYYVGiF05yXDiys hFYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784412873; x=1785017673; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=0Idzlhue3W/MiDudz36WGyiI7d1evH1tZrrwWXspMl0=; b=I0Ag4+DAh25SJLiXpAM6B2MIKYEeYddrBBhoDge3Hy+O4gpUnhiEEEVHIglAIw4sgX TBNCT0y6tAMqqFUv7UjbL2DJeZ44+To4khoTs4lQ8J+KVGyfz7tPPGOekSMNy8kGSIVt ZzccQkDhCUhV/X/cmi8udI5qcR0Ap09bjUaxw3vCCYY4BANyk6zaSpwNxBoIIepSLT0L 850xEdhMWRvY2iGdzB3N1MRNA88Cc+HwBXFXxy1hlhUHrwQvhbF2ujYZ46vNVz/XI2rH T8ioJDav6gVV3o3De2w99sK2zg8TYuS5LSuv2YVCEmJQ4fpx4pnBrsw5pXcB363LYSuy 8yOw== X-Forwarded-Encrypted: i=1; AHgh+Rou8rMHepDYeUB5kI5iiqGbT5KeRXnCLm83fARmW5UXZnrrKRWyvPqTO15iT1W12sCxoUCQrgxROt2ZY8Q=@vger.kernel.org X-Gm-Message-State: AOJu0YwTyQQYkgd8n+SbuxYHTyLqqSoIadyxXM3zO+sRqtvZyzOAzqsA 0TF7bzNaEybSkQsnUykmhCrmA6Wr+dh3ssg9wv2sTs6Xqv4ybxFGNdnTp8Zc8UPcyf02Qv+X5NK dQ9SjWGl/iAtpwDBou4+0s4ZuDHVwHqhI+hDufQio4PMMV9IwAkutHMVg5oLFfssCJcY= X-Gm-Gg: AfdE7cmVnOIvoNfPmMWeZ3a8dQse/D9xF7PMPmf2gzPySFT5xDt9arNtx3uAz5uysd0 6gm8iVOspGVIcYNwMCZBd+PGiH3NkTVU1RcgG9Vqyr+5usKYXrJPLXKHnIXK5+tKA7Ry65F3cue rnPxn94hgA98zCXN4106XielH0mKT1mUK3S+ZlrMa3VL/MvEnTUkLW4TayXRu921RBJSXQ/7hGb G0YLfXzEfA6q1lI+GiF3oB0R/cqcXp5mAlCcn2ufiTyof9690V3OqxDf6VQij60lz4GYuuajoaI YUfc1BxI4sAVGLLKG1bjBsn/m0zKYbC2GvZhD664J1P4UeMi/erjk7akBNTg4iDIpw3/mxPzhiX ct1txMBdpya0DqbTB X-Received: by 2002:a05:6a00:1486:b0:848:2f74:1d66 with SMTP id d2e1a72fcca58-84c2957cd43mr8463632b3a.76.1784412872809; Sat, 18 Jul 2026 15:14:32 -0700 (PDT) X-Received: by 2002:a05:6a00:1486:b0:848:2f74:1d66 with SMTP id d2e1a72fcca58-84c2957cd43mr8463611b3a.76.1784412872269; Sat, 18 Jul 2026 15:14:32 -0700 (PDT) Received: from jic23-huawei ([50.35.46.84]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84c2adc33easm3367836b3a.13.2026.07.18.15.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jul 2026 15:14:31 -0700 (PDT) Date: Sat, 18 Jul 2026 23:14:25 +0100 From: Jonathan Cameron To: Can Peng Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, rajat.khandelwal@linux.intel.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] iio: pressure: mpl115: Fix runtime PM cleanup on probe failure Message-ID: <20260718231414.07ead912@jic23-huawei> In-Reply-To: <20260718061909.428476-1-pengcan@kylinos.cn> References: <20260718061909.428476-1-pengcan@kylinos.cn> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=Le0MLDfi c=1 sm=1 tr=0 ts=6a5bfac9 cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=qC1CW/w66vtJz1P9yTJxNA==:17 a=kj9zAlcOel0A:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=P-IC7800AAAA:8 a=VwQbUJbxAAAA:8 a=-D4sB8j93cQFzHUrTu0A:9 a=CjuIK1q_8ugA:10 a=zc0IvFSfCIW2DFIPzwfm:22 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-GUID: wNH7Fy9NjNHPKRcx1FPs6H4ed4nK2tdL X-Proofpoint-ORIG-GUID: wNH7Fy9NjNHPKRcx1FPs6H4ed4nK2tdL X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE4MDIzMyBTYWx0ZWRfX9ZcJwNrfjpBH iNj2hMyfb7a3cNxsN3XRGEvTcocEmCYmrM9YOQpgRvBYlvkUF6TLz/JO9a7sN47d1TzSWETSrQE /xMaCfaavRd9WgkBOAj/9m+M2z5zj2KmShQgPpd/PDg+Doowg4SRzdyoFe9YYWM3ceOBvxCPu8M nG+mXCZqG5s7yjWteUI+s95y29C0CRHc15QxuGE2ZQXbRwuP2Jhgdu0Row8dojdDY6+WNypT3H+ ItYg/ZmWF9b/WpxCc0jPJH8jdg+Ae500rDZ33CAoi6byOjzheJG7eRQ2VdxhohmiW9SUt0Xc6E3 vjIcZmjf0EPxFOozj7pOeZgDYcSz/0M/mjy5yDY1iVpzDWZ47U+3EV2TM80NplYc2T0CE5uTOuT IldWfxs6lO/DR/55ArPOxzYlK7Z48RkZJhAEwPpsyFMVCeXc2Coz5BWv7AmNJMAVTyWaozqJyDW pkhuCEX6VWG5w4X8rfw== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE4MDIzMyBTYWx0ZWRfX+3eRYmw54JG/ uFvJVplU26fppzxy5ObZSC3klVmaQe4qrs2gUxAcCwyqrjOSNU1WfR6L+9cupM9XZwNyAManZDN DhR2rYJebhlPEGj5zrsJQq/LTIOhssE= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-18_06,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 phishscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607180233 On Sat, 18 Jul 2026 14:19:09 +0800 Can Peng wrote: > mpl115_probe() enables runtime PM when a shutdown GPIO is present and > then returns the result of devm_iio_device_register(). If registration > fails, runtime PM remains enabled and autosuspend remains selected. > > The same unmanaged runtime PM state is also left behind on driver > unbind, as the IIO device registration is managed but the runtime PM > setup is not. > > Use devm_pm_runtime_enable() so runtime PM is disabled automatically > on probe failure and driver unbind. Also unwind the initial > pm_runtime_get_noresume() reference if setting up runtime PM fails > before the matching put. > > Fixes: 0c3a333524a3 ("iio: pressure: mpl115: Implementing low power mode by shutdown gpio") > Cc: stable@vger.kernel.org > Signed-off-by: Can Peng Hi Can Peng, A similar code pattern came up recently based as bold claim from sashiko that autosuspend won't kick in if we don't do a get / put pair. Turned out not to be true. If no one touches the runtime pm counts and turns runtime pm on, then this line: https://elixir.bootlin.com/linux/v7.1.3/source/drivers/base/dd.c#L872 becomes relevant. That ends up calling auto suspend. Please chase through this call sequence just in case we got it wrong! Hence I believe this is a simplification change that can be made here. > --- > drivers/iio/pressure/mpl115.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c > index 16e112b796ba..9e77b76bd1fa 100644 > --- a/drivers/iio/pressure/mpl115.c > +++ b/drivers/iio/pressure/mpl115.c > @@ -204,8 +204,17 @@ int mpl115_probe(struct device *dev, const char *name, > if (data->shutdown) { > /* Enable runtime PM */ > pm_runtime_get_noresume(dev); Drop this get_noresume() > - pm_runtime_set_active(dev); > - pm_runtime_enable(dev); > + ret = pm_runtime_set_active(dev); > + if (ret) { > + pm_runtime_put_noidle(dev); No need for the put here > + return ret; > + } > + > + ret = devm_pm_runtime_enable(dev); > + if (ret) { > + pm_runtime_put_noidle(dev); or here. The switch to devm_pm_runtime_enable() and error checks all look good to me. > + return ret; > + } > > /* > * As the device takes 3 ms to come up with a fresh and the pm_runtime_put() at end of this block We don't mind if auto runtime suspend happens a tiny bit later.