Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp696802pxu; Wed, 14 Oct 2020 11:16:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzo3Lpzhl9m0fOnwH7Au+SLjaXM063WGpnJGNmnSDetG6jZ/AmlXzdiIJl+klyMPzZXPzB+ X-Received: by 2002:aa7:d384:: with SMTP id x4mr169525edq.105.1602699367474; Wed, 14 Oct 2020 11:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602699367; cv=none; d=google.com; s=arc-20160816; b=UhI5/762Ah2CHOgUU5PSyggQy4cfot9yg6OtBUdmZ2uiB00f3YVuhpE+4uYxatESSY 3t3N+oIZ6KZc6661sqJnYb/bL7tECRHEZpTeFPeSsODdNamXLWU11yXpvt8m5VO8P1jY /n3257NbKnhZ5GckVxjUhDv3Nen6qZA/cgDKg5jMfDjBfHuU8R4Vq5PPYf7lZtEouTdH fXMSwCzqDph55wazLzVvmK+yG/VOahTAC2prfoYPSaqv4Vkwg6wzQWYzYxbFSk8og49S VwtWsDp8/LOLhknpE75X+ZfyasCWaMmrDbQSogBl4cs3WtmglizgZTBYSGT1+ZIlQYeC 76zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=nqdaUF7gqpa5vAd2ReIntmze4Dnkg+JAjkQo8DWqFmg=; b=uGkRdSy0p3Dfj9AmEt9gelBVYKheJt0OPpVeD0LHehV7r5otd7iOuVP5SJM2JSYeIe gtoSmqJo+xCnamwIEslZgQaSGZi+GLPEj9kA4mrK88APmsrkC0t5AfMsKBQUGSf5tLnP TY1laVJ0Wov5/hTc2ylzIIfcQF6bnIFAaFKi71bKoXCeJVOzoisWMciKJXWmlBUeTcM2 SEpQiHOldnKYDcBAo7+IXVl8ibux7kMloOmEDee2h0InptdstLFF9RB2EsuGqgNzu4OJ 6qh+OOqzqq5skkW4cVGtBqpZ3ll8fPH8Oj3uBHDXk6xwtlIJr0gF8xUBbe7F+dpOlhhs JAug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si153677edr.413.2020.10.14.11.15.45; Wed, 14 Oct 2020 11:16:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729669AbgJNSNW (ORCPT + 99 others); Wed, 14 Oct 2020 14:13:22 -0400 Received: from netrider.rowland.org ([192.131.102.5]:47901 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727369AbgJNSNW (ORCPT ); Wed, 14 Oct 2020 14:13:22 -0400 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 Cc: Thomas Gleixner , LKML , Peter Zijlstra , "Ahmed S. Darwish" , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Thomas Winischhofer , Johan Hovold , Mathias Nyman , Valentina Manea , Shuah Khan , linux-omap@vger.kernel.org, Kukjin Kim , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Felipe Balbi , Duncan Sands 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201014164123.hnqqkyrjrjytcxgz@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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