firewire: ohci: fix successive Config ROM changes
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20110430132424.02166e71@stein
A message that is not in the archive (sent off-list or not yet received): 20110430151640.6f299d63@stein
PATCH 1/1 firewire: ohci: fix successive Config ROM changes
When fw_core_add_descriptor() or fw_core_remove_descriptor() is called several times within the same bus generation, firewire-ohci would only take over the first of these changes into the image that is shown in read responses in the Configuration ROM range.
This bug always existed at least theoretically. It became easy to trigger since 2.6.36 commit 02d37bed188c "firewire: core: integrate software-forced bus resets with bus management" which introduced long mandatory delays between janitorial bus resets.
Fix this by a different buffer management for the Configuration ROM image:
a) Instead of holding 1 buffer during the lifetime of the fw_ohci instance + 1 buffer from ROM update request until self-ID-complete event, hold 2 buffers during the fw_ohci lifetime. (Since dma_alloc_coherent() apparently takes more memory than requested, the new scheme does not result in more memory consumption.)
b) Assume that we can scribble over the image for the next generation until the moment when the ROMheader quadlet is copied into the controller's corresponding register, i.e. even after the buffer address was written to the ConfigROMmap register. We assumed this already for the first ROM quadlet but extend this assumption to the entire ROM now.
The new scheme eliminates not only the -EBUSY case from ohci_set_config_rom() which caused the bug, but also its -ENOMEM case which would likewise result in dropped Configuration ROM updates. card->driver->set_config_rom() is now a function that never fails, just like firewire-core's implementation already assumed all the time.
--- drivers/firewire/core.h | 6 drivers/firewire/ohci.c | 192 +++++++++++++++++----------------------- 2 files changed, 84 insertions(+), 114 deletions(-)
drivers/firewire/core.h +3 -3
@@ -58,10 +58,10 @@ struct fw_card_driver {/* * Update the config rom for an enabled card. This function * should change the config rom that is presented on the bus -* and initiate a bus reset. +* and schedule a bus reset. */ -int (*set_config_rom)(struct fw_card *card, -const __be32 *config_rom,size_t length); +void (*set_config_rom)(struct fw_card *card, +const __be32 *config_rom,size_t length);void (*send_request)(struct fw_card *card,struct fw_packet *packet);void (*send_response)(struct fw_card *card,struct fw_packet *packet);
drivers/firewire/ohci.c +81 -111
319 lines not on this page · raw message
Signature · 3 lines
Stefan Richter -=====-==-== -=-= ----= http://arcgraph.de/sr/