Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2481452rdb; Mon, 5 Feb 2024 07:54:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXvGQpA4DkhbVOUTzcOjCNRdn1WLllQu3al98t0NOFVf4uujNmzmoP3wP4ZIOuCXhRGK/8 X-Received: by 2002:a05:620a:2949:b0:785:403b:7ab9 with SMTP id n9-20020a05620a294900b00785403b7ab9mr130291qkp.16.1707148467900; Mon, 05 Feb 2024 07:54:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707148467; cv=pass; d=google.com; s=arc-20160816; b=Ar6oPVs8p59UEzHhTH38FQLxALDaMG5SVj1kaHJHMzrOf/0UkaVJ7ceywMVhz6afUs Plp7aN9gw5kgxfbwIU8Hwhqk6hWfDfL8XxCtzBEc2wsz/DC27s/gmHuTaGTH/rsDV6Ez nnXdqyleJnUizg67vAEwxDJayHpzjfRKPHzj5rzHfk1ePHVZ3XgBluXevlMT+3wyeR5y S+GzYDe3Wnx5EexmcF4ozHSZg2g1kK13YuOp61FaM2aIhh3Ez+dkCAuVZAqfmRIBLv0P CilSUymdZ3ro/tpKeuF3qh5Npp90E5CQXoYDZ8NTAWXyjROxibAtqFpNx/6E4o/ZdZBP 03Ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=zS780vlGntYZacKPlHqlgwc63LainHxFGWozCOCw+ag=; fh=NXr45SqzM0VBfamBX6nyYEbzurTKQ4M9Ke23edmTEZ8=; b=gdXQ7wnv9FC05VLBfZVM6xm3TS2cCYmUl6Q+lpQi77H5vGI4Aj9/v/KyEsVFaB5aNn 2oOGSrwu95eA4AvIWUOzTxZcWR5fZaMkkr8s0srzfSmebyVS6aFDwTfk3PN53YXWPxy/ jMvyKRP77YQipYM3hb3cBmJr0D5d+jr1JtdPGISJskIQah4VWmloAiMrOvWgrv/F9h8s JYEi0r0z1HgDf/v/vpPSY/lLumwrSC7PerD8k3pMIueIwyD/xD/FJOfPyeYTJdY7hp99 SlXbv/RHSJCco+yY25r2HK34IgN8BeE7lXHsJ6ZlHU5xx06WLh+T0+7SmrNxh2J+jAl7 jqgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=FobrK0UM; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-52959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=1; AJvYcCXMD4bCv/2MtxAW+zM/KWNsXifo5l/tQUboloUWw56JZH+NxhqBAkB5uSehVyxSOIUm7pK2SS+nybDSBNiwU9OQFvbZueZebakDFBCbxw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v28-20020a05620a123c00b007858821163csi77387qkj.660.2024.02.05.07.54.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 07:54:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=FobrK0UM; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-52959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 989331C22119 for ; Mon, 5 Feb 2024 15:54:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C7D62E634; Mon, 5 Feb 2024 15:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="FobrK0UM" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CAC032C93; Mon, 5 Feb 2024 15:54:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707148460; cv=none; b=jJTwhFX0XUqZBrTGFrHPYxDKkoKAeTxuZnUq8MTi8XzN5JR3PolYLnWAQG4cKDZVLKUTA2TJqwoP7BqvxEMXGr86rpcipHZnUxuXVsssOz40rtqzgWq5uZtxkvzgkifXcm1nzY4F3Pa/Tc0SPL5ZQIAjjtU1m+R8cbPI8YnGFL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707148460; c=relaxed/simple; bh=b/Dem0ECsfMrCXdGfQp14Mkyx8f0VspGV1icFGlRQeA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VKtvsVJse4xwigLZifVlKgh92N4G40V4tIHhC0Gu99AT+nuKPKQn4XUs2giH/eliOnof5QETQMTITR6shU1a4QlnyfzMcWpDDJhEAiq5GpTPR0xzbVR/SRT7qk5Z5zky7b575Ho+JHtFR/f2YebNTbbdR28Ttd6Al7q6sAWo5L8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=FobrK0UM; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1707148447; bh=b/Dem0ECsfMrCXdGfQp14Mkyx8f0VspGV1icFGlRQeA=; h=Date:From:To:Cc:Subject:X-My-GPG-KeyId:References:From; b=FobrK0UMQyhHSrlREwoLvPtAVptvi2xFUmDJg36QNbRUJrs/xpegkCawOJQT74A6E 9oPkfNja6Z7Ij2bGtj+KsGR/kId4f8a376BX1e2miJcsdLuRJoT9Bhmj6k3eO6exlc ct90WiwR4YUPjLuWr5oX1IOv4M4X5tjcaxHchuzE= Date: Mon, 5 Feb 2024 16:54:07 +0100 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: Frank Oltmanns Cc: Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Guido =?utf-8?Q?G=C3=BCnther?= , Purism Kernel Team , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org Subject: Re: [PATCH v2 0/6] Pinephone video out fixes (flipping between two frames) Message-ID: Mail-Followup-To: =?utf-8?Q?Ond=C5=99ej?= Jirman , Frank Oltmanns , Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Guido =?utf-8?Q?G=C3=BCnther?= , Purism Kernel Team , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org X-My-GPG-KeyId: EBFBDDE11FB918D44D1F56C1F9F0A873BE9777ED References: <20240205-pinephone-pll-fixes-v2-0-96a46a2d8c9b@oltmanns.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240205-pinephone-pll-fixes-v2-0-96a46a2d8c9b@oltmanns.dev> On Mon, Feb 05, 2024 at 04:22:23PM +0100, Frank Oltmanns wrote: > On some pinephones the video output sometimes freezes (flips between two > frames) [1]. It seems to be that the reason for this behaviour is that > PLL-MIPI, PLL-GPU and GPU are operating outside their limits. > > In this patch series I propose the followin changes: > 1. sunxi-ng: Adhere to the following constraints given in the > Allwinner A64 Manual regarding PLL-MIPI: > * M/N <= 3 > * (PLL_VIDEO0)/M >= 24MHz > * 500MHz <= clockrate <= 1400MHz > > 2. Choose a higher clock rate for the ST7703 based XDB599 panel, so > that the panel function well with the Allwinner A64 SOC. PLL-MIPI > must run between 500 MHz and 1.4 GHz. As PLL-MIPI runs at 6 times > the panel's clock rate, we need the panel's clock to be at least > 83.333 MHz. > > 3. Increase the minimum frequency in the A64 DTS OPPs from 120 MHz to > 192 MHz. This further reduces the issue. > > Unfortunately, with these patches the issue [1] is not completely gone, > but becomes less likely. > > Note, that when pinning the GPU to 432 MHz the issue completely > disappears for me. I've searched the BSP and could not find any > indication that supports the idea of having the three OPPs. The only > frequency I found in the BPSs for A64 is 432 MHz, that has also proven > stable for me. So, while increasing the minimum frequency to 192 MHz > reduces the issue, should we maybe instead set the GPU to a fixed 432 > MHz instead? Per A64 User Manual 1.1 page 81: (9). Clock output of PLL_GPU can be used for GPU;and dynamic frequency scaling is not supported; Also sunxi-ng clk driver does apply NM factors at once to PLL_GPU clock, which can cause sudden frequency increase beyond intended output frequency, because division is applied immediately while multiplication is reflected slowly. Eg. if you're changing divider from 7 to 1, you can get a sudden 7x output frequency spike, before PLL VCO manages to lower the frequency through N clk divider feedback loop and lock on again. This can mess up whatever's connected to the output quite badly. You'd have to put logging on kernel writes to PLL_GPU register to see what is written in there and if divider is lowered significantly on some GPU devfreq frequency transitions. It's also unclear what happens when FRAC_CLK_OUT or PLL_MODE_SEL changes. Maybe not much because M is supposed to be set to 1, but you still need to care when enabling fractional mode, and setting M to 1 because that's exactly the bad scenario if M was previously higher than 1. It's tricky. Having GPU module clock gated during PLL config changes may help! You can do that without locking yourself out, unlike with the CPU PLL. There's a gate enable bit for it at GPU_CLK_REG.SCLK_GATING. (page 122) Kind regards, o. > I very much appreciate your feedback! > > [1] https://gitlab.com/postmarketOS/pmaports/-/issues/805 > > Signed-off-by: Frank Oltmanns > --- > Changes in v2: > - dts: Increase minimum GPU frequency to 192 MHz. > - nkm and a64: Add minimum and maximum rate for PLL-MIPI. > - nkm: Use the same approach for skipping invalid rates in > ccu_nkm_find_best() as in ccu_nkm_find_best_with_parent_adj(). > - nkm: Improve names for ratio struct members and hence get rid of > describing comments. > - nkm and a64: Correct description in the commit messages: M/N <= 3 > - Remove patches for nm as they were not needed. > - st7703: Rework the commit message to cover more background for the > change. > - Link to v1: https://lore.kernel.org/r/20231218-pinephone-pll-fixes-v1-0-e238b6ed6dc1@oltmanns.dev > > --- > Frank Oltmanns (6): > clk: sunxi-ng: nkm: Support constraints on m/n ratio and parent rate > clk: sunxi-ng: a64: Add constraints on PLL-MIPI's n/m ratio and parent rate > clk: sunxi-ng: nkm: Support minimum and maximum rate > clk: sunxi-ng: a64: Set minimum and maximum rate for PLL-MIPI > drm/panel: st7703: Drive XBD599 panel at higher clock rate > arm64: dts: allwinner: a64: Fix minimum GPU OPP rate > > arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 4 ++-- > drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 14 +++++++---- > drivers/clk/sunxi-ng/ccu_nkm.c | 34 +++++++++++++++++++++++++++ > drivers/clk/sunxi-ng/ccu_nkm.h | 4 ++++ > drivers/gpu/drm/panel/panel-sitronix-st7703.c | 14 +++++------ > 5 files changed, 56 insertions(+), 14 deletions(-) > --- > base-commit: 059c53e877ca6e723e10490c27c1487a63e66efe > change-id: 20231218-pinephone-pll-fixes-0ccdfde273e4 > > Best regards, > -- > Frank Oltmanns >