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 84940C352A1 for ; Wed, 7 Dec 2022 09:00:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8AFF285658; Wed, 7 Dec 2022 09:55:53 +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="fm2nwMAK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F137855F2; Wed, 7 Dec 2022 09:55:32 +0100 (CET) Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (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 F3F84855BD for ; Wed, 7 Dec 2022 09:55:28 +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-pg1-x52b.google.com with SMTP id 142so258606pga.1 for ; Wed, 07 Dec 2022 00:55:28 -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=6/l+FTg568SOj+veAiv5wsm1+jNCWJlyS0vS1TFQesg=; b=fm2nwMAKeEOtzBaKNo7lU8v2QxylEzh+32QAbVsgF8EnLoqXSbA+rSPe72BVqx4ReR 57VyQ4ZatN8H6qkEz0HwEHzpkJRm4lEZp4MoH2QxRAhan1124nf1X0I7DbbwbSVraVhi gCUpIeA0EOq40A8H4MYccy5as0goIbpFdlLZM= 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=6/l+FTg568SOj+veAiv5wsm1+jNCWJlyS0vS1TFQesg=; b=uIH1AKqaHzebeD3KX+uYD+/maku8huv16Uaoe7qxFwhS+sIsjcCSHLrWXrr3o8CrQu t0KfXTfXYmqkaGS0VN5lgEZC2MNZdDT8p88+AjmnvtnLSGGgEJTLKbstHYYoTNMc9+pQ obNySGFFNueR0oqRBwOu/xldR5Mw8GJVErFFtZOKyt6vLdzNwmOQcRRXXt4nyaOMAFST mCjcU9pdl4pD3vTKsceYSA4mh+nigto/+kRo+m+/q1j4ljRxnht5fNa8x772JY8454Uj CRS1rTiLJ5LELZfEkizk3pzG6s5qIF8K8n/oAnZKl1vyIVfDaheFYQn8AQPesDIYW40h ZHBg== X-Gm-Message-State: ANoB5plolfjYtwycwsr71XgSDZq9dtBAAvao65WX6gFcubuXBMrRBNnu I/D56b00ykMzB2n7jxg0PzOr+kvKc+C9Q/QH X-Google-Smtp-Source: AA0mqf5YNt2/eQ3SazUhSXBdS4mZDuUfaXMyKs4it5OOd66DeGp4wqbQ7qJ1DHz2IJzD9BUoJM6XWg== X-Received: by 2002:a65:64d1:0:b0:478:980a:53fb with SMTP id t17-20020a6564d1000000b00478980a53fbmr17631281pgv.484.1670403328317; Wed, 07 Dec 2022 00:55:28 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Marek Vasut Subject: [PATCH 28/71] bootstd: Add a USB hunter Date: Wed, 7 Dec 2022 21:50:54 +1300 Message-Id: <20221207085137.445249-29-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-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 --- 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.rc0.267.gcb52ba06e7-goog