diff options
author | Dan Williams <dcbw@redhat.com> | 2010-12-19 03:17:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-28 16:41:41 -0500 |
commit | 12f188f2e59394ec1f1c8c0a4439f48ec16bc336 (patch) | |
tree | af7ccd94ab4173dad997d0ff0a45c852799f639a | |
parent | d7c1255a3a21e98bdc64df8ccf005a174d7e6289 (diff) |
ueagle-atm: fix PHY signal initialization race
A race exists when initializing ueagle-atm devices where the generic atm
device may not yet be created before the driver attempts to initialize
it's PHY signal state, which checks whether the atm device has been
created or not. This often causes the sysfs 'carrier' attribute to be
'1' even though no signal has actually been found.
uea_probe
usbatm_usb_probe
driver->bind (uea_bind)
uea_boot
kthread_run(uea_kthread) uea_kthread
usbatm_atm_init uea_start_reset
atm_dev_register UPDATE_ATM_SIGNAL
UPDATE_ATM_SIGNAL checks whether the ATM device has been created and if
not, will not update the PHY signal state. Because of the race that
does not always happen in time, and the PHY signal state remains
ATM_PHY_SIG_FOUND even though no signal exists.
To fix the race, just create the kthread during initialization, and only
after initialization is complete, start the thread that reboots the
device and initializes PHY state.
[ 3030.490931] uea_probe: calling usbatm_usb_probe
[ 3030.490946] ueagle-atm 8-2:1.0: usbatm_usb_probe: trying driver ueagle-atm with vendor=1110, product=9031, ifnum 0
[ 3030.493691] uea_bind: setting usbatm
[ 3030.496932] usb 8-2: [ueagle-atm] using iso mode
[ 3030.497283] ueagle-atm 8-2:1.0: usbatm_usb_probe: using 3021 byte buffer for rx channel 0xffff880125953508
<kthread already started before usbatm_usb_probe() has returned>
[ 3030.497292] usb 8-2: [ueagle-atm] (re)booting started
<UPDATE_ATM_SIGNAL checks whether ATM device has been created yet before setting PHY state>
[ 3030.497298] uea_start_reset: atm dev (null)
<and since it hasn't been created yet PHY state is not set>
[ 3030.497306] ueagle-atm 8-2:1.0: usbatm_usb_probe: using 3392 byte buffer for tx channel 0xffff8801259535b8
[ 3030.497374] usbatm_usb_probe: about to init
[ 3030.497379] usbatm_usb_probe: calling usbatm_atm_init
<atm device finally gets created>
[ 3030.497384] usbatm_atm_init: creating atm device!
Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/usb/atm/ueagle-atm.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 44447f54942f..99ac70e32556 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -2206,8 +2206,11 @@ static int uea_boot(struct uea_softc *sc) | |||
2206 | goto err1; | 2206 | goto err1; |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | sc->kthread = kthread_run(uea_kthread, sc, "ueagle-atm"); | 2209 | /* Create worker thread, but don't start it here. Start it after |
2210 | if (sc->kthread == ERR_PTR(-ENOMEM)) { | 2210 | * all usbatm generic initialization is done. |
2211 | */ | ||
2212 | sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm"); | ||
2213 | if (IS_ERR(sc->kthread)) { | ||
2211 | uea_err(INS_TO_USBDEV(sc), "failed to create thread\n"); | 2214 | uea_err(INS_TO_USBDEV(sc), "failed to create thread\n"); |
2212 | goto err2; | 2215 | goto err2; |
2213 | } | 2216 | } |
@@ -2624,6 +2627,7 @@ static struct usbatm_driver uea_usbatm_driver = { | |||
2624 | static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) | 2627 | static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) |
2625 | { | 2628 | { |
2626 | struct usb_device *usb = interface_to_usbdev(intf); | 2629 | struct usb_device *usb = interface_to_usbdev(intf); |
2630 | int ret; | ||
2627 | 2631 | ||
2628 | uea_enters(usb); | 2632 | uea_enters(usb); |
2629 | uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n", | 2633 | uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n", |
@@ -2637,7 +2641,19 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2637 | if (UEA_IS_PREFIRM(id)) | 2641 | if (UEA_IS_PREFIRM(id)) |
2638 | return uea_load_firmware(usb, UEA_CHIP_VERSION(id)); | 2642 | return uea_load_firmware(usb, UEA_CHIP_VERSION(id)); |
2639 | 2643 | ||
2640 | return usbatm_usb_probe(intf, id, &uea_usbatm_driver); | 2644 | ret = usbatm_usb_probe(intf, id, &uea_usbatm_driver); |
2645 | if (ret == 0) { | ||
2646 | struct usbatm_data *usbatm = usb_get_intfdata(intf); | ||
2647 | struct uea_softc *sc = usbatm->driver_data; | ||
2648 | |||
2649 | /* Ensure carrier is initialized to off as early as possible */ | ||
2650 | UPDATE_ATM_SIGNAL(ATM_PHY_SIG_LOST); | ||
2651 | |||
2652 | /* Only start the worker thread when all init is done */ | ||
2653 | wake_up_process(sc->kthread); | ||
2654 | } | ||
2655 | |||
2656 | return ret; | ||
2641 | } | 2657 | } |
2642 | 2658 | ||
2643 | static void uea_disconnect(struct usb_interface *intf) | 2659 | static void uea_disconnect(struct usb_interface *intf) |