Re: WARNING in cm109_urb_irq_callback/usb_submit_urb

From: Oliver Neukum
Date: Thu Mar 20 2025 - 11:42:53 EST


On 20.03.25 15:25, Alan Stern wrote:

This test must itself be subject to the same race, right? There needs
to be some kind of synchronization between the two tasks (i.e., a mutex,
spinlock, or something similar).

Hi,

there is:

static void cm109_stop_traffic(struct cm109_dev *dev)
{
dev->shutdown = 1;
/*
* Make sure other CPUs see this
*/
smp_wmb();
usb_kill_urb(dev->urb_ctl);
usb_kill_urb(dev->urb_irq);
cm109_toggle_buzzer_sync(dev, 0);
dev->shutdown = 0;
smp_wmb();
}

This driver has a tough job as the two completion
handlers submitted each other's as well as their own
URBs based on the data they get.
That scheme is rather complex, but as far as I can tell correct,
but you need to test that flag everywhere.

Regards
Oliver