Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2491553rdb; Mon, 5 Feb 2024 08:08:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5SHi7JbjjBxBZbWYeA0rSrh+X9bLgCzgSj8SElDJFNjC4CTPgQienJldFnPKFN8dpHRBX X-Received: by 2002:a17:903:94d:b0:1d9:6de3:9980 with SMTP id ma13-20020a170903094d00b001d96de39980mr12127630plb.48.1707149308325; Mon, 05 Feb 2024 08:08:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707149308; cv=pass; d=google.com; s=arc-20160816; b=LE9wpUVNSxJA3yY3JCYgi+RD3QvEZLODpz/miO4iHRqjAVCYvEmGBTd5lo6B09dveZ /1AXuP7G0vJNOiRqyHlus4nGiJflPE+sahidoQm8LAWkKkoycfWfRrUU6Ww8k7PA46CR WOMXs9VqjsY58BRo5oSP0nKhMoG8VXpstnfVRS83eUUCtcn6mX5pe99sLOAnM+GENXVK s4iN2KcydKolP1qYAumer3cr6Z4O27NMWDcounV9MBAoDlTHav/9qHwzwoeidoQGtEtU We4GFsnwYL+Ac1No8cssFzvxzX7+f8q3zrUm/E4deeDLHH9ATCBvgAa9GzYaIcr0Bm37 nS0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:mail-followup-to:message-id:subject:to:from:date :dkim-signature; bh=LKDZthTorv78A2Z4KQZqOuBVBuLeKfDoMzQ2K70jTgg=; fh=qD/+sVcvw2vmaZTgY+w+VITj/G0PXBO8qn4TsZ9vlCY=; b=Y52mxaJU/lMlPlxkrsiamMwHJR9/wvwfu17CuS0XUJiBArHlJ1w/jlN/WfBPqMhXU1 r93pmHHJacAibf2I2t58kTEy2apwGqJeIiig386eiMl5aKHBnvAXyMPz5+KxiezLEZwL v1rw1RLn0iwACmZLq7fujY0CeTflqaKqpG0NNCACoCC7FK/i4QybBx/S1zshjQqNDrpy FK4DgC2bDsuCKF0iMwo+v2u5g1T9SMmELqPQsrIjDa6ZI/uWIinfSJyOl0sGpbXnZeVx 57xL+EhYrIS0BimF91naE0Uko1tWrX93/BXzKTWGj9I7HqRiX5octCJ4t+DufL0FVlIk 7tAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=NpsUEChh; 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-52989-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52989-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; AJvYcCW+ON/jWBm1SFS8X5y3pPoavZ0Of4iyHf9QBF2ZWMeMtZwM1Dkg5g6P+Ga94rAZx3MbEx04eNT2o9stR1EfOR67OzOuYo6zKAR+2qwx0Q== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f11-20020a170903104b00b001d74cee69ebsi36630plc.450.2024.02.05.08.08.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 08:08:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52989-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=NpsUEChh; 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-52989-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52989-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DF79B28380C for ; Mon, 5 Feb 2024 16:03:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DAEE3A8F9; Mon, 5 Feb 2024 16:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="NpsUEChh" 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 8B57A32C9C; Mon, 5 Feb 2024 16:02:03 +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=1707148925; cv=none; b=mlyInoWtauKi0MJlvVgAgPbzDqpGnkNqvqMQqa0KH4NCw0DG29uCK0F5HC4cj10d44eXKDiIAB46qTsGlItjW2u74oDuAvf9cJAp+pn7fECKvSArFrco/PsbS0Y9t1aCgNCTUibsm1RQ7OEINVIqVwX26pssWlhPJ+i929tH2fg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707148925; c=relaxed/simple; bh=GZ/QrUYoWHJZzCpyI+a8pGcqG7MuwYWLC0kpCm+GmS8=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZvAOSc98qqiREGc7DWiIHbT4GwzZE7k2vJRFNWt5ano0c30csu16v4Nr2ErpnU5X+RLfQJW5vKmEm65Qmo5UXCqO/NBZNrT/444YGtDtLTPR3gGiHwJFXcdyKKG+uAqYXVXy2HsJTCCColScrRPBTFPgUvTRc64v/3QkrgF0wys= 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=NpsUEChh; 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=1707148921; bh=GZ/QrUYoWHJZzCpyI+a8pGcqG7MuwYWLC0kpCm+GmS8=; h=Date:From:To:Subject:X-My-GPG-KeyId:References:From; b=NpsUEChhU9gd0quVquwhz9BL0um6DVapV5Mpz54Q+Os7uRpbtYhVgr75LFVW2Bjyb ije6tg/et7yVyZFkIjdB8luezZ7HJjEFWin1TfEiHXvuoYIvbxuAwxvrUcajFG3REK oUWXa9jHrNJByezx0xWEofG1Q7rMawy675GqnhhA= Date: Mon, 5 Feb 2024 17:02:00 +0100 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: 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 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Feb 05, 2024 at 04:54:07PM +0100, Ondřej Jirman wrote: > 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; You may be able to elegantly work around this by pinning PLL_GPU to a certain frequency (assing it in DT and then don't decalre gpu clock as CLK_SET_RATE_PARENT). Say 432 MHz for PLL and then do the scaling via GPU_CLK_REG N divider between 432MHz and 216MHz and maybe 108MHz if that brings any gains. Then you can perhaps sidestep all these potential issues with PLL_GPU and lack of DVFS support decalred in the manual. regards, o. > 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 > >