driver,platform,firmware,system, data data data ....
Subsystems (2)
Hi Greg !
I'm in need of something around the lines of pci "sysdata" but generically (for all devices). So I had a look, and noticed that in struct device, we have already 3 "data":
- driver_data (ok, that one we know all about)
- firmware_data (just discovered it, I already know what to use it
for :)
- platform_data (ugh ?)
It's my understanding that the later is for use by platform drivers, right ?
So except for the size of the patch and boredom of going through all of them fixing them, do you see any reason why this later one shouldn't be moved out to platform_driver ? (I haven't actually checked at all the occurences in the tree though).
On the other hand, we have in pci_dev
- sysdata (ok, let's call it system_data)
Which I would quite like to see in struct device instead :)
The reason is that I have to deal with setups with multiple iommu's and non-PCI devices. The current powerpc infrastructure for findign the right iommu for dma_ops tests various bus types (pci and vio for now for pci and virtual ios) and get the right data structure defined by each of these (in sysdata for pci, some other field for vio) to get the iommu table pointer.
Now, with more non-pci bus types coming in, and the advent of some platform-like OF (open firmware probed) devices, we end up with more of these bus types and a fairly complicated situation to get to the iommu. Since it's a fairly hot path, I'm not happy comparing the bus type with 3 or more types and going looking at various bus specific data structures to find it.
Thus I want a arch-wide data structure that can be attached to any struct device to carry the iommu table pointer (and maybe a couple of other things in the future but it's mostly that for now).
Thus that would be a nice fit for a system_data there (and since that's what we use sysdata in pci_dev for, basically, remove the later).
As a temporary measure, I'll hijack firmware_data which isn't used for anything on powerpc at the moment (though I'd like to use it in the future for a pointer to the OF device node if any).
Any comments on the approach ? If you are ok, I'll look into doing the tedious work of converting the whole tree to those 2 changes (moving platform_data to platform_driver and pci sysdata to generic system_data) and cook some patches for after 2.6.19.
Cheers,
Ben.
Benjamin Herrenschmidt wrote:
[ device->platform_data ]
Quoted 4 lines
So except for the size of the patch and boredom of going through all of them fixing them, do you see any reason why this later one shouldn't be moved out to
platform_driver? (I haven't actually checked at all the occurences in the tree though).
You'll find it being used in drivers/base/isa.c for one. I only used it there because it was available and made for slightly nicer code though. If platform_data is going away (and assuming you wouldn't want similar abuse of your new system_data) it wouldn't be a problem to move the driver pointer to the private struct isa_dev as in the attached.
Rene.
drivers/base/isa.c +25 -19
@@ -16,6 +16,7 @@struct isa_dev {struct device dev;struct device *next; +struct isa_driver *isa_driver;unsigned int id; };
@@ -23,61 +24,66 @@static int isa_bus_match (struct device *dev,struct device_driver *driver) { -struct isa_driver *isa_driver =to_isa_driver (driver); +struct isa_dev *isa_dev =to_isa_dev (dev); +struct isa_driver *isa_driver = isa_dev->isa_driver; -if (dev->platform_data == isa_driver) { -if (!isa_driver->match || - isa_driver->match (dev,to_isa_dev (dev)->id)) +if (isa_driver ==to_isa_driver (driver)) { +if (!isa_driver->match || isa_driver->match (dev, isa_dev->id))return 1 ; - dev->platform_data =NULL ; + isa_dev->isa_driver =NULL ; }return 0 ; }static int isa_bus_probe (struct device *dev) { -struct isa_driver *isa_driver = dev->platform_data; +struct isa_dev *isa_dev =to_isa_dev (dev); +struct isa_driver *isa_driver = isa_dev->isa_driver;if (isa_driver->probe) -return isa_driver->probe (dev,to_isa_dev (dev)->id); +return isa_driver->probe (dev, isa_dev->id);return 0 ; }static int isa_bus_remove (struct device *dev) { -struct isa_driver *isa_driver = dev->platform_data; +struct isa_dev *isa_dev =to_isa_dev (dev); +struct isa_driver *isa_driver = isa_dev->isa_driver;if (isa_driver->remove) -return isa_driver->remove (dev,to_isa_dev (dev)->id); +return isa_driver->remove (dev, isa_dev->id);return 0 ; }static void isa_bus_shutdown (struct device *dev) { -struct isa_driver *isa_driver = dev->platform_data; +struct isa_dev *isa_dev =to_isa_dev (dev); +struct isa_driver *isa_driver = isa_dev->isa_driver;if (isa_driver->shutdown) - isa_driver->shutdown (dev,to_isa_dev (dev)->id); + isa_driver->shutdown (dev, isa_dev->id); }static int isa_bus_suspend (struct device *dev,pm_message_t state) { -struct isa_driver *isa_driver = dev->platform_data; +struct isa_dev *isa_dev =to_isa_dev (dev); +struct isa_driver *isa_driver = isa_dev->isa_driver;if (isa_driver->suspend) -return isa_driver->suspend (dev,to_isa_dev (dev)->id, state); +return isa_driver->suspend (dev, isa_dev->id, state);return 0 ; }static int isa_bus_resume (struct device *dev) { -struct isa_driver *isa_driver = dev->platform_data; +struct isa_dev *isa_dev =to_isa_dev (dev); +struct isa_driver *isa_driver = isa_dev->isa_driver;if (isa_driver->resume) -return isa_driver->resume (dev,to_isa_dev (dev)->id); +return isa_driver->resume (dev, isa_dev->id);return 0 ; }
@@ -137,9 +143,9 @@snprintf (isa_dev->dev.bus_id,BUS_ID_SIZE ,"%s.%u" , isa_driver->driver.name, id); - isa_dev->dev.platform_data = isa_driver; - isa_dev->dev.release = isa_dev_release; - isa_dev->id = id; + isa_dev->dev.release = isa_dev_release; + isa_dev->isa_driver = isa_driver; + isa_dev->id = id; error =device_register (&isa_dev->dev);if (error) {
@@ -147,7 +153,7 @@break ; } -if (isa_dev->dev.platform_data) { +if (isa_dev->isa_driver) { isa_dev->next = isa_driver->devices; isa_driver->devices = &isa_dev->dev; }else
Quoted 9 lines · Rene Herman
Benjamin Herrenschmidt wrote:
[
device->platform_data]Quoted 4 lines
So except for the size of the patch and boredom of going through all of them fixing them, do you see any reason why this later one shouldn't be moved out to
platform_driver? (I haven't actually checked at all the occurences in the tree though).
Quoted 5 lines
You'll find it being used in
drivers/base/isa.cfor one. I only used it there because it was available and made for slightly nicer code though. Ifplatform_datais going away (and assuming you wouldn't want similar abuse of your newsystem_data) it wouldn't be a problem to move the driver pointer to the private structisa_devas in the attached.
Ah thanks, I missed that use.
Well, we'll see what Greg has to say but thanks for the patch.
Cheers,
Ben.