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 D8D3CC46467 for ; Sun, 8 Jan 2023 02:58:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1AF278567D; Sun, 8 Jan 2023 03:53:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DvtoGQwU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 489D98561B; Sun, 8 Jan 2023 03:52:41 +0100 (CET) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 37B248564A for ; Sun, 8 Jan 2023 03:51:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id u8so3320803ilg.0 for ; Sat, 07 Jan 2023 18:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3vleJvT6sA2ceqghCgnBkfylI2NOYntfySvzIxTgl8I=; b=DvtoGQwUoxBMNpORGJrCtGV8L2a7qxo1KVOkFh3wdcTnQrKzGiJJpE2feg8ThKV2Ge sasIFj/sGfrX2WO4C+fmABay/+kuIipvqP1WgMswUixZTcm/WWm6p0LHFv+CF43GwPH1 +vCwln7ePaV4DDlZp/e9PUE3REkUako1/LsCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3vleJvT6sA2ceqghCgnBkfylI2NOYntfySvzIxTgl8I=; b=eDnaBL4cX40Nd1XGDDkPYg4AFj/0IhTwUVRv1KJ3DEa6gAkBgkt+pBYX278m5KICvE cWiwQNbO/QtW6FniCAbQHfellr/OrfViAL61xQrvMNYhOk7/hKKP1Jb7ZX7a8vSKyG06 RBeNbL44xyZQn7uU1wAnZogVuM+V9M1LOGW8N4nHoqHIoMtfHGfCSv81FZDi/RQIO8Iz 42YyNaJ+a1zamU3/MXCfCS8Ly2iJ/bNqoiBTdsR6sBmoJ+4r63DwWaHSCA16TGikSDEy oYQZojK9suKcBwr26XSXQIBgTzcV8nMPG1MraNal8G9wHo3zJC7sUsdXEevYCA7DIMzD q8Gw== X-Gm-Message-State: AFqh2kqP9Pcpu5AoEUEbh4WxCCCnbzc1c4MpQAEUeDta5zFaF2e5IskW Zc4uTxiHwvZsssL8fpWWy5vszLTFPozPbv4T X-Google-Smtp-Source: AMrXdXs2S5zKMr59AbBb/y3ekcM/ER2zx+ig3FZxSIvNiINFyy/xdS6BTyk1Vf5ZimJyILQeZmdFGA== X-Received: by 2002:a92:ad06:0:b0:30b:fd11:8b2 with SMTP id w6-20020a92ad06000000b0030bfd1108b2mr32547392ilh.1.1673146277503; Sat, 07 Jan 2023 18:51:17 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id c17-20020a92bd11000000b00302a00aaefasm1622174ile.26.2023.01.07.18.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 18:51:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH v2 28/71] bootstd: Add a USB hunter Date: Sat, 7 Jan 2023 19:50:04 -0700 Message-Id: <20230108025047.522240-29-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230108025047.522240-1-sjg@chromium.org> References: <20230108025047.522240-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean Add a hunter for USB which enumerates the bus to find new bootdevs. Update the tests and speed up bootdev_test_prio() while we are here, by dropping the USB delays. Signed-off-by: Simon Glass --- (no changes since v1) drivers/usb/host/usb_bootdev.c | 12 ++++++++++++ test/boot/bootdev.c | 26 +++++++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/usb_bootdev.c b/drivers/usb/host/usb_bootdev.c index b2d157faf33..66d0b6ae8f5 100644 --- a/drivers/usb/host/usb_bootdev.c +++ b/drivers/usb/host/usb_bootdev.c @@ -20,6 +20,11 @@ static int usb_bootdev_bind(struct udevice *dev) return 0; } +static int usb_bootdev_hunt(struct bootdev_hunter *info, bool show) +{ + return usb_init(); +} + struct bootdev_ops usb_bootdev_ops = { }; @@ -35,3 +40,10 @@ U_BOOT_DRIVER(usb_bootdev) = { .bind = usb_bootdev_bind, .of_match = usb_bootdev_ids, }; + +BOOTDEV_HUNTER(usb_bootdev_hunter) = { + .prio = BOOTDEVP_3_SCAN_SLOW, + .uclass = UCLASS_USB, + .hunt = usb_bootdev_hunt, + .drv = DM_DRIVER_REF(usb_bootdev), +}; diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 45a00c34c0c..7a0c5793890 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -190,6 +190,8 @@ static int bootdev_test_prio(struct unit_test_state *uts) struct bootflow bflow; struct udevice *blk; + test_set_skip_delays(true); + /* Start up USB which gives us three additional bootdevs */ usb_started = false; ut_assertok(run_command("usb start", 0)); @@ -227,6 +229,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts) { struct bootstd_priv *std; + test_set_skip_delays(true); + /* get access to the used hunters */ ut_assertok(bootstd_get_priv(&std)); @@ -234,12 +238,17 @@ static int bootdev_test_hunter(struct unit_test_state *uts) bootdev_list_hunters(std); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_nextline("(total hunters: 0)"); + ut_assert_nextline(" 40 usb usb_bootdev"); + ut_assert_nextline("(total hunters: 1)"); ut_assert_console_end(); - ut_assertok(bootdev_hunt("mmc1", false)); + ut_assertok(bootdev_hunt("usb1", false)); + ut_assert_nextline( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); + ut_asserteq(GENMASK(0, 0), std->hunters_used); + return 0; } BOOTSTD_TEST(bootdev_test_hunter, UT_TESTF_DM | UT_TESTF_SCAN_FDT); @@ -249,6 +258,8 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) { struct bootstd_priv *std; + test_set_skip_delays(true); + /* get access to the used hunters */ ut_assertok(bootstd_get_priv(&std)); @@ -256,21 +267,26 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextline("Prio Used Uclass Hunter"); ut_assert_nextlinen("----"); - ut_assert_nextline("(total hunters: 0)"); + ut_assert_nextline(" 40 usb usb_bootdev"); + ut_assert_nextline("(total hunters: 1)"); ut_assert_console_end(); /* Scan all hunters */ ut_assertok(run_command("bootdev hunt", 0)); + ut_assert_nextline("Hunting with: usb"); + ut_assert_nextline( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); ut_assert_console_end(); /* List available hunters */ ut_assertok(run_command("bootdev hunt -l", 0)); ut_assert_nextlinen("Prio"); ut_assert_nextlinen("----"); - ut_assert_nextline("(total hunters: 0)"); + ut_assert_nextline(" 40 * usb usb_bootdev"); + ut_assert_nextline("(total hunters: 1)"); ut_assert_console_end(); - ut_asserteq(0, std->hunters_used); + ut_asserteq(GENMASK(0, 0), std->hunters_used); return 0; } -- 2.39.0.314.g84b9a713c41-goog