spmi: prefix spmi bus device names with "spmi"
Subsystems (2)
PATCH RESEND 1/1 spmi: prefix spmi bus device names with "spmi"
Change the format of spmi bus device names from:
<spmi_bus_number>-<spmi_device_sid>
Example: 0-01
to this:
spmi<spmi_bus_number>-<spmi_device_sid>
Example: spmi0-01
This helps to disambiguate SPMI device regmaps from I2C ones at /sys/kernel/debug/regmap since I2C devices use a very similar naming scheme: 0-0000.
--- drivers/spmi/spmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spmi/spmi.c +2 -2
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. +* Copyright (c) 2012-2015, 2020, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> #include <linux/errno.h>
@@ -62,7 +62,7 @@ int spmi_device_add(struct spmi_device *sdev)struct spmi_controller *ctrl = sdev->ctrl;int err; -dev_set_name (&sdev->dev,"%d-%02x" , ctrl->nr, sdev->usid); +dev_set_name (&sdev->dev,"spmi%d-%02x" , ctrl->nr, sdev->usid); err =device_add (&sdev->dev);if (err <0 ) {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Stephen Boyd
maintainerQuoting David Collins (2020-09-22 15:04:18)
Quoted 10 lines
Change the format of spmi bus device names from:
<spmi_bus_number>-<spmi_device_sid>
Example: 0-01
to this:
spmi<spmi_bus_number>-<spmi_device_sid>
Example: spmi0-01This helps to disambiguate SPMI device regmaps from I2C ones at
/sys/kernel/debug/regmapsince I2C devices use a very similar naming scheme: 0-0000.
Can regmap debugfs prepend the bus name on the node made in debugfs? Does it do that already?
Quoted 27 lines
Signed-off-by David Collins <[email protected]>--- drivers/spmi/spmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/spmi/spmi.c +2
-2@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. +* Copyright (c) 2012-2015, 2020, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> #include <linux/errno.h> @@ -62,7 +62,7 @@ int spmi_device_add(struct spmi_device *sdev)struct spmi_controller *ctrl = sdev->ctrl;int err; -dev_set_name (&sdev->dev,"%d-%02x" , ctrl->nr, sdev->usid); +dev_set_name (&sdev->dev,"spmi%d-%02x" , ctrl->nr, sdev->usid); err =device_add (&sdev->dev);if (err <0 ) {
Quoted 8 lines · Stephen Boyd
Quoting David Collins (2020-09-22 15:04:18)
Quoted 3 lines
This helps to disambiguate SPMI device regmaps from I2C ones at
/sys/kernel/debug/regmapsince I2C devices use a very similar naming scheme: 0-0000.Can regmap debugfs prepend the bus name on the node made in debugfs? Does it do that already?
It doesn't do that. I have to say that given the use of dev_name() in logging it does feel like it'd be useful to have distinct names for grepping if we're running into collisions, IIRC the reason I went with dev_name() was that it's a commonly used human readable handle for diagnostic infrastrucuture so it makes it easier to follow things around.
Stephen Boyd
maintainerQuoting Mark Brown (2020-10-01 10:43:26)
Quoted 7 lines · Stephen Boyd
Quoted 5 lines
Quoting David Collins (2020-09-22 15:04:18)
Quoted 3 lines
This helps to disambiguate SPMI device regmaps from I2C ones at
/sys/kernel/debug/regmapsince I2C devices use a very similar naming scheme: 0-0000.
Quoted 8 lines
Quoted 2 lines
Can regmap debugfs prepend the bus name on the node made in debugfs? Does it do that already?
It doesn't do that. I have to say that given the use of
dev_name()in logging it does feel like it'd be useful to have distinct names for grepping if we're running into collisions, IIRC the reason I went withdev_name()was that it's a commonly used human readable handle for diagnostic infrastrucuture so it makes it easier to follow things around.
To me the dev_name() usage seems fine. Maybe David has some real reason to change this though?
In general I don't think userspace cares what the SPMI device name is, i.e. the device name isn't used for dev nodes because SPMI doesn't support ioctls or read/write APIs on the bus. That could be a nice feature addition though, to support something like i2c-dev.
Changing it so that regmap debugfs is less likely to collide looks weird. It doesn't actually collide anyway, so it seems like we're adding spmi prefix to make it easier to find in debugfs?
Quoted 20 lines · Stephen Boyd
Quoting Mark Brown (2020-10-01 10:43:26)
Quoted 7 lines · Stephen Boyd
Quoted 5 lines
Quoting David Collins (2020-09-22 15:04:18)
Quoted 3 lines
This helps to disambiguate SPMI device regmaps from I2C ones at
/sys/kernel/debug/regmapsince I2C devices use a very similar naming scheme: 0-0000.Quoted 8 lines
Quoted 2 lines
Can regmap debugfs prepend the bus name on the node made in debugfs? Does it do that already?
It doesn't do that. I have to say that given the use of
dev_name()in logging it does feel like it'd be useful to have distinct names for grepping if we're running into collisions, IIRC the reason I went withdev_name()was that it's a commonly used human readable handle for diagnostic infrastrucuture so it makes it easier to follow things around.To me the
dev_name()usage seems fine. Maybe David has some real reason to change this though?
Quoted 8 lines
In general I don't think userspace cares what the SPMI device name is, i.e. the device name isn't used for dev nodes because SPMI doesn't support ioctls or read/write APIs on the bus. That could be a nice feature addition though, to support something like i2c-dev.
Changing it so that regmap debugfs is less likely to collide looks weird. It doesn't actually collide anyway, so it seems like we're adding spmi prefix to make it easier to find in debugfs?
Yes, that is correct. There isn't a collision since I2C uses 0-0000 and SPMI uses 0-00 naming scheme. However, those names are very similar and it is hard for a user to tell which is which inside /sys/kernel/debug/regmap without a deep understanding of the I2C and SPMI code.
The SPMI regmap debugfs files are used extensively for testing and debug purposes internally at Qualcomm and by our customers. It would be helpful if the more verbose naming scheme were accepted upstream to avoid confusion and broken test scripts.
Thanks,
David
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 4 lines · David Collins
The SPMI regmap debugfs files are used extensively for testing and debug purposes internally at Qualcomm and by our customers. It would be helpful if the more verbose naming scheme were accepted upstream to avoid confusion and broken test scripts.
...and doing this in the dev_name() should help other diagnostic users (like dev_printk() for example).
Stephen Boyd
maintainerQuoting Mark Brown (2020-10-02 09:03:24)
Quoted 9 lines · David Collins
Quoted 5 lines
The SPMI regmap debugfs files are used extensively for testing and debug purposes internally at Qualcomm and by our customers. It would be helpful if the more verbose naming scheme were accepted upstream to avoid confusion and broken test scripts.
...and doing this in the
dev_name()should help other diagnostic users (likedev_printk()for example).
Don't thinks like dev_printk() prefix the bus name? See dev_driver_string()? So I agree that having the bus name is useful, but confused why there are testing scripts and things on top of regmap debugfs
Put another way, why not introduce something similar to i2c-dev where userspace can read/write registers for devices on the SPMI bus? Otherwise I presume the test scripts inside Qualcomm are just reading registers out of regmap?
Quoted 9 lines · Stephen Boyd
Quoting Mark Brown (2020-10-02 09:03:24)
Quoted 2 lines
...and doing this in the
dev_name()should help other diagnostic users (likedev_printk()for example).Don't thinks like
dev_printk()prefix the bus name? Seedev_driver_string()? So I agree that having the bus name is useful, but confused why there are testing scripts and things on top of regmap debugfs
Not that I've ever noticed, eg on the console.
Quoted 4 lines
Put another way, why not introduce something similar to i2c-dev where userspace can read/write registers for devices on the SPMI bus? Otherwise I presume the test scripts inside Qualcomm are just reading registers out of regmap?
I know some other vendors use the regmap debugfs for their diagnostic tools (obviously not with SPMI). It's generally so they can get the benefit of the cache, it's a combination of allowing the state to be inspected while the driver has the device powered down and for devices on slower buses being much more performant.
Stephen Boyd
maintainerQuoting Mark Brown (2020-10-02 11:04:30)
Quoted 6 lines · Stephen Boyd
Quoted 4 lines
Quoting Mark Brown (2020-10-02 09:03:24)
Quoted 2 lines
...and doing this in the
dev_name()should help other diagnostic users (likedev_printk()for example).
Quoted 6 lines
Quoted 4 lines
Don't thinks like
dev_printk()prefix the bus name? Seedev_driver_string()? So I agree that having the bus name is useful, but confused why there are testing scripts and things on top of regmap debugfsNot that I've ever noticed, eg on the console.
I see things like this on my console:
[ 1.684617] spmi spmi-0: PMIC arbiter version v5 (0x50000000)
and 'spmi' is the bus name I'm thinking about. But I think that's because there isn't a driver attached. Nothing prints for the 0-00 device by default, so I enabled the debug print for it and I see
[ 1.693280] pmic-spmi 0-00: 28: unknown v2.0
Anyway, the device name was written to follow i2c as far as I can tell.
If scripts, i.e. computers, have a hard time figuring out the name of the device then fix the script?
Quoted 8 lines · Stephen Boyd
I see things like this on my console:
[ 1.684617] spmi spmi-0: PMIC arbiter version v5 (0x50000000)and 'spmi' is the bus name I'm thinking about. But I think that's because there isn't a driver attached. Nothing prints for the 0-00 device by default, so I enabled the debug print for it and I see
Quoted 6 lines
[ 1.693280] pmic-spmi 0-00: 28: unknown v2.0Anyway, the device name was written to follow i2c as far as I can tell.
If scripts, i.e. computers, have a hard time figuring out the name of the device then fix the script?
I agree that we can drop this patch. There is no technical requirement for the spmi device naming scheme to be changed. We will update our downstream test scripts to use the upstream naming scheme and also socialize the naming difference internally.
Take care,
David
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project