Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2298470pxt; Sun, 8 Aug 2021 18:55:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiWUGKR2EKrxMejBElJ4VZJQ0BdL6Zy2Z/q8LGGrjHi4bIgXjpLPldIpTTiXujuVVElmuh X-Received: by 2002:a05:6e02:2146:: with SMTP id d6mr375697ilv.294.1628474148162; Sun, 08 Aug 2021 18:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628474148; cv=none; d=google.com; s=arc-20160816; b=kRBFavXI1C2hKUwui/Vkx4kY0Y24BMgHONIB9VAVNmilCpUM91LC6Fv3Bh/L2oooul AHGLJONooa6If4++3FCDvhH/wVLDz1FMT9wNZOl77Z1BJxBuTiX2naX+4TIIivHc/yEJ peqUAmwlwIF3TX4/nKRaCzRW0yLnBG/4zxv4mX3LuZwYPVtPz8aTeE9B3k7XIgbFYOQL wPCucOLbRbzyFEVJNorrgcsE6WMwzEiWNuMtZCJBcckWyTzPVMRd6+C4vSQ89F/SITqi iUNCAfBw3CFpdQdvoKW15shh00rG/BZAFnrUp51Ij6s8VnsfKZj9fV5wnZBfB7edGp8a hm/A== 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 :dkim-signature; bh=BHLza8oaEdLFlNQicJrVZ0QPqbWX/bTTcL7fOboyWOQ=; b=0woThXNPGJiBQbLxma0tThxUz2h07xU6waFAIjP/NSt4bjPDPCDcF/nORl3sPyrCdr Ah+wCQW1+TUCtH4tEvXDAx8IYV9izVfNQozhmVyscfNck8h6ailMxqsu7+EONoRQs1WM lcSlkrYnxx1nsXf3b6TmpZC8SSOhnMSv/vS+mJ9QI0nOvfs4O8ifofnMVtEYaitg8OMy wiEOefYVSzvJTx+hj6TxBAmDFZq2MtHchkX2PhKRoJaU9n4cQ5lnK84kpdGYPL/xOfXo oh2eCl7+r/fXthGT24dyn0X8Urv0pt1ZsDWRYwS6A/1fLxUm+lv40JnRNbg+NxgAaIkt aZlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ELnHoYf7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si17813648ilj.65.2021.08.08.18.55.36; Sun, 08 Aug 2021 18:55:48 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ELnHoYf7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbhHIB2N (ORCPT + 99 others); Sun, 8 Aug 2021 21:28:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:50114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232359AbhHIB2M (ORCPT ); Sun, 8 Aug 2021 21:28:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 096BB604D7; Mon, 9 Aug 2021 01:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628472472; bh=XPp8rG08ZWrplVlCPRKs47QXV8DYIX2lILk+jz/sn4Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ELnHoYf79h2LIuAOQL0IjUZZBTqWq3+GgWY4XtCO6Af6t3of3nGHKAfyfhqyHWtdp tVNUzHaS7xQzAZ1gpcqBLvPtaTS/Od6/ozkhPsS7FIJ2dfpr33lPT3RRXDIewqeKsa 0LghcAIZLPY8bLIEg+e+ahdJCRs9lKzztIv7EEFTGXSvxybaQ8iSCv54aC0E5VWY/m MJHpNJGXhevFhVSmQ+VSbmBbdR9XDUmF/uwIpIhbZoc+BUX/yVRS/ArW5keyWodzIG vJJ8GQ06M0dCt7qpx8y8It0Iz5UIYwrg090FR8VWTqnKB5j/sgLb9yxLDib1fcdzRz ONIyGkpWk6nmg== Date: Mon, 9 Aug 2021 09:27:47 +0800 From: Peter Chen To: Jeaho Hwang Cc: linux-usb@vger.kernel.org, =?utf-8?B?67OA66y06rSRKEJ5ZW9uIE1vbyBLd2FuZykv7J6Q64+Z7ZmU7JewKUF1dG9t?= =?utf-8?B?YXRpb24gUGxhdGZvcm3sl7DqtaztjIA=?= , Linux team , linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Chipidea USB device goes infinite loop due to interrupt while hw_ep_prime Message-ID: <20210809012747.GA6814@nchen> References: <20210804013252.GA16420@nchen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-08-04 11:03:44, Jeaho Hwang wrote: > Hi. linux-usb and linux-rt experts. > > > > On 21-08-02 17:35:01, Jeaho Hwang wrote: > > > Hi. > > > > > > We found an infinite loop inside the function hw_ep_set_halt > > > (drivers/usb/chipidea/udc.c) if a cablle is repeatedly > > > connnected/disconnected while ping through RNDIS with chipidea USB device. > > > > > > Using ftrace tracing, we found that hw_ep_set_halt is called due to error > > > return of hw_ep_prime(drivers/usb/chipidea/udc.c:202) which is called from > > > isr_tr_complete_handler -> isr_setup_status_phase -> _ep_queue. > > > > > > The comment of function hw_ep_prime says (execute without interruption) but > > > timer interrupt is occurred while hw_ep_prime is executing. We believe that > > > the interrupt causes an error return of hw_ep_prime. We tried to protect > > > hw_ep_prime from irqs and then no case of the infinite loop is occurred. > > > > > > I want ask if it is appropriate way that turning off irq inside (threaded) > > > irq handlers. And should we explicitly turn off irqs before calling > > > hw_ep_prime? > > > > > > > Jeaho, do you use RT-Linux or standard Linux? The function hw_ep_prime is > > only called at udc_irq which is registered as top-half irq handlers. > > Why the timer interrupt is occurred when hw_ep_prime is executing? > > We use preempt_RT so timer interrupt could be occurred. Now I found > out that forced threaded irq handler disables local irq on standard > linux so It is a linux-rt issue. Then should I make patch which > disables local irqs during hw_ep_prime for RT kernel and suggest it to > linux-rt maintainers? > > Thanks for a kind answer Peter. > No, that will lead to deadlock since the normal request queue API function ep_queue disables irq which also calls into hw_ep_prime. For RT kernel, you may try to disable local irq at isr_setup_status_phase. -- Thanks, Peter Chen