From patchwork Wed Nov 22 09:30:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Bingbu" X-Patchwork-Id: 13464309 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dQS75R62" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A5C399D for ; Wed, 22 Nov 2023 01:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700644894; x=1732180894; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qgc0zFCrWOpbv//UwNwruOdvEFMg+Or2TsGVXoF3+p0=; b=dQS75R62j/VYyirz/FblHEJoNM/iGYhmS++bBYdDCbVrqt9R67Cy+iVF icVSWOAbBbi+oNtYQ8lB+GdAkDBGwlC889g71o1Vu9S4MnLKykEb0JK3+ I1t2VWwfEBeUNHi7a2Bn7zb19fPS2ixAW7OKi3RC4QX5Iyjf99i6sY+iM 3nIvyykpp6t2+RCw8dRoG0zHrxLXmiX72QPOtnSj7iT4QXxfJpeFJa89Y +5U79QRr55ySoOn21XXwSLnlrHl2dYdd2gUBhZ8IZKNSXQGFU7apiklQd stvBYitRvmKzBIfFbU55xmgBHHR//2VKqY6D1Bs8t6wHF90XeoReVLDoT A==; X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="372193658" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="372193658" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 01:21:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="910729317" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="910729317" Received: from icg-kernel3.bj.intel.com ([172.16.126.107]) by fmsmga001.fm.intel.com with ESMTP; 22 Nov 2023 01:21:32 -0800 From: bingbu.cao@intel.com To: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com Cc: hdegoede@redhat.com, bingbu.cao@intel.com, bingbu.cao@linux.intel.com Subject: [PATCH v3 1/4] media: imx355: Enable runtime PM before registering async sub-device Date: Wed, 22 Nov 2023 17:30:40 +0800 Message-ID: <20231122093043.233148-2-bingbu.cao@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122093043.233148-1-bingbu.cao@intel.com> References: <20231122093043.233148-1-bingbu.cao@intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bingbu Cao As the sensor device maybe accessible right after its async sub-device is registered, such as ipu-bridge will try to power up sensor by sensor's client device's runtime PM from the async notifier callback, if runtime PM is not enabled, it will fail. So runtime PM should be ready before its async sub-device is registered and accessible by others. Fixes: df0b5c4a7ddd ("media: add imx355 camera sensor driver") Cc: stable@vger.kernel.org Signed-off-by: Bingbu Cao --- drivers/media/i2c/imx355.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 9c79ae8dc842..059a41b7eefc 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -1788,10 +1788,6 @@ static int imx355_probe(struct i2c_client *client) goto error_handler_free; } - ret = v4l2_async_register_subdev_sensor(&imx355->sd); - if (ret < 0) - goto error_media_entity; - /* * Device is already turned on by i2c-core with ACPI domain PM. * Enable runtime PM and turn off the device. @@ -1800,9 +1796,15 @@ static int imx355_probe(struct i2c_client *client) pm_runtime_enable(&client->dev); pm_runtime_idle(&client->dev); + ret = v4l2_async_register_subdev_sensor(&imx355->sd); + if (ret < 0) + goto error_media_entity_runtime_pm; + return 0; -error_media_entity: +error_media_entity_runtime_pm: + pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); media_entity_cleanup(&imx355->sd.entity); error_handler_free: From patchwork Wed Nov 22 09:30:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Bingbu" X-Patchwork-Id: 13464310 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dITogRhL" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 632FB9E for ; Wed, 22 Nov 2023 01:21:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700644896; x=1732180896; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=79zhsmHbC9L3HZltzeo7ojFHA8HLIlDMuLcMtCwD4ZI=; b=dITogRhL4fmXm2z7aDQwp91UCrk5feuAXLfPehT8ZaiesHQCTXhlMsUH 45ExMLP/STHALSsHOg7UBF8jLzJZg8y7k34WvPBs9+kECx4XUDvzPXi2k Y3SkNMLKVrl4XO1FncqW0tQe5BnNxXdqxyqIAzCnF5FTsbvWjHCa+AG7R IXkCEW6VkHAVfqIeP7D7fBXYSAKrbF7rozqojqnrmYD6cssGDosPJFWIq kLTstVvNPDQuopK9o+z7O6nQ5MFbb85LN8Qkdu2yxB/kQ1Gga4HXqxta1 YXUW6VE0oaAxHXgqWrsMvTaZdsehzFe8Su+6+BQVoXGVoHo1ygUuxBBnO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="372193662" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="372193662" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 01:21:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="910729322" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="910729322" Received: from icg-kernel3.bj.intel.com ([172.16.126.107]) by fmsmga001.fm.intel.com with ESMTP; 22 Nov 2023 01:21:34 -0800 From: bingbu.cao@intel.com To: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com Cc: hdegoede@redhat.com, bingbu.cao@intel.com, bingbu.cao@linux.intel.com Subject: [PATCH v3 2/4] media: ov01a10: Enable runtime PM before registering async sub-device Date: Wed, 22 Nov 2023 17:30:41 +0800 Message-ID: <20231122093043.233148-3-bingbu.cao@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122093043.233148-1-bingbu.cao@intel.com> References: <20231122093043.233148-1-bingbu.cao@intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bingbu Cao As the sensor device maybe accessible right after its async sub-device is registered, such as ipu-bridge will try to power up sensor by sensor's client device's runtime PM from the async notifier callback, if runtime PM is not enabled, it will fail. So runtime PM should be ready before its async sub-device is registered and accessible by others. It also sets the runtime PM status to active as the sensor was turned on by i2c-core. Fixes: 0827b58dabff ("media: i2c: add ov01a10 image sensor driver") Cc: stable@vger.kernel.org Signed-off-by: Bingbu Cao --- drivers/media/i2c/ov01a10.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov01a10.c b/drivers/media/i2c/ov01a10.c index 2b9e1b3a3bf4..9afe9bf50334 100644 --- a/drivers/media/i2c/ov01a10.c +++ b/drivers/media/i2c/ov01a10.c @@ -907,6 +907,7 @@ static void ov01a10_remove(struct i2c_client *client) v4l2_ctrl_handler_free(sd->ctrl_handler); pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); } static int ov01a10_probe(struct i2c_client *client) @@ -953,17 +954,26 @@ static int ov01a10_probe(struct i2c_client *client) goto err_media_entity_cleanup; } + /* + * Device is already turned on by i2c-core with ACPI domain PM. + * Enable runtime PM and turn off the device. + */ + pm_runtime_set_active(&client->dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); + ret = v4l2_async_register_subdev_sensor(&ov01a10->sd); if (ret < 0) { dev_err(dev, "Failed to register subdev: %d\n", ret); - goto err_media_entity_cleanup; + goto err_pm_disable; } - pm_runtime_enable(dev); - pm_runtime_idle(dev); - return 0; +err_pm_disable: + pm_runtime_disable(dev); + pm_runtime_set_suspended(&client->dev); + err_media_entity_cleanup: media_entity_cleanup(&ov01a10->sd.entity); From patchwork Wed Nov 22 09:30:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Bingbu" X-Patchwork-Id: 13464311 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="njHvlK2X" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27ABCDD for ; Wed, 22 Nov 2023 01:21:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700644898; x=1732180898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qdme8zeLEE3RjEKJqoAGaAlzyQrSPd6vb2Jyv+30AnU=; b=njHvlK2XPpZ2oiIF0oJeg73i65TrNH0Ms9OJvyyT+57HANmTgRIpk3G2 V3l9wsoeFWhxpU9unkRSv7n0GddyCGfWYjmivv4408sKF0legi+55J8fD 4NLVmAHQrT3PyeoJyY5lRwxRqcbLvh60HzlcpKVV3Mhak2SlVzJrkCbhw TEA7tPzTdCmp0FMxTLN9lsRbHyQgFKLYVMfJntgI5370eXT4Ws7pmHfM7 hTTIOKtEAgin47W3dpSrmGhlmejrFmxdVqNzK4UXDChMzfvzToer7oLXa fCQB3ZDDOnZ1FRw2m2migjqpIbwIVzGBE/nNBb1welgesSrcze9hbgUfb w==; X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="372193670" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="372193670" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 01:21:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="910729326" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="910729326" Received: from icg-kernel3.bj.intel.com ([172.16.126.107]) by fmsmga001.fm.intel.com with ESMTP; 22 Nov 2023 01:21:36 -0800 From: bingbu.cao@intel.com To: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com Cc: hdegoede@redhat.com, bingbu.cao@intel.com, bingbu.cao@linux.intel.com Subject: [PATCH v3 3/4] media: ov13b10: Enable runtime PM before registering async sub-device Date: Wed, 22 Nov 2023 17:30:42 +0800 Message-ID: <20231122093043.233148-4-bingbu.cao@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122093043.233148-1-bingbu.cao@intel.com> References: <20231122093043.233148-1-bingbu.cao@intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bingbu Cao As the sensor device maybe accessible right after its async sub-device is registered, such as ipu-bridge will try to power up sensor by sensor's client device's runtime PM from the async notifier callback, if runtime PM is not enabled, it will fail. So runtime PM should be ready before its async sub-device is registered and accessible by others. Fixes: 7ee850546822 ("media: Add sensor driver support for the ov13b10 camera.") Cc: stable@vger.kernel.org Signed-off-by: Bingbu Cao --- drivers/media/i2c/ov13b10.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov13b10.c b/drivers/media/i2c/ov13b10.c index dbc642c5995b..f28a79c16a43 100644 --- a/drivers/media/i2c/ov13b10.c +++ b/drivers/media/i2c/ov13b10.c @@ -1536,24 +1536,27 @@ static int ov13b10_probe(struct i2c_client *client) goto error_handler_free; } - ret = v4l2_async_register_subdev_sensor(&ov13b->sd); - if (ret < 0) - goto error_media_entity; /* * Device is already turned on by i2c-core with ACPI domain PM. * Enable runtime PM and turn off the device. */ - /* Set the device's state to active if it's in D0 state. */ if (full_power) pm_runtime_set_active(&client->dev); pm_runtime_enable(&client->dev); pm_runtime_idle(&client->dev); + ret = v4l2_async_register_subdev_sensor(&ov13b->sd); + if (ret < 0) + goto error_media_entity_runtime_pm; + return 0; -error_media_entity: +error_media_entity_runtime_pm: + pm_runtime_disable(&client->dev); + if (full_power) + pm_runtime_set_suspended(&client->dev); media_entity_cleanup(&ov13b->sd.entity); error_handler_free: @@ -1576,6 +1579,7 @@ static void ov13b10_remove(struct i2c_client *client) ov13b10_free_controls(ov13b); pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); } static DEFINE_RUNTIME_DEV_PM_OPS(ov13b10_pm_ops, ov13b10_suspend, From patchwork Wed Nov 22 09:30:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Bingbu" X-Patchwork-Id: 13464312 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YGm3hS5m" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3472B9E for ; Wed, 22 Nov 2023 01:21:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700644900; x=1732180900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eOBoafPmE3Cy5R4CYWXvOsODA4dEu8M7atsG4F5x6Mk=; b=YGm3hS5m65QTtIDXDemCjxVOupfnY9jLq6ujjGFqnQ2KV+wNJfi9mnpX at9YRlJXE0kzqIROOckfbLR8NXEZblwm/+0OjWPepcgikGQgbN0IYOJTg RGn1ViFrt8QbWQ7MLnZjQB25v667U1NqJhBCO5VrOQq8ZA5At/+joHDcX mfx8nn0ssx779Sc0Wd/LLieRxxwjiOvTtxyhIkCDfoR84hDRS2sfoq1cJ qX3hbMTjdidxKvN9B8YbCYhUUnTZ8FZvwfrgKr2kTWJTHmXCuJgK7WY3p MGK92ELmV9N4/OwIxrlzgsLEuE5yxLBeStC2YrDtkRAauo17ceWtdeMJ7 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="372193674" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="372193674" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 01:21:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="910729329" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="910729329" Received: from icg-kernel3.bj.intel.com ([172.16.126.107]) by fmsmga001.fm.intel.com with ESMTP; 22 Nov 2023 01:21:38 -0800 From: bingbu.cao@intel.com To: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com Cc: hdegoede@redhat.com, bingbu.cao@intel.com, bingbu.cao@linux.intel.com Subject: [PATCH v3 4/4] media: ov9734: Enable runtime PM before registering async sub-device Date: Wed, 22 Nov 2023 17:30:43 +0800 Message-ID: <20231122093043.233148-5-bingbu.cao@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122093043.233148-1-bingbu.cao@intel.com> References: <20231122093043.233148-1-bingbu.cao@intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bingbu Cao As the sensor device maybe accessible right after its async sub-device is registered, such as ipu-bridge will try to power up sensor by sensor's client device's runtime PM from the async notifier callback, if runtime PM is not enabled, it will fail. So runtime PM should be ready before its async sub-device is registered and accessible by others. Fixes: d3f863a63fe4 ("media: i2c: Add ov9734 image sensor driver") Cc: stable@vger.kernel.org Signed-off-by: Bingbu Cao --- drivers/media/i2c/ov9734.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ov9734.c b/drivers/media/i2c/ov9734.c index b6244772bc59..b36fc0fedad4 100644 --- a/drivers/media/i2c/ov9734.c +++ b/drivers/media/i2c/ov9734.c @@ -939,6 +939,7 @@ static void ov9734_remove(struct i2c_client *client) media_entity_cleanup(&sd->entity); v4l2_ctrl_handler_free(sd->ctrl_handler); pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); mutex_destroy(&ov9734->mutex); } @@ -984,13 +985,6 @@ static int ov9734_probe(struct i2c_client *client) goto probe_error_v4l2_ctrl_handler_free; } - ret = v4l2_async_register_subdev_sensor(&ov9734->sd); - if (ret < 0) { - dev_err(&client->dev, "failed to register V4L2 subdev: %d", - ret); - goto probe_error_media_entity_cleanup; - } - /* * Device is already turned on by i2c-core with ACPI domain PM. * Enable runtime PM and turn off the device. @@ -999,9 +993,18 @@ static int ov9734_probe(struct i2c_client *client) pm_runtime_enable(&client->dev); pm_runtime_idle(&client->dev); + ret = v4l2_async_register_subdev_sensor(&ov9734->sd); + if (ret < 0) { + dev_err(&client->dev, "failed to register V4L2 subdev: %d", + ret); + goto probe_error_media_entity_cleanup_pm; + } + return 0; -probe_error_media_entity_cleanup: +probe_error_media_entity_cleanup_pm: + pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); media_entity_cleanup(&ov9734->sd.entity); probe_error_v4l2_ctrl_handler_free: