Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp56425iof; Sun, 5 Jun 2022 20:59:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEA8oN7Z9+U/3QKg1WgxtiG/t2cp+rXpEKVz18x2GlwAicpIl/w+WFIc+bVyfKMRwWRCkN X-Received: by 2002:a17:902:cf0c:b0:15b:63a4:9f47 with SMTP id i12-20020a170902cf0c00b0015b63a49f47mr22256902plg.1.1654487976400; Sun, 05 Jun 2022 20:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654487976; cv=none; d=google.com; s=arc-20160816; b=bwzQe9+qytyc8K7x/aWk5TgrLrzEVr3GYFH2989aG+yt8svpUHE/axaAEaj/cy+9nd MfbjgDyQM4FFRFoAlcC3mjvshM7E+YxEPYtWv46AU5PeYGwd7ein8GLl3FgfXBlCZRWJ AkJN5loZyIZKeZd/vjTOEcswn/LHeBMKVb7hC8cYPor9/FHQmdrpzlHG5gID5pLn4hti vByp6BLmc1Gu8x5BcjqvAQnL7W4IQqAJjSGu01rOmMC5A0Mg9f1TqRVYSoyWiziuTFst DapI8IkbRD744xqb6MsOtoXGxYSY30Ej8Mle5gNY4ZSa0jvixRa4TtZJzxjwwsemIpuv MvRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:to:subject:message-id :date:from:in-reply-to:references:mime-version:dkim-signature; bh=dIJZ7XsK+jUGLZjZMwQas9x7LlLeZtDPahCJOQk733E=; b=Kwnd487L5+y7NtyOvkdKoT8pRIScj4GJmgWEauyKiJmUqSAfrWv5nncdk1y6pONBqK oXlANy5tQ9JuIb2fcMjDyQFWm42OWNSOv2jUOminxiQB3U7TtglyqBPV0TPDT6XT01NU es9CBuG3ERPxQHEyJ7AFQZG/Gls/jqB94lW8Pd319Ke9Nd8q/IMMUaRhDjxKCP21aozu mfQGze05a98guub8QGosjbvZ9pQb/Alj537FaxPT97NSxNnxezqFItiJjHGeY5q9w6He LlevCExGnNkaWx70OiBacU78JATzvtWy69j7qENH2GSt6yfUrr3qAjexGNvaONq2AXVr 18UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jkyBTOxx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u16-20020a631410000000b003fb92eb8e97si18527456pgl.119.2022.06.05.20.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 20:59:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jkyBTOxx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1930F546B9; Sun, 5 Jun 2022 20:45:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241510AbiFCHQ1 (ORCPT + 99 others); Fri, 3 Jun 2022 03:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbiFCHQY (ORCPT ); Fri, 3 Jun 2022 03:16:24 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 005832D1FF for ; Fri, 3 Jun 2022 00:16:22 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id o73so379758qke.7 for ; Fri, 03 Jun 2022 00:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=dIJZ7XsK+jUGLZjZMwQas9x7LlLeZtDPahCJOQk733E=; b=jkyBTOxxEkc5EnW3kRRScGh7EhoEvpA+BVddYFEzXQfPdZsvrkd7HA26dG0iBYT7xJ 5TFos+OhidJKPZJSley/1Kzprhptn+qGCJ8tLF5rnz24g+LM8fcSXLe/1BKy8f9mqCDn 7rB68U2s0KqnAsp8+emdCPCEA8j/dea+a+PtHqUYJxWlbM1lsDwJhobYHUY3HR6FMj7J gqI4fUkcBQ//TQjlMEiiAEwGsbPiXUpC/t/W4TyDquUD5OKnlYSoBbADKWXOrw3zYZNV 89iJsBtwq+W/zgn6uACJ8+FvGQJiaCCv4qSlUC1OXfG2cDy3aHd3Fe4CmO+Ew6fbIJ2r uS4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=dIJZ7XsK+jUGLZjZMwQas9x7LlLeZtDPahCJOQk733E=; b=aMdg9PZy7Z7PlgQjxe4IiZl5GHZXk8caj7hhg5nT3dhQvwnOQVy/+wNKZydSrCBFEM dxcydYY7gwvqkgvIvFxqroFmwys6ugIxvY0M6LmtSm989c+PRGErTjhhFEbcrKtFDhpO 6N8pMCxifNq8pBh4jaRnw6Cz7a2VBddo/ZIIVSlY2G9xpLL+5fxo4tl6P1q/cuBJxPOl U4CDKr4IigrtDL9YaY79BZXbpgU4RZzlEctT7v0BmkCyIlZIwE/ZY1l2rV9S0+upCIBy wQo9g3yq5WlGIysvFHGe2LAV2sboNQfya5XL92GTYpUks3cDmYILvMFG4m+b8ZWWnFEH PibQ== X-Gm-Message-State: AOAM531AJMs9jwJC/wz60djcQrQiGyRUD2g/m3s4fih32J/OZQGO+fkf 9D1QFjBAW1/oVkUlO0L02Rf7JX5ulroRq+tBNj4= X-Received: by 2002:a05:620a:11b6:b0:6a3:2569:7a4f with SMTP id c22-20020a05620a11b600b006a325697a4fmr5527968qkk.666.1654240582110; Fri, 03 Jun 2022 00:16:22 -0700 (PDT) MIME-Version: 1.0 References: <20220602180118.66170-1-r.stratiienko@gmail.com> <20220602215547.scsabzbeztgduaj3@core> In-Reply-To: <20220602215547.scsabzbeztgduaj3@core> From: Roman Stratiienko Date: Fri, 3 Jun 2022 10:16:10 +0300 Message-ID: Subject: Re: [PATCH] drm/sun4i: sun8i: Add the ability to keep scaler enabled for VI layer To: =?UTF-8?Q?Ond=C5=99ej_Jirman?= , Roman Stratiienko , mripard@kernel.org, wens@csie.org, =?UTF-8?Q?Jernej_=C5=A0krabec?= , airlied@linux.ie, Daniel Vetter , Samuel Holland , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ondrej, =D0=BF=D1=82, 3 =D0=B8=D1=8E=D0=BD. 2022 =D0=B3. =D0=B2 00:55, Ond=C5=99ej = Jirman : > > Hi Roman, > > On Thu, Jun 02, 2022 at 06:01:18PM +0000, Roman Stratiienko wrote: > > According to DE2.0/DE3.0 manual VI scaler enable register is double > > buffered, but de facto it doesn't, or the hardware has the shadow > > register latching issues which causes single-frame picture corruption > > after changing the state of scaler enable register. > > > > Allow the user to keep the scaler always enabled, preventing the UI > > glitches on the transition from scaled to unscaled state. > > > > NOTE: > > UI layer scaler has more registers with double-buffering issue and can'= t > > be workarounded in the same manner. > > > > You may find a python test and a demo video for this issue at [1] > > Isn't this an issue with kernel driver not waiting for DE2 FINISH IRQ, bu= t > for VBLANK IRQ from TCON instead, before allowing to write new set of reg= ister > values? No, DE2 FINISH IRQ is triggered just some micro or even nanoseconds earlier from vblank IRQ (I have checked it using tracing). I can guess MISSION FINISH IRQ triggered when the last line is being sent to the line buffer cache (in between of the mixer output and tcon input). But VBLANG IRQ triggers when the last line is being sent to the display + hfront porch time + hsync time. I have also tried scheduling the register updates that have double-buffering issues at VBLANK irq. And such a solution fixes the test for both VI and UI scalers. But under high loads there are still glitches happening. This patch solves the issue for both test and high load conditions. (but for VI only) I'll post my solution with a deferred scaling register update soon. > > https://megous.com/dl/tmp/4fe35b3fc72ee7de.png > > I haven't checked if FINISH flag is set at time of VBLANK interrupt, so m= aybe > this is not the issue. > > regards, > o. > > > [1]: https://github.com/GloDroid/glodroid_tests/issues/4 > > Signed-off-by: Roman Stratiienko > > --- > > drivers/gpu/drm/sun4i/sun8i_mixer.c | 12 ++++++++++++ > > drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 4 +++- > > 2 files changed, 15 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4= i/sun8i_mixer.c > > index 71ab0a00b4de..15cad0330f66 100644 > > --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c > > +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c > > @@ -27,6 +27,18 @@ > > #include "sun8i_vi_layer.h" > > #include "sunxi_engine.h" > > > > +/* According to DE2.0/DE3.0 manual VI scaler enable register is double > > + * buffered, but de facto it doesn't, or the hardware has the shadow > > + * register latching issues which causes single-frame picture corrupti= on > > + * after changing the state of scaler enable register. > > + * Allow the user to keep the scaler always enabled, preventing the UI > > + * glitches on the transition from scaled to unscaled state. > > + */ > > +int sun8i_vi_keep_scaler_enabled; > > +MODULE_PARM_DESC(keep_vi_scaler_enabled, > > + "Keep VI scaler enabled (1 =3D enabled, 0 =3D disabled (= default))"); > > +module_param_named(keep_vi_scaler_enabled, sun8i_vi_keep_scaler_enable= d, int, 0644); > > + > > struct de2_fmt_info { > > u32 drm_fmt; > > u32 de2_fmt; > > diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/s= un4i/sun8i_vi_layer.c > > index 662ba1018cc4..f005ab883503 100644 > > --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c > > +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c > > @@ -17,6 +17,8 @@ > > #include "sun8i_vi_layer.h" > > #include "sun8i_vi_scaler.h" > > > > +extern int sun8i_vi_keep_scaler_enabled; > > + > > static void sun8i_vi_layer_enable(struct sun8i_mixer *mixer, int chann= el, > > int overlay, bool enable, unsigned int = zpos) > > { > > @@ -149,7 +151,7 @@ static int sun8i_vi_layer_update_coord(struct sun8i= _mixer *mixer, int channel, > > */ > > subsampled =3D format->hsub > 1 || format->vsub > 1; > > > > - if (insize !=3D outsize || subsampled || hphase || vphase) { > > + if (insize !=3D outsize || subsampled || hphase || vphase || sun8= i_vi_keep_scaler_enabled) { > > unsigned int scanline, required; > > struct drm_display_mode *mode; > > u32 hscale, vscale, fps; > > -- > > 2.30.2 > >