linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/1] i2c: acpi: revert setting a "stable" device name
@ 2015-08-14 19:37 Dustin Byford
  2015-08-14 19:37 ` [RFC 1/1] " Dustin Byford
  2015-08-15 15:13 ` [RFC 0/1] " Guenter Roeck
  0 siblings, 2 replies; 5+ messages in thread
From: Dustin Byford @ 2015-08-14 19:37 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	jarkko.nikula-VuQAYsv1563Yd54FQh9/CA, jdelvare-IBi9RG/b67k,
	linux-0h96xk9xTtrk1uMJSBkQmQ, lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
	rjw-LthD3rsA81gm4RdzfppkhA, linux-acpi-u79uwXL29TY76Z2rM5mHXA

70762ab from 11/2014 (i2c: Use stable dev_name for ACPI enumerated I2C
slaves) modified the sysfs-visible dev_name() for ACPI enumerated I2C
devices.  With that change, /sys/bus/i2c/devices/i2c-0-004a, for
example, became /sys/bus/i2c/devices/i2c-PNPXXXX:xx

That causes problems for userspace code such as 'sensors' which does
this:

lib/sysfs.c:665:
if ((!subsys || !strcmp(subsys, "i2c")) &&
    sscanf(dev_name, "%hd-%x", &entry.chip.bus.nr,
           &entry.chip.addr) == 2) {
...

Therefore, in theory, sensors that were previously visible by running
'sensors' no longer show up.  On the other hand, there are probably few,
if any, cases of this because ACPI enumerated I2C hwmon devices are not
common.

I'm not defending the 'sensors' code, I'm sure there are better ways to
discover a hwmon I2C device from userspace.  But, I'm also not sure
70762ab achieved its stated goal in a meaningful way.  Won't
"i2c-<acpi_dev_name>" also vary with ACPI scan order, BIOS settings,
firmware upgrades, etc...?

Hence the RFC patch.  To submit a change like this I would need to
consider the fallout for ALSA SoC.  The other option is to see what can
be done in 'sensors' to include the ACPI enumerated hwmon devices.

Any opinions on which way to go?

   --Dustin

Dustin Byford (1):
  i2c: acpi: revert setting a "stable" device name

 drivers/i2c/i2c-core.c | 7 -------
 1 file changed, 7 deletions(-)

-- 
2.1.4

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

* [RFC 1/1] i2c: acpi: revert setting a "stable" device name
  2015-08-14 19:37 [RFC 0/1] i2c: acpi: revert setting a "stable" device name Dustin Byford
@ 2015-08-14 19:37 ` Dustin Byford
  2015-08-15 15:13 ` [RFC 0/1] " Guenter Roeck
  1 sibling, 0 replies; 5+ messages in thread
From: Dustin Byford @ 2015-08-14 19:37 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c
  Cc: linux-kernel, jarkko.nikula, jdelvare, linux, lm-sensors, rjw,
	linux-acpi

70762ab from 11/2014 (i2c: Use stable dev_name for ACPI enumerated I2C
slaves) modified the sysfs-visible dev_name() for ACPI enumerated I2C
devices.  With that change, /sys/bus/i2c/devices/i2c-0-004a, for
example, became /sys/bus/i2c/devices/i2c-PNPXXXX:xx

That causes problems for userspace code such as 'sensors' which does
this:

lib/sysfs.c:665:
if ((!subsys || !strcmp(subsys, "i2c")) &&
    sscanf(dev_name, "%hd-%x", &entry.chip.bus.nr,
           &entry.chip.addr) == 2) {
...

Fix 'sensors' by reverting the kernel change.

Signed-off-by: Dustin Byford <dustin@cumulusnetworks.com>
---
 drivers/i2c/i2c-core.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index c83e4d1..fb77031 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -916,13 +916,6 @@ EXPORT_SYMBOL_GPL(i2c_unlock_adapter);
 static void i2c_dev_set_name(struct i2c_adapter *adap,
 			     struct i2c_client *client)
 {
-	struct acpi_device *adev = ACPI_COMPANION(&client->dev);
-
-	if (adev) {
-		dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev));
-		return;
-	}
-
 	/* For 10-bit clients, add an arbitrary offset to avoid collisions */
 	dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
 		     client->addr | ((client->flags & I2C_CLIENT_TEN)
-- 
2.1.4

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

* Re: [RFC 0/1] i2c: acpi: revert setting a "stable" device name
  2015-08-14 19:37 [RFC 0/1] i2c: acpi: revert setting a "stable" device name Dustin Byford
  2015-08-14 19:37 ` [RFC 1/1] " Dustin Byford
@ 2015-08-15 15:13 ` Guenter Roeck
  2015-08-17  8:00   ` Jarkko Nikula
  1 sibling, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2015-08-15 15:13 UTC (permalink / raw)
  To: Dustin Byford
  Cc: Wolfram Sang, linux-i2c, linux-kernel, jarkko.nikula, jdelvare,
	lm-sensors, rjw, linux-acpi

On Fri, Aug 14, 2015 at 12:37:13PM -0700, Dustin Byford wrote:
> 70762ab from 11/2014 (i2c: Use stable dev_name for ACPI enumerated I2C
> slaves) modified the sysfs-visible dev_name() for ACPI enumerated I2C
> devices.  With that change, /sys/bus/i2c/devices/i2c-0-004a, for
> example, became /sys/bus/i2c/devices/i2c-PNPXXXX:xx
> 
> That causes problems for userspace code such as 'sensors' which does
> this:
> 
> lib/sysfs.c:665:
> if ((!subsys || !strcmp(subsys, "i2c")) &&
>     sscanf(dev_name, "%hd-%x", &entry.chip.bus.nr,
>            &entry.chip.addr) == 2) {
> ...
> 
> Therefore, in theory, sensors that were previously visible by running
> 'sensors' no longer show up.  On the other hand, there are probably few,
> if any, cases of this because ACPI enumerated I2C hwmon devices are not
> common.
> 
> I'm not defending the 'sensors' code, I'm sure there are better ways to
> discover a hwmon I2C device from userspace.  But, I'm also not sure

Is it necessary to defend user space applications nowadays if a kernel change
breaks a well established ABI ? WHat happened to "Thou Shalt Not Break
Userspace" ?

I absolutely agree that i2c bus renumbering across reboots is a problem.
However, it seems to me that 70762ab doesn't solve that problem, it just
paints it over. And, as you have noticed, it introduces new problems along
the way.

Guenter

> 70762ab achieved its stated goal in a meaningful way.  Won't
> "i2c-<acpi_dev_name>" also vary with ACPI scan order, BIOS settings,
> firmware upgrades, etc...?
> 
> Hence the RFC patch.  To submit a change like this I would need to
> consider the fallout for ALSA SoC.  The other option is to see what can
> be done in 'sensors' to include the ACPI enumerated hwmon devices.
> 
> Any opinions on which way to go?
> 
>    --Dustin
> 
> Dustin Byford (1):
>   i2c: acpi: revert setting a "stable" device name
> 
>  drivers/i2c/i2c-core.c | 7 -------
>  1 file changed, 7 deletions(-)
> 
> -- 
> 2.1.4
> 

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

* Re: [RFC 0/1] i2c: acpi: revert setting a "stable" device name
  2015-08-15 15:13 ` [RFC 0/1] " Guenter Roeck
@ 2015-08-17  8:00   ` Jarkko Nikula
       [not found]     ` <55D1948C.6080501-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Jarkko Nikula @ 2015-08-17  8:00 UTC (permalink / raw)
  To: Guenter Roeck, Dustin Byford
  Cc: Wolfram Sang, linux-i2c, linux-kernel, jdelvare, lm-sensors, rjw,
	linux-acpi

On 15.08.2015 18:13, Guenter Roeck wrote:
> On Fri, Aug 14, 2015 at 12:37:13PM -0700, Dustin Byford wrote:
>> 70762ab from 11/2014 (i2c: Use stable dev_name for ACPI enumerated I2C
>> slaves) modified the sysfs-visible dev_name() for ACPI enumerated I2C
>> devices.  With that change, /sys/bus/i2c/devices/i2c-0-004a, for
>> example, became /sys/bus/i2c/devices/i2c-PNPXXXX:xx
>>
>> That causes problems for userspace code such as 'sensors' which does
>> this:
>>
>> lib/sysfs.c:665:
>> if ((!subsys || !strcmp(subsys, "i2c")) &&
>>      sscanf(dev_name, "%hd-%x", &entry.chip.bus.nr,
>>             &entry.chip.addr) == 2) {
>> ...
>>
>> Therefore, in theory, sensors that were previously visible by running
>> 'sensors' no longer show up.  On the other hand, there are probably few,
>> if any, cases of this because ACPI enumerated I2C hwmon devices are not
>> common.
>>
>> I'm not defending the 'sensors' code, I'm sure there are better ways to
>> discover a hwmon I2C device from userspace.  But, I'm also not sure
>
> Is it necessary to defend user space applications nowadays if a kernel change
> breaks a well established ABI ? WHat happened to "Thou Shalt Not Break
> Userspace" ?
>
> I absolutely agree that i2c bus renumbering across reboots is a problem.
> However, it seems to me that 70762ab doesn't solve that problem, it just
> paints it over. And, as you have noticed, it introduces new problems along
> the way.
>
This indeed is unwanted and needs to be fixed. Looking at the 
lib/sysfs.c also SPI chip detection breaks because of commit 
e13ac47bec20 ("spi: Use stable dev_name for ACPI enumerated SPI slaves").

However plain revert won't work as it breaks those ALSA SoC drivers that 
depend on this. Good thing is that matching there is purely kernel space 
and at quick look "git grep '"i2c-.*:[0-9]'" and "git grep 
'"spi-.*:[0-9]'" don't find other in-kernel users.

>> 70762ab achieved its stated goal in a meaningful way.  Won't
>> "i2c-<acpi_dev_name>" also vary with ACPI scan order, BIOS settings,
>> firmware upgrades, etc...?
>>
If I remember correctly ACPI ID should not ever change and instance id 
:xy after INTABCD:xy should also be visible and keep the order even if 
device is disabled or not plugged. But I'm not absolute sure about this.

At least on a test platform that allow disable devices will show those 
devices off-line (/sys/bus/acpi/devices/INTABCD:xy/status == 0).

-- 
Jarkko

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

* Re: [RFC 0/1] i2c: acpi: revert setting a "stable" device name
       [not found]     ` <55D1948C.6080501-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-08-25  5:03       ` Dustin Byford
  0 siblings, 0 replies; 5+ messages in thread
From: Dustin Byford @ 2015-08-25  5:03 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: Guenter Roeck, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, jdelvare-IBi9RG/b67k,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, rjw-LthD3rsA81gm4RdzfppkhA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On Mon Aug 17 11:00, Jarkko Nikula wrote:

> If I remember correctly ACPI ID should not ever change and instance id :xy
> after INTABCD:xy should also be visible and keep the order even if device is
> disabled or not plugged. But I'm not absolute sure about this.
> 
> At least on a test platform that allow disable devices will show those
> devices off-line (/sys/bus/acpi/devices/INTABCD:xy/status == 0).

I'm always surprised how hard it is to tell what *can't* happen in ACPI.
How about a conditional call to LoadTable()?  Seems like that would mess
up the :xy.  Moot point, I think you're on the right track in your RFC
patch.

		--Dustin

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

end of thread, other threads:[~2015-08-25  5:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-14 19:37 [RFC 0/1] i2c: acpi: revert setting a "stable" device name Dustin Byford
2015-08-14 19:37 ` [RFC 1/1] " Dustin Byford
2015-08-15 15:13 ` [RFC 0/1] " Guenter Roeck
2015-08-17  8:00   ` Jarkko Nikula
     [not found]     ` <55D1948C.6080501-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-08-25  5:03       ` Dustin Byford

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).