From patchwork Sun Oct 29 07:09:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856691 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=e5l44Gc7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6wH4k5Fz1yQ4 for ; Sun, 29 Oct 2023 18:09:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 08CE08722E; Sun, 29 Oct 2023 08:09:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="e5l44Gc7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 404D2871C4; Sun, 29 Oct 2023 08:09:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B9A9E8721C for ; Sun, 29 Oct 2023 08:09:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 62ED94268B; Sun, 29 Oct 2023 07:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698563357; bh=skDEW9jI8C0AxGJbd1kKImBnUzt3Mz72TkQ8vFUF4/8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=e5l44Gc7Ku17AX4InvidusdVjVUBw3rh3o7vHNCXGX3ra0QUhTZRC9bzHU5FxoS/7 hwzf7EAKyqXv9dChO2hDP1DSuKUfQZfmx1Nu2O9Lp/MMoX9gyGVQ1s/xmIAzWz2WTj Agw47qv+ewssJIJgI3IgyU7shiaObciGviYuZH1vqPw49+K175nmOj+oD4sIPmgsFW OjdteFkwHILiFTM3lXFAWp9FxdaqjVvju/GmlC2/vKVt1ytbYDWBlD8merFRNvx7jz Q5PRLp7fCavgSqRexlj4xB2FpsrryiA96ZQ33iSPQHxL7EX6qQoLwDBKSZjT0/nIUE 2ZuuU+eRYjqcQ== From: Hector Martin Date: Sun, 29 Oct 2023 16:09:08 +0900 Subject: [PATCH 1/2] usb: kbd: Ignore Yubikeys MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-2-v1-1-9f793aa20fe4@marcan.st> References: <20231029-usb-fixes-2-v1-0-9f793aa20fe4@marcan.st> In-Reply-To: <20231029-usb-fixes-2-v1-0-9f793aa20fe4@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1988; i=marcan@marcan.st; h=from:subject:message-id; bh=skDEW9jI8C0AxGJbd1kKImBnUzt3Mz72TkQ8vFUF4/8=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlQ7VvFpst4q1WccjqrPe9CYvvwg++OfbgUnrjx18Bfdp pyrJDyvo5SFQYyDQVZMkaXxRO+pbs/p59RVU6bDzGFlAhnCwMUpABNJjGJkePdnmVjI5mU6WRK/ d/xsctbyV0hoVdR9uW9b//wu+e0Oygx/eJK/cO2dfuxVbNmKNdo1+f3/z207fm95mK6IdMv23Cx dPgA= X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 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.8 at phobos.denx.de X-Virus-Status: Clean We currently only support one USB keyboard device, but some devices emulate keyboards for other purposes. Most commonly, people run into this with Yubikeys, so let's ignore those. Even if we end up supporting multiple keyboards in the future, it's safer to ignore known non-keyboard devices. This is particularly important to avoid regressing some users, since YubiKeys often *don't* work due to other bugs in the USB stack, but will start to work once they are fixed. Signed-off-by: Hector Martin --- common/usb_kbd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 352d86fb2ece..e8c102c567e4 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -120,6 +120,15 @@ struct usb_kbd_pdata { extern int __maybe_unused net_busy_flag; +/* + * Since we only support one usbkbd device in the iomux, + * ignore common keyboard-emulating devices that aren't + * real keyboards. + */ +const uint16_t vid_blocklist[] = { + 0x1050, /* Yubico */ +}; + /* The period of time between two calls of usb_kbd_testc(). */ static unsigned long kbd_testc_tms; @@ -465,6 +474,7 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum) struct usb_endpoint_descriptor *ep; struct usb_kbd_pdata *data; int epNum; + int i; if (dev->descriptor.bNumConfigurations != 1) return 0; @@ -480,6 +490,15 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum) if (iface->desc.bInterfaceProtocol != USB_PROT_HID_KEYBOARD) return 0; + for (i = 0; i < ARRAY_SIZE(vid_blocklist); i++) { + if (dev->descriptor.idVendor == vid_blocklist[i]) { + printf("Ignoring keyboard device 0x%x:0x%x\n", + dev->descriptor.idVendor, + dev->descriptor.idProduct); + return 0; + } + } + for (epNum = 0; epNum < iface->desc.bNumEndpoints; epNum++) { ep = &iface->ep_desc[epNum]; From patchwork Sun Oct 29 07:09:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856692 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=KFdXOaZd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6wV1vYqz1yQ4 for ; Sun, 29 Oct 2023 18:09:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE68F874BD; Sun, 29 Oct 2023 08:09:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="KFdXOaZd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C2A6C871C4; Sun, 29 Oct 2023 08:09:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 360338723E for ; Sun, 29 Oct 2023 08:09:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id D750942699; Sun, 29 Oct 2023 07:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698563359; bh=R1/ij1xn3qoay0zcqhigpB4xRnUemNR3rVgbqRUep4E=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=KFdXOaZdm6cKqWZl/AE1Qhg2kPnR4CJq4kzD91KLexPNM13phjNNrNlGcreQeUTnN UWN7u757jjN46HjqeYIdhoFqdug0pyQWShGdna+oO+cYLKXQbUlWHrPXG74PHw5HvN 3yPppjKYGB14l71+YPyR0wuc+YU3H/PQIXKJ3kpvoTEeedzLwIRimMfdJVEgKsBFdR 2Z4AoL1u2jlK/vG6GusC8X273QUswTHraeu6vvFItw6NNfiS9HN5tUQgD1+Cq/1/v/ ULiJGHfeu4B+Tk0PUlkq6IaG0G3e2i8SUe3S6utoxfhHjI5bJjvOyNvL93ARi/y8NJ fqrlCEDoWeAaQ== From: Hector Martin Date: Sun, 29 Oct 2023 16:09:09 +0900 Subject: [PATCH 2/2] usb: hub: Add missing reset recovery delay MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-2-v1-2-9f793aa20fe4@marcan.st> References: <20231029-usb-fixes-2-v1-0-9f793aa20fe4@marcan.st> In-Reply-To: <20231029-usb-fixes-2-v1-0-9f793aa20fe4@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=757; i=marcan@marcan.st; h=from:subject:message-id; bh=R1/ij1xn3qoay0zcqhigpB4xRnUemNR3rVgbqRUep4E=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlQ7VvEfFoIVkmn/LyXMti7lZ+AXfDHlePiq+akdCpd6/ jKkNoR2lLIwiHEwyIopsjSe6D3V7Tn9nLpqynSYOaxMIEMYuDgFYCKv2xgZFv+cfF6IN8bgxMcp 5ral8SK5b34HPN9VJ/Tbe6naP88nvxkZ/iYUmATm89i3d+rq8Sgk1U5yDTplwzmVxeH7m893Tvx gBQA= X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 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.8 at phobos.denx.de X-Virus-Status: Clean Some devices like YubiKeys need more time before SET_ADDRESS. The spec says we need to wait 10ms. Signed-off-by: Hector Martin Reviewed-by: Marek Vasut --- common/usb_hub.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/usb_hub.c b/common/usb_hub.c index ba11a188ca64..858ada0f73be 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -391,6 +391,13 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port) break; } + /* + * USB 2.0 7.1.7.5: devices must be able to accept a SetAddress() + * request (refer to Section 11.24.2 and Section 9.4 respectively) + * after the reset recovery time 10 ms + */ + mdelay(10); + #if CONFIG_IS_ENABLED(DM_USB) struct udevice *child;