Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1033081pxb; Tue, 9 Nov 2021 04:08:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdc93ZH8p1f4fSCabX/yPdfKxLMjJiZIzVy3uaFb5n4NAB+pJcuum+6MOMXbkyXlLni8br X-Received: by 2002:a05:6e02:144b:: with SMTP id p11mr4604231ilo.70.1636459736760; Tue, 09 Nov 2021 04:08:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636459736; cv=none; d=google.com; s=arc-20160816; b=D4Q/19K9Kod6Zy86WtW4ZKzBwpNoR6Zz5zRvlbdgGroKZi5tJOBSBfrALe7UpTSxgJ cwFjD2mi3I5UchxWvFLh/mTSmPnRFqY34PoEP+r+UYZ55kDAqPG2GugnbGk7t8wQnnrg tAp1hQgjSNH+ovuRyothbGarCT9avLjg+GOWHHzI2YZxm08MXUFl1IJwMJtrao3a+2jv qgfT9kSOvFk/dpKCnwJYaiwZvltujnKoy5ZWg0rszL7/oyx7VSjCx/8RI3fTgMqvqABX xn7mHV7pc6e55MjvR96Ji7pFmI/M20m8sY0bxYRoZ8m94LsMkbJSea+hEXr/oapdJq5S +51A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jnvMJyTad/i5hrdWPRI44xvz6ZDlr5LJeQN7ulJhBLY=; b=Bg4HvwVQC5TF8i9CJmMNHhX+nlct1xkOeqaP2wfe7jRLLdrntTeIOEuTLzfvUee09f AN4VnotvYYVxDZURG/gpAKQ+lc544Dwc5+Q2+WSS1Tdzb0tPhSV36u4/J4kzlahhhU4C dcyEUbvsu6TVgvFwaD8qBX4hvB1l6Pc8tVU71Z6/Il59aBV0lt+lZ2+q8upoU7PDKg1h XWWCam+ELO1RUsCngAPWscAQ8Xmw4QhZ0LOqn+nLRryketmitfdpPMLPkcbYqUTCQCos 0QtzNW1RCPmas3x3OFnDDo7TTSh4//rKgQFupsQQdTHvQ6KIm/SjYW0wLguUkA/bwnXY 9qww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si6099861jad.28.2021.11.09.04.08.41; Tue, 09 Nov 2021 04:08:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242422AbhKIDPS (ORCPT + 99 others); Mon, 8 Nov 2021 22:15:18 -0500 Received: from twspam01.aspeedtech.com ([211.20.114.71]:7769 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235901AbhKIDPR (ORCPT ); Mon, 8 Nov 2021 22:15:17 -0500 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 1A92nC39061473; Tue, 9 Nov 2021 10:49:12 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from JammyHuang-PC.aspeed.com (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 9 Nov 2021 11:12:27 +0800 From: Jammy Huang To: , , , , , , , , CC: Paul Menzel Subject: [PATCH v2] media: aspeed: Update signal status immediately to ensure sane hw state Date: Tue, 9 Nov 2021 11:12:27 +0800 Message-ID: <20211109031227.1792-1-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.2.115] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 1A92nC39061473 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If res-chg, VE_INTERRUPT_MODE_DETECT_WD irq will be raised. But v4l2_input_status won't be updated to no-signal immediately until aspeed_video_get_resolution() in aspeed_video_resolution_work(). During the period of time, aspeed_video_start_frame() could be called because it doesn't know signal becomes unstable now. If it goes with aspeed_video_init_regs() of aspeed_video_irq_res_change() simultaneously, it will mess up hw state. To fix this problem, v4l2_input_status is updated to no-signal immediately for VE_INTERRUPT_MODE_DETECT_WD irq. Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver") Signed-off-by: Jammy Huang Acked-by: Paul Menzel --- v2: - update subject and commit message --- drivers/media/platform/aspeed-video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index 1ade264a8b69..3facd7ecc1a1 100644 --- a/drivers/media/platform/aspeed-video.c +++ b/drivers/media/platform/aspeed-video.c @@ -762,6 +762,8 @@ static void aspeed_video_irq_res_change(struct aspeed_video *video, ulong delay) set_bit(VIDEO_RES_CHANGE, &video->flags); clear_bit(VIDEO_FRAME_INPRG, &video->flags); + video->v4l2_input_status = V4L2_IN_ST_NO_SIGNAL; + aspeed_video_off(video); aspeed_video_on(video); aspeed_video_bufs_done(video, VB2_BUF_STATE_ERROR); @@ -1889,7 +1891,6 @@ static void aspeed_video_resolution_work(struct work_struct *work) struct delayed_work *dwork = to_delayed_work(work); struct aspeed_video *video = container_of(dwork, struct aspeed_video, res_work); - u32 input_status = video->v4l2_input_status; /* Exit early in case no clients remain */ if (test_bit(VIDEO_STOPPED, &video->flags)) @@ -1902,8 +1903,7 @@ static void aspeed_video_resolution_work(struct work_struct *work) aspeed_video_get_resolution(video); if (video->detected_timings.width != video->active_timings.width || - video->detected_timings.height != video->active_timings.height || - input_status != video->v4l2_input_status) { + video->detected_timings.height != video->active_timings.height) { static const struct v4l2_event ev = { .type = V4L2_EVENT_SOURCE_CHANGE, .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION, -- 2.25.1