Skip to contentSkip to conversation

firewire: time out in fw_core_remove_card

PATCH In review Stefan Richter 1 participant 2 messages Sep 14, 2008 Firewire

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firewire: time out in fw_core_remove_card

This allows "modprobe -r firewire-ohci" (or card unbinding in general) to proceed after 40 seconds even if there is a reference counting bug or other shutdown bug in upper layers.

---
 drivers/firewire/fw-card.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/firewire/fw-card.c +3 -1
Index: linux/drivers/firewire/fw-card.c
===================================================================
@@ -16,6 +16,7 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <linux/bug.h>
 #include <linux/completion.h>
 #include <linux/crc-itu-t.h>
 #include <linux/delay.h>
@@ -508,7 +509,8 @@ fw_core_remove_card(struct fw_card *card
 
 	/* Wait for all users, especially device workqueue jobs, to finish. */
 	fw_card_put(card);
-	wait_for_completion(&card->done);
+	WARN(wait_for_completion_timeout(&card->done, 40 * HZ) == 0,
+	     KBUILD_MODNAME ": forced card shutdown with references held\n");
 
 	cancel_delayed_work_sync(&card->work);
 	WARN_ON(!list_empty(&card->transaction_list));
Signature · 3 lines
Stefan Richter
-=====-==--- =--= -===-
http://arcgraph.de/sr/
#1 lore raw
Quoted 3 lines · I wrote:

This allows "modprobe -r firewire-ohci" (or card unbinding in general) to proceed after 40 seconds even if there is a reference counting bug or other shutdown bug in upper layers.

Hmm, this doesn't work quite perfectly yet if there are userspace clients which keep a device open. fw-cdev needs to be trained to let go of a device as gracefully as fw-sbp2 does nowadays.

Signature · 3 lines
Stefan Richter
-=====-==--- =--= -===-
http://arcgraph.de/sr/