From patchwork Wed Nov 22 02:54:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Bingbu" X-Patchwork-Id: 746356 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gtHxfubA" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D21DF90 for ; Tue, 21 Nov 2023 18:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700621105; x=1732157105; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1Z1ZptD0R5JmHv3gdZvzwl/MhD7h25FarYBaEar7mbk=; b=gtHxfubAfcZEUHc0aTRfhn8xNwEisiImqx4z5ZLAZbPf9xFl3e1KjzYe UM//caZHlxDycfj/1s0NyWOvhV8+2VGI9fp4NERSIZzeLxhUrj4SXYmVI w5akq4KCfNqeADaryReCVBpCvyNgF5W+wnFYKjtEjmSNuJrR1ArG1K9bE 3L/bKkw750/ilnJdBACKXRl4YVpUhFh1f8C7pqiB3KUSTOlPmYGSYXg+G zbBjW4aT1iPANj81iUMEYTo3MrYFa8baZnPEu2ReF72fYDmN70g2E8gKY GiOkIPv9w+kCvRZMZe78UZCR1oxlKRRTXbbicU4epigscU+3+jverwKAa g==; X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="371320002" X-IronPort-AV: E=Sophos;i="6.04,217,1695711600"; d="scan'208";a="371320002" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2023 18:45:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="857508578" X-IronPort-AV: E=Sophos;i="6.04,217,1695711600"; d="scan'208";a="857508578" Received: from icg-kernel3.bj.intel.com ([172.16.126.107]) by FMSMGA003.fm.intel.com with ESMTP; 21 Nov 2023 18:45:02 -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 v2 2/4] media: ov01a10: Enable runtime PM before registering async sub-device Date: Wed, 22 Nov 2023 10:54:08 +0800 Message-ID: <20231122025411.2961572-3-bingbu.cao@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122025411.2961572-1-bingbu.cao@intel.com> References: <20231122025411.2961572-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. Signed-off-by: Bingbu Cao --- drivers/media/i2c/ov01a10.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov01a10.c b/drivers/media/i2c/ov01a10.c index 2b9e1b3a3bf4..8e36f91913aa 100644 --- a/drivers/media/i2c/ov01a10.c +++ b/drivers/media/i2c/ov01a10.c @@ -953,17 +953,20 @@ static int ov01a10_probe(struct i2c_client *client) goto err_media_entity_cleanup; } + 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); + err_media_entity_cleanup: media_entity_cleanup(&ov01a10->sd.entity); From patchwork Wed Nov 22 02:54:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Bingbu" X-Patchwork-Id: 746355 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HHuk/IHr" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7360B199 for ; Tue, 21 Nov 2023 18:45:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700621108; x=1732157108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bHxhG97nXxoKobkdQjZmIBLlGiJkoiG4o00AJmYrLQ0=; b=HHuk/IHr84kgHhfeDi8S/0QOm5Xz9DGVeBoWqI+JTKbORt6fi5ESY7U0 AumJpM8q5NQab7ugqav1IG9VRi6gdC+7wuFIftoMXXV44Li2mATabX0A1 EcafMMTVnlSISubuPd2Ln9G0IkDOj2XswetOeXmLEJAWKj3Sph7JEBoAk 1djkGyZiL0aGzGOhhuRM2tTzrbzf6CkXofH+Nuwq4ubleuVPtwCKiDXQS waIknZQbqpUYexLcpK6rcYfnBG5fLInbZVeF8xBvQVFezMEleBVi0rgWH 1R3Bro3Pl+9zbQCPMs3sZIlJtCHpHDj3Wyk1kiea+867HFFyicP6hCV6T Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="371320014" X-IronPort-AV: E=Sophos;i="6.04,217,1695711600"; d="scan'208";a="371320014" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2023 18:45:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="857508594" X-IronPort-AV: E=Sophos;i="6.04,217,1695711600"; d="scan'208";a="857508594" Received: from icg-kernel3.bj.intel.com ([172.16.126.107]) by FMSMGA003.fm.intel.com with ESMTP; 21 Nov 2023 18:45:06 -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 v2 4/4] media: ov9734: Enable runtime PM before registering async sub-device Date: Wed, 22 Nov 2023 10:54:10 +0800 Message-ID: <20231122025411.2961572-5-bingbu.cao@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122025411.2961572-1-bingbu.cao@intel.com> References: <20231122025411.2961572-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. Signed-off-by: Bingbu Cao --- drivers/media/i2c/ov9734.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ov9734.c b/drivers/media/i2c/ov9734.c index b6244772bc59..e4239b77e1d6 100644 --- a/drivers/media/i2c/ov9734.c +++ b/drivers/media/i2c/ov9734.c @@ -984,13 +984,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 +992,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: