Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: function: f_fs: Move epfile waitqueue to ffs_data.

There were individual waitqueues for each epfile but eps_enable
would iterate through all of them, resulting in essentially the
same wakeup time.

The waitqueue represents the function being enabled, so a central
waitqueue in ffs_data makes more sense and is less redundant.

Also use wake_up_interruptible to reflect use of
wait_event_interruptible.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Jerry Zhang <zhangjerry@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Jerry Zhang and committed by
Felipe Balbi
e16828cf 222155de

+13 -9
+10 -9
drivers/usb/gadget/function/f_fs.c
··· 127 127 struct ffs_epfile { 128 128 /* Protects ep->ep and ep->req. */ 129 129 struct mutex mutex; 130 - wait_queue_head_t wait; 131 130 132 131 struct ffs_data *ffs; 133 132 struct ffs_ep *ep; /* P: ffs->eps_lock */ ··· 888 889 if (file->f_flags & O_NONBLOCK) 889 890 return -EAGAIN; 890 891 891 - ret = wait_event_interruptible(epfile->wait, (ep = epfile->ep)); 892 + ret = wait_event_interruptible( 893 + epfile->ffs->wait, (ep = epfile->ep)); 892 894 if (ret) 893 895 return -EINTR; 894 896 } ··· 1203 1203 if (file->f_flags & O_NONBLOCK) 1204 1204 return -EAGAIN; 1205 1205 1206 - ret = wait_event_interruptible(epfile->wait, (ep = epfile->ep)); 1206 + ret = wait_event_interruptible( 1207 + epfile->ffs->wait, (ep = epfile->ep)); 1207 1208 if (ret) 1208 1209 return -EINTR; 1209 1210 } ··· 1609 1608 pr_info("%s(): freeing\n", __func__); 1610 1609 ffs_data_clear(ffs); 1611 1610 BUG_ON(waitqueue_active(&ffs->ev.waitq) || 1612 - waitqueue_active(&ffs->ep0req_completion.wait)); 1611 + waitqueue_active(&ffs->ep0req_completion.wait) || 1612 + waitqueue_active(&ffs->wait)); 1613 1613 kfree(ffs->dev_name); 1614 1614 kfree(ffs); 1615 1615 } ··· 1657 1655 mutex_init(&ffs->mutex); 1658 1656 spin_lock_init(&ffs->eps_lock); 1659 1657 init_waitqueue_head(&ffs->ev.waitq); 1658 + init_waitqueue_head(&ffs->wait); 1660 1659 init_completion(&ffs->ep0req_completion); 1661 1660 1662 1661 /* XXX REVISIT need to update it in some places, or do we? */ ··· 1779 1776 for (i = 1; i <= count; ++i, ++epfile) { 1780 1777 epfile->ffs = ffs; 1781 1778 mutex_init(&epfile->mutex); 1782 - init_waitqueue_head(&epfile->wait); 1783 1779 if (ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR) 1784 1780 sprintf(epfile->name, "ep%02x", ffs->eps_addrmap[i]); 1785 1781 else ··· 1803 1801 ENTER(); 1804 1802 1805 1803 for (; count; --count, ++epfile) { 1806 - BUG_ON(mutex_is_locked(&epfile->mutex) || 1807 - waitqueue_active(&epfile->wait)); 1804 + BUG_ON(mutex_is_locked(&epfile->mutex)); 1808 1805 if (epfile->dentry) { 1809 1806 d_delete(epfile->dentry); 1810 1807 dput(epfile->dentry); ··· 1890 1889 break; 1891 1890 } 1892 1891 1893 - wake_up(&epfile->wait); 1894 - 1895 1892 ++ep; 1896 1893 ++epfile; 1897 1894 } 1895 + 1896 + wake_up_interruptible(&ffs->wait); 1898 1897 spin_unlock_irqrestore(&func->ffs->eps_lock, flags); 1899 1898 1900 1899 return ret;
+3
drivers/usb/gadget/function/u_fs.h
··· 216 216 #define FFS_FL_CALL_CLOSED_CALLBACK 0 217 217 #define FFS_FL_BOUND 1 218 218 219 + /* For waking up blocked threads when function is enabled. */ 220 + wait_queue_head_t wait; 221 + 219 222 /* Active function */ 220 223 struct ffs_function *func; 221 224