Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp625064pxv; Thu, 15 Jul 2021 11:51:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBhY8q7VWUhaRKexObxYeTpoUk2v5sFJRiwBZV46uSKm1HGHjPvkICOy1/WFoho8quv6iG X-Received: by 2002:a92:d8c5:: with SMTP id l5mr3661331ilo.79.1626375073231; Thu, 15 Jul 2021 11:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375073; cv=none; d=google.com; s=arc-20160816; b=YHkpwJ1hfOylR9jbgTI01NTC498vUD8HIdCHSvGUkcXFa9GsFvl47V4XNHoMYWnoMq BFbGLvg5dIy7RoD3UaORccWaU/WYLx2ZSQEKtRL04JFOBUESx1gXc92kVyk5v5aVlEV/ 9s+6yykw8zlusUtetLvRducULtfCCzOEHdjKqUnt87ztB4/X63W8UEXOBk+rUUzDXzJx 70fqdo4jO8PvfDHF7pnoQjIuVuB6fpoWaTDidx2O7Y97U/OuLfgLx+WMF5lhdgV1j7df RcaQzQBL4UkjMpRYX5xUkwOP/pd2TeTtUcOF7MwiXWxg690BxtqgepO27OCHTUtRto3f lQuQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ukg9yAtKwIe3yQdLnAzVq9ecZ7EDjEU1CRHtBHInu/8=; b=T9Bqqx6hIIJayxqPcrD8NW29D9rDcotvbAWOF7KA68HNdAOgIa2aBvoPssjjs8Y0zm YKI79NKMCd92TB/ZoaiiMQf9XPVyMEcc9rGQ5pyA9VQucwfpr2b0Z0YtEIuI4fmRawyP rvGq/A6+JC97IgfOBwJKtXR4cl8/0Jhml/ZanBTCVIxPb4ZA/nlME1lJNS0T5sSbS5Ps bavHj/Bk8Vk4AbjLFA3TNoo2IfqFFXCmg/zB8l05rCjKr53veAyYFJEsu5Fjz5vrRUNb oxLzqwNIxUGcwU2nIRYUqZ89CTdBzQgPas2OvGVWcw4WZeqXyANTF32eDVT7bH73s3Wn d9Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=li0JwmiN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j2si5870895ilo.119.2021.07.15.11.51.00; Thu, 15 Jul 2021 11:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=li0JwmiN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240822AbhGOSxU (ORCPT + 99 others); Thu, 15 Jul 2021 14:53:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:52350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236182AbhGOStv (ORCPT ); Thu, 15 Jul 2021 14:49:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 029B3613D0; Thu, 15 Jul 2021 18:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374817; bh=WNd2XvsHmMzMTc8q8RW82ovz6hXwJfeCBtj0g4KFKKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=li0JwmiNRqcwvXVgHyUUdQPF5CeZKYpW1+Zk2COg1ZK8WlEcLUqTO0e2BD2me1BcL uFRC3TrffyB5xB7PpUt0JCBblCauzVUv3cfLtTm8Ti7rjh6zsOXUI0O5iJxxwQzQZ1 ndp34zMw5fdjr9m4+jAZK7ss2FiBqgTEiW0wDKXU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 038/215] net: stmmac: the XPCS obscures a potential "PHY not found" error Date: Thu, 15 Jul 2021 20:36:50 +0200 Message-Id: <20210715182606.018626833@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit 4751d2aa321f2828d8c5d2f7ce4ed18a01e47f46 ] stmmac_mdio_register() has logic to search for PHYs on the MDIO bus and assign them IRQ lines, as well as to set priv->plat->phy_addr. If no PHY is found, the "found" variable remains set to 0 and the function errors out. After the introduction of commit f213bbe8a9d6 ("net: stmmac: Integrate it with DesignWare XPCS"), the "found" variable was immediately reused for searching for a PCS on the same MDIO bus. This can result in 2 types of potential problems (none of them seems to be seen on the only Intel system that sets has_xpcs = true, otherwise it would have been reported): 1. If a PCS is found but a PHY is not, then the code happily exits with no error. One might say "yes, but this is not possible, because of_mdiobus_register will probe a PHY for all MDIO addresses, including for the XPCS, so if an XPCS exists, then a PHY certainly exists too". Well, that is not true, see intel_mgbe_common_data(): /* Ensure mdio bus scan skips intel serdes and pcs-xpcs */ plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR; plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR; 2. A PHY is found but an MDIO device with the XPCS PHY ID isn't, and in that case, the error message will be "No PHY found". Confusing. Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20210527155959.3270478-1-olteanv@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index b2a707e2ef43..678726c62a8a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -441,6 +441,12 @@ int stmmac_mdio_register(struct net_device *ndev) found = 1; } + if (!found && !mdio_node) { + dev_warn(dev, "No PHY found\n"); + err = -ENODEV; + goto no_phy_found; + } + /* Try to probe the XPCS by scanning all addresses. */ if (priv->hw->xpcs) { struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args; @@ -449,6 +455,7 @@ int stmmac_mdio_register(struct net_device *ndev) xpcs->bus = new_bus; + found = 0; for (addr = 0; addr < max_addr; addr++) { xpcs->addr = addr; @@ -458,13 +465,12 @@ int stmmac_mdio_register(struct net_device *ndev) break; } } - } - if (!found && !mdio_node) { - dev_warn(dev, "No PHY found\n"); - mdiobus_unregister(new_bus); - mdiobus_free(new_bus); - return -ENODEV; + if (!found && !mdio_node) { + dev_warn(dev, "No XPCS found\n"); + err = -ENODEV; + goto no_xpcs_found; + } } bus_register_done: @@ -472,6 +478,9 @@ bus_register_done: return 0; +no_xpcs_found: +no_phy_found: + mdiobus_unregister(new_bus); bus_register_fail: mdiobus_free(new_bus); return err; -- 2.30.2