Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp389056pxb; Thu, 19 Aug 2021 01:49:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZfSqARmxNzSblqcoPzb2rawVGFI3khR6PUBk6oKiwHkdl4F5tirn7haA39zIOon2aZk2a X-Received: by 2002:a05:6e02:f44:: with SMTP id y4mr9089422ilj.257.1629362974691; Thu, 19 Aug 2021 01:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629362974; cv=none; d=google.com; s=arc-20160816; b=jNC1C+K6xypSJ9HKmkT5/iAyz59YHxdDem9oAegHekLB5jtNkICH8ccVpnHMF+NvqB H2STjcj9/sW6BQrG8NUSaYb+PkcUgrPTZrz8OPFuVIqsMXHlz8/1QtX9kanQ7IrL6AP3 4WIFTSfPwKULlXZtTFgfpjKvfcwSRzr7UbYIUAkFvEQYKpzKehw9vaa880wEwZuPZZpr 87ROsPT3BUBcrwYs6Qduwsj88XKmsMvdhZeMA2vSd9iC0/ypGbnXiaLfPFHRXrG0Ses7 mdUbqsk/MnQA9Ijd0U4vcu7qfeZLNQIqxETqoOQ6fxx3MjI51pjQQOOuQ8IKaBlXXOSq iQKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=UGhrbP1M+bRZykm1qw5MiTgXr3U+PK7s8IS34ZgSXfI=; b=tgsSwKhyPOVoUxSwMktmQ1YcSAtyTtnsT3dvEusFNLLJ/Hzn+ziJ+t4fjACElVbMMY i3OVc+BiKXEaM8zpIUv+xaU5hPQumNOR6boKMWnW1ynEWoGtADU3lYLfpX2pNgz6an4H oK743i7qMCiyAY8EU7BpdTw56pD6odSZehkcEA0nxrysQ7EnSl9QjnbK781OUMm3q9hL ljjqYscH1H/lvGORubAT6AWnAhSFA7fIkI7CZyPfy/2Cz0KO9in+j+lH77we6G53pkaz onSE05wlJv3RCzu9e9xgLH7fKDnxulOLyjYe6zhaKD3YG1P7WvbjL6QmRjtwNbEbsd0/ R6vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=trRnakSa; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=JjvGNmfh; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si2652739jai.84.2021.08.19.01.49.23; Thu, 19 Aug 2021 01:49:34 -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=@linutronix.de header.s=2020 header.b=trRnakSa; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=JjvGNmfh; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237407AbhHSIsm (ORCPT + 99 others); Thu, 19 Aug 2021 04:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232653AbhHSIsk (ORCPT ); Thu, 19 Aug 2021 04:48:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8969DC061575; Thu, 19 Aug 2021 01:48:03 -0700 (PDT) Date: Thu, 19 Aug 2021 10:47:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1629362881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UGhrbP1M+bRZykm1qw5MiTgXr3U+PK7s8IS34ZgSXfI=; b=trRnakSacqt1GZoA9rmQailL5D5FdiYvG9vn4H4IFSVPUuWLCyGNE3upOx6UzCrekwYQu9 z+t5i2jnQFmKNWirRpJGU5BDAHEh9a6ky98KKNDrifqHIPIcTYV1udP+e+DbWwf/SqA6ei CzJbhgveJDyBwI0GQDUOqvq64BNVd1EBJvCrhznR34C+0VwcaY9X7G8TTsBkD/dmIylZgV Y1WnfiDhGzEiCift0C/3zHq+48caOnhzgalo/dsrP0+nLYzapQakn+BzJ3hGaOt1IIQo4X r8c9w4chvjvgNFkOuXSPEoy42tIlwMRlVLGwbpF8UXsddT5EvY40yYqrsXQiUA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1629362881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UGhrbP1M+bRZykm1qw5MiTgXr3U+PK7s8IS34ZgSXfI=; b=JjvGNmfhOeqlCc3FmDvm6MBn+YE/490dRcvw6yXJbnrf28mkeSruEBZAUMfd8+Jm3ZcESc 8NxYzP6+dKiU1ZCg== From: Sebastian Andrzej Siewior To: Jeaho Hwang Cc: Peter Chen , 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+Z7ZmU7JewKUF1dG9t?= =?utf-8?B?YXRpb24gUGxhdGZvcm3sl7DqtaztjIA=?= , =?utf-8?B?7LWc6riw7ZmNKENob2kgS2kgSG9uZykv7J6Q64+Z7ZmU7JewKUF1dG9tYXRp?= =?utf-8?B?b24gUGxhdGZvcm3sl7DqtaztjIA=?= Subject: Re: [PATCH v2] usb: chipidea: local_irq_save/restore added for hw_ep_prime Message-ID: <20210819084759.stnmit32vs2be46m@linutronix.de> References: <20210817095313.GA671484@ubuntu> <20210818161752.vu6abfv3e6bfqz23@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-08-19 08:50:27 [+0900], Jeaho Hwang wrote: > Without RT, udc_irq runs as a forced threaded irq handler, so it runs > 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 with threadirqs would not lead to the problem since commit 81e2073c175b8 ("genirq: Disable interrupts for force threaded handlers") =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. >=20 > The controller sets ENDPTSETUPSTAT register if the host sent a setup pack= et. > 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. >=20 > 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 issue. 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 and 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?=20 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