Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp651643pxv; Thu, 15 Jul 2021 12:30:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9w9VOa4IJdEti3IJSD0oCeNH6m4T1TxBkQICwwwkTM8qRVHom6UnuLC01uHI5l5OKGF2p X-Received: by 2002:aa7:d84f:: with SMTP id f15mr3928862eds.216.1626377437957; Thu, 15 Jul 2021 12:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377437; cv=none; d=google.com; s=arc-20160816; b=O0+yZN1jAzjk77a8/4SNmun0eB7t4Osa69B7yZqeAwIbTzdqIk3cpfWM9LGy2dOoZm sZVpCPsM+88beZbTdMr9d36qOVjOwqVlMEcK3/xhA31pegR29BsAvGQoPVaWD3apdJRY iHRiC/XfwkjZ8+6dEwKp1Og3D/Y8DPqKfT+s094IvdtLyNQspduZ9XLoKt5hac3/taX6 ElWbH+a3EYZQ7/kRlFJQWknP165Fgm/+7mPQ3LInqjvD3rR7i5GYH74rlvxBhoob8J+B gNMrjOvTR6pUp+hn/NWnxxDBRW1NNBfHJb8/GGcupYFrXx+x28WLdDyjWCZ9486sEw4C hbNA== 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=IHMu2h3wqLAgBrUr4dP3X5bWwrhcUNbR8AZ90DB8nxY=; b=OMzeHFHxQ/BF6UCPONqE4H2EsUIfPU2iajoRqIL98UwhRMdPGqccRB7FS/iNeR9BVd LJk7f+sZJeqQzIoNXI1QFwbUVhSR7T71rmeGnZpj/kq3WR0YRl7Kr02NScLB588RQeal q31nJ/6+NACK2UV36kUuzn6XR80QvphazA3zsun80UHgOaGLe00vSy8lKg79vEBj7IoU 2tQMHZQ0Jh/5+e6sjJ8UA4VL/cREK1M8FR6DiMZElzgeFZpLPh7rUhkq5dd9Y0wXlB74 umKGN7GxM64jhO+mrSgny7RiHc6N/6CipOyE2BVIOo/q9I520+Uq+dTF74SMi/AALo00 t3hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2FieDg1v; 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 f19si7884756edf.525.2021.07.15.12.30.12; Thu, 15 Jul 2021 12:30:37 -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=2FieDg1v; 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 S1343624AbhGOT3b (ORCPT + 99 others); Thu, 15 Jul 2021 15:29:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:46402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243231AbhGOTJi (ORCPT ); Thu, 15 Jul 2021 15:09:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E0D5613D7; Thu, 15 Jul 2021 19:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375921; bh=6NQfrjTCwGu0yI8QS3j8OxGNtiY/MRKl+J+5wzAbrTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2FieDg1vXIex628MO3W7n0BceyjFLU/oi/r9n/SBKYliX+gplXpYiPIpo1F96zIRg lxTHhQB0BkKxP8TI7sQyugcGrEwBbGmOF91bv3yuBd4s5BGlCXekJq/Fd/jDFNqPl1 EJUrc+SyjapsRxZ3MiiMJje5/CJPzIOJ+l33lWpY= 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.13 050/266] net: stmmac: the XPCS obscures a potential "PHY not found" error Date: Thu, 15 Jul 2021 20:36:45 +0200 Message-Id: <20210715182623.009946906@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 b750074f8f9c..e293bf1ce9f3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -503,6 +503,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; @@ -511,6 +517,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; @@ -520,13 +527,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: @@ -534,6 +540,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