diff options
author | Thomas Pugliese <thomas.pugliese@gmail.com> | 2013-06-24 14:26:35 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-24 16:20:43 -0700 |
commit | a899575191ba85a71401f2c8f36bec7b14487043 (patch) | |
tree | 74070049b20ec44cf625db68ac62751e4b33cab0 /drivers/usb/wusbcore | |
parent | 6e6581e0a94758a4e69fab82407d39312eeff5c4 (diff) | |
download | talos-obmc-linux-a899575191ba85a71401f2c8f36bec7b14487043.tar.gz talos-obmc-linux-a899575191ba85a71401f2c8f36bec7b14487043.zip |
USB: HWA: fix device probe failure
This patch fixes a race condition that caused the HWA_HC interface probe
function to occasionally fail. The HWA_HC would attempt to register
itself with the HWA_RC by searching for a uwb_rc class device with the
same parent device ptr. If the probe function for the HWA_RC interface
had yet to run, the uwb_rc class device would not have been created
causing the look up to fail and the HWA_HC probe function to return an
error causing the device to be unusable.
The fix is for the HWA to delay registering with the HWA_RC until
receiving the command from userspace to start the wireless channel. It
is the responsibility of userspace to ensure that the uwb_rc class
device has been created before starting the HWA channel.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/wusbcore')
-rw-r--r-- | drivers/usb/wusbcore/mmc.c | 27 | ||||
-rw-r--r-- | drivers/usb/wusbcore/pal.c | 5 | ||||
-rw-r--r-- | drivers/usb/wusbcore/reservation.c | 3 | ||||
-rw-r--r-- | drivers/usb/wusbcore/wusbhc.c | 9 |
4 files changed, 35 insertions, 9 deletions
diff --git a/drivers/usb/wusbcore/mmc.c b/drivers/usb/wusbcore/mmc.c index 021467f86d9e..b71760c8d3ad 100644 --- a/drivers/usb/wusbcore/mmc.c +++ b/drivers/usb/wusbcore/mmc.c @@ -195,6 +195,7 @@ int wusbhc_start(struct wusbhc *wusbhc) struct device *dev = wusbhc->dev; WARN_ON(wusbhc->wuie_host_info != NULL); + BUG_ON(wusbhc->uwb_rc == NULL); result = wusbhc_rsv_establish(wusbhc); if (result < 0) { @@ -276,12 +277,38 @@ int wusbhc_chid_set(struct wusbhc *wusbhc, const struct wusb_ckhdid *chid) } wusbhc->chid = *chid; } + + /* register with UWB if we haven't already since we are about to start + the radio. */ + if ((chid) && (wusbhc->uwb_rc == NULL)) { + wusbhc->uwb_rc = uwb_rc_get_by_grandpa(wusbhc->dev->parent); + if (wusbhc->uwb_rc == NULL) { + result = -ENODEV; + dev_err(wusbhc->dev, "Cannot get associated UWB Host Controller\n"); + goto error_rc_get; + } + + result = wusbhc_pal_register(wusbhc); + if (result < 0) { + dev_err(wusbhc->dev, "Cannot register as a UWB PAL\n"); + goto error_pal_register; + } + } mutex_unlock(&wusbhc->mutex); if (chid) result = uwb_radio_start(&wusbhc->pal); else uwb_radio_stop(&wusbhc->pal); + + return result; + +error_pal_register: + uwb_rc_put(wusbhc->uwb_rc); + wusbhc->uwb_rc = NULL; +error_rc_get: + mutex_unlock(&wusbhc->mutex); + return result; } EXPORT_SYMBOL_GPL(wusbhc_chid_set); diff --git a/drivers/usb/wusbcore/pal.c b/drivers/usb/wusbcore/pal.c index d0b172c5ecc7..59e100c2eb50 100644 --- a/drivers/usb/wusbcore/pal.c +++ b/drivers/usb/wusbcore/pal.c @@ -45,10 +45,11 @@ int wusbhc_pal_register(struct wusbhc *wusbhc) } /** - * wusbhc_pal_register - unregister the WUSB HC as a UWB PAL + * wusbhc_pal_unregister - unregister the WUSB HC as a UWB PAL * @wusbhc: the WUSB HC */ void wusbhc_pal_unregister(struct wusbhc *wusbhc) { - uwb_pal_unregister(&wusbhc->pal); + if (wusbhc->uwb_rc) + uwb_pal_unregister(&wusbhc->pal); } diff --git a/drivers/usb/wusbcore/reservation.c b/drivers/usb/wusbcore/reservation.c index 6f4fafdc2401..ead79f793927 100644 --- a/drivers/usb/wusbcore/reservation.c +++ b/drivers/usb/wusbcore/reservation.c @@ -80,6 +80,9 @@ int wusbhc_rsv_establish(struct wusbhc *wusbhc) struct uwb_dev_addr bcid; int ret; + if (rc == NULL) + return -ENODEV; + rsv = uwb_rsv_create(rc, wusbhc_rsv_complete_cb, wusbhc); if (rsv == NULL) return -ENOMEM; diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c index e712af3e46c2..742c607d1fa3 100644 --- a/drivers/usb/wusbcore/wusbhc.c +++ b/drivers/usb/wusbcore/wusbhc.c @@ -325,13 +325,7 @@ int wusbhc_b_create(struct wusbhc *wusbhc) goto error_create_attr_group; } - result = wusbhc_pal_register(wusbhc); - if (result < 0) - goto error_pal_register; return 0; - -error_pal_register: - sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group); error_create_attr_group: return result; } @@ -457,7 +451,8 @@ EXPORT_SYMBOL_GPL(wusbhc_giveback_urb); */ void wusbhc_reset_all(struct wusbhc *wusbhc) { - uwb_rc_reset_all(wusbhc->uwb_rc); + if (wusbhc->uwb_rc) + uwb_rc_reset_all(wusbhc->uwb_rc); } EXPORT_SYMBOL_GPL(wusbhc_reset_all); |