linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] regulator: core: Log forbidden DRMS operation
@ 2019-02-19 16:02 Marc Gonzalez
  2019-02-19 16:39 ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Gonzalez @ 2019-02-19 16:02 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: LKML, MSM, Bjorn Andersson, Jeffrey Hugo, Evan Green, Douglas Anderson

When REGULATOR_CHANGE_DRMS is not set, drms_uA_update is a no-op.
It used to print a debug message, which was dropped in commit
8a34e979f684 ("regulator: refactor valid_ops_mask checking code")

Let's bring the debug message back as KERN_INFO, because it is very
useful to diagnose missing regulator-allow-set-load properties.

Signed-off-by: Marc Gonzalez <marc.w.gonzalez@free.fr>
---
 drivers/regulator/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 59782a706ac4..2ff9b55cfcd8 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -930,8 +930,10 @@ static int drms_uA_update(struct regulator_dev *rdev)
 	 * first check to see if we can set modes at all, otherwise just
 	 * tell the consumer everything is OK.
 	 */
-	if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_DRMS))
+	if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_DRMS)) {
+		rdev_info(rdev, "DRMS operation not allowed\n");
 		return 0;
+	}
 
 	if (!rdev->desc->ops->get_optimum_mode &&
 	    !rdev->desc->ops->set_load)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] regulator: core: Log forbidden DRMS operation
  2019-02-19 16:02 [PATCH v1] regulator: core: Log forbidden DRMS operation Marc Gonzalez
@ 2019-02-19 16:39 ` Mark Brown
  2019-02-21  9:37   ` Marc Gonzalez
  2019-02-21  9:42   ` Marc Gonzalez
  0 siblings, 2 replies; 6+ messages in thread
From: Mark Brown @ 2019-02-19 16:39 UTC (permalink / raw)
  To: Marc Gonzalez
  Cc: Liam Girdwood, LKML, MSM, Bjorn Andersson, Jeffrey Hugo,
	Evan Green, Douglas Anderson

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

On Tue, Feb 19, 2019 at 05:02:46PM +0100, Marc Gonzalez wrote:
> When REGULATOR_CHANGE_DRMS is not set, drms_uA_update is a no-op.
> It used to print a debug message, which was dropped in commit
> 8a34e979f684 ("regulator: refactor valid_ops_mask checking code")

> Let's bring the debug message back as KERN_INFO, because it is very
> useful to diagnose missing regulator-allow-set-load properties.

No, it's perfectly normal for machine constraints to stop drivers from
doing things so we shouldn't warn on this - it would get incredibly
noisy if we started printing every time constraints didn't let us do
something at info level.  Debug level might be viable, or definitely
vdbg or trace points.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] regulator: core: Log forbidden DRMS operation
  2019-02-19 16:39 ` Mark Brown
@ 2019-02-21  9:37   ` Marc Gonzalez
  2019-02-21  9:42   ` Marc Gonzalez
  1 sibling, 0 replies; 6+ messages in thread
From: Marc Gonzalez @ 2019-02-21  9:37 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, LKML, MSM, Bjorn Andersson, Jeffrey Hugo,
	Evan Green, Douglas Anderson

On 19/02/2019 17:39, Mark Brown wrote:

> On Tue, Feb 19, 2019 at 05:02:46PM +0100, Marc Gonzalez wrote:
> 
>> When REGULATOR_CHANGE_DRMS is not set, drms_uA_update is a no-op.
>> It used to print a debug message, which was dropped in commit
>> 8a34e979f684 ("regulator: refactor valid_ops_mask checking code")
>> 
>> Let's bring the debug message back as KERN_INFO, because it is very
>> useful to diagnose missing regulator-allow-set-load properties.
> 
> No, it's perfectly normal for machine constraints to stop drivers from
> doing things so we shouldn't warn on this - it would get incredibly
> noisy if we started printing every time constraints didn't let us do
> something at info level.  Debug level might be viable, or definitely
> vdbg or trace points.

I had a look at the various REGULATOR_CHANGE_* flags.

#define REGULATOR_CHANGE_VOLTAGE	0x1
#define REGULATOR_CHANGE_CURRENT	0x2
#define REGULATOR_CHANGE_MODE		0x4
#define REGULATOR_CHANGE_STATUS		0x8
#define REGULATOR_CHANGE_DRMS		0x10
#define REGULATOR_CHANGE_BYPASS		0x20

Several functions return an error (and log a KERN_ERR message) if their
corresponding flag is not set:

regulator_check_voltage()	REGULATOR_CHANGE_VOLTAGE
regulator_check_current_limit()	REGULATOR_CHANGE_CURRENT
regulator_mode_constrain()	REGULATOR_CHANGE_MODE

Others succeed silently even if their corresponding flag is not set:

drms_uA_update()		REGULATOR_CHANGE_DRMS
regulator_allow_bypass()	REGULATOR_CHANGE_BYPASS


Why is setting the voltage handled differently than setting the load?

Regards.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] regulator: core: Log forbidden DRMS operation
  2019-02-19 16:39 ` Mark Brown
  2019-02-21  9:37   ` Marc Gonzalez
@ 2019-02-21  9:42   ` Marc Gonzalez
  2019-02-21 10:12     ` Mark Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Marc Gonzalez @ 2019-02-21  9:42 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, LKML, MSM, Bjorn Andersson, Jeffrey Hugo,
	Evan Green, Douglas Anderson

[ SMTP server blocked by spamcop -- trying a different one ]

On 19/02/2019 17:39, Mark Brown wrote:

> On Tue, Feb 19, 2019 at 05:02:46PM +0100, Marc Gonzalez wrote:
> 
>> When REGULATOR_CHANGE_DRMS is not set, drms_uA_update is a no-op.
>> It used to print a debug message, which was dropped in commit
>> 8a34e979f684 ("regulator: refactor valid_ops_mask checking code")
>> 
>> Let's bring the debug message back as KERN_INFO, because it is very
>> useful to diagnose missing regulator-allow-set-load properties.
> 
> No, it's perfectly normal for machine constraints to stop drivers from
> doing things so we shouldn't warn on this - it would get incredibly
> noisy if we started printing every time constraints didn't let us do
> something at info level.  Debug level might be viable, or definitely
> vdbg or trace points.

I had a look at the various REGULATOR_CHANGE_* flags.

#define REGULATOR_CHANGE_VOLTAGE	0x1
#define REGULATOR_CHANGE_CURRENT	0x2
#define REGULATOR_CHANGE_MODE		0x4
#define REGULATOR_CHANGE_STATUS		0x8
#define REGULATOR_CHANGE_DRMS		0x10
#define REGULATOR_CHANGE_BYPASS		0x20

Several functions return an error (and log a KERN_ERR message) if their
corresponding flag is not set:

regulator_check_voltage()	REGULATOR_CHANGE_VOLTAGE
regulator_check_current_limit()	REGULATOR_CHANGE_CURRENT
regulator_mode_constrain()	REGULATOR_CHANGE_MODE

Others succeed silently even if their corresponding flag is not set:

drms_uA_update()		REGULATOR_CHANGE_DRMS
regulator_allow_bypass()	REGULATOR_CHANGE_BYPASS


Why is setting the voltage handled differently than setting the load?

Regards.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] regulator: core: Log forbidden DRMS operation
  2019-02-21  9:42   ` Marc Gonzalez
@ 2019-02-21 10:12     ` Mark Brown
  2019-02-21 11:55       ` [PATCH v2] " Marc Gonzalez
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2019-02-21 10:12 UTC (permalink / raw)
  To: Marc Gonzalez
  Cc: Liam Girdwood, LKML, MSM, Bjorn Andersson, Jeffrey Hugo,
	Evan Green, Douglas Anderson

[-- Attachment #1: Type: text/plain, Size: 1278 bytes --]

On Thu, Feb 21, 2019 at 10:42:01AM +0100, Marc Gonzalez wrote:
> On 19/02/2019 17:39, Mark Brown wrote:
> > On Tue, Feb 19, 2019 at 05:02:46PM +0100, Marc Gonzalez wrote:

> > No, it's perfectly normal for machine constraints to stop drivers from
> > doing things so we shouldn't warn on this - it would get incredibly
> > noisy if we started printing every time constraints didn't let us do
> > something at info level.  Debug level might be viable, or definitely
> > vdbg or trace points.

> Several functions return an error (and log a KERN_ERR message) if their
> corresponding flag is not set:
> 
> regulator_check_voltage()	REGULATOR_CHANGE_VOLTAGE

That's a bug due to an incomplete implementation, what it's supposed to
be doing there is checking if the voltage request is satisfied by the
current voltage and returning an error only if the requested voltage is
out of range.

> regulator_check_current_limit()	REGULATOR_CHANGE_CURRENT

This one is less clear than anything else - we might want to error out
here if the device is somehow relying on being able to lower the current
limit for safety.  We'd need an audit of users.

> regulator_mode_constrain()	REGULATOR_CHANGE_MODE

This one is also a bug, modes barely mean anything anyway.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] regulator: core: Log forbidden DRMS operation
  2019-02-21 10:12     ` Mark Brown
@ 2019-02-21 11:55       ` Marc Gonzalez
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Gonzalez @ 2019-02-21 11:55 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: LKML, MSM, Bjorn Andersson, Jeffrey Hugo, Evan Green, Douglas Anderson

When REGULATOR_CHANGE_DRMS is not set, drms_uA_update is a no-op.
It used to print a debug message, which was dropped in commit
8a34e979f684 ("regulator: refactor valid_ops_mask checking code")

Let's bring the debug message back, because it helps find missing
regulator-allow-set-load properties.

Signed-off-by: Marc Gonzalez <marc.w.gonzalez@free.fr>
---
 drivers/regulator/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 59782a706ac4..64f91cf21846 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -930,8 +930,10 @@ static int drms_uA_update(struct regulator_dev *rdev)
 	 * first check to see if we can set modes at all, otherwise just
 	 * tell the consumer everything is OK.
 	 */
-	if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_DRMS))
+	if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_DRMS)) {
+		rdev_dbg(rdev, "DRMS operation not allowed\n");
 		return 0;
+	}
 
 	if (!rdev->desc->ops->get_optimum_mode &&
 	    !rdev->desc->ops->set_load)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-02-21 11:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19 16:02 [PATCH v1] regulator: core: Log forbidden DRMS operation Marc Gonzalez
2019-02-19 16:39 ` Mark Brown
2019-02-21  9:37   ` Marc Gonzalez
2019-02-21  9:42   ` Marc Gonzalez
2019-02-21 10:12     ` Mark Brown
2019-02-21 11:55       ` [PATCH v2] " Marc Gonzalez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).