Integrating code with msleep into code with mutexes (AR9271 driver)

Hello FreeBSD community!

As you can see here: https://forums.freebsd.org/threads/ar9271-usb-driver.93007/, we are developing the AR9271 USB driver. We want to integrate it with an existing ATH driver.

Existing ATH driver uses PCI communication, which is fast and doesn't require synchronization.
Our driver uses USB communication with msleep and interrupts to wake it up.
The challenge is that ATH drivers use separate locks. After integrating our code, the scenario looks like this:
C:
ATH_LOCK();
/* Our code */
ATH_USB_LOCK();
msleep(...);        // Wait for wakeup from USB interrupt
ATH_USB_UNLOCK();
/* Our code end */
ATH_UNLOCK();
In this example ATH_LOCK and ATH_USB_LOCK are mtx_lock of different mutexes. There are different recursive locks in the ATH driver so it's not always ATH_LOCK.

The problem is that the msleep drops the outer mutex.

We don't know how to fix the problem.

Would appreciate any tips you can offer!

Cheers,
Mikolaj
 
Agree with SirDice: Mailing lists!

When calling msleep, you have to specify which lock to drop. I think that's done in a mtx structure. Which lock does it contain?
 
I pass the one used in USB_LOCK. Now I think it's invalid and the lock doesn't really do much.

I've sent an email to the mailing lists. Thanks for the suggestion!
 
Back
Top