From patchwork Tue Aug 22 16:16:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 715957 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 21B83EE49B0 for ; Tue, 22 Aug 2023 16:16:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237575AbjHVQQj (ORCPT ); Tue, 22 Aug 2023 12:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237586AbjHVQQh (ORCPT ); Tue, 22 Aug 2023 12:16:37 -0400 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 6584ECEE for ; Tue, 22 Aug 2023 09:16:34 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31781e15a0cso4205840f8f.3 for ; Tue, 22 Aug 2023 09:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692720993; x=1693325793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X48QdO7ZGmP4DgIzy4AepzJ0PTfhLqJqNGkl4UYymyI=; b=gYyBA5s0dymZ6dhLnxYaGLZWFiorzQMmIfddojMH5qoC9CBVbRdCcDmIiww0HORiik wZK+2IzBc2mCkj8606O2kct0ENdqY8kbBAZeOHUxKzmyqY55xy9pwI59fXCxtzwH8pMd ivsQuoIbf+b+pgcPwUvvNe0QaKfyz3PBokE2hn2PjpvIHNAaDnorwdnccqX6AJZputdF 8Ae0a0L0/fAoK4THeFHyTK3HQcUcZClKAt9G0SwntUy+mkKlbwAL67gzWk0eXJTJ0kEw KhKAO98A605I+p4J8jlPQObuwwPjs/etlq3Sy2QuCAkdS0mNWQNXexfB51ulTK88SX5r tkUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692720993; x=1693325793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X48QdO7ZGmP4DgIzy4AepzJ0PTfhLqJqNGkl4UYymyI=; b=dhvZ6Xv8YiH/FfDCDE9pUdZfyIBcvTyOlQWuV5kMp2iet6x0As/Fzb/L+E+G9M89u+ eItHQPCoPjrjMNDu+UR2X3z752KGld0v+savrB6FIaz7WOByEfU1XAXmCP5+P41gcp+F YzFE5MwPFvaEB/KxlKaAoSncYN7aCGlSqKELNoUh7TnpTnY1Ch2UZtiPqvi0eEGGsRzA gFo6uJwj427GIu9vO6rYhGBsOWfoxNaS3FTR2/c0+LGbE4Jr0tXG6ati8TLvw6p3wTl3 fI+Azz/ZoRkuQXA8Zh4fCPR+4tKeIvtqeEY1rUAhVqxwHSN+D3nWeZsWTwtKzG9iE7Z0 Uzjg== X-Gm-Message-State: AOJu0YxBq62stedQ3qgPGTQ1lAVtNMaL79XVIEvx/yGeIUSdb4NjVZnY +6AdgqVKbVDKlfdoVvZ2zVrJyQ== X-Google-Smtp-Source: AGHT+IGIMDF8lppDQgxjPIAKW1ri+H7YPka52vp9cQO/xOhvri9kKzihS3t11gTZtEk1pR3zIU0FZg== X-Received: by 2002:a5d:6a07:0:b0:314:415:cbf5 with SMTP id m7-20020a5d6a07000000b003140415cbf5mr7817538wru.51.1692720992993; Tue, 22 Aug 2023 09:16:32 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id t23-20020a7bc3d7000000b003fe1fe56202sm16516130wmj.33.2023.08.22.09.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 09:16:31 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v1 4/9] media: qcom: camss: Fix VFE-17x vfe_disable_output() Date: Tue, 22 Aug 2023 17:16:15 +0100 Message-ID: <20230822161620.1915110-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230822161620.1915110-1-bryan.odonoghue@linaro.org> References: <20230822161620.1915110-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There are two problems with the current vfe_disable_output() routine. Firstly we rightly use a spinlock to protect output->gen2.active_num everywhere except for in the IDLE timeout path of vfe_disable_output(). Even if that is not racy "in practice" somehow it is by happenstance not by design. Secondly we do not get consistent behaviour from this routine. On sc8280xp 50% of the time I get "VFE idle timeout - resetting". In this case the subsequent capture will succeed. The other 50% of the time, we don't hit the idle timeout, never do the VFE reset and subsequent captures stall indefinitely. Rewrite the vfe_disable_output() routine to - Quiesce write masters with vfe_wm_stop() - Set active_num = 0 remembering to hold the spinlock when we do so followed by - Reset the VFE Testing on sc8280xp and sdm845 shows this to be a valid fix. Fixes: 7319cdf189bb ("media: camss: Add support for VFE hardware version Titan 170") Cc: stable@vger.kernel.org Signed-off-by: Bryan O'Donoghue --- .../media/platform/qcom/camss/camss-vfe-170.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 02494c89da91c..ae9137633c301 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -500,28 +500,15 @@ static int vfe_disable_output(struct vfe_line *line) struct vfe_output *output = &line->output; unsigned long flags; unsigned int i; - bool done; - int timeout = 0; - - do { - spin_lock_irqsave(&vfe->output_lock, flags); - done = !output->gen2.active_num; - spin_unlock_irqrestore(&vfe->output_lock, flags); - usleep_range(10000, 20000); - - if (timeout++ == 100) { - dev_err(vfe->camss->dev, "VFE idle timeout - resetting\n"); - vfe_reset(vfe); - output->gen2.active_num = 0; - return 0; - } - } while (!done); spin_lock_irqsave(&vfe->output_lock, flags); for (i = 0; i < output->wm_num; i++) vfe_wm_stop(vfe, output->wm_idx[i]); + output->gen2.active_num = 0; spin_unlock_irqrestore(&vfe->output_lock, flags); + vfe_reset(vfe); + return 0; }