struct urb_list {
struct list_head list;
+ struct list_head in_flight;
spinlock_t lock;
wait_queue_head_t sleep;
int available;
int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len);
int udl_sync_pending_urbs(struct drm_device *dev);
+void udl_kill_pending_urbs(struct drm_device *dev);
void udl_urb_completion(struct urb *urb);
int udl_init(struct udl_device *udl);
urb->transfer_buffer_length = udl->urbs.size; /* reset to actual */
spin_lock_irqsave(&udl->urbs.lock, flags);
- list_add_tail(&unode->entry, &udl->urbs.list);
+ list_move(&unode->entry, &udl->urbs.list);
udl->urbs.available++;
spin_unlock_irqrestore(&udl->urbs.lock, flags);
retry:
udl->urbs.size = size;
INIT_LIST_HEAD(&udl->urbs.list);
+ INIT_LIST_HEAD(&udl->urbs.in_flight);
init_waitqueue_head(&udl->urbs.sleep);
udl->urbs.count = 0;
}
unode = list_first_entry(&udl->urbs.list, struct urb_node, entry);
- list_del_init(&unode->entry);
+ list_move(&unode->entry, &udl->urbs.in_flight);
udl->urbs.available--;
unlock:
spin_lock_irq(&udl->urbs.lock);
/* 2 seconds as a sane timeout */
if (!wait_event_lock_irq_timeout(udl->urbs.sleep,
- udl->urbs.available == udl->urbs.count,
+ list_empty(&udl->urbs.in_flight),
udl->urbs.lock,
msecs_to_jiffies(2000)))
ret = -ETIMEDOUT;
return ret;
}
+/* kill pending URBs */
+void udl_kill_pending_urbs(struct drm_device *dev)
+{
+ struct udl_device *udl = to_udl(dev);
+ struct urb_node *unode;
+
+ spin_lock_irq(&udl->urbs.lock);
+ while (!list_empty(&udl->urbs.in_flight)) {
+ unode = list_first_entry(&udl->urbs.in_flight,
+ struct urb_node, entry);
+ spin_unlock_irq(&udl->urbs.lock);
+ usb_kill_urb(unode->urb);
+ spin_lock_irq(&udl->urbs.lock);
+ }
+ spin_unlock_irq(&udl->urbs.lock);
+}
+
int udl_init(struct udl_device *udl)
{
struct drm_device *dev = &udl->drm;
{
struct udl_device *udl = to_udl(dev);
+ udl_kill_pending_urbs(dev);
udl_free_urb_list(dev);
put_device(udl->dmadev);
udl->dmadev = NULL;