Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp832732ybe; Thu, 5 Sep 2019 06:39:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkgwOpZute+ZCuefZmhzqUaKQjqbMmi2kEj7T9owbtnOwYfTQOm/WRdFyiGxjD779cncv+ X-Received: by 2002:a62:26c4:: with SMTP id m187mr3965940pfm.49.1567690755304; Thu, 05 Sep 2019 06:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567690755; cv=none; d=google.com; s=arc-20160816; b=XXCpFBVxCTjATrr4Ee543zBUcICJaTlpCp8n3npuFnwT0M3JSodoDOx92g7eb2nffS uEkuMUasWoGZ0FrGOO1Oko02wM2URdXrMxCUd6gxiD7IeLDmeIEEcUvfwSLFxA06KXR2 NgYZ79nlx8hKICXsB0iCPqPqe7VHFiwAueGucy5mwPNuox6sn3vpJrJWowhhRuZAb+LQ PdNoIoRFf0agz8gLrGLGYHrudBZ7VTwBO2Q00U8TuJCbhtgh6TkfL/3cwzwMn2cffh/2 Vab5X6wsTQ6hybsGQTwfZM0YutCBeS9kOd4JLodPVUKiXJ14UnXokppCVdzhXa0zAKe1 26/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=T3FCFMN2z9Bt1GK8k3lpSyj2uENPY0dUEXr7VygNtFI=; b=PpUl2bY62gcM36xkJUxvnPjZnuJ+3ei1n4VHt6JfCwG0bG8SAt4CdD5Tr2YPf4qAd5 W5nk+LsXb+B4gkcA1KXweY/pSlKnHDk0nnObClUKdyz2T6l6gGI7lQG0pA3K5wKRJrMj CHY7jl60guja22+SjSPV/YJi5WxlgXp4/VvAHN0rcAUDlOhFmnEkIyeueynbAwiktIk0 XD6JyYigiLTNrXMAsOSDrQP54RTrTZVO/8+qXsYNQrg53D1782lGUjU0TbySp1/+oU8G YYvMRL+Z71rZCQm4oQ+O9KkYTwHjFvcZuTF+J69aAeYMqINvuaEVGllmUmJAN0Svp1hB qbEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=G2bixAfM; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si2040802pll.186.2019.09.05.06.38.59; Thu, 05 Sep 2019 06:39:15 -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; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=G2bixAfM; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387741AbfIEMkV (ORCPT + 99 others); Thu, 5 Sep 2019 08:40:21 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:35752 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730959AbfIEMkV (ORCPT ); Thu, 5 Sep 2019 08:40:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=T3FCFMN2z9Bt1GK8k3lpSyj2uENPY0dUEXr7VygNtFI=; b=G2bixAfMhR1u99XuvPXclaQZA EDcHSToBuaWXxAm/tT74GMleq2mBrO1d4/MaIah/qObMNDAFDiAslubrLpAaKnCUIsPZNU42io1u8 EAOo7eDdGzWpvlL6oX+L22CxJLkFbFdHtCzvNTcFWOrnLlJwCVLxEspaRDt7lU5ZVJ0WI=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=ypsilon.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1i5r3g-0004X8-0K; Thu, 05 Sep 2019 12:40:16 +0000 Received: by ypsilon.sirena.org.uk (Postfix, from userid 1000) id 0F1422742D07; Thu, 5 Sep 2019 13:40:14 +0100 (BST) Date: Thu, 5 Sep 2019 13:40:14 +0100 From: Mark Brown To: Steven Price Cc: Rob Herring , David Airlie , dri-devel , Tomeu Vizoso , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] drm/panfrost: Fix regulator_get_optional() misuse Message-ID: <20190905124014.GA4053@sirena.co.uk> References: <20190904123032.23263-1-broonie@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="tThc/1wpZn/ma/RB" Content-Disposition: inline In-Reply-To: X-Cookie: You humans are all alike. User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 05, 2019 at 10:37:53AM +0100, Steven Price wrote: > Ah, I didn't realise that regulator_get() will return a dummy regulator > if none is provided in the DT. In theory that seems like a nicer > solution to my two commits. However there's still a problem - the dummy > regulator returned from regulator_get() reports errors when > regulator_set_voltage() is called. So I get errors like this: > [ 299.861165] panfrost e82c0000.mali: Cannot set voltage 1100000 uV > [ 299.867294] devfreq devfreq0: dvfs failed with (-22) error > (And therefore the frequency isn't being changed) > Ideally we want a dummy regulator that will silently ignore any > regulator_set_voltage() calls. Is that safe? You can't rely on being able to change voltages even if there's a physical regulator available, system constraints or the results of sharing the regulator with other users may prevent changes. I guess at the minute the code is assuming that if you can't vary the regulator it's fixed at the maximum voltage and that it's safe to run at a lower clock with a higher voltage (some devices don't like doing that). If the device always starts up at full speed I guess that's OK. It's certainly in general a bad idea to do this in general, we can't tell how important it is to the consumer that they actually get the voltage that they asked for - for some applications like this it's just adding to the power saving it's likely fine but for others it might break things. If you're happy to change the frequency without the ability to vary the voltage you can query what's supported through the API (the simplest interface is regulator_is_supported_voltage()). You should do the regulator API queries at initialization time since they can be a bit expensive, the usual pattern would be to go through your OPP table and disable states where you can't support the voltage but you *could* also flag states where you just don't set the voltage. That seems especially reasonable if no voltages in the range the device supports can be set. I do note that the current code requires exactly specified voltages with no variation which doesn't match the behaviour you say you're OK with here, what you're describing sounds like the driver should be specifying a voltage range from the hardware specified maximum down to whatever the minimum the OPP supports rather than exactly the OPP voltage. As things are you might also run into voltages that can't be hit exactly (eg, in the Exynos 5433 case in mainline a regulator that only offers steps of 2mV will error out trying to set several of the OPPs). --tThc/1wpZn/ma/RB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl1xAisACgkQJNaLcl1U h9Dktwf/cU2P46lDZKOxus22wJ39FsrKnSMmarYUxJuVwMOvHiUCedJgRxcjMSJG 8qxD91/c5mLJn2adGdZx/3Wrf0RbY/EEjpk/Ru3sbFl/LEow2OwsAWLG9U/RBmJV GfPwPTRgCOcKIJIEnrCkJV/XjaJhVdAQ6akUaOQtE8N5/+UAgi1qnmDkwndsLPcJ SPvfK7oVN4/xtwxmwomTqz92oCIlcfwubjEl07jZB/DZARaN6LjhGFj18aHSiZqM HV/6gNWaxeVMUpQktnuKzW5fGhAPmutN/+67cx0S9pUXIOeHENz8pE/H9RGeLKo0 oiXGbcDp/ied1I8DHJF8j5PiQ0qUdw== =aLW0 -----END PGP SIGNATURE----- --tThc/1wpZn/ma/RB--