From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AB15828DEF4; Wed, 23 Apr 2025 15:11:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745421094; cv=none; b=TRGiWs/yR/2m7GZHO9GpGQe1R98ltycFXsBLLMpQD5S5XyFDatVr/ixIjLNqxIx6Rrr/8l8GUqI23VA6JK7hImbHqblbHQY54LMpZQqZMCqi5/VdNwXmI2m6u4exh8P/bbLQIciC+sl6wa+SInfPfWFoft0Y+RSn/CbSJ+b/cpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745421094; c=relaxed/simple; bh=TUgfKmPU99P31chfzG80s0/zFa5GqBmloheD7bGs8x0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CwSHtSXg7wFx2AnPEenE6g0uHHKc1uFsrBPzbxhfdtbFneZREM+WD7CR1fdyetAfqBg+DKqo0n+QP2cRW9uBdALV6+xAYQOq3CBAhKlxnunqXXVaIEcr1eWlnGYovcmjpZKmIridq2Sg6LrzyfHD9RMJbpapAIJctOr2nkMYbPo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OkrjXt+T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="OkrjXt+T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F125C4CEE2; Wed, 23 Apr 2025 15:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745421094; bh=TUgfKmPU99P31chfzG80s0/zFa5GqBmloheD7bGs8x0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OkrjXt+T/3kUxE+YZS8ZFGBBmjCEYjoZGo2YNk1H3JwM+FbBigTDcujWrme9AMzQf n6qq6jzYSYgGQ05OgdOhnllyprXHWPsovaH8H+G/Vy0Wy0YcA9W6hfjgNnyCxVTZVe c37JWpws5hBU4/nUWuPDCOxJ0LiJ/LkyBvV/Az4Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bingbu Cao , Sakari Ailus , Hans Verkuil Subject: [PATCH 6.6 146/393] media: i2c: imx219: Rectify runtime PM handling in probe and remove Date: Wed, 23 Apr 2025 16:40:42 +0200 Message-ID: <20250423142649.411388839@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423142643.246005366@linuxfoundation.org> References: <20250423142643.246005366@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sakari Ailus commit 42eceae9793566d0df53d509be3e416465c347f5 upstream. Set the device's runtime PM status and enable runtime PM before registering the async sub-device. This is needed to avoid the case where the device is runtime PM resumed while runtime PM has not been enabled yet. Also set the device's runtime PM status to suspended in remove only if it wasn't so already. Fixes: 1283b3b8f82b ("media: i2c: Add driver for Sony IMX219 sensor") Cc: stable@vger.kernel.org # for >= v6.6 Reviewed-by: Bingbu Cao Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/i2c/imx219.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -1334,21 +1334,23 @@ static int imx219_probe(struct i2c_clien goto error_media_entity; } + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + ret = v4l2_async_register_subdev_sensor(&imx219->sd); if (ret < 0) { dev_err(dev, "failed to register sensor sub-device: %d\n", ret); goto error_subdev_cleanup; } - /* Enable runtime PM and turn off the device */ - pm_runtime_set_active(dev); - pm_runtime_enable(dev); pm_runtime_idle(dev); return 0; error_subdev_cleanup: v4l2_subdev_cleanup(&imx219->sd); + pm_runtime_disable(dev); + pm_runtime_set_suspended(dev); error_media_entity: media_entity_cleanup(&imx219->sd.entity); @@ -1373,9 +1375,10 @@ static void imx219_remove(struct i2c_cli imx219_free_controls(imx219); pm_runtime_disable(&client->dev); - if (!pm_runtime_status_suspended(&client->dev)) + if (!pm_runtime_status_suspended(&client->dev)) { imx219_power_off(&client->dev); - pm_runtime_set_suspended(&client->dev); + pm_runtime_set_suspended(&client->dev); + } } static const struct of_device_id imx219_dt_ids[] = {