Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5330216ybe; Tue, 10 Sep 2019 01:55:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgbjI1eUO65v3cht4VfPWYYQf8n9CLPSOSqJzBKvjysLRr+gmgzj6mxEMNiP8Ll685eRjA X-Received: by 2002:a17:906:149b:: with SMTP id x27mr23839476ejc.113.1568105737285; Tue, 10 Sep 2019 01:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568105737; cv=none; d=google.com; s=arc-20160816; b=WnmNA/E0Q+G4ATjT1JzO61fZAkhj4WJTOMQXTfgj9pCNjLdH0cWMzjKrtDGl//IQnS eszAoYF+e5xNN13fXJeOwJL4eYYVJAa3CjoCwZq+73a1USwcVK18VG+VWnnwfUekJ3UI yYWL8wgMan9GiQGoBXBWnMVoDvyvgG7JG61lOR9GiATuf56kkvfnnOlxTpey5oiKTRdZ apcvANNR/BR2tvC/nwFt/8bZc4TmpXJTH2L0bXppPK4rNi9wwUL6HSpDBVVE0K+FD9qz ZBd/VZsZ2t7Gim4R4OAu/3b/q9GzdSYsJWG1oaU2edEvK+79G3MRwXIZAhpa5D8th/fO AM0g== 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:references:cc:to:subject:from; bh=/8mFxBz14bxphiKIyi19U/bArwM69zGIZoxLe0CzHnY=; b=qK41Pjv3eYS/PZgQSximM+SA4bdJAbdA3NZea7PoZ4TRRLuOKpHGczY2x76iuJYLTR cZrEGnhh8YXEY9xQFX9DFP3b2zEjHZ1cp5P31oJx2VlDqhvey4GliWIRYOXzi5W93PwO zOo4ce7UZi0ta0JQSP5z/VxgYMkPqFQomc2PCXlqhYTNlXZzcEKIkchpwMwdAVFd6HRa YcImp1hNWaGhKmdcvUY5gQwTotpaCwls6eokqE7hmyZxldfeFXmkOYpASzuQJfdB2Sg6 1bMYxbz6W81zeymakZbkxAKpGRYYiOtPD1TVMFa0TcmF66vX+jwMaA35EbYDILBcLOkB 66Fw== 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 r14si11088904edx.451.2019.09.10.01.55.13; Tue, 10 Sep 2019 01:55:37 -0700 (PDT) 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 S2389424AbfIIQW7 (ORCPT + 99 others); Mon, 9 Sep 2019 12:22:59 -0400 Received: from foss.arm.com ([217.140.110.172]:53372 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389271AbfIIQW6 (ORCPT ); Mon, 9 Sep 2019 12:22:58 -0400 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 9777728; Mon, 9 Sep 2019 09:22:57 -0700 (PDT) Received: from [10.1.196.133] (e112269-lin.cambridge.arm.com [10.1.196.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C93633F59C; Mon, 9 Sep 2019 09:22:56 -0700 (PDT) From: Steven Price Subject: Re: [PATCH] drm/panfrost: Fix regulator_get_optional() misuse To: Rob Herring Cc: Tomeu Vizoso , David Airlie , "linux-kernel@vger.kernel.org" , dri-devel , Mark Brown References: <20190904123032.23263-1-broonie@kernel.org> Message-ID: <3e3a2c8a-b4fc-8af6-39e1-b26160db2c7c@arm.com> Date: Mon, 9 Sep 2019 17:22:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 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 09/09/2019 16:41, Rob Herring wrote: > On Fri, Sep 6, 2019 at 4:23 PM Steven Price wrote: >> >> On 04/09/2019 13:30, Mark Brown wrote: >>> The panfrost driver requests a supply using regulator_get_optional() >>> but both the name of the supply and the usage pattern suggest that it is >>> being used for the main power for the device and is not at all optional >>> for the device for function, there is no meaningful handling for absent >>> supplies. Such regulators should use the vanilla regulator_get() >>> interface, it will ensure that even if a supply is not described in the >>> system integration one will be provided in software. >>> >>> Signed-off-by: Mark Brown >> >> Tested-by: Steven Price >> >> Looks like my approach to this was wrong - so we should also revert the >> changes I made previously. >> >> ----8<---- >> From fe20f8abcde8444bb41a8f72fb35de943a27ec5c Mon Sep 17 00:00:00 2001 >> From: Steven Price >> Date: Fri, 6 Sep 2019 15:20:53 +0100 >> Subject: [PATCH] drm/panfrost: Revert changes to cope with NULL regulator >> >> Handling a NULL return from devm_regulator_get_optional() doesn't seem >> like the correct way of handling this. Instead revert the changes in >> favour of switching to using devm_regulator_get() which will return a >> dummy regulator instead. >> >> Reverts commit 52282163dfa6 ("drm/panfrost: Add missing check for pfdev->regulator") >> Reverts commit e21dd290881b ("drm/panfrost: Enable devfreq to work without regulator") > > Does a straight revert of these 2 patches not work? If it does work, > can you do that and send to the list. I don't want my hand slapped > again reverting things. I wasn't sure what was best here - 52282163dfa6 is a bug fix, so reverting that followed by e21dd290881b would (re-)introduce a regression for that one commit (i.e. not completely bisectable). Reverting in the other order would work, but seems a little odd. Squashing the reverts seemed the neatest option - but it's not my hand at risk... :) Perhaps it would be best to simply apply Mark's change followed by something like the following. That way it's not actually a revert! It also avoids (re-)adding the now redundant check in panfrost_devfreq_init(). Steve ---8<---- From fb2956acdf46ca04095ef11363c136dc94a1ab18 Mon Sep 17 00:00:00 2001 From: Steven Price Date: Fri, 6 Sep 2019 15:20:53 +0100 Subject: [PATCH] drm/panfrost: Remove NULL checks for regulator devm_regulator_get() is now used to populate pfdev->regulator which ensures that this cannot be NULL (a dummy regulator will be returned if necessary). So remove the checks in panfrost_devfreq_target(). Signed-off-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index a1f5fa6a742a..12ff77dacc95 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -39,7 +39,7 @@ static int panfrost_devfreq_target(struct device *dev, unsigned long *freq, * If frequency scaling from low to high, adjust voltage first. * If frequency scaling from high to low, adjust frequency first. */ - if (old_clk_rate < target_rate && pfdev->regulator) { + if (old_clk_rate < target_rate) { err = regulator_set_voltage(pfdev->regulator, target_volt, target_volt); if (err) { @@ -53,14 +53,12 @@ static int panfrost_devfreq_target(struct device *dev, unsigned long *freq, if (err) { dev_err(dev, "Cannot set frequency %lu (%d)\n", target_rate, err); - if (pfdev->regulator) - regulator_set_voltage(pfdev->regulator, - pfdev->devfreq.cur_volt, - pfdev->devfreq.cur_volt); + regulator_set_voltage(pfdev->regulator, pfdev->devfreq.cur_volt, + pfdev->devfreq.cur_volt); return err; } - if (old_clk_rate > target_rate && pfdev->regulator) { + if (old_clk_rate > target_rate) { err = regulator_set_voltage(pfdev->regulator, target_volt, target_volt); if (err) -- 2.20.1