uwb: avoid radio controller reset loops
authorDavid Vrabel <david.vrabel@csr.com>
Tue, 25 Aug 2009 15:41:06 +0000 (16:41 +0100)
committerDavid Vrabel <david.vrabel@csr.com>
Wed, 26 Aug 2009 11:39:29 +0000 (12:39 +0100)
If a radio controller reset attempt occurs while a probe() or remove()
is in progress it fails and is retried endlessly, potentially preventing
the probe() or remove() from completing.

If a reset fails, sleep for a bit before retrying the reset.  This
allows the probe()/remove() to complete.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
drivers/uwb/hwa-rc.c
drivers/uwb/reset.c
drivers/uwb/umc-bus.c
drivers/uwb/whc-rc.c
include/linux/uwb.h

index 9052bcb..e7eeb63 100644 (file)
@@ -887,8 +887,7 @@ static int hwarc_post_reset(struct usb_interface *iface)
        struct hwarc *hwarc = usb_get_intfdata(iface);
        struct uwb_rc *uwb_rc = hwarc->uwb_rc;
 
-       uwb_rc_post_reset(uwb_rc);
-       return 0;
+       return uwb_rc_post_reset(uwb_rc);
 }
 
 /** USB device ID's that we handle */
index 70f8050..7f0512e 100644 (file)
@@ -30,6 +30,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/err.h>
+#include <linux/delay.h>
 
 #include "uwb-internal.h"
 
@@ -323,13 +324,15 @@ int uwbd_msg_handle_reset(struct uwb_event *evt)
 
        dev_info(&rc->uwb_dev.dev, "resetting radio controller\n");
        ret = rc->reset(rc);
-       if (ret) {
+       if (ret < 0) {
                dev_err(&rc->uwb_dev.dev, "failed to reset hardware: %d\n", ret);
                goto error;
        }
        return 0;
 error:
-       /* Nothing can be done except try the reset again. */
+       /* Nothing can be done except try the reset again. Wait a bit
+          to avoid reset loops during probe() or remove(). */
+       msleep(1000);
        uwb_rc_reset_all(rc);
        return ret;
 }
@@ -368,22 +371,20 @@ void uwb_rc_pre_reset(struct uwb_rc *rc)
 }
 EXPORT_SYMBOL_GPL(uwb_rc_pre_reset);
 
-void uwb_rc_post_reset(struct uwb_rc *rc)
+int uwb_rc_post_reset(struct uwb_rc *rc)
 {
        int ret;
 
        ret = rc->start(rc);
        if (ret)
-               goto error;
+               goto out;
        ret = uwb_rc_mac_addr_set(rc, &rc->uwb_dev.mac_addr);
        if (ret)
-               goto error;
+               goto out;
        ret = uwb_rc_dev_addr_set(rc, &rc->uwb_dev.dev_addr);
        if (ret)
-               goto error;
-       return;
-error:
-       /* Nothing can be done except try the reset again. */
-       uwb_rc_reset_all(rc);
+               goto out;
+out:
+       return ret;
 }
 EXPORT_SYMBOL_GPL(uwb_rc_post_reset);
index 5ad3616..cdd6c8e 100644 (file)
@@ -66,7 +66,7 @@ int umc_controller_reset(struct umc_dev *umc)
                return -EAGAIN;
        ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper);
        if (ret >= 0)
-               device_for_each_child(parent, parent, umc_bus_post_reset_helper);
+               ret = device_for_each_child(parent, parent, umc_bus_post_reset_helper);
        up(&parent->sem);
 
        return ret;
index 19a1dd1..1d9a6f5 100644 (file)
@@ -443,8 +443,7 @@ static int whcrc_post_reset(struct umc_dev *umc)
        struct whcrc *whcrc = umc_get_drvdata(umc);
        struct uwb_rc *uwb_rc = whcrc->uwb_rc;
 
-       uwb_rc_post_reset(uwb_rc);
-       return 0;
+       return uwb_rc_post_reset(uwb_rc);
 }
 
 /* PCI device ID's that we handle [so it gets loaded] */
index c021289..7fc9746 100644 (file)
@@ -597,7 +597,7 @@ void uwb_rc_neh_grok(struct uwb_rc *, void *, size_t);
 void uwb_rc_neh_error(struct uwb_rc *, int);
 void uwb_rc_reset_all(struct uwb_rc *rc);
 void uwb_rc_pre_reset(struct uwb_rc *rc);
-void uwb_rc_post_reset(struct uwb_rc *rc);
+int uwb_rc_post_reset(struct uwb_rc *rc);
 
 /**
  * uwb_rsv_is_owner - is the owner of this reservation the RC?