Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp16415319ybl; Wed, 1 Jan 2020 04:58:56 -0800 (PST) X-Google-Smtp-Source: APXvYqyAvNcsXaXZc9cYS+Hzk61/F6sCd7M5d8pKG5RcE1QbGai0yCYer4vES4BF5K5ywgTrU52l X-Received: by 2002:a17:906:5ac2:: with SMTP id x2mr82984902ejs.29.1577883536836; Wed, 01 Jan 2020 04:58:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577883536; cv=none; d=google.com; s=arc-20160816; b=pJ4qVoBWQuN5UBuCrjCIa7cktJZb2lzyxtIA2N1SuY5UlyKanky8pQVpFTEqNKdW/D IBKkvDC0QtTNR6/o0FEYg2q/8Ldy7JPNZSPTX2fIWZ6Y4PN9w0qmzMEZe4gWfFimw/HM wrzok25T+xCym58spEl8EOL8adfgcTETJz8Mg99wB2bHlR3BvCgarmxFIG79eNfdSRli TBp89vmfPh2jwBnUmcWAL0GE6Qe3RGqM4PI1ijOVVxYkl0BVMJjDoLOTRxixPJtJo82U jXPHXjj3/mMkc07QFtkMcwVf7B+hHGc46+hhoewWHnIMHXzWo1q+LKrc2NajcPZe4Q9z 5Z3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=RdR6KdoXETQVkDB79vmwlKo4T5ml5yrIbs+gx6Iw9OM=; b=A9nwXtguVpm8IFyPAuiZCs0tGzEjInHcxxKXdkam2imxAOBJnv9XVFVgkuci+Ux0D5 bPemHQXyKDnU7C3cxx5ioRVd3g9TcUlPgFf2sEYQ363ERoeJYL356WwK6qZTTOM3ELV7 5Waor7jSGW+p6V5iAzs618HQ+UqP1smsans0dByxRs03x/VJQRxvi2dNFDEaUMIuX2kF pH5AoBjTvdWMlK8IbGf0pFPpa416xAvgDXYDKRwGkHT27M8E3S7u1B+SZbgJZtJwLH8v EBaQW0PoKd+0CuqpCHl5qU3wjL3MfVzLtxU3WUaY6qawiEuj0WgMIyl6DpPAb763pjKY Uxrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18si33117350ejr.358.2020.01.01.04.58.19; Wed, 01 Jan 2020 04:58:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725877AbgAAMzr (ORCPT + 99 others); Wed, 1 Jan 2020 07:55:47 -0500 Received: from foss.arm.com ([217.140.110.172]:40178 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbgAAMzr (ORCPT ); Wed, 1 Jan 2020 07:55:47 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 952F831B; Wed, 1 Jan 2020 04:55:46 -0800 (PST) Received: from [192.168.1.123] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BDD9E3F68F; Wed, 1 Jan 2020 04:55:44 -0800 (PST) Subject: Re: [RFC v2 1/1] drm/lima: Add optional devfreq support To: Martin Blumenstingl Cc: yuq825@gmail.com, dri-devel@lists.freedesktop.org, robh@kernel.org, tomeu.vizoso@collabora.com, airlied@linux.ie, linux-kernel@vger.kernel.org, steven.price@arm.com, linux-rockchip@lists.infradead.org, wens@csie.org, alyssa.rosenzweig@collabora.com, daniel@ffwll.ch, linux-amlogic@lists.infradead.org References: <20191227173707.20413-1-martin.blumenstingl@googlemail.com> <20191227173707.20413-2-martin.blumenstingl@googlemail.com> From: Robin Murphy Message-ID: <629205c8-68c5-5895-d926-75984110dd49@arm.com> Date: Wed, 1 Jan 2020 12:55:44 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-12-31 4:47 pm, Martin Blumenstingl wrote: > Hi Robin, > > On Tue, Dec 31, 2019 at 5:40 PM Robin Murphy wrote: >> >> On 2019-12-31 2:17 pm, Martin Blumenstingl wrote: >>> Hi Robin, >>> >>> On Mon, Dec 30, 2019 at 1:47 AM Robin Murphy wrote: >>>> >>>> On 2019-12-29 11:19 pm, Martin Blumenstingl wrote: >>>>> Hi Robin, >>>>> >>>>> On Sun, Dec 29, 2019 at 11:58 PM Robin Murphy wrote: >>>>>> >>>>>> Hi Martin, >>>>>> >>>>>> On 2019-12-27 5:37 pm, Martin Blumenstingl wrote: >>>>>>> Most platforms with a Mali-400 or Mali-450 GPU also have support for >>>>>>> changing the GPU clock frequency. Add devfreq support so the GPU clock >>>>>>> rate is updated based on the actual GPU usage when the >>>>>>> "operating-points-v2" property is present in the board.dts. >>>>>>> >>>>>>> The actual devfreq code is taken from panfrost_devfreq.c and modified so >>>>>>> it matches what the lima hardware needs: >>>>>>> - a call to dev_pm_opp_set_clkname() during initialization because there >>>>>>> are two clocks on Mali-4x0 IPs. "core" is the one that actually clocks >>>>>>> the GPU so we need to control it using devfreq. >>>>>>> - locking when reading or writing the devfreq statistics because (unlike >>>>>>> than panfrost) we have multiple PP and GP IRQs which may finish jobs >>>>>>> concurrently. >>>>>> >>>>>> I gave this a quick try on my RK3328, and the clock scaling indeed kicks >>>>>> in nicely on the glmark2 scenes that struggle, however something appears >>>>>> to be missing in terms of regulator association, as the appropriate OPP >>>>>> voltages aren't reflected in the GPU supply (fortunately the initial >>>>>> voltage seems close enough to that of the highest OPP not to cause major >>>>>> problems, on my box at least). With panfrost on RK3399 I do see the >>>>>> supply voltage scaling accordingly, but I don't know my way around >>>>>> devfreq well enough to know what matters in the difference :/ >>>>> first of all: thank you for trying this out! :-) >>>>> >>>>> does your kernel include commit 221bc77914cbcc ("drm/panfrost: Use >>>>> generic code for devfreq") for your panfrost test? >>>>> if I understand the devfreq API correct then I suspect with that >>>>> commit panfrost also won't change the voltage anymore. >>>> >>>> Oh, you're quite right - I was already considering that change as >>>> ancient history, but indeed it's only in 5.5-rc, while that board is >>>> still on 5.4.y release kernels. No wonder I couldn't make sense of how >>>> the (current) code could possibly be working :) >>>> >>>> I'll try the latest -rc kernel tomorrow to confirm (now that PCIe is >>>> hopefully fixed), but I'm already fairly confident you've called it >>>> correctly. >>> I just tested it with the lima driver (by undervolting the GPU by >>> 0.05V) and it seems that dev_pm_opp_set_regulators is really needed. >>> I'll fix this in the next version of this patch and also submit a fix >>> for panfrost (I won't be able to test that though, so help is >>> appreciated in terms of testing :)) >> >> Yeah, I started hacking something up for panfrost yesterday, but at the >> point of realising the core OPP code wants refactoring to actually >> handle optional regulators without spewing errors, decided that was >> crossing the line into "work" and thus could wait until next week :D > I'm not sure what you mean, dev_pm_opp_set_regulators uses > regulator_get_optional. > doesn't that mean that it is optional already? Indeed it does call regulator_get_optional(), but it then goes on to treat the absence of a supposedly-optional regulator as a hard failure. It doesn't seem very useful having a nice abstracted interface if users still end up have to dance around and duplicate half the parsing in order to work out whether it's worth calling or not - far better IMO if it could just successfully set/put zero regulators in the cases where the OPPs are behind a firmware/mailbox DVFS interface rather than explicit in-kernel clock/regulator control. That said, given that I think the current lima/panfrost users should all be relatively simple with either 0 or 1 regulator, you could probably just special-case -ENODEV and accept a spurious error message sometimes for the sake of an immediate fix, then we can make general improvements to the interface separately afterwards. Robin.