From patchwork Mon Nov 6 08:35:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Bingbu" X-Patchwork-Id: 741682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E923C4332F for ; Mon, 6 Nov 2023 08:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231348AbjKFI0o (ORCPT ); Mon, 6 Nov 2023 03:26:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbjKFI00 (ORCPT ); Mon, 6 Nov 2023 03:26:26 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B4810C6 for ; Mon, 6 Nov 2023 00:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699259178; x=1730795178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L/3xXkT6AtY4ar8kvSRpDfysjS1AC0MoXkFPVthmJYU=; b=lvHoD2Z6FGSBu4XTnWVzNXPpA2V4Scma2ma9Z+DRrNCn4KF1Fan9mCvr 2eujlxVPC1RkZ+hMwwUqAPwsO+7xqj6X8wIlEosklGo5tz/4smtUNJM+F QoDsD0pWceCqaNFP5Scb1NIoWnZ2GKBtcB0GGjZXV8YVmCC3FuPdhht5G hgLKhUBcUkpn1WFWylHhNKBmpV/l/FriAjh+k4zJHo8ZbYv8xwO4VwBo0 fuIOEsZGKtM/1X1u95aSwrcM2BpFmiIoB6huGhYX3SW8dGrX6Rr83dxIr X58fiKPayJtdfppjJqbIViWcmofw1RDNQmFJnPEh8L/XyB2SQPsSduBfi A==; X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="2213884" X-IronPort-AV: E=Sophos;i="6.03,280,1694761200"; d="scan'208";a="2213884" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 00:26:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="762254781" X-IronPort-AV: E=Sophos;i="6.03,280,1694761200"; d="scan'208";a="762254781" Received: from icg-kernel3.bj.intel.com ([172.16.126.174]) by orsmga002.jf.intel.com with ESMTP; 06 Nov 2023 00:26:15 -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 3/4] media: ov13b10: Enable runtime PM before registering async sub-device Date: Mon, 6 Nov 2023 16:35:15 +0800 Message-ID: <20231106083516.763184-4-bingbu.cao@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231106083516.763184-1-bingbu.cao@intel.com> References: <20231106083516.763184-1-bingbu.cao@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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/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..f5c6d4a5ae0b 100644 --- a/drivers/media/i2c/ov13b10.c +++ b/drivers/media/i2c/ov13b10.c @@ -1536,24 +1536,28 @@ 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); + + ret = v4l2_async_register_subdev_sensor(&ov13b->sd); + if (ret < 0) + goto error_media_entity_runtime_pm; + pm_runtime_idle(&client->dev); 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: