From patchwork Sun Jun 24 22:08:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10484891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2F2DF6019D for ; Sun, 24 Jun 2018 22:09:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27E9828857 for ; Sun, 24 Jun 2018 22:09:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CF9F2885C; Sun, 24 Jun 2018 22:09:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1CD728857 for ; Sun, 24 Jun 2018 22:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752143AbeFXWJH (ORCPT ); Sun, 24 Jun 2018 18:09:07 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:45339 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbeFXWJG (ORCPT ); Sun, 24 Jun 2018 18:09:06 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fXDBu-0000Vg-2l; Mon, 25 Jun 2018 00:09:02 +0200 From: Sebastian Andrzej Siewior To: linux-usb@vger.kernel.org Cc: tglx@linutronix.de, Greg Kroah-Hartman , Sebastian Andrzej Siewior Subject: [PATCH 11/12] usb: ldusb: use irqsave() in USB's complete callback Date: Mon, 25 Jun 2018 00:08:44 +0200 Message-Id: <20180624220845.6726-12-bigeasy@linutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180624220845.6726-1-bigeasy@linutronix.de> References: <20180624220845.6726-1-bigeasy@linutronix.de> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The USB completion callback does not disable interrupts while acquiring the lock. We want to remove the local_irq_disable() invocation from __usb_hcd_giveback_urb() and therefore it is required for the callback handler to disable the interrupts while acquiring the lock. The callback may be invoked either in IRQ or BH context depending on the USB host controller. Use the _irqsave() variant of the locking primitives. Cc: Greg Kroah-Hartman Signed-off-by: Sebastian Andrzej Siewior --- drivers/usb/misc/ldusb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index c2e255f02a72..006762b72ff5 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -225,6 +225,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) size_t *actual_buffer; unsigned int next_ring_head; int status = urb->status; + unsigned long flags; int retval; if (status) { @@ -236,12 +237,12 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) dev_dbg(&dev->intf->dev, "%s: nonzero status received: %d\n", __func__, status); - spin_lock(&dev->rbsl); + spin_lock_irqsave(&dev->rbsl, flags); goto resubmit; /* maybe we can recover */ } } - spin_lock(&dev->rbsl); + spin_lock_irqsave(&dev->rbsl, flags); if (urb->actual_length > 0) { next_ring_head = (dev->ring_head+1) % ring_buffer_size; if (next_ring_head != dev->ring_tail) { @@ -270,7 +271,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) dev->buffer_overflow = 1; } } - spin_unlock(&dev->rbsl); + spin_unlock_irqrestore(&dev->rbsl, flags); exit: dev->interrupt_in_done = 1; wake_up_interruptible(&dev->read_wait);