Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2162296rwb; Sun, 15 Jan 2023 10:11:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXvc2Bbl9zD+AqIdc0pvaWPDU7Uvup98aLp1CSbV91AsMITT83T85ALdgwIK7pvMiOAgAyuH X-Received: by 2002:a05:6a20:8ede:b0:b8:7ce2:7fad with SMTP id m30-20020a056a208ede00b000b87ce27fadmr1263384pzk.51.1673806293259; Sun, 15 Jan 2023 10:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673806293; cv=none; d=google.com; s=arc-20160816; b=c/P+prgL7jYS4akeONROmqv8krPF7Lh/c4FPNrnMqnyUm4SedCzzxcliPSkxfXpT5A PsbVotOmPK+HdCeiUP8Nw2jhC56EeWGFmsNAluzu3oIpPPgBGpUWZtHk8SC9aRw4KQJH 7Dthxx+bzsdrRMbGnPFi7m00N93WgqaJ24CkHs9G3yhZJNuhqzyqchLzJC+yuT65vQDV M5Fi+tjjD6Ww5GZlKNlYS1o0Go3WzRTCH0yfQ7F6F+O3xHKAgDo8UFRWvriSr/gEF9WM QxA0173rRwCS9ycNbyUMNGU5EvZPjOEHDjv9t6mBjofxzaSHHoO1CSGvcNQQUACKZt5z 02cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1pHnSVvnYc1fuLFjMyl2/Ut5FQtAdStr7PJnGlkXIg8=; b=toYdPjDruWXRKETfMHIstxZVLignqqQp5uUqT+r1IOcnCtEk0ls8xjMOw1MzeEZZKr vqbvXVqYsR9aV+uOmsvqRFsnDvunBWr2svdX/FFrWD/NwaexVgF/BB5EVkIw1Ows3hUK rmE8hJVGOdWAoPRiacuaM21HVextkojum2p9YwrZk0ExIUq17wJS4lQVUdsglY0BplC7 1gg9UcVINhmxrNqz/7Fs7fU2iaoC1HRjDq3s7XuxrPNOPFg0mq0HfjMqbD2prNbkoRrh s4gGyh1C6ievxNLEqLW5RM8kbvaeWngXAy3GCo1RRvkDfpqBWs5RyWmEWmT2INlbcdme VSsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f1HqlTEw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 138-20020a630090000000b004c6cca6a1ecsi6556479pga.577.2023.01.15.10.11.25; Sun, 15 Jan 2023 10:11:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f1HqlTEw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231492AbjAORt1 (ORCPT + 54 others); Sun, 15 Jan 2023 12:49:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231362AbjAORt0 (ORCPT ); Sun, 15 Jan 2023 12:49:26 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1092CC39; Sun, 15 Jan 2023 09:49:24 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so20669144wms.2; Sun, 15 Jan 2023 09:49:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1pHnSVvnYc1fuLFjMyl2/Ut5FQtAdStr7PJnGlkXIg8=; b=f1HqlTEwMw3oWjQEXhDxelkjzhaEGD/x80ZF65JZU32scgLJaf55oqHaBNdGL/SOfG EDvpJ+hpeFQPV/IMFD4Te5GtgLhSuLzjzGVn5Pi02500Gpwi3GBkcz63VEg31kNlzpCM VEQ/8Vdi27WZgpYLskgcIvv9UC9WvuGtRrlMXZg32kFA2+LwUQuniERkGh+aETdhIfsJ Z1/4Gz+U98BIXVW6iGsFs74S5cEuCLHSXAb48k8kv7RR5A89eGQA36iHQptwwcDG3JfM CLYuVero+HSegxFVpm6R7eu4MfJowJj3+p2rDdzNX8T52Rb040z0WdC3LnOK6oVx+ixe 4xbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1pHnSVvnYc1fuLFjMyl2/Ut5FQtAdStr7PJnGlkXIg8=; b=6Z5WDtD6fxOJiAkyRbiv2QhkvlHz91YjnDzzW2DckaFWmqE0Sr4gqhP7SPdscdFK6J NcBTGOm56D0gY5sVj9jPMRWoQyChnbKeXK6C5pGjDdddFmPz55GpyW8OO+6fgaTQ8vSF ZiEazwhikNSUagZ8SAnKzuvJTk7QvJVVfD0cBPRQM+nxGYq+r29C9ahvEXev8FInud6n laH0J2KGirgup6lygADuh9y/ehNW8usruINclqMaql+cwcWrLzVujCWJg8D3brVQCTjN 4nEvz2dj2uSJOVXgMej/zMTyor09sziHta9DqxIbJLWpCNornuXZym953R2upG+6dupn 3T8w== X-Gm-Message-State: AFqh2krpMM28e2b5+LOrSZ+hQ4IlEORxZw7T7filttPgMYSIvQIM3Uqq PSxqoVPYOQOn8zLHdqe9P70= X-Received: by 2002:a05:600c:4aa8:b0:3d1:cee0:46d0 with SMTP id b40-20020a05600c4aa800b003d1cee046d0mr64068100wmp.25.1673804963344; Sun, 15 Jan 2023 09:49:23 -0800 (PST) Received: from localhost.localdomain (host-79-51-7-163.retail.telecomitalia.it. [79.51.7.163]) by smtp.googlemail.com with ESMTPSA id iv14-20020a05600c548e00b003b47b80cec3sm41186261wmb.42.2023.01.15.09.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 09:49:23 -0800 (PST) From: Pierluigi Passaro X-Google-Original-From: Pierluigi Passaro To: wei.fang@nxp.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com, linux-imx@nxp.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: eran.m@variscite.com, nate.d@variscite.com, francesco.f@variscite.com, pierluigi.p@variscite.com Subject: [PATCH] net: fec: manage corner deferred probe condition Date: Sun, 15 Jan 2023 18:49:10 +0100 Message-Id: <20230115174910.18353-1-pierluigi.p@variscite.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For dual fec interfaces, external phys can only be configured by fec0. When the function of_mdiobus_register return -EPROBE_DEFER, the driver is lately called to manage fec1, which wrongly register its mii_bus as fec0_mii_bus. When fec0 retry the probe, the previous assignement prevent the MDIO bus registration. Use a static boolean to trace the orginal MDIO bus deferred probe and prevent further registrations until the fec0 registration completed succesfully. Signed-off-by: Pierluigi Passaro --- drivers/net/ethernet/freescale/fec_main.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 644f3c963730..b4ca3bd4283f 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2284,6 +2284,18 @@ static int fec_enet_mii_init(struct platform_device *pdev) int err = -ENXIO; u32 mii_speed, holdtime; u32 bus_freq; + static bool wait_for_mdio_bus = false; + + bus_freq = 2500000; /* 2.5MHz by default */ + node = of_get_child_by_name(pdev->dev.of_node, "mdio"); + if (node) { + wait_for_mdio_bus = false; + of_property_read_u32(node, "clock-frequency", &bus_freq); + suppress_preamble = of_property_read_bool(node, + "suppress-preamble"); + } + if (wait_for_mdio_bus) + return -EPROBE_DEFER; /* * The i.MX28 dual fec interfaces are not equal. @@ -2311,14 +2323,6 @@ static int fec_enet_mii_init(struct platform_device *pdev) return -ENOENT; } - bus_freq = 2500000; /* 2.5MHz by default */ - node = of_get_child_by_name(pdev->dev.of_node, "mdio"); - if (node) { - of_property_read_u32(node, "clock-frequency", &bus_freq); - suppress_preamble = of_property_read_bool(node, - "suppress-preamble"); - } - /* * Set MII speed (= clk_get_rate() / 2 * phy_speed) * @@ -2389,6 +2393,8 @@ static int fec_enet_mii_init(struct platform_device *pdev) fep->mii_bus->parent = &pdev->dev; err = of_mdiobus_register(fep->mii_bus, node); + if (err == -EPROBE_DEFER) + wait_for_mdio_bus = true; if (err) goto err_out_free_mdiobus; of_node_put(node); -- 2.37.2