Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753252AbdHRNd5 (ORCPT ); Fri, 18 Aug 2017 09:33:57 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:55531 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752815AbdHRNPt (ORCPT ); Fri, 18 Aug 2017 09:15:49 -0400 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Amitoj Kaur Chawla" , "Greg Kroah-Hartman" Date: Fri, 18 Aug 2017 14:13:20 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 088/134] staging: gdm724x: gdm_mux: Remove create_workqueue() In-Reply-To: X-SA-Exim-Connect-IP: 82.70.136.246 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2557 Lines: 85 3.16.47-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Amitoj Kaur Chawla commit c272dc2da14cde0bfd9495a5aafb8e3e94f35601 upstream. With concurrency managed workqueues, use of dedicated workqueues can be replaced by using system_wq. Drop mux_rx_wq by using system_wq. Since there is only one work item per mux_dev and different mux_devs do not need to be ordered, increase of concurrency level by switching to system_wq should not break anything. cancel_work_sync() is used to ensure that work is not pending or executing on any CPU. Lastly, since all devices are suspended, which shutdowns the work item before the driver can be unregistered, it is guaranteed that no work item is pending or executing by the time exit path runs. Signed-off-by: Amitoj Kaur Chawla Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/staging/gdm724x/gdm_mux.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -26,8 +26,6 @@ #include "gdm_mux.h" -static struct workqueue_struct *mux_rx_wq; - static u16 packet_type[TTY_MAX_COUNT] = {0xF011, 0xF010}; #define USB_DEVICE_CDC_DATA(vid, pid) \ @@ -277,7 +275,7 @@ static void gdm_mux_rcv_complete(struct r->len = r->urb->actual_length; spin_lock_irqsave(&rx->to_host_lock, flags); list_add_tail(&r->to_host_list, &rx->to_host_list); - queue_work(mux_rx_wq, &mux_dev->work_rx.work); + schedule_work(&mux_dev->work_rx.work); spin_unlock_irqrestore(&rx->to_host_lock, flags); } } @@ -604,6 +602,8 @@ static int gdm_mux_suspend(struct usb_in mux_dev = tty_dev->priv_dev; rx = &mux_dev->rx; + cancel_work_sync(&mux_dev->work_rx.work); + if (mux_dev->usb_state != PM_NORMAL) { pr_err("usb suspend - invalid state\n"); return -1; @@ -659,13 +659,6 @@ static struct usb_driver gdm_mux_driver static int __init gdm_usb_mux_init(void) { - - mux_rx_wq = create_workqueue("mux_rx_wq"); - if (mux_rx_wq == NULL) { - pr_err("work queue create fail\n"); - return -1; - } - register_lte_tty_driver(); return usb_register(&gdm_mux_driver); @@ -675,11 +668,6 @@ static void __exit gdm_usb_mux_exit(void { unregister_lte_tty_driver(); - if (mux_rx_wq) { - flush_workqueue(mux_rx_wq); - destroy_workqueue(mux_rx_wq); - } - usb_deregister(&gdm_mux_driver); }