From patchwork Wed Sep 15 01:50:12 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: 12495311 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.7 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,URIBL_BLOCKED,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 80AB1C433FE for ; Wed, 15 Sep 2021 01:50:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67BB561211 for ; Wed, 15 Sep 2021 01:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229489AbhIOBv7 (ORCPT ); Tue, 14 Sep 2021 21:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbhIOBv7 (ORCPT ); Tue, 14 Sep 2021 21:51:59 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15CFCC061766 for ; Tue, 14 Sep 2021 18:50:41 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id l18-20020a05600c4f1200b002f8cf606262so3557593wmq.1 for ; Tue, 14 Sep 2021 18:50:41 -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=ve0ND4UBUtoUsSmBb/d0sk2VLmXxugvcGbqrng16nFQ=; b=oJWx0DOL9rcSzv32jyMD4k6BUzlr3HdVDeBWS9DfSoIR1I2kpAZ4rgRU0cdgI4LXkn 6E675WS2hhXPXfma8Jx+LrKeO6n69vEiuY254K21yI0iCvtbsh3R7w0QWHBRvemxHOPG 6d3cjF7ML4bPbGQFXeANdIUo+v8OKYvll9dxExLDIAw/SuGwigTxDcTPy2ILk23EHW6m FWFXPXADkg35GYVk/b+Zpm2fd4tYktkw9y4ul6eXdUX+fL+dA9mGiTismfNwlS8LSc6S 6S3kxaAhvO+Q0XQMFiZ+jJo8/sFSjAHH0HKhZPoC/i/y9QqSFm3h/RnKjkSe3Sec4Yul W8yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ve0ND4UBUtoUsSmBb/d0sk2VLmXxugvcGbqrng16nFQ=; b=uI4XnYD97Ox0DhbVT/OooG1qwrzL31la+3TVASJDiL9vF0hcvT+PiirTFv+fOJ0lzQ rk1FhnOKZgUKCOhWFvkycKnx1z45FpmGnUQLmNNHjk6885Z3Wk4hr/UHbeHrvPr/2vme D4lYtcUnVN0R2Txe0wKuQGqL2XeUFgCLxD1FDVdJdTETxwIQageg78sWFmvRa5jGCN9R JX42zSePM6q1FWW/+dxvbmWjtZW/leYmypIRz2ein/D9DnOmZ4wEO21LGBL6jtezrcdW fB2SaKs1AJZelF1ycErgR+vGF7W+VDlz/ZegO1w0Rq+RnfgBk2XdQTwdGICE0e2eB7Vi IVKQ== X-Gm-Message-State: AOAM530f6zL4bzQhbO7EIeNFuTqd+BL3rX7f4bLXS7dq8/42pPwjV8pi j+Z3zwCTnGD1vgqSeH1OYTuN3Q== X-Google-Smtp-Source: ABdhPJzNOU+4RJWC02/KeeE88/YDMG42AWECECOz94A7GVN0VoTAmVd7kgSO6bp/UyECdlf7cSrv5w== X-Received: by 2002:a1c:2705:: with SMTP id n5mr1847214wmn.176.1631670639666; Tue, 14 Sep 2021 18:50:39 -0700 (PDT) Received: from bismarck.berto.se (p54ac5892.dip0.t-ipconnect.de. [84.172.88.146]) by smtp.googlemail.com with ESMTPSA id k17sm3486863wmj.0.2021.09.14.18.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 18:50:39 -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?= , Jacopo Mondi Subject: [PATCH v2 1/2] media: rcar-csi2: Cleanup mutex on remove and fail Date: Wed, 15 Sep 2021 03:50:12 +0200 Message-Id: <20210915015013.3169934-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210915015013.3169934-1-niklas.soderlund+renesas@ragnatech.se> References: <20210915015013.3169934-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 Reviewed-by: Kieran Bingham --- 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 Wed Sep 15 01:50:13 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: 12495309 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.7 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,URIBL_BLOCKED,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 3F7CAC43217 for ; Wed, 15 Sep 2021 01:50:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2822B60FBF for ; Wed, 15 Sep 2021 01:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234031AbhIOBwA (ORCPT ); Tue, 14 Sep 2021 21:52:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233895AbhIOBwA (ORCPT ); Tue, 14 Sep 2021 21:52:00 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E278DC061762 for ; Tue, 14 Sep 2021 18:50:41 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id g19-20020a1c9d13000000b003075062d4daso900742wme.0 for ; Tue, 14 Sep 2021 18:50:41 -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=zM8FsXiM9O4eBZdkXaqFVNn1tTornIe046XH9M/vUAo=; b=ITTklQFgG3s6JDx1la106SAbbJymHKIxsXGMVxvhhjWdDYHTqhnC+9/zigBbwHNwsC j7ksWU2Ygjjtcgu2SZokKjzBzjIXIuXUyZ5cul0byJs4VQ5JO/6x524dmwzYshLXeMq1 1eYOL1kL9NJTUyoZuTKkj2vP60nk1WotYueH8uCxMtc42YNRf9c75QoVl3Z4NjKasqcQ AkLlpjRi6E4kXsIl8alY0Dx3Lc8S9hsBIAP/RYeoY+QxktgieHW0ulgpj5jDDqG9nura xr0QPnaeJH58Q0hRzvL0bZeRxZr4YFFeZMXCHwZ3bwYwWzTDCXw3vuLtJFx7xLD+PRkB 0m9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zM8FsXiM9O4eBZdkXaqFVNn1tTornIe046XH9M/vUAo=; b=NfjZbjSlHEsdArNpfdORAO9s7P2vOubs4XRX9VDlFV+zMygjGIFs+DLA3ijLIJDGPD 2Eszt4BIhBgFGujZMP4YGgmQWFZoOwcbnv1r9iN1KJ+joEY9CweNCNy39Cy9CW/0E5hB RYNiWprIS73OGqkNCu7Dkiv8BP7NAg8V91ici4eUBxyCeuXxx1Vv7LeYXp6/bJOBjpaw NUTr2O9g43P8eJvt4/K33zGtivqTDJOb6rkw65zNkftOy6lpAhbhUG1JjD/V+zl4KEH/ tMsr6F3NuBVpc8uMEXvGT8dTxiCA7brs2+nmHS1cxhjpNuI07Ocag/wfMP9CHnLnnkD9 bEFQ== X-Gm-Message-State: AOAM5300wcDp1VdqALNZx6cZ7L7Kj8mL9+7lDYvBT9oHLMBMs93270Yw yXP05mrfUSP+QfTfUkUHLSwuwA== X-Google-Smtp-Source: ABdhPJwbRo5NrwKJhg2n6ORF2bczxZ4tl+VhEo+No1jKxRFo79yONd7Liw3MJQ42pjX/XDzUkco6OQ== X-Received: by 2002:a7b:c30b:: with SMTP id k11mr1747912wmj.49.1631670640385; Tue, 14 Sep 2021 18:50:40 -0700 (PDT) Received: from bismarck.berto.se (p54ac5892.dip0.t-ipconnect.de. [84.172.88.146]) by smtp.googlemail.com with ESMTPSA id k17sm3486863wmj.0.2021.09.14.18.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 18:50:40 -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?= , Jacopo Mondi Subject: [PATCH v2 2/2] media: rcar-csi2: Serialize access to set_fmt and get_fmt Date: Wed, 15 Sep 2021 03:50:13 +0200 Message-Id: <20210915015013.3169934-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210915015013.3169934-1-niklas.soderlund+renesas@ragnatech.se> References: <20210915015013.3169934-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 Reviewed-by: Kieran Bingham --- 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; }