From patchwork Mon Nov 8 16:02:17 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: 12608773 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C24FC433F5 for ; Mon, 8 Nov 2021 16:02:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3316961279 for ; Mon, 8 Nov 2021 16:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239192AbhKHQFf (ORCPT ); Mon, 8 Nov 2021 11:05:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239380AbhKHQFf (ORCPT ); Mon, 8 Nov 2021 11:05:35 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 670A3C061746 for ; Mon, 8 Nov 2021 08:02:50 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id i5so27810089wrb.2 for ; Mon, 08 Nov 2021 08:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m1WqzcjlgMOIezM3Do4q/Hqs3GubepKnTprvWPIb2Vg=; b=sA/zVbmFu61dEZxvBhXBQWZcR+W4FNHy55CU08xUYyQQqmDEUmZ6Jeh3PMJeeLz71f xcioG9il13KMQhbAQoI8QuUL5clyQjeGEA9H+U+10hS2+M8QL25G6AKWegWkf6QmWWf6 Gm7bJdU9TUWei9s/jENpgWFGpulPfSl5DYevmZvvWYOw36xxmMAJF6Wq3zLqg8X9JU5R wqgWzGa9T/eisPDRt6gmIJ16JaKZuCDh0tc+9kB8UuwG7PQjM7POWRu6GVKDQabe+IAu nSJZ+lgxz55mAeNZvQGFDCV1LG8htD9EfqY+cO9+cyMJJwy9ndLDCtAK/DnfMyAJaz4t fXyg== 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=m1WqzcjlgMOIezM3Do4q/Hqs3GubepKnTprvWPIb2Vg=; b=qz3Rmpft1qGwewWofQ/aQw7N9pcemPmZ08EyCVodNTSpEI/GQrlE3+yiVPm9ayw05y 3UCDyDLmylUnG2iS8GRV3TZ/0D3jYx6+3+Bo04TYqFUY3s56OtEvZQhWgoL90vxFM4yC No1lcCnCwlxaF6bPzymtxkO5g1JHyHGxrSLTwxI2Ia/UfkHZ78dLjdd7P2mx69p0Q3G1 8vUw6OTzH6b5nfgSsRSfcpbYx9teiAwwH71ndb2HHzagy/Qsh8bRyHQCeGxc4IUl9VB+ CPMStgSkhSOn96e1sadNQSGrgHbtA18s6ui5wjmbtTnVnsZkYo083rJr4n5zJ9e1Be30 FSvg== X-Gm-Message-State: AOAM532Gajbf08z/GtfFSIa2222SF6EMakbYip8oogIt7LdsfL+FCMhu AWg+KQtC+32DbKFbXYJ0VA3iszhKLQnBghny X-Google-Smtp-Source: ABdhPJzcHbVKB3IgU5vC1uiyzzMhri/gd0h3nG9NyH8NzUyg74mSz/ZHlH15/grVx6pPxl72ytofpw== X-Received: by 2002:adf:e8c8:: with SMTP id k8mr225459wrn.135.1636387369022; Mon, 08 Nov 2021 08:02:49 -0800 (PST) Received: from bismarck.berto.se (p54ac5892.dip0.t-ipconnect.de. [84.172.88.146]) by smtp.googlemail.com with ESMTPSA id d16sm12703176wmb.37.2021.11.08.08.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 08:02:48 -0800 (PST) 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/4] media: rcar-vin: Free buffers with error if hardware stop fails Date: Mon, 8 Nov 2021 17:02:17 +0100 Message-Id: <20211108160220.767586-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211108160220.767586-1-niklas.soderlund+renesas@ragnatech.se> References: <20211108160220.767586-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The driver already have logic to detect if it fails to stop properly and report this error to the user. The driver however did not report the unused buffers or buffers given to the hardware (if any) with an error, the buffers where instead returned to user-space in the active state. Build on the existing detection of the error condition and correctly return the buffers with an error if it triggers. Signed-off-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-dma.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index 25ead9333d0046e7..79bb9081853f8781 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -1371,6 +1371,16 @@ void rvin_stop_streaming(struct rvin_dev *vin) spin_unlock_irqrestore(&vin->qlock, flags); + /* If something went wrong, free buffers with an error. */ + if (!buffersFreed) { + return_unused_buffers(vin, VB2_BUF_STATE_ERROR); + for (i = 0; i < HW_BUFFER_NUM; i++) { + if (vin->buf_hw[i].buffer) + vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf, + VB2_BUF_STATE_ERROR); + } + } + rvin_set_stream(vin, 0); /* disable interrupts */ From patchwork Mon Nov 8 16:02:18 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: 12608771 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5519C4332F for ; Mon, 8 Nov 2021 16:02:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C7556109E for ; Mon, 8 Nov 2021 16:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239435AbhKHQFg (ORCPT ); Mon, 8 Nov 2021 11:05:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239433AbhKHQFf (ORCPT ); Mon, 8 Nov 2021 11:05:35 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE4CC061570 for ; Mon, 8 Nov 2021 08:02:50 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id d5so27772117wrc.1 for ; Mon, 08 Nov 2021 08:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=StolZF6As2JqwmKdnDrgpcrLCxn6sqYLr+z2iBrARUI=; b=Lzg9V3LwIO6BW8VHcKU+IXsxZw+mqxMRO8eTgcCvVyuyje9NQIxapwWKYGP/M4xCZF GREtinyfPzfLTOUUtax0pHMFGNyCzH2hCskcTj+opo7BlL0tIhCAeeTV5RVhprFdEgex 1DWghRYQvBqRtSDqcuzsP1K1/gUAg5ObWOlZH0EITR417zkrAdfSrOgEzkbFYu2urK+G i5Z7jCNIIPPrVN29yG9MEFmuVrZOC9MnMhDMncPe/fzW4vcVkQ6drEcBX8psisbzr1T5 B3ZJVHvUX6FUVRU3w2Dm4zaJyNpj3fxVH9Tv2t/fJj8caqlLqY3p59hgzO1lyIBjHBle bgtA== 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=StolZF6As2JqwmKdnDrgpcrLCxn6sqYLr+z2iBrARUI=; b=4/hrbqP5hlC6FMEK/3a/CgZwSIMEv6qYvoxNcDBCbt91XoRB8X6J26sR+k/PDNqC0b TL7D+2UrO+U/kT5jKJChM8mHJm//NQnMlcLJ1DVGyBsRUvhn7GFKYqW4AKow0RkiD034 vZxcsEW6oVLWSWf4WGXhoF6acU5JgNcHnzi0QbGvbYBLVwkSG9hqEbnYlOjzG+FHBA+2 H/haCHLiOMcTa6pN8lTh9PONsYoXEPZJMRY0u9nMp3P8ASM1L4yHFWTddOf88YLsWI18 LuLj1XRTrSV6IgRmyYEoPHRBpC7B+W6+5Mi54NO6cVY7a3ZgseOPdPKfmjSJ0YTDMSso Cvmg== X-Gm-Message-State: AOAM530tpQnxyVXBnrtm9lIAHyU9uE33A2ZqdUeJ04jl7Cm5H5749iVM nx+ZpFcBZRGeqEFi+zXXgFMyNQ== X-Google-Smtp-Source: ABdhPJy7LHQJ5T1HTh4q+oz4n3P6YUYylIxM0wTwWI8oE1itpbmEYXg7r9t0vXP4WQV9v/IJe4xjKA== X-Received: by 2002:adf:e7cf:: with SMTP id e15mr206664wrn.287.1636387369594; Mon, 08 Nov 2021 08:02:49 -0800 (PST) Received: from bismarck.berto.se (p54ac5892.dip0.t-ipconnect.de. [84.172.88.146]) by smtp.googlemail.com with ESMTPSA id d16sm12703176wmb.37.2021.11.08.08.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 08:02:49 -0800 (PST) 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/4] media: videobuf2: Add a transfer error event Date: Mon, 8 Nov 2021 17:02:18 +0100 Message-Id: <20211108160220.767586-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211108160220.767586-1-niklas.soderlund+renesas@ragnatech.se> References: <20211108160220.767586-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Add a new V4L2_EVENT_XFER_ERROR event to signal if a unrecoverable error happens during video transfer. The use-case that sparked this new event is to signal to the video device driver that an error has happen on the CSI-2 bus from the CSI-2 receiver subdevice. Signed-off-by: Niklas Söderlund --- Documentation/userspace-api/media/v4l/vidioc-dqevent.rst | 5 +++++ Documentation/userspace-api/media/videodev2.h.rst.exceptions | 1 + include/uapi/linux/videodev2.h | 1 + 3 files changed, 7 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/vidioc-dqevent.rst b/Documentation/userspace-api/media/v4l/vidioc-dqevent.rst index 6eb40073c906deba..84984641c9351aa9 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-dqevent.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-dqevent.rst @@ -182,6 +182,11 @@ call. the regions changes. This event has a struct :c:type:`v4l2_event_motion_det` associated with it. + * - ``V4L2_EVENT_XFER_ERROR`` + - 7 + - This event is triggered when an transfer error is detected while + streaming. For example if a unrecoverable error is detected on a video + bus in the pipeline. * - ``V4L2_EVENT_PRIVATE_START`` - 0x08000000 - Base event number for driver-private events. diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions index eb0b1cd37abd9381..7ed9884b879c888e 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -498,6 +498,7 @@ replace define V4L2_EVENT_CTRL event-type replace define V4L2_EVENT_FRAME_SYNC event-type replace define V4L2_EVENT_SOURCE_CHANGE event-type replace define V4L2_EVENT_MOTION_DET event-type +replace define V4L2_EVENT_XFER_ERROR event-type replace define V4L2_EVENT_PRIVATE_START event-type replace define V4L2_EVENT_CTRL_CH_VALUE ctrl-changes-flags diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index f118fe7a9f58d240..48d4738eb862418b 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -2373,6 +2373,7 @@ struct v4l2_streamparm { #define V4L2_EVENT_FRAME_SYNC 4 #define V4L2_EVENT_SOURCE_CHANGE 5 #define V4L2_EVENT_MOTION_DET 6 +#define V4L2_EVENT_XFER_ERROR 7 #define V4L2_EVENT_PRIVATE_START 0x08000000 /* Payload for V4L2_EVENT_VSYNC */ From patchwork Mon Nov 8 16:02:19 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: 12608769 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1EBEC43217 for ; Mon, 8 Nov 2021 16:02:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E44361279 for ; Mon, 8 Nov 2021 16:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239433AbhKHQFh (ORCPT ); Mon, 8 Nov 2021 11:05:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239413AbhKHQFg (ORCPT ); Mon, 8 Nov 2021 11:05:36 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E40AC061764 for ; Mon, 8 Nov 2021 08:02:51 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id b12so27766058wrh.4 for ; Mon, 08 Nov 2021 08:02:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qyp9SrPyLgYIMuwT9MuDBXOOdH5XssHnAfufE4fLJtg=; b=teDNng7JJhTgR6g//mAv6tFTA1F2vNBlEujo2RboVanS1aqq2v4MkPHC6ALJXenAMz rB9Vp8uLnztnLunjD05H6IQFuoXn7aUYpacPx8js0xETcPHHZcnkkykzYn0h/k3K6nzA T2wb046BpRLZD/WIFzKgqFIMPO323ntLKIMTt07jg6blQDWy2UHE4RCLsY2xu5hoICHg 0gFLKLgWHnI2Cw4X1F78xs16J0tPkIKjqjFY4Yow5pK5z2qPe4IqIEmXNtQc0tODCIUN PQOsSFAYJVUUBiWA6kugzTNlLR2XkNu2amwTQQmu1OoAGgkSgK7ryS1FxAQsqE6rMPkV VaIA== 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=qyp9SrPyLgYIMuwT9MuDBXOOdH5XssHnAfufE4fLJtg=; b=ie/Y9TwBnT+5EaA5iiF3ks3pGdLmUOxE5H7OxG60z8WbpUuUTmgiSoIpOIt6s8HIP3 dzhpFsZs2y4L0yF2mbmrBqzcbyCyiJkjST1i0YVHLAc4i9iZP/88pRJ0rn55XyoQeKf5 64nM/Kff/xgSEjy7JBLuQVsBLdK+vVG4gA/DKUe6MEfYFufWGGNnzQEbfz3e0tvH2aDO PLcm5+4fezmUNg1mCWsfbgBhb7Pss7ryc+LwXPMpSLUKlVTxcGQiOlPgmbqgLQ3Zr8kS iQr6Zkuh0xQimK6ENdt/8Tqv0+4uSEzpkLG1kUUSyNc79evciWF4FEEkAb61frW/F+A3 y5rw== X-Gm-Message-State: AOAM530d9UfELFKOJrDv8bsDstKqsXnOJaIcaYW6Q0N+tOSvocCoOfpX bMHKoFJsj/phYoJihi9tKC5qsg== X-Google-Smtp-Source: ABdhPJzgV6DxAZiDjIs+PPHKUUwVqT+TIl1sbEIpjk8sXV0LxUM75hu0sHADPa+HtDYeSpyeSGQgvg== X-Received: by 2002:a05:6000:1b8f:: with SMTP id r15mr246622wru.27.1636387370197; Mon, 08 Nov 2021 08:02:50 -0800 (PST) Received: from bismarck.berto.se (p54ac5892.dip0.t-ipconnect.de. [84.172.88.146]) by smtp.googlemail.com with ESMTPSA id d16sm12703176wmb.37.2021.11.08.08.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 08:02:49 -0800 (PST) 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 3/4] rcar-vin: Stop stream when subdevice signal transfer error Date: Mon, 8 Nov 2021 17:02:19 +0100 Message-Id: <20211108160220.767586-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211108160220.767586-1-niklas.soderlund+renesas@ragnatech.se> References: <20211108160220.767586-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org When a subdevice signals a transfer error stop the VIN in addition to informing user-space of the event. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- * Changes since v3 - Switch to new V4L2_EVENT_XFER_ERROR from V4L2_EVENT_EOS. - Call vb2_queue_error() when encountering the event. * Changes since v2 - Log using vin_dbg() instead of v4l2_info(). --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index a5bfa76fdac6e55a..bf17fdefe90aabf5 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -992,9 +992,24 @@ void rvin_v4l2_unregister(struct rvin_dev *vin) static void rvin_notify_video_device(struct rvin_dev *vin, unsigned int notification, void *arg) { + const struct v4l2_event *event; + switch (notification) { case V4L2_DEVICE_NOTIFY_EVENT: - v4l2_event_queue(&vin->vdev, arg); + event = arg; + + switch (event->type) { + case V4L2_EVENT_XFER_ERROR: + vin_dbg(vin, + "Subdevice signaled transfer error, stopping.\n"); + rvin_stop_streaming(vin); + vb2_queue_error(&vin->queue); + break; + default: + break; + } + + v4l2_event_queue(&vin->vdev, event); break; default: break; From patchwork Mon Nov 8 16:02:20 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: 12608775 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31FA2C4321E for ; Mon, 8 Nov 2021 16:02:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C9196134F for ; Mon, 8 Nov 2021 16:02:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239413AbhKHQFh (ORCPT ); Mon, 8 Nov 2021 11:05:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239389AbhKHQFg (ORCPT ); Mon, 8 Nov 2021 11:05:36 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22900C061570 for ; Mon, 8 Nov 2021 08:02:52 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id u1so27746137wru.13 for ; Mon, 08 Nov 2021 08:02:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mojgCVLJMoKThIT8DUdaUryxFtRnWF1rpJJ1434yAp0=; b=CpYHFkMqPklcIrKCPcb9eQ3PWegg8QW5dmM9XK+Q2liuQZzWtDbnCtOb9DE4AevjHS 51bnluVKvKFBF4Lj3a4NOTmBRuH3cqTwwf/aVHrq23pgc0vG/YRgv7j4sX4RtrnErI7Y 2NgjNtudKHb7D/CucFTZ5Mvpcci1aqFcjn18Hmf7TSugtkwBhCd+6nlPaKWjNyABATWS +y03y/GJGj88HM4bgdjYirt0r4OQ2c2adozYXzr1Vb9KKJMbnvpYj3fX+qrMtRqc3IrZ WJ/jYmPgopSjn9UM4KMq/ctSTMN0V4aWuJw+oVe7LPaJBxucfhDOifUllLdXISjSl9YN x00A== 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=mojgCVLJMoKThIT8DUdaUryxFtRnWF1rpJJ1434yAp0=; b=FqP0URf7zzNjtEUNICnwG22EJLWnPERxXdJDyX8Q0p22okJKl0NqnryRI0AqtFf2RY T1R6iXs3Zda8cZ54k2CD4MfYLxsWQTmovqT+F+uLzJXvphgvUsyLXR7r4TaKN5wLX8Ob uW0faY2ngt3snZOadxmq1k3VHM80QiLtmHKgAXVU688yp36DOO+vSczkNeqAWMD63QVA dotP8+V3EoqzJd3z2XMKLSMmIYlzvoTw1sYtZcYuLUXjJg46cploSpWwLliUJyzy72b1 BwFJbBZJ1q6/rYOVmrobxlDGN6MPrIBHE9PlN9jiOCS1OqqI5Eakn4bUnT8tfme1/oAn +6vg== X-Gm-Message-State: AOAM530y8yHP+6QMpoZNZmB+2Zgm0iLr1GaoLOMVSF2eSxUy478X9yQ8 aWJsJnj3oC7AobY9M6w9HHo5oA== X-Google-Smtp-Source: ABdhPJxRphq9a3euntBalVq9JviSuH8jleCNvnOHhYdStDqT3fLL+rjN7xD1FCFxzWRTqLnF9FnK8w== X-Received: by 2002:adf:eece:: with SMTP id a14mr203998wrp.333.1636387370792; Mon, 08 Nov 2021 08:02:50 -0800 (PST) Received: from bismarck.berto.se (p54ac5892.dip0.t-ipconnect.de. [84.172.88.146]) by smtp.googlemail.com with ESMTPSA id d16sm12703176wmb.37.2021.11.08.08.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 08:02:50 -0800 (PST) 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 4/4] rcar-csi2: Do not try to recover after transfer error Date: Mon, 8 Nov 2021 17:02:20 +0100 Message-Id: <20211108160220.767586-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211108160220.767586-1-niklas.soderlund+renesas@ragnatech.se> References: <20211108160220.767586-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Instead of restarting the R-Car CSI-2 receiver if a transmission error is detected, inform the R-Car VIN driver of the error so it can stop the whole pipeline and inform user-space. This is done to reflect a updated usage recommendation in later versions of the datasheet. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- * Changes since v3 - Switch to new V4L2_EVENT_XFER_ERROR from V4L2_EVENT_EOS. - Disable error interrupts after the first one to not spam the error event. * Changes since v2 - Update spelling in commit message. --- drivers/media/platform/rcar-vin/rcar-csi2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index 11848d0c4a55cb4c..427c236243a03ec2 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -902,21 +902,22 @@ static irqreturn_t rcsi2_irq(int irq, void *data) rcsi2_write(priv, INTERRSTATE_REG, err_status); - dev_info(priv->dev, "Transfer error, restarting CSI-2 receiver\n"); - return IRQ_WAKE_THREAD; } static irqreturn_t rcsi2_irq_thread(int irq, void *data) { struct rcar_csi2 *priv = data; + struct v4l2_event event = { + .type = V4L2_EVENT_XFER_ERROR, + }; - mutex_lock(&priv->lock); - rcsi2_stop(priv); - usleep_range(1000, 2000); - if (rcsi2_start(priv)) - dev_warn(priv->dev, "Failed to restart CSI-2 receiver\n"); - mutex_unlock(&priv->lock); + /* Disable further interrupts to not spam the transfer error event. */ + rcsi2_write(priv, INTEN_REG, 0); + + dev_err(priv->dev, "Transfer error detected.\n"); + + v4l2_subdev_notify_event(&priv->subdev, &event); return IRQ_HANDLED; }