From patchwork Sun Aug 15 02:49:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 12437051 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5B7BC4320E for ; Sun, 15 Aug 2021 02:50:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC47F61002 for ; Sun, 15 Aug 2021 02:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229453AbhHOCuQ (ORCPT ); Sat, 14 Aug 2021 22:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234853AbhHOCuP (ORCPT ); Sat, 14 Aug 2021 22:50:15 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F2FBC061764 for ; Sat, 14 Aug 2021 19:49:46 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id q11-20020a7bce8b0000b02902e6880d0accso12410286wmj.0 for ; Sat, 14 Aug 2021 19:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jjixc7LVMXe0bD3rZWuXthNBA6KrBliq5QpvQpx/lIY=; b=UJgLNKravN1J4O5txgp+u/5e/AvMSWEksFZBgkNzrfSKY4qCzwlDH/fDvyoMI34jKH vNQ1GDmzERx8PbsGHKWDaXkA6YLSY2231zkjx5tripTvXKkz3MQJoT+VXvqDKKbEXkPr IxJXeQETQtZQNimAH/9xr1CDL5xDYNJAuyw+IvnOmSJhcAYy+IUSZSnsu5ltAutMPdV3 Uf0Jm5rFdtLkEZr6r08yv0DqWTT8i/bNKLTTnZdFlaJUj1aFjj/i5XPJmXQC6kaDNyXc FCkZLQeAOf1Tm4/Au5ZdgumERb7CVRlqNQZUbptDYi/a9gpLBb4kvcSsCWQEZB+4pIE3 48pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jjixc7LVMXe0bD3rZWuXthNBA6KrBliq5QpvQpx/lIY=; b=fDJ4vhFn+/snpH8qsEmg0tMXgudyjQnrZffVdtfG/BUCSNjwF2VehsJu4U13yEwVce qI6Vx19HK6LvqiXJl8N0R+SleDBX4OiFjalNkMw2pdAnlVkVlgrA+gE55hWFEMqipXpf wWNVopRQbWjXgujJmuC1eOWpiudzR+1sV6K5G56kY+q/T6pYN2gi2gtQ8X+SrtYbQ37M PDCb3C+JJrPoqUAOEowGOkYECpvhBGL3VKdIFW4EyCoQ/TaGhXvHqfeHOs4xBz+oya4V nQAimnFq0/5Mmf/8Nf3vOX47cjuG0/jZcqAH48IWR247xRiKnB9OltUDh2XPgIuUEcl2 n8Gg== X-Gm-Message-State: AOAM533syDHlvVe11Bm5EkBMm53uXcIF2fV8poaHmCEwooj3oBGygD7o SByWZaQtH5x/bpA0aBtC5x0ir/UW6hK+kQ== X-Google-Smtp-Source: ABdhPJypWSh6UFvRp+cVUxpN/vFejFYry3wjQAPIMUN62oEA06odK+faFb3zPJrWLllI5tjEHWLF4g== X-Received: by 2002:a05:600c:350a:: with SMTP id h10mr9287501wmq.89.1628995783659; Sat, 14 Aug 2021 19:49:43 -0700 (PDT) Received: from bismarck.berto.se (p54ac5892.dip0.t-ipconnect.de. [84.172.88.146]) by smtp.googlemail.com with ESMTPSA id h9sm5866342wmb.35.2021.08.14.19.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Aug 2021 19:49:43 -0700 (PDT) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Hans Verkuil , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 1/2] media: rcar-csi2: Cleanup mutex on remove and fail Date: Sun, 15 Aug 2021 04:49:14 +0200 Message-Id: <20210815024915.1183417-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210815024915.1183417-1-niklas.soderlund+renesas@ragnatech.se> References: <20210815024915.1183417-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The mutex was not destroyed on remove or failed probe, fix this. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- drivers/media/platform/rcar-vin/rcar-csi2.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index e28eff0396888f2d..a02573dbd5da4f62 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -1245,14 +1245,14 @@ static int rcsi2_probe(struct platform_device *pdev) ret = rcsi2_probe_resources(priv, pdev); if (ret) { dev_err(priv->dev, "Failed to get resources\n"); - return ret; + goto error_mutex; } platform_set_drvdata(pdev, priv); ret = rcsi2_parse_dt(priv); if (ret) - return ret; + goto error_mutex; priv->subdev.owner = THIS_MODULE; priv->subdev.dev = &pdev->dev; @@ -1272,21 +1272,23 @@ static int rcsi2_probe(struct platform_device *pdev) ret = media_entity_pads_init(&priv->subdev.entity, NR_OF_RCAR_CSI2_PAD, priv->pads); if (ret) - goto error; + goto error_async; pm_runtime_enable(&pdev->dev); ret = v4l2_async_register_subdev(&priv->subdev); if (ret < 0) - goto error; + goto error_async; dev_info(priv->dev, "%d lanes found\n", priv->lanes); return 0; -error: +error_async: v4l2_async_notifier_unregister(&priv->notifier); v4l2_async_notifier_cleanup(&priv->notifier); +error_mutex: + mutex_destroy(&priv->lock); return ret; } @@ -1301,6 +1303,8 @@ static int rcsi2_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); + mutex_destroy(&priv->lock); + return 0; } From patchwork Sun Aug 15 02:49:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 12437049 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8A32C4320A for ; Sun, 15 Aug 2021 02:50:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89D336101E for ; Sun, 15 Aug 2021 02:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232750AbhHOCuP (ORCPT ); Sat, 14 Aug 2021 22:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbhHOCuP (ORCPT ); Sat, 14 Aug 2021 22:50:15 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD72EC0613CF for ; Sat, 14 Aug 2021 19:49:45 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id r7so18692857wrs.0 for ; Sat, 14 Aug 2021 19:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+uWJKEuzVCQFca12BS6BPlTfrO9jNYAl/Ixczig0hiA=; b=bld7193XBVPHLgBbM+bbRrNbFzpcvOzTeE2m3NgTJko8+5+H0jlqpm5qOoFB4zD08h tSplXU3C/fnmyUj/keLIgiDHgFEQbpBo0Oxh5dVyganmznmh3tg57t8VgmP8ZYT7vxCv KjrFnxm9uAcd0fPt8XFhEPkQiTS19PnCYq6+axK/cxrRjLEsyO7MTDJXyhOJPvpJFfrL SDOCnNP6YZXTOJ2kRkLoCF1TmzK5efxTf8USWOMPfFQyLNxZ0YHbnpow5YW/uZkXDGg8 GJpkSQaW6I/w5Otno+7iajXeEl9uPFkvYtjKfAcXm3j/MpvgRe6nDpOPsxbqKnFYg7WZ acTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+uWJKEuzVCQFca12BS6BPlTfrO9jNYAl/Ixczig0hiA=; b=EVCXSHzhhENe/N3La8QKbROfBWp4+PH60CpxedYUbiLNPp96CGxBcz3wzJRXIEEiHd vtR3Up4k+lUACRXnmpvFz+OE6IrMkKmdRp3DwitPtls3qnQLKIM4LswBJ7G15jaRZwPN 5ZUZJiDIEV3HzTo531udyWmuOyDDdP5INKiZKwNuTaHkpM1tczfGLo5p8m5hYMVl2XGc UKPP5TE4bQPZibeGZzZ9YZ03O3BX1TdxwjbPx+Ad3GiG8tceHLe1us7R7Rq5zHgDOSzQ dY9RMO6CKuvnw+DW7WsjQocN/PpLW3BR1052tE4q5+Xyg0xYmGiuQ5GFxcfX6y4IPDHw Sm4A== X-Gm-Message-State: AOAM5308iEziDs1H7jMWy8dzeWUDGYcmK9N18I5BTLXl35c73CSBOgRs UU8OX+F56ATUV38maosTRhSTkQ== X-Google-Smtp-Source: ABdhPJx//7m+Zn+R4N5G7obBEucwKrCJ7l41gv2uEizQydXEex3ty54p+mMmjAjgJm/cWssalg+xgA== X-Received: by 2002:a05:6000:1b02:: with SMTP id f2mr10876770wrz.274.1628995784318; Sat, 14 Aug 2021 19:49:44 -0700 (PDT) Received: from bismarck.berto.se (p54ac5892.dip0.t-ipconnect.de. [84.172.88.146]) by smtp.googlemail.com with ESMTPSA id h9sm5866342wmb.35.2021.08.14.19.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Aug 2021 19:49:44 -0700 (PDT) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Hans Verkuil , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 2/2] media: rcar-csi2: Serialize access to set_fmt and get_fmt Date: Sun, 15 Aug 2021 04:49:15 +0200 Message-Id: <20210815024915.1183417-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210815024915.1183417-1-niklas.soderlund+renesas@ragnatech.se> References: <20210815024915.1183417-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The access to the internal storage of the format rcar_csi2.mf should be serialized, extend the exciting lock mutex to also cover this. While at it document the mutex. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- drivers/media/platform/rcar-vin/rcar-csi2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index a02573dbd5da4f62..2fdfdc38de424c72 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -370,9 +370,8 @@ struct rcar_csi2 { struct v4l2_subdev *remote; unsigned int remote_pad; + struct mutex lock; /* Protects mf and stream_count. */ struct v4l2_mbus_framefmt mf; - - struct mutex lock; int stream_count; unsigned short lanes; @@ -725,6 +724,8 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *sd, struct rcar_csi2 *priv = sd_to_csi2(sd); struct v4l2_mbus_framefmt *framefmt; + mutex_lock(&priv->lock); + if (!rcsi2_code_to_fmt(format->format.code)) format->format.code = rcar_csi2_formats[0].code; @@ -735,6 +736,8 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *sd, *framefmt = format->format; } + mutex_unlock(&priv->lock); + return 0; } @@ -744,11 +747,15 @@ static int rcsi2_get_pad_format(struct v4l2_subdev *sd, { struct rcar_csi2 *priv = sd_to_csi2(sd); + mutex_lock(&priv->lock); + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) format->format = priv->mf; else format->format = *v4l2_subdev_get_try_format(sd, sd_state, 0); + mutex_unlock(&priv->lock); + return 0; }