From patchwork Wed Jun 20 16:21:10 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: 10477855 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 F058260210 for ; Wed, 20 Jun 2018 16:22:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E218428B9B for ; Wed, 20 Jun 2018 16:22:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5CB628ECC; Wed, 20 Jun 2018 16:22:02 +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 7E54528EBB for ; Wed, 20 Jun 2018 16:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754308AbeFTQVZ (ORCPT ); Wed, 20 Jun 2018 12:21:25 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:60926 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754253AbeFTQVY (ORCPT ); Wed, 20 Jun 2018 12:21:24 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fVfrC-0008QF-4a; Wed, 20 Jun 2018 18:21:18 +0200 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: linux-usb@vger.kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior , Lee Jones , Octavian Purdila Subject: [PATCH] mfd: dln2: use irqsave() in USB's complete callback Date: Wed, 20 Jun 2018 18:21:10 +0200 Message-Id: <20180620162110.20855-1-bigeasy@linutronix.de> X-Mailer: git-send-email 2.17.1 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: Lee Jones Cc: Octavian Purdila Signed-off-by: Sebastian Andrzej Siewior --- drivers/mfd/dln2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c index 704e189ca162..1ef3c92f32e0 100644 --- a/drivers/mfd/dln2.c +++ b/drivers/mfd/dln2.c @@ -194,6 +194,7 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb, struct device *dev = &dln2->interface->dev; struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle]; struct dln2_rx_context *rxc; + unsigned long flags; bool valid_slot = false; if (rx_slot >= DLN2_MAX_RX_SLOTS) @@ -206,13 +207,13 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb, * context elsewhere in this driver. This function (or its callers) are * also not exported to other modules. */ - spin_lock(&rxs->lock); + spin_lock_irqsave(&rxs->lock, flags); if (rxc->in_use && !rxc->urb) { rxc->urb = urb; complete(&rxc->done); valid_slot = true; } - spin_unlock(&rxs->lock); + spin_unlock_irqrestore(&rxs->lock, flags); out: if (!valid_slot)