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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 86962C433DF for ; Wed, 14 Oct 2020 18:14:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EC3E21D81 for ; Wed, 14 Oct 2020 18:14:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="H4FQqu/w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EC3E21D81 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pS2717u96m0L7cJMTFwhBI0C79k5QekkkR9VnqIv4Jk=; b=H4FQqu/w+oYviaKnH/pmpjO0d ecoSRKtmER+v98EwGIQyUnePrt8o5nbFeOkYj+6FH/4dcQtK4qoLPlRxkLau2F7fFiXq6eC9fxJPv +VbuDAcbAxlInqWIBGYWraFUT2sIg6B+XmUjjfpCar2ViaRTBkAhpq/tsrdZdEZzuxz6vCToUjrDg 5EvUzbcG34kss3qATLKM/iZ5uemKiisWcQVE/guQFJWx+kNLR0IGG520n5XyAcwPI6YHbd/10wg8N /I8eXE8vntGBY6Bok5B+velAm7snLqDKUjavZ4+PHV6qb73h9xIll18CieIWH9s7EoSxhQCDO7zqo sRPYEWr9A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSlHC-0003u0-UH; Wed, 14 Oct 2020 18:13:26 +0000 Received: from netrider.rowland.org ([192.131.102.5]) by merlin.infradead.org with smtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSlH9-0003sa-KQ for linux-arm-kernel@lists.infradead.org; Wed, 14 Oct 2020 18:13:24 +0000 Received: (qmail 724401 invoked by uid 1000); 14 Oct 2020 14:13:20 -0400 Date: Wed, 14 Oct 2020 14:13:20 -0400 From: Alan Stern To: Sebastian Andrzej Siewior Subject: Re: [patch 11/12] usb: core: Replace in_interrupt() in comments Message-ID: <20201014181320.GA723420@rowland.harvard.edu> References: <20201014145215.518912759@linutronix.de> <20201014145728.318078828@linutronix.de> <20201014162721.GE712494@rowland.harvard.edu> <20201014164123.hnqqkyrjrjytcxgz@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201014164123.hnqqkyrjrjytcxgz@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201014_141323_733286_48537746 X-CRM114-Status: GOOD ( 29.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , Thomas Winischhofer , Mathias Nyman , Peter Zijlstra , Greg Kroah-Hartman , linux-usb@vger.kernel.org, LKML , Krzysztof Kozlowski , Johan Hovold , linux-samsung-soc@vger.kernel.org, Kukjin Kim , Valentina Manea , Duncan Sands , "Ahmed S. Darwish" , Thomas Gleixner , linux-omap@vger.kernel.org, Shuah Khan , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 14, 2020 at 06:41:23PM +0200, Sebastian Andrzej Siewior wrote: > On 2020-10-14 12:27:21 [-0400], Alan Stern wrote: > > > --- a/drivers/usb/core/hcd.c > > > +++ b/drivers/usb/core/hcd.c > > > @@ -746,9 +746,6 @@ static int rh_call_control (struct usb_h > > > * Root Hub interrupt transfers are polled using a timer if the > > > * driver requests it; otherwise the driver is responsible for > > > * calling usb_hcd_poll_rh_status() when an event occurs. > > > - * > > > - * Completions are called in_interrupt(), but they may or may not > > > - * be in_irq(). > > > > This comment should not be removed; instead it should be changed to say > > that completion handlers are called with interrupts disabled. > > The timer callback: > rh_timer_func() -> usb_hcd_poll_rh_status() > > invokes the function with enabled interrupts. Well, it doesn't change the interrupt settings. It might call usb_hcd_poll_rh_status() with interrupts enabled or disabled, depending on how it was called originally. But that wasn't what I meant. usb_hcd_poll_rh_status() calls usb_hcd_giveback_urb() with interrupts disabled always, and that routine may call __usb_hcd_giveback_urb(), which calls urb->complete(urb); In this case the completion handler would be invoked with interrupts disabled. Alternatively, __usb_hcd_giveback_urb() may be invoked from a BH handler, in which case the completion handler will run in softirq context with interrupts enabled. So I guess it would be best to say that completion handlers may be called with interrupts enabled or disabled. Or you might want to put such a comment in __usb_hcd_giveback_urb(). > > > @@ -1691,7 +1690,6 @@ static void usb_giveback_urb_bh(unsigned > > > * @hcd: host controller returning the URB > > > * @urb: urb being returned to the USB device driver. > > > * @status: completion status code for the URB. > > > - * Context: in_interrupt() > > > > The comment should be changed to say that the routine runs in a BH > > handler (or however you want to express it). > > Do you mean usb_hcd_giveback_urb() runs in BH context or that the > completion callback of the URB runs in BH context? Actually I meant that usb_hcd_giveback_urb_bh() runs in BH context. Sorry, I got confused about the location of this hunk. To be explicit: The comment for usb_hcd_giveback_urb() should say that the function expects to be called with interrupts disabled (whether the context is task, atomic, BH, interrupt, etc. doesn't matter). > The completion callback of the URB may run in BH or IRQ context > depending on HCD. > > > > --- a/drivers/usb/core/message.c > > > +++ b/drivers/usb/core/message.c > > > > > @@ -934,7 +939,7 @@ int usb_get_device_descriptor(struct usb > > > /* > > > * usb_set_isoch_delay - informs the device of the packet transmit delay > > > * @dev: the device whose delay is to be informed > > > - * Context: !in_interrupt() > > > + * Context: can sleep > > > > Why is this comment different from all the others? > > It says !in_interrupt() which is also true for preempt-disabled regions. > But the caller must not have preemption disabled. "can sleep" is more > obvious as what it needs. But all the other comments in this patch say: * Context: task context, might sleep. Why doesn't this comment say the same thing? Alan Stern _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel