From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20C8DC4363A for ; Tue, 6 Oct 2020 01:23:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0E2D2076B for ; Tue, 6 Oct 2020 01:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbgJFBXe (ORCPT ); Mon, 5 Oct 2020 21:23:34 -0400 Received: from netrider.rowland.org ([192.131.102.5]:48333 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1725922AbgJFBXe (ORCPT ); Mon, 5 Oct 2020 21:23:34 -0400 Received: (qmail 399907 invoked by uid 1000); 5 Oct 2020 21:23:33 -0400 Date: Mon, 5 Oct 2020 21:23:33 -0400 From: Alan Stern To: Shuah Khan Cc: Andrey Konovalov , Greg Kroah-Hartman , Valentina Manea , Shuah Khan , USB list , LKML , Dmitry Vyukov , Nazime Hande Harputluoglu , syzkaller Subject: Re: Is usb_hcd_giveback_urb() allowed in task context? Message-ID: <20201006012333.GA399825@rowland.harvard.edu> References: <20201005151857.GA2309511@kroah.com> <20201005152540.GG376584@rowland.harvard.edu> <65b4ff62-f9c8-b9cf-50bb-c9b08cce7230@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <65b4ff62-f9c8-b9cf-50bb-c9b08cce7230@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 05, 2020 at 05:38:22PM -0600, Shuah Khan wrote: > On 10/5/20 9:25 AM, Alan Stern wrote: > > On Mon, Oct 05, 2020 at 05:21:30PM +0200, Andrey Konovalov wrote: > > No, no -- it won't work right if it's called in process context. Not > > only do the spinlock calls leave the interrupt flag unchanged, also the > > driver callback routines may expect to be invoked with interrupts > > disabled. (We have tried to fix this, but I'm not at all certain that > > all the cases have been updated.) > > > > In the case of vhci case, usb_hcd_giveback_urb() is called from vhci's > urb_enqueue, when it determines it doesn't need to xmit the urb and can give > it back. This path runs in task context. > > Do you have any recommendation on how this case can be handled? Just call local_irq_disable() before usb_hcd_giveback_urb(), and local_irq_enable() afterward. Alan Stern