Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1544713ybe; Fri, 6 Sep 2019 21:05:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwew3lSLC6D6LTaV04qFeNuRIxc0xdvapSI/mGr90t9TvNaBJARZv/ZKz+9dCOWRze53jt+ X-Received: by 2002:a17:90a:a4c3:: with SMTP id l3mr13439162pjw.46.1567829109087; Fri, 06 Sep 2019 21:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567829109; cv=none; d=google.com; s=arc-20160816; b=IWYBD/p/Roj/e/+mbZnAWl4pXuwpZ9ooc7njHa1vt3UiUq8tLVPvMoPO1NtxmE+75v uia9rLgexiIcL4hxZGnAbM4mWI1jR+M1I+xW+kjt/vGhe0xtFxNJFdbkspUymTjkjExz PbO2u4k5TtP50bxwL8lXflp4bu+JD3l2vMgxqFzxBEAb/bDvBiNJHkijP070/Hjr0W1k cJZqwwNCgJxlz/FTX7pWsziwO6Bn7Oovf3iZugPItLbqIXrnygolV0II5TcojoMqfUvz mDEj1xGvBk7Vfk6U+0mvuFHpxTxmeZiuZ1Io8/iut11MXYIrKmam5rwnvwpxuTqJy8sj EgfA== 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=HBbmK1lCeXZW63w/QKoYBofvko1KmrNa2dPeHR8TNuc=; b=OTgzXHDFEmAoE0sVEgIWu9GxlX095OKvh8q4OU4yI/QZiVWkrWnmrRcacwAtM+rYoT P57DH/w7otMUg6JY3IBmaWdth/kfuYgPCpzcw4FyCCqBy2/T+PB8Pke4cXXdGEdpEYT0 kIwboaqJ++Ze1k5ofP8PTAmnHCcUzW3rVT9T4nJaWClnr9aKyg9BvEFy4bb66Yw5pX/e k6VFzuqUeHxEJrVMCcYHmNUO3ww/VThq42mqJBCRL/idb9g9xWgxu2QggiDtokn5oSZZ 8eAM9BaBjyVWJwPgdlkdw2awn0mte+2+msEoIc3tKs4kWTtiX6knDOoTeXyNQTWItAEE yZ6A== 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 c11si5976637pga.118.2019.09.06.21.04.18; Fri, 06 Sep 2019 21:05:09 -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 S2394760AbfIFPX3 (ORCPT + 99 others); Fri, 6 Sep 2019 11:23:29 -0400 Received: from foss.arm.com ([217.140.110.172]:58326 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726019AbfIFPX3 (ORCPT ); Fri, 6 Sep 2019 11:23:29 -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 7E0ED1576; Fri, 6 Sep 2019 08:23:28 -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 8D3603F59C; Fri, 6 Sep 2019 08:23:27 -0700 (PDT) From: Steven Price Subject: Re: [PATCH] drm/panfrost: Fix regulator_get_optional() misuse To: Mark Brown , Rob Herring , Tomeu Vizoso , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20190904123032.23263-1-broonie@kernel.org> Message-ID: Date: Fri, 6 Sep 2019 16:23:26 +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: <20190904123032.23263-1-broonie@kernel.org> 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 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") Signed-off-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index a1f5fa6a742a..076983071e58 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) @@ -138,6 +136,9 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) int ret; struct dev_pm_opp *opp; + if (!pfdev->regulator) + return 0; + ret = dev_pm_opp_of_add_table(&pfdev->pdev->dev); if (ret == -ENODEV) /* Optional, continue without devfreq */ return 0; -- 2.20.1