From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7D63C2B9F4 for ; Mon, 14 Jun 2021 20:55:23 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5C54860241 for ; Mon, 14 Jun 2021 20:55:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C54860241 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 895AF81D48; Mon, 14 Jun 2021 22:55:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="qlOGKsyV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3ED7782024; Mon, 14 Jun 2021 22:55:17 +0200 (CEST) Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (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 22E1980412 for ; Mon, 14 Jun 2021 22:55:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rfried.dev@gmail.com Received: by mail-oi1-x22e.google.com with SMTP id a26so15735083oie.11 for ; Mon, 14 Jun 2021 13:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Nqe/jADXHkgAPXkf3/9cHbVNNUHRPZzhvot2LGiZT3g=; b=qlOGKsyVx51aEdo/ODbnmps0Sh3XPXGgQUteJwTZhcqkCJFBOK6hIV3uhDYFr1D5S8 oUQTyVu9PNZU/X9dOI73UpL+39iAau25gbKYPK0ppLJfjt3GAX1HNxH+3rpu32qYzKBf X27OinSsZusUUbHILxvyCy13GrYES0iQgqN1tncw2JuLo8L0TKL4h+QWq9gppBhfhl/1 7Sd/lym6RGMThVlpfodr6quYud1baGNBbagcrbv4x4hX3zN+/cOtfXW2ULtc/lj5WTuT U6TAs4mciHWvevW9L6JxLvHH2la2PAsHo0lPhO1ZrKS08v79vPvXCSP37EWkS8NoKjlU /uDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Nqe/jADXHkgAPXkf3/9cHbVNNUHRPZzhvot2LGiZT3g=; b=GXaGJ/kgVjDAisIioZyzFYRdnoxXyDwuH7to3HorJb9KI6us/CKPf/qEVJHAkmsz0H 1E572EGE6Wa/FnZQRwZ0lpO6X6IyX3EuQHoqcrID5BfZC489CBAlwDOVLapMbm2m/KjD GUsvDbbXIQ1j3W2g+WSx/bxBkSQ5jak+K/VSxVoocfThiwFXxpIZIQB2/VfSLZukcz8B KHoWJbZEJ85AbKozi0nA6xKJvpj7LWA0WrWnX6S80RUMUA6syhmgZmaqvei7KfLkfVzu YFGgjLrnuFW3p+EvpHcVFIC9CGNHDniNNC7ReIrSg3mvyWooZ5cSYmphIORS5MpHoSlt xIxA== X-Gm-Message-State: AOAM533c3CEG3FO/IfdGtUxIPhWdFhDakBlbZvyAFrpq2WvD3B3nfTqN Mvk3q2q6bIRhnT7jobhp8dWaiVhpsm06RDRva1A= X-Google-Smtp-Source: ABdhPJyLp04qqvwuNp+UmpLt4enwNnIGjbvstGKrIVGvVqJtN+ixxABHfWqq1fIvRbDz59aH5EMLfUm9g7J6U0N9Blo= X-Received: by 2002:aca:407:: with SMTP id 7mr682330oie.22.1623704112672; Mon, 14 Jun 2021 13:55:12 -0700 (PDT) MIME-Version: 1.0 References: <20210224163044.17017-1-michael@walle.cc> In-Reply-To: From: Ramon Fried Date: Mon, 14 Jun 2021 23:55:01 +0300 Message-ID: Subject: Re: [PATCH] net: use a more deterministic approach to get the active ethernet device To: Michael Walle Cc: U-Boot Mailing List , Joe Hershberger Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Thu, Apr 29, 2021 at 11:03 PM Ramon Fried wrote: > > On Wed, Feb 24, 2021 at 6:30 PM Michael Walle wrote: > > > > If the environment variable "ethact" is not set, the first device in the > > uclass is returned. This depends on the probing order of the ethernet > > devices. Moreover it is not not configurable at all. > > > > Try to return the ethernet device with sequence id 0 first which then > > can be configured by the aliases in a device tree. Fall back to the old > > mechanism in case of an error. > > > > Signed-off-by: Michael Walle > > --- > > net/eth-uclass.c | 17 ++++++++++++----- > > 1 file changed, 12 insertions(+), 5 deletions(-) > > > > diff --git a/net/eth-uclass.c b/net/eth-uclass.c > > index 34ca731d1e..0b4260dc5b 100644 > > --- a/net/eth-uclass.c > > +++ b/net/eth-uclass.c > > @@ -69,8 +69,11 @@ void eth_set_current_to_next(void) > > /* > > * Typically this will simply return the active device. > > * In the case where the most recent active device was unset, this will attempt > > - * to return the first device. If that device doesn't exist or fails to probe, > > - * this function will return NULL. > > + * to return the device with sequence id 0 (which can be configured by the > > + * device tree). If this fails, fall back to just getting the first device. > > + * The latter is non-deterministic and depends on the order of the probing. > > + * If that device doesn't exist or fails to probe, this function will return > > + * NULL. > > */ > > struct udevice *eth_get_dev(void) > > { > > @@ -80,9 +83,13 @@ struct udevice *eth_get_dev(void) > > if (!uc_priv) > > return NULL; > > > > - if (!uc_priv->current) > > - eth_errno = uclass_first_device(UCLASS_ETH, > > - &uc_priv->current); > > + if (!uc_priv->current) { > > + eth_errno = uclass_get_device_by_seq(UCLASS_ETH, 0, > > + &uc_priv->current); > > + if (eth_errno) > > + eth_errno = uclass_first_device(UCLASS_ETH, > > + &uc_priv->current); > > + } > > return uc_priv->current; > > } > > > > -- > > 2.20.1 > > > Reviewed-by: Ramon Fried Applied to u-boot-net/master, thanks! Best regards, Ramon Fried