Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D859C433F5 for ; Thu, 10 Feb 2022 23:04:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4207F836A9; Fri, 11 Feb 2022 00:04:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1644534288; bh=m1VzerPz9iCRMobNCnmvKZT2TsLkt50w2Fg0uP5+hiI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rd3U6TE7HabuWjgAM38W4ivhBek32FSxKZBTS9xacm74Dp6I00aBXqqJyj//tXU9v EKOx2mokOqpWXK7FImky0/kYpfhuvvIKM2n4M/vxnSuLfZvZbo52JYGHjLXqPE0X71 pSvbel4gGfiZHCSe6kl0GlqPQPdgX7JVn4V9yLVtTksJC8c4+xCdBL/b0pcfhvH4W2 LRWWAKmwnhmbDSUGH78dZ+x2CZD+hRmZWgG92tlLS1MKbSTaPCAwpI//2BTj+gT/QE mNhajf7YuaVEZwM/rrQXx4h+GR96nTOcXy2Mg8osW9vgvsn0qGi1JTEs9zTf58U6wr IytZa/5EYF1BQ== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id A9A7880F68; Fri, 11 Feb 2022 00:04:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1644534287; bh=m1VzerPz9iCRMobNCnmvKZT2TsLkt50w2Fg0uP5+hiI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=EiO6CcXCac2DUdS6I/8L96+qTe2dCip9NITBfTld50C+SwMxgRrn0tg7oiQ0giseg xOnNhbmlszLDs15WyFPXt9ctBwDKK6SpKMWcVQsk2J59W0GLf2xM5kJcqmGHL15+a2 A2DLEkLijtnr3zr5lTyov+1unoj6bEs3MU29uKOrl5fEMQxF9UujlCjK0XAbBYKHd/ TzD7qyIYI+viZ+DKkKiU5z2aeVLiZ8LK+tSdF9te82ImqFFdlz5xRhpee30prtPn+o FD5ULY01lYK0GrUBUZQ8YTtcgBgfjyKaxAaLM5MZZH8TcGPA7TJ5vGBD53xxmMr0so vDxUaRS4OsPQQ== Message-ID: <0b66308d-81e2-7aff-91c5-ce2cb476d6ab@denx.de> Date: Fri, 11 Feb 2022 00:04:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v3] console: usb: kbd: Limit poll frequency to improve performance Content-Language: en-US To: Simon Glass Cc: Thomas Watson , U-Boot Mailing List , Mark Kettenis References: <20220210211314.4678-1-twatson52@icloud.com> <0fd1555a-cd16-b98c-33c7-b305fb9270f5@denx.de> From: Marek Vasut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 2/11/22 00:02, Simon Glass wrote: > Hi Marek, > > On Thu, 10 Feb 2022 at 14:42, Marek Vasut wrote: >> >> On 2/10/22 22:13, Thomas Watson wrote: >>> Using the XHCI driver, the function `usb_kbd_poll_for_event` takes >>> 30-40ms to run. The exact time is dependent on the polling interval the >>> keyboard requests in its descriptor, and likely cannot be significantly >>> reduced without major rework to the XHCI driver. >>> >>> The U-Boot EFI console service sets a timer to poll the keyboard every 5 >>> microseconds, and this timer is checked every time a block is read off >>> disk. The net effect is that, on my system, loading a ~40MiB kernel and >>> initrd takes about 62 seconds with a slower keyboard and 53 seconds >>> with a faster one, with the vast majority of the time spent polling the >>> keyboard. >>> >>> To solve this problem, this patch adds a 20ms delay between consecutive >>> calls to `usb_kbd_poll_for_event`. This is sufficient to reduce the >>> total loading time to under half a second for both keyboards, and does >>> not impact the perceived keystroke latency. >>> >>> Signed-off-by: Thomas Watson >>> --- >>> This revision fixes a sandbox test failure by honoring the test's >>> request to skip delays. >>> >>> common/usb_kbd.c | 31 ++++++++++++++++++++++++++----- >>> 1 file changed, 26 insertions(+), 5 deletions(-) > > We don't want to delay the CI tests which take enough time as it is. > So time needs to be faked. > > It could be an if() though, rather than #if, perhaps? Since there are multiple instances of the ifdef already , subsequent patch to clean them up would be fine.