From patchwork Mon Oct 9 22:09:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 733134 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 44BECE81E16 for ; Mon, 9 Oct 2023 22:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378868AbjJIWJP (ORCPT ); Mon, 9 Oct 2023 18:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378741AbjJIWJO (ORCPT ); Mon, 9 Oct 2023 18:09:14 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1998A3 for ; Mon, 9 Oct 2023 15:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696889352; x=1728425352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c49XPAjuHDXYtqbxmRDmqhUJOa2+EOstv1rRmUF6/l8=; b=JUeKw4eH1MsEDj3BfcXhiRXNPLcBDRcvaTFqHyIGYKYdOsQmRnIcalYL P4OO/zmG1n9FAE+xHOqoZCNE/jFuiyiooZtwQE3wBlaR5UP8sJURuwCs/ galZ1ZiJOwBPt/wtuVfM+KTIUCwxbWIXurzhKNVpVGC2woHNj78ogkUgB pevuub/D7lFbNcQhyA8et8QAyNW/FF1VOYRo1jJcLYb2QPRdmSYw41X8Q AgwVVbkg3EtrKdB+5an2VMZbuwVjWwNAlEMNHKyils0fZ6qKybBF+KtTA XGWdw3/1GrbnIfhfSuC6yOgVevzRqnDetgFiOZe7BsSihZCWfIaO614ax Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="388123376" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="388123376" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 15:09:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="782647385" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="782647385" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 15:09:10 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 8EDDF1206D2; Tue, 10 Oct 2023 01:09:07 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com Subject: [PATCH v2 1/4] media: v4l: subdev: Set sub-device active state earlier Date: Tue, 10 Oct 2023 01:09:03 +0300 Message-Id: <20231009220906.221303-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009220906.221303-1-sakari.ailus@linux.intel.com> References: <20231009220906.221303-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Set sub-device active state earlier in order to have it available to the sub-device driver when driver's init_cfg operation is called. Signed-off-by: Sakari Ailus --- .../media/platform/renesas/rcar-vin/rcar-v4l2.c | 3 ++- drivers/media/platform/renesas/vsp1/vsp1_entity.c | 3 ++- drivers/media/v4l2-core/v4l2-subdev.c | 14 +++++++++----- drivers/staging/media/tegra-video/vi.c | 2 +- include/media/v4l2-subdev.h | 3 ++- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c index 073f70c6ac68..26c2470dc289 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c @@ -266,7 +266,8 @@ static int rvin_try_format(struct rvin_dev *vin, u32 which, * FIXME: Drop this call, drivers are not supposed to use * __v4l2_subdev_state_alloc(). */ - sd_state = __v4l2_subdev_state_alloc(sd, "rvin:state->lock", &key); + sd_state = __v4l2_subdev_state_alloc(sd, "rvin:state->lock", &key, + false); if (IS_ERR(sd_state)) return PTR_ERR(sd_state); diff --git a/drivers/media/platform/renesas/vsp1/vsp1_entity.c b/drivers/media/platform/renesas/vsp1/vsp1_entity.c index c31f05a80bb5..ab0f47a5fd96 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_entity.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_entity.c @@ -680,7 +680,8 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, * __v4l2_subdev_state_alloc(). */ entity->config = __v4l2_subdev_state_alloc(&entity->subdev, - "vsp1:config->lock", &key); + "vsp1:config->lock", &key, + false); if (IS_ERR(entity->config)) { media_entity_cleanup(&entity->subdev.entity); return PTR_ERR(entity->config); diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index d295a4e87b66..cd590951c393 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -53,7 +53,7 @@ static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd) struct v4l2_subdev_state *state; static struct lock_class_key key; - state = __v4l2_subdev_state_alloc(sd, "fh->state->lock", &key); + state = __v4l2_subdev_state_alloc(sd, "fh->state->lock", &key, false); if (IS_ERR(state)) return PTR_ERR(state); @@ -1426,7 +1426,7 @@ EXPORT_SYMBOL_GPL(v4l2_subdev_has_pad_interdep); struct v4l2_subdev_state * __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name, - struct lock_class_key *lock_key) + struct lock_class_key *lock_key, bool active) { struct v4l2_subdev_state *state; int ret; @@ -1451,6 +1451,9 @@ __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name, } } + if (active) + sd->active_state = state; + /* * There can be no race at this point, but we lock the state anyway to * satisfy lockdep checks. @@ -1470,6 +1473,9 @@ __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name, kfree(state); + if (active) + sd->active_state = NULL; + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(__v4l2_subdev_state_alloc); @@ -1493,12 +1499,10 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, { struct v4l2_subdev_state *state; - state = __v4l2_subdev_state_alloc(sd, name, key); + state = __v4l2_subdev_state_alloc(sd, name, key, true); if (IS_ERR(state)) return PTR_ERR(state); - sd->active_state = state; - return 0; } EXPORT_SYMBOL_GPL(__v4l2_subdev_init_finalize); diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index e98b3010520e..733fccb157fe 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -450,7 +450,7 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, * __v4l2_subdev_state_alloc(). */ sd_state = __v4l2_subdev_state_alloc(subdev, "tegra:state->lock", - &key); + &key, false); if (IS_ERR(sd_state)) return PTR_ERR(sd_state); /* diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index c1f90c1223a7..ea05b70389b3 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1346,7 +1346,8 @@ bool v4l2_subdev_has_pad_interdep(struct media_entity *entity, */ struct v4l2_subdev_state *__v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name, - struct lock_class_key *key); + struct lock_class_key *key, + bool active); /** * __v4l2_subdev_state_free - free a v4l2_subdev_state From patchwork Mon Oct 9 22:09:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 733135 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 B8A78C2BA1B for ; Mon, 9 Oct 2023 22:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378763AbjJIWJP (ORCPT ); Mon, 9 Oct 2023 18:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233776AbjJIWJN (ORCPT ); Mon, 9 Oct 2023 18:09:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB9D3B6 for ; Mon, 9 Oct 2023 15:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696889352; x=1728425352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SnFvz40nTo1wWnvsvdfGJGtKxDfJKBDQfesPPQsi49I=; b=CpHRGPmMWCoGyG2FLMv5BVhF0tVt7+rSR4sC6dVncoATbdEYlInQod8k LZATdOHeba/fsqN6vHQPcFoLv6CQTqJTPyY2uUQ7SkJi7lYh1Cx9ZdN3v QKyWO4mUnqs26tBFylZl/h76SusIGf8S4xxO7VyiCmbNlafMbBmYcWdRB dk0bC6YE+AN1LcmuOAZVwxTNV5naE/EehJfZyCuTDLhvJ1j8h6bLG55zf nyO8zrbJhvEbvCv3oXpM858iEZYSGk5TQjRS6YIW5LXzGG3C3LcoyRI58 RoHJCudN7iDBVjDtMh5U7G5XfVmks9tuQ6qwSyQP6nrOotpf2ZCAeyiak Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="388123380" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="388123380" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 15:09:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="782647386" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="782647386" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 15:09:10 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 2C3C5120797; Tue, 10 Oct 2023 01:09:08 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com Subject: [PATCH v2 2/4] media: v4l: subdev: Add a helper to tell if a sub-device state is active Date: Tue, 10 Oct 2023 01:09:04 +0300 Message-Id: <20231009220906.221303-3-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009220906.221303-1-sakari.ailus@linux.intel.com> References: <20231009220906.221303-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a helper called v4l2_subdev_state_whence() to return enum v4l2_subdev_format_whence to tell whether a state the driver is dealing with it active or not. Signed-off-by: Sakari Ailus --- include/media/v4l2-subdev.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index ea05b70389b3..ff211b0f07ff 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1645,6 +1645,14 @@ v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state, u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state, u32 pad0, u32 pad1, u64 *streams); +static inline enum v4l2_subdev_format_whence +v4l2_subdev_state_whence(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state) +{ + return sd->active_state == state ? + V4L2_SUBDEV_FORMAT_ACTIVE : V4L2_SUBDEV_FORMAT_TRY; +} + /** * enum v4l2_subdev_routing_restriction - Subdevice internal routing restrictions * From patchwork Mon Oct 9 22:09:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 731275 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 50F45E784AF for ; Mon, 9 Oct 2023 22:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378869AbjJIWJQ (ORCPT ); Mon, 9 Oct 2023 18:09:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378865AbjJIWJP (ORCPT ); Mon, 9 Oct 2023 18:09:15 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76C48C5 for ; Mon, 9 Oct 2023 15:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696889353; x=1728425353; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8unoJ2CF6b7ZuIxRpKSJzquoipvjGCHV6k77AhsjWdU=; b=M5nANJxq5XAai8JRLLv5tWoxweGLGzvNuvLGJasvm+FhQV+2LIjKArNX deXUzlcmhyseFp6jtZ0/N1Lf8N59NtDF2KasOQYe4FcmM1yj1TP/xju+x gaMPUTLBHSNf8gRujYhi3mcigeC6eSX2cvmSYvkUV9bfX3u5aPqgJUg+7 9KzUZqceYNBISeQ5SLiTtzBVBBWgn7HgPROtV0AWh20PqXBcIjOzfjg0V 8nm/HwsPPofzAxGfPmi76Nr+vH+ECzVL/fDCvjoJuu62/WeFASvqiL5k1 /I6lYNcr4hKITnh53m57ap6zWAeB5uIBXliu3sX3wjkpbBTxtuAHFs/aW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="388123384" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="388123384" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 15:09:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="782647387" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="782647387" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 15:09:11 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id E74881209E7; Tue, 10 Oct 2023 01:09:08 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com Subject: [PATCH v2 3/4] media: ccs: Rework initialising sub-device state Date: Tue, 10 Oct 2023 01:09:05 +0300 Message-Id: <20231009220906.221303-4-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009220906.221303-1-sakari.ailus@linux.intel.com> References: <20231009220906.221303-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Initialise sub-device state in init_cfg callback using ccs_propagate() to the extent it covers of the initialisation. This fixes a bug where the driver configuration was incorrectly initialised. Fixes: 4b05b1baae3e ("media: ccs: Use sub-device active state") Signed-off-by: Sakari Ailus --- drivers/media/i2c/ccs/ccs-core.c | 47 ++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index 2abfd5932e02..6589b0d84e06 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -2075,6 +2075,7 @@ static void ccs_propagate(struct v4l2_subdev *subdev, struct ccs_sensor *sensor = to_ccs_sensor(subdev); struct ccs_subdev *ssd = to_ccs_subdev(subdev); struct v4l2_rect *comp, *crops[CCS_PADS]; + struct v4l2_mbus_framefmt *fmt; ccs_get_crop_compose(subdev, sd_state, crops, &comp); @@ -2096,6 +2097,9 @@ static void ccs_propagate(struct v4l2_subdev *subdev, fallthrough; case V4L2_SEL_TGT_COMPOSE: *crops[CCS_PAD_SRC] = *comp; + fmt = v4l2_subdev_get_pad_format(subdev, sd_state, CCS_PAD_SRC); + fmt->width = comp->width; + fmt->height = comp->height; if (which == V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src) sensor->src_src = *crops[CCS_PAD_SRC]; break; @@ -3003,31 +3007,40 @@ static int ccs_init_cfg(struct v4l2_subdev *sd, { struct ccs_subdev *ssd = to_ccs_subdev(sd); struct ccs_sensor *sensor = ssd->sensor; - unsigned int i; + unsigned int pad = ssd == sensor->pixel_array ? + CCS_PA_PAD_SRC : CCS_PAD_SINK; + struct v4l2_mbus_framefmt *fmt = + v4l2_subdev_get_pad_format(sd, sd_state, pad); + struct v4l2_rect *crop = + v4l2_subdev_get_pad_crop(sd, sd_state, pad); mutex_lock(&sensor->mutex); - for (i = 0; i < ssd->npads; i++) { - struct v4l2_mbus_framefmt *fmt = - v4l2_subdev_get_pad_format(sd, sd_state, i); - struct v4l2_rect *crop = - v4l2_subdev_get_pad_crop(sd, sd_state, i); - struct v4l2_rect *comp; - - ccs_get_native_size(ssd, crop); + ccs_get_native_size(ssd, crop); - fmt->width = crop->width; - fmt->height = crop->height; - fmt->code = sensor->internal_csi_format->code; - fmt->field = V4L2_FIELD_NONE; + fmt->width = crop->width; + fmt->height = crop->height; + fmt->code = sensor->internal_csi_format->code; + fmt->field = V4L2_FIELD_NONE; - if (ssd == sensor->pixel_array) - continue; + if (ssd == sensor->pixel_array) { + if (v4l2_subdev_state_whence(sd, sd_state) == + V4L2_SUBDEV_FORMAT_ACTIVE) + sensor->pa_src = *crop; - comp = v4l2_subdev_get_pad_compose(sd, sd_state, i); - *comp = *crop; + mutex_unlock(&sensor->mutex); + return 0; } + fmt = v4l2_subdev_get_pad_format(sd, sd_state, CCS_PAD_SRC); + fmt->code = ssd == sensor->src ? + sensor->csi_format->code : sensor->internal_csi_format->code; + fmt->field = V4L2_FIELD_NONE; + + ccs_propagate(sd, sd_state, + v4l2_subdev_state_whence(sd, sd_state), + V4L2_SEL_TGT_CROP); + mutex_unlock(&sensor->mutex); return 0; From patchwork Mon Oct 9 22:09:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 731274 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 C4201C2BA1B for ; Mon, 9 Oct 2023 22:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378871AbjJIWJR (ORCPT ); Mon, 9 Oct 2023 18:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378885AbjJIWJQ (ORCPT ); Mon, 9 Oct 2023 18:09:16 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4044A6 for ; Mon, 9 Oct 2023 15:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696889353; x=1728425353; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z2/kj9VPKDSWf50h0Ub2vphEwmDcBMduOifQK2YlvZk=; b=lo8CaHiU0z5IShqMLKk9l94DLCfJuF47jbs7WLjMw3qMpEQsxNxLFnqM GzP4zzIurPSExU2p4/UZwr1uKybVhKSGDM3aM/POSJUWonmrv8+HI90+X HyYz9HhM5qaH2y5LbtRlj9blF58JhqN80HE9MOL43XCBQyOTOYPhTN07n PGR89L54RfC0R0hN65MMZHg9qpIJoDi4LW07m4v+nJJ6i5xP9q3uqu/Wp sVdfDBSbU36ZUxyvJ+K6OrW2MdNCMsj4qWei/hTO5KvyozAlDuWde3b+X +vvXUko8smcoUghx+F9k5m2nnHNlAP4BdYaFzaldz7mkNsE6fLNbX0Siw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="388123391" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="388123391" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 15:09:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="782647388" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="782647388" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 15:09:12 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id AC3E91209F6; Tue, 10 Oct 2023 01:09:09 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com Subject: [PATCH v2 4/4] media: ccs: Fix a (harmless) lockdep warning Date: Tue, 10 Oct 2023 01:09:06 +0300 Message-Id: <20231009220906.221303-5-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009220906.221303-1-sakari.ailus@linux.intel.com> References: <20231009220906.221303-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The v4l2_subdev_init_finalize() is a macro that creates an unique lockdep key and name. As the CCS driver initialises all three of its sub-devices using the same call site, this creates a lockdep warning. Address it. Fixes: 4b05b1baae3e ("media: ccs: Use sub-device active state") Signed-off-by: Sakari Ailus --- drivers/media/i2c/ccs/ccs-core.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index 6589b0d84e06..2b3b712d60b5 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -2955,7 +2955,9 @@ static void ccs_cleanup(struct ccs_sensor *sensor) static int ccs_init_subdev(struct ccs_sensor *sensor, struct ccs_subdev *ssd, const char *name, - unsigned short num_pads, u32 function) + unsigned short num_pads, u32 function, + const char *lock_name, + struct lock_class_key *lock_key) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); int rval; @@ -2993,7 +2995,7 @@ static int ccs_init_subdev(struct ccs_sensor *sensor, return rval; } - rval = v4l2_subdev_init_finalize(&ssd->sd); + rval = __v4l2_subdev_init_finalize(&ssd->sd, lock_name, lock_key); if (rval) { media_entity_cleanup(&ssd->sd.entity); return rval; @@ -3208,6 +3210,8 @@ static int ccs_firmware_name(struct i2c_client *client, static int ccs_probe(struct i2c_client *client) { + static struct lock_class_key pixel_array_lock_key, binner_lock_key, + scaler_lock_key; const struct ccs_device *ccsdev = device_get_match_data(&client->dev); struct ccs_sensor *sensor; const struct firmware *fw; @@ -3491,15 +3495,18 @@ static int ccs_probe(struct i2c_client *client) } rval = ccs_init_subdev(sensor, sensor->scaler, " scaler", 2, - MEDIA_ENT_F_PROC_VIDEO_SCALER); + MEDIA_ENT_F_PROC_VIDEO_SCALER, + "ccs scaler mutex", &scaler_lock_key); if (rval) goto out_cleanup; rval = ccs_init_subdev(sensor, sensor->binner, " binner", 2, - MEDIA_ENT_F_PROC_VIDEO_SCALER); + MEDIA_ENT_F_PROC_VIDEO_SCALER, + "ccs binner mutex", &binner_lock_key); if (rval) goto out_cleanup; rval = ccs_init_subdev(sensor, sensor->pixel_array, " pixel_array", 1, - MEDIA_ENT_F_CAM_SENSOR); + MEDIA_ENT_F_CAM_SENSOR, "ccs pixel array mutex", + &pixel_array_lock_key); if (rval) goto out_cleanup;