Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp213389pxb; Sat, 21 Aug 2021 00:09:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIVJIkEwqQioauuPsYiez4Dn15uRFSrWspokjVto3HLo1gvBHb26YAA678AycYjr6qMVQo X-Received: by 2002:a5d:990f:: with SMTP id x15mr19311919iol.200.1629529753296; Sat, 21 Aug 2021 00:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629529753; cv=none; d=google.com; s=arc-20160816; b=kgtsTQZeQphJcm4B4wGA98ZM+sa8IcgfzGRd2sfkMXmza6ChjnFDXhASyt/arL5srN T6RIESv1Npr3Kv3sGey7S2I5KNOxUg+zN/BmW/77b8G8MXsTsiHTnIHo58vRfT6foG6R mOtneZOBjEspcYl3A+HPgBhGAHNK46dOiDb/deTBIdQX6zBmaAKu+nUxpbbFt9oqllvG p0v7AMkVOWCWFIoQkCaI/hcleotWXmsAJhX+A1k/2y5xDzsyRZBw7Kh++udjpOnGxMSP JOb59dUpe1bzo3zyxC8oRBPYa+bMpUh5ZkcVewxhWrR5E3l2pUr4Jyl/gOq9xBPx1GjF coiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=WgM87f7rpLd/jbOLyf9WZP12/bowR6IrwwDEu2GtuV8=; b=m9y+jlHFGT4T2dX2byenV3KskfVyjbfNkIZjGqHoserz9lDtEMyJIgID25TWS0Mipr g5gjiBHybjYkzMB3jjgpnUovrTc00IiFGayhljUwConDE2LfcmJ3oqIowXfLKVQ+6tU7 0ztkFjXAqgJXkyijg1RPQK74dax6fUmMmvusKtb3XiUO3i6pUW41JmdmkxawOXR4fYh2 Yh95F7uVtEsZZ4Tts+H/fEO4jLZXJdX2p6VJi1h/Bpcitu3qaHpHThjGbGw6rasRJpQx ZjI1X/sd+2sG1JePOnM9XZjYmupKjJxPhzwac/e3rtY9crixwZM8fneYQDFozZXaRpVA LTfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rtst-co-kr.20150623.gappssmtp.com header.s=20150623 header.b=Pv336bT6; 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 6si2443614ill.90.2021.08.21.00.08.45; Sat, 21 Aug 2021 00:09:13 -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=@rtst-co-kr.20150623.gappssmtp.com header.s=20150623 header.b=Pv336bT6; 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 S232425AbhHUHEy (ORCPT + 99 others); Sat, 21 Aug 2021 03:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232037AbhHUHEx (ORCPT ); Sat, 21 Aug 2021 03:04:53 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC7CC061757 for ; Sat, 21 Aug 2021 00:04:14 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id z4so1768412wrr.6 for ; Sat, 21 Aug 2021 00:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rtst-co-kr.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=WgM87f7rpLd/jbOLyf9WZP12/bowR6IrwwDEu2GtuV8=; b=Pv336bT6BS8zVUAFL8pWU1CGoQdBEw/yAxLORZT8Cj/Ba0BPBttWUz+vdEQINtnec5 q2RFdHep9cG1R6MfS7RuAsBAUf71QOvvsylwQVXcszxZWZLGdJfao5uT5J80KXdOtlu9 SHtyBk5SWC/eZGBBjo+tV85udJiqv5I8QHTKOfnvsQMkqX7SlRtnfYau5O4uzOrkvo+l rMFJR4MAD1C3+4bzI0SoUQ3gTZd6u6nch6F4B+kxdf2ImkNJD5dIfgb1PX9TFJTZz2vf KbzOGeFnG9Mwqm9PfoEJXDhVxDOelhrZAmwoosSLEOPzfXQGSu5fxkL7R5sg5qkiGjhx WiHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=WgM87f7rpLd/jbOLyf9WZP12/bowR6IrwwDEu2GtuV8=; b=HfJIGtL77Q/TIHKmuOkBbPGogH3d8XZwVOFUAj4CryKfKTdHf/5+iP2lx8+GKleV+Z hioPgFt9CcQlDPzUJGRitqMqYWcgXchK01XMkFBfwHYt/oxKn5tIUd5ENlAR9iCdZgoP 4O4/g4OsodHfAG//dGbp+oebt5jDbk3/4ij2Qr6VV/ANHoUXeeAgfIlCddQOmh0boA6w Wc79BoEYDCWA1XxalmqSmU2Z7as4qOr20YHZklKHrNe6QCWIZr9/bpiJaPx4Rr0qHkfZ HuRGhmGTsR1ii6nsw2JQUiBhk3ZTplj9/angDxLZdT+Av3qn7gQY4CVq50fXUdcysOjz sK2g== X-Gm-Message-State: AOAM533XrVgtlCy+WXBQ/Gg3C5Lg8Sy7ArP4t2JPJjgnaRDplAeVolc0 yWB8TB/gCghEHTnpVBAOlPhofAKpKENrJH4UyL7slQ== X-Received: by 2002:adf:e7d1:: with SMTP id e17mr2450792wrn.151.1629529452393; Sat, 21 Aug 2021 00:04:12 -0700 (PDT) MIME-Version: 1.0 References: <20210817095313.GA671484@ubuntu> <20210818161752.vu6abfv3e6bfqz23@linutronix.de> <20210819084759.stnmit32vs2be46m@linutronix.de> <20210821050511.GA14810@Peter> In-Reply-To: <20210821050511.GA14810@Peter> From: Jeaho Hwang Date: Sat, 21 Aug 2021 16:04:01 +0900 Message-ID: Subject: Re: [PATCH v2] usb: chipidea: local_irq_save/restore added for hw_ep_prime To: Peter Chen Cc: Sebastian Andrzej Siewior , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , linux-rt-users@vger.kernel.org, Linux team , =?UTF-8?B?67OA66y06rSRKEJ5ZW9uIE1vbyBLd2FuZykv7J6Q64+Z7ZmU7JewKUF1dG9tYXRpb24gUGxhdGZvcm0=?= =?UTF-8?B?7Jew6rWs7YyA?= , =?UTF-8?B?7LWc6riw7ZmNKENob2kgS2kgSG9uZykv7J6Q64+Z7ZmU7JewKUF1dG9tYXRpb24gUGxhdGZvcm3sl7A=?= =?UTF-8?B?6rWs7YyA?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2021=EB=85=84 8=EC=9B=94 21=EC=9D=BC (=ED=86=A0) =EC=98=A4=ED=9B=84 2:05, P= eter Chen =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On 21-08-20 14:15:55, Jeaho Hwang wrote: > > 2021=EB=85=84 8=EC=9B=94 19=EC=9D=BC (=EB=AA=A9) =EC=98=A4=ED=9B=84 5:4= 8, Sebastian Andrzej Siewior > > =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > > > > > On 2021-08-19 08:50:27 [+0900], Jeaho Hwang wrote: > > > > Without RT, udc_irq runs as a forced threaded irq handler, so it ru= ns > > > > without any interruption or preemption. NO similar case is found on > > > > non-RT. > > > > > > I see only a devm_request_irq() so no force-threading here. Booting w= ith > > > threadirqs would not lead to the problem since commit > > > 81e2073c175b8 ("genirq: Disable interrupts for force threaded hand= lers") > > > > > > > I was wrong. udc threaded irq handler allows twd interrupt even on > > non-RT and with threaded irq. > > I believed Chen's comment "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?". > > Hi Jeaho, > > How could you let udc irq as threaded irq? The chipidea interrupt > is registered using devm_request_irq. > HI Peter. We configured the kernel as "low latency desktop" and added "threadirqs" inside the cmdline parameter. Then udc irq handler runs as a thread and shows no suspicious working. I Hope It will help. Thanks. > > We have additional experiments and got the results like below. RNDIS > > host was Windows. > > > > RT, 1ms delay between first ENDPTSETUPSTAT read and priming : error > > case occurred > > RT, 1ms delay + irq_save : no error case occurred. > > non-RT, threaded irq, 1ms delay : no error case occurred even twd > > fires inside the function execution. > > Again, how do you observe it? > > Peter > > > > > It doesn't seem to be a timing issue. But irq definitely affects > > priming on the RT kernel. Do you RT experts have any idea about the > > causes? > > If isr_tr_complete_handler fails ep priming it calls _ep_set_halt and > > goes an infinite loop in hw_ep_set_halt. It was an actual problem we > > experienced. > > So we protect irqs inside hw_ep_priming not to make error cases and > > also add a timeout inside the hw_ep_set_halt loop for a walkaround. > > The timeout patch is submitted to linux-usb. > > ( https://marc.info/?l=3Dlinux-usb&m=3D162918269024007&w=3D2 ) > > > > We withdrew this patch since we don't know if disabling irq is the > > best solution to solve the problem and udc would work fine with > > hw_ep_set_halt walkaround even though hw_ep_prime fails. > > But we are still trying to find out the cause of this symptom so We'd > > so appreciate it if RT or USB experts share some ideas or ways to > > report somewhere. Xilinx doesn't provide any support without their > > official kernel :( > > > > Thanks for the discussion Sebastian. > > > > Jeaho Hwang. > > > > > =E2=80=A6 > > > > > If this function here is sensitive to timing (say the cpu_relax()= loop > > > > > gets interrupt for 1ms) then it has to be documented as such. > > > > > > > > The controller sets ENDPTSETUPSTAT register if the host sent a setu= p packet. > > > > yes it is a timing problem. I will document that and resubmit again= if > > > > you agree that local_irq_save could help from the timing problem. > > > > > > > > Thanks for the advice. > > > > > > If it is really a timing issue in the function as you describe below > > > then disabling interrupts would help and it is indeed an RT only issu= e. > > > > > > So you read OP_ENDPTSETUPSTAT, it is 0, all good. > > > You write OP_ENDPTPRIME, wait for it to be cleared. > > > Then you read OP_ENDPTSETUPSTAT again and if it is 0, all good. > > > > > > And the TWD interrupt could delay say the second read would read 1 an= d > > > it is invalidated. Which looks odd. > > > However, it is "okay" if the TWD interrupt happens after the second > > > read? Even if the host sends a setup packet, nothing breaks? > > > Do you have numbers on how long irq-off section is here? It seems to > > > depend on how long the HW needs to clear the OP_ENDPTPRIME bits. > > > > > > Sebastian > > > > > > > > -- > > =ED=99=A9=EC=9E=AC=ED=98=B8, Jay Hwang, linux team manager of RTst > > 010-7242-1593 > > -- > > Thanks, > Peter Chen > --=20 =ED=99=A9=EC=9E=AC=ED=98=B8, Jay Hwang, linux team manager of RTst