linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Fix Firmware class name collision
@ 2007-12-04 23:45 Timur Tabi
  2007-12-04 23:52 ` Scott Wood
  0 siblings, 1 reply; 8+ messages in thread
From: Timur Tabi @ 2007-12-04 23:45 UTC (permalink / raw)
  To: Markus Rechberger, Greg Kroah-Hartman, PowerPC dev list

Markus and Greg,

I've found a problem with this patch that probably affects a number of embedded 
PowerPC systems:

http://marc.info/?l=linux-kernel&m=119222892713518&w=2

The problem is that the device name for many PowerPC SoC devices is based on the 
physical address.  So we have stuff like this:

# ls -l /sys/devices/
drwxr-xr-x    9 root     root            0 Nov  9 17:29 e0000000.soc8323
drwxr-xr-x   11 root     root            0 Nov  9 17:22 e0100000.qe
[snip]
# ls -l /sys/devices/e0000000.soc8323/
drwxr-xr-x    2 root     root            0 Nov  9 17:34 e0000200.wdt
drwxr-xr-x    2 root     root            0 Nov  9 17:34 e0000700.pic
drwxr-xr-x    2 root     root            0 Nov  9 17:34 e0001400.par_io
drwxr-xr-x    2 root     root            0 Nov  9 17:34 e0003000.i2c
drwxr-xr-x    2 root     root            0 Nov  9 17:34 e0004500.serial
drwxr-xr-x    2 root     root            0 Nov  9 17:34 e0004600.serial
drwxr-xr-x    2 root     root            0 Nov  9 17:34 e0030000.crypto
[snip]

With this patch, the device names in /sys/class/firmware look like this:

# ls -l /sys/class/firmware/
drwxr-xr-x    2 root     root            0 Nov  9 17:37 firmware-e0102400.u
-rw-r--r--    1 root     root         4096 Nov  9 17:22 timeout

In other words, the only thing you get is the first letter of the device name. 
You used to get the whole name.  The physical address obviously isn't very helpful.

The problem is the size of the string is only 20 characters:

static inline void fw_setup_device_id(struct device *f_dev, struct device *dev)
{
	snprintf(f_dev->bus_id, BUS_ID_SIZE, "firmware-%s", dev->bus_id);
}

Now, there are two solutions:

1) Change the PowerPC device names from physical_address.device_name to 
device_name.physical_address (so that e0102400.ucc becomes ucc.e0102400)

2) Change fw_setup_device_id() to something like this:

	snprintf(f_dev->bus_id, BUS_ID_SIZE, "fw-%s", dev->bus_id);

which do you think is a better idea?

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* Re: Fix Firmware class name collision
  2007-12-04 23:45 Fix Firmware class name collision Timur Tabi
@ 2007-12-04 23:52 ` Scott Wood
  2007-12-05  1:28   ` Timur Tabi
  0 siblings, 1 reply; 8+ messages in thread
From: Scott Wood @ 2007-12-04 23:52 UTC (permalink / raw)
  To: Timur Tabi; +Cc: PowerPC dev list, Greg Kroah-Hartman, Markus Rechberger

Timur Tabi wrote:
> 
> In other words, the only thing you get is the first letter of the device name. 
> You used to get the whole name.  The physical address obviously isn't very helpful.

The physical address certainly is useful when you have more than one 
device of the same name.

> Now, there are two solutions:
> 
> 1) Change the PowerPC device names from physical_address.device_name to 
> device_name.physical_address (so that e0102400.ucc becomes ucc.e0102400)

So then you'd get "firmware-ucc.e01024".  What if there's another ucc at 
  e0102480?  For devices with longer names, you'd have even less 
precision in the address.

-Scott

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

* Re: Fix Firmware class name collision
  2007-12-04 23:52 ` Scott Wood
@ 2007-12-05  1:28   ` Timur Tabi
  2007-12-14 22:40     ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Timur Tabi @ 2007-12-05  1:28 UTC (permalink / raw)
  To: Scott Wood; +Cc: PowerPC dev list, Greg Kroah-Hartman, Markus Rechberger

Scott Wood wrote:

> The physical address certainly is useful when you have more than one 
> device of the same name.

What I meant was that the physical address isn't helpful by itself.

> So then you'd get "firmware-ucc.e01024".  What if there's another ucc at 
>  e0102480?  For devices with longer names, you'd have even less 
> precision in the address.

Maybe we need to consider a more sophisticated algorithm, one that guarantees 
that the device name in its entirety is preserved?  Either that, or replace 
the physical address with something shorter, like the offset to the root node 
only?  That way, ucc.e0102400 because just ucc.2400.

-- 
Timur Tabi
Linux Kernel Developer @ Freescale

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

* Re: Fix Firmware class name collision
  2007-12-05  1:28   ` Timur Tabi
@ 2007-12-14 22:40     ` Greg KH
  2007-12-14 22:46       ` Timur Tabi
  2007-12-15  6:14       ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 8+ messages in thread
From: Greg KH @ 2007-12-14 22:40 UTC (permalink / raw)
  To: Timur Tabi; +Cc: PowerPC dev list, Markus Rechberger

On Tue, Dec 04, 2007 at 07:28:00PM -0600, Timur Tabi wrote:
> Scott Wood wrote:
>
>> The physical address certainly is useful when you have more than one 
>> device of the same name.
>
> What I meant was that the physical address isn't helpful by itself.
>
>> So then you'd get "firmware-ucc.e01024".  What if there's another ucc at  
>> e0102480?  For devices with longer names, you'd have even less precision 
>> in the address.
>
> Maybe we need to consider a more sophisticated algorithm, one that 
> guarantees that the device name in its entirety is preserved?  Either that, 
> or replace the physical address with something shorter, like the offset to 
> the root node only?  That way, ucc.e0102400 because just ucc.2400.

You should do something :)

In the near future (2.6.26) there will not be a limit on the size of the
file name, so we should not have this problem anymore.

thanks,

greg k-h

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

* Re: Fix Firmware class name collision
  2007-12-14 22:40     ` Greg KH
@ 2007-12-14 22:46       ` Timur Tabi
  2007-12-15  6:14       ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 8+ messages in thread
From: Timur Tabi @ 2007-12-14 22:46 UTC (permalink / raw)
  To: Greg KH; +Cc: PowerPC dev list, Markus Rechberger

Greg KH wrote:

> In the near future (2.6.26) there will not be a limit on the size of the
> file name, so we should not have this problem anymore.

In that case, I won't worry about it.  I would have preferred 2.6.25, since I 
have code going into 2.6.25 that is affected by the current limit.

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* Re: Fix Firmware class name collision
  2007-12-14 22:40     ` Greg KH
  2007-12-14 22:46       ` Timur Tabi
@ 2007-12-15  6:14       ` Benjamin Herrenschmidt
  2007-12-15  6:39         ` Greg KH
  1 sibling, 1 reply; 8+ messages in thread
From: Benjamin Herrenschmidt @ 2007-12-15  6:14 UTC (permalink / raw)
  To: Greg KH; +Cc: PowerPC dev list, Markus Rechberger, Timur Tabi


On Fri, 2007-12-14 at 14:40 -0800, Greg KH wrote:
> On Tue, Dec 04, 2007 at 07:28:00PM -0600, Timur Tabi wrote:
> > Scott Wood wrote:
> >
> >> The physical address certainly is useful when you have more than one 
> >> device of the same name.
> >
> > What I meant was that the physical address isn't helpful by itself.
> >
> >> So then you'd get "firmware-ucc.e01024".  What if there's another ucc at  
> >> e0102480?  For devices with longer names, you'd have even less precision 
> >> in the address.
> >
> > Maybe we need to consider a more sophisticated algorithm, one that 
> > guarantees that the device name in its entirety is preserved?  Either that, 
> > or replace the physical address with something shorter, like the offset to 
> > the root node only?  That way, ucc.e0102400 because just ucc.2400.
> 
> You should do something :)
> 
> In the near future (2.6.26) there will not be a limit on the size of the
> file name, so we should not have this problem anymore.

Not even .25 ? damn ! Any way that fix can be fastracked ? This
limitation has been a major PITA for some time now (this is just -one-
example where it gets in the way).

Ben.

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

* Re: Fix Firmware class name collision
  2007-12-15  6:14       ` Benjamin Herrenschmidt
@ 2007-12-15  6:39         ` Greg KH
  2007-12-15 15:46           ` Kay Sievers
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2007-12-15  6:39 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Kay Sievers
  Cc: PowerPC dev list, Markus Rechberger, Timur Tabi

On Sat, Dec 15, 2007 at 05:14:29PM +1100, Benjamin Herrenschmidt wrote:
> 
> On Fri, 2007-12-14 at 14:40 -0800, Greg KH wrote:
> > On Tue, Dec 04, 2007 at 07:28:00PM -0600, Timur Tabi wrote:
> > > Scott Wood wrote:
> > >
> > >> The physical address certainly is useful when you have more than one 
> > >> device of the same name.
> > >
> > > What I meant was that the physical address isn't helpful by itself.
> > >
> > >> So then you'd get "firmware-ucc.e01024".  What if there's another ucc at  
> > >> e0102480?  For devices with longer names, you'd have even less precision 
> > >> in the address.
> > >
> > > Maybe we need to consider a more sophisticated algorithm, one that 
> > > guarantees that the device name in its entirety is preserved?  Either that, 
> > > or replace the physical address with something shorter, like the offset to 
> > > the root node only?  That way, ucc.e0102400 because just ucc.2400.
> > 
> > You should do something :)
> > 
> > In the near future (2.6.26) there will not be a limit on the size of the
> > file name, so we should not have this problem anymore.
> 
> Not even .25 ? damn ! Any way that fix can be fastracked ? This
> limitation has been a major PITA for some time now (this is just -one-
> example where it gets in the way).

I'll let Kay answer that, last he said, it involves a _lot_ of changes
throughout the kernel :(

thanks,

greg k-h

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

* Re: Fix Firmware class name collision
  2007-12-15  6:39         ` Greg KH
@ 2007-12-15 15:46           ` Kay Sievers
  0 siblings, 0 replies; 8+ messages in thread
From: Kay Sievers @ 2007-12-15 15:46 UTC (permalink / raw)
  To: Greg KH; +Cc: Markus Rechberger, Timur Tabi, PowerPC dev list

On Fri, 2007-12-14 at 22:39 -0800, Greg KH wrote:
> On Sat, Dec 15, 2007 at 05:14:29PM +1100, Benjamin Herrenschmidt wrote:
> > 
> > On Fri, 2007-12-14 at 14:40 -0800, Greg KH wrote:
> > > On Tue, Dec 04, 2007 at 07:28:00PM -0600, Timur Tabi wrote:
> > > > Scott Wood wrote:
> > > >
> > > >> The physical address certainly is useful when you have more than one 
> > > >> device of the same name.
> > > >
> > > > What I meant was that the physical address isn't helpful by itself.
> > > >
> > > >> So then you'd get "firmware-ucc.e01024".  What if there's another ucc at  
> > > >> e0102480?  For devices with longer names, you'd have even less precision 
> > > >> in the address.
> > > >
> > > > Maybe we need to consider a more sophisticated algorithm, one that 
> > > > guarantees that the device name in its entirety is preserved?  Either that, 
> > > > or replace the physical address with something shorter, like the offset to 
> > > > the root node only?  That way, ucc.e0102400 because just ucc.2400.
> > > 
> > > You should do something :)
> > > 
> > > In the near future (2.6.26) there will not be a limit on the size of the
> > > file name, so we should not have this problem anymore.
> > 
> > Not even .25 ? damn ! Any way that fix can be fastracked ? This
> > limitation has been a major PITA for some time now (this is just -one-
> > example where it gets in the way).
> 
> I'll let Kay answer that, last he said, it involves a _lot_ of changes
> throughout the kernel :(

The current patch gets rid of bus_id and uses the dynamic kobject_name
directly all over the place. It's huge, because the current code expects
a static array and uses strncpy/snprintf all over the place.

I'm currently waiting for the new kobject api to finish, before I update
the patch, not sure if we will make it in time for .25.

Kay

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

end of thread, other threads:[~2007-12-15 15:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-04 23:45 Fix Firmware class name collision Timur Tabi
2007-12-04 23:52 ` Scott Wood
2007-12-05  1:28   ` Timur Tabi
2007-12-14 22:40     ` Greg KH
2007-12-14 22:46       ` Timur Tabi
2007-12-15  6:14       ` Benjamin Herrenschmidt
2007-12-15  6:39         ` Greg KH
2007-12-15 15:46           ` Kay Sievers

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