Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WhNQhQAc" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47190BD for ; Wed, 22 Nov 2023 01:37: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=1700645828; x=1732181828; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wILH5FWV7BdgUHaaYmvc+mlsv9WIB8M7vLxfH7hy9ow=; b=WhNQhQAcoBT3RQg2in9jzWG4e9nFZui7sibZZNK778PpqjgpZ5XkjwZR bcyJeh5e87g6OyCP9p2A2VEkCpq529ti8Zr/xihbc1n7ylfssg6WxxJgV HCCDOsDTpIO/RLSIKF9VZdl7nkWldMIO0mdFPprkZ18YZGRRf/SJVFt02 2TFSperQyDnjQzwLb1Nmx6r6AIlu+xZDXZyB/ToppTDNThZp3GCRl71mV iGA/DjjD/JYRlNa4U7X3d2CIH/pkBz9AlHLWEIM5lfRIhCEIfpkSUXAJ4 X7bodSAII9xONLqplXI6f7+Fn04PthrA2bFTNo1SX7ecxcOthbvl+QoJv w==; X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="377049463" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="377049463" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 01:37:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="857662425" X-IronPort-AV: E=Sophos;i="6.04,218,1695711600"; d="scan'208";a="857662425" Received: from icg-kernel3.bj.intel.com ([172.16.126.107]) by FMSMGA003.fm.intel.com with ESMTP; 22 Nov 2023 01:37:05 -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 v4 3/4] media: ov13b10: Enable runtime PM before registering async sub-device Date: Wed, 22 Nov 2023 17:46:08 +0800 Message-ID: <20231122094609.292304-4-bingbu.cao@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122094609.292304-1-bingbu.cao@intel.com> References: <20231122094609.292304-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 Content-Transfer-Encoding: 8bit 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, -- 2.42.0