From patchwork Sun Jun 2 14:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13682909 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 226DAC25B74 for ; Sun, 2 Jun 2024 14:37:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UmRv8LhB6lrfuize4jedwuuKsJOYYDGhTO2/0/wAxy4=; b=cCzp8HoV66VO3n JKfEeWStxFSo8myc2XBxLRdglX+Neoba8KeCQ/zPWOCwfhTQEO/3sgiT/anh/VKZG8EXuEOap5C29 wB2EA7raTKXnKYB1q25OKppm+WKXMnKx7Gzb7i14vZ4qV4PkEMcTIxbkmeKOsJ1TwldXu8YbFA4Td /MpyOALY27wVdpWNl3AgJOuRX5VuIQOggcb6feeTAhGjBydEMvNv+oeVSFd6uWtF9Esd+F5iaGg7J WgwgwCDYtjxWB2F4gYF0HwTMtSAwV0MxvL85J75laEl+3ccciUIv0AwZPecQn/eCH+n4BqyP8edzN Lhis5y8y4A88fJvBPMYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDmKY-0000000EQ5k-31wJ; Sun, 02 Jun 2024 14:37:06 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDmKW-0000000EQ3R-0qjE for linux-arm-kernel@lists.infradead.org; Sun, 02 Jun 2024 14:37:05 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52965199234so3905286e87.2 for ; Sun, 02 Jun 2024 07:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717339021; x=1717943821; darn=lists.infradead.org; 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=7vjMvBNpGJ2YRY1Cb9nA1dqsGS8aAwxtGRodJv9KKVo=; b=PicHrIgei4+8iw9Ukqx2Idnh16yuTM5WpSf1JgHdkD3PzACfsnI5S2BTz/BDpE9Izj Z9EAZz++Wfo+9fdyImxjdRn1tditHVuZON4fEHaKjevW136F5ofKwo8+/fH0x+YIF4IW sFe1B9wItptrIYTxLXaBHwyNkOdltY/m+/1vZiz52drAHZ8RTucvpCsncs0vZCwtdm53 0aid+kPGlv3Uql2XKHIrHV/l5hvDA7v27zCostDtPv58PLQETJMJihZupGL8FH5Rw5Su vhB0UlUJ08FUYvXgn3EPLi9K1lCKPkmHiEzcp0/jVrlnitcVFqepGeLWDxb8J9jZxkwR xirw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717339021; x=1717943821; 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=7vjMvBNpGJ2YRY1Cb9nA1dqsGS8aAwxtGRodJv9KKVo=; b=JzNV87irgCuUb2dSiOY6tT2MumFFOSh4XMQketto6sQmMl3tDlV/b/NAdW57HoKEYp n4gSqxCvHznavba9eAcfODJqEjRStQ7psPuIH2hn4vemVxXspMoBiFgSgHzFll5S+Trx phUEdLFLh5q+kbgszMv11r5zrOuTpSZfZVgR3b6HzkDtrDUAlVwgbw+bPEUhwgYQ8pR6 YLJu6UZVbz9zyRsaaWxbYqeMh8WfuvcNoBIkvLYR3uCBbOgbp1ASfzMhR7fqL5a8qh9y w2AxaRSq2cld4VhtZjjCnBwzDN3aLgUB5QHnhMgPhgLtzhpJKUK8gU4HaSOR/xKObP8D aoqg== X-Forwarded-Encrypted: i=1; AJvYcCU3blohIcrP7yREFSnslZNNrs10SMRXSZXzsEsYLYNSzPleMTBYAlcWvTsWIs2YB2OIzxM88HHf9zF1HbSZ7FNec3xmmY4wo7XreFFEVJevzNKasjU= X-Gm-Message-State: AOJu0YyODqbqAuOe4gefzudI391N+JLtSEvHR9gI3KTDXj3nA2BDVikZ K+35OMv3qXE/S4JgMYQJRgBChF/bFqJ6G2Ts19M4bKbms2o6FhYL X-Google-Smtp-Source: AGHT+IF+Hex+g3j4f6h2pCksD9/xzuP9uZz4YvqyQTtFSMyXUw0x6Mqvz4SNvUNBrOtKz3gPvsNgXg== X-Received: by 2002:a05:6512:4c6:b0:52b:5f39:9221 with SMTP id 2adb3069b0e04-52b896f183fmr4063497e87.64.1717339021163; Sun, 02 Jun 2024 07:37:01 -0700 (PDT) Received: from localhost ([178.178.142.64]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52b98fb5c5asm152445e87.16.2024.06.02.07.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 07:37:00 -0700 (PDT) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Vladimir Oltean , Florian Fainelli , Maxime Chevallier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Serge Semin , Sagar Cheluvegowda , Abhishek Chauhan , Andrew Halaney , Jiawen Wu , Mengyuan Lou , Tomer Maimon , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next v2 09/10] net: stmmac: Create DW XPCS device with particular address Date: Sun, 2 Jun 2024 17:36:23 +0300 Message-ID: <20240602143636.5839-10-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240602143636.5839-1-fancer.lancer@gmail.com> References: <20240602143636.5839-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240602_073704_266252_C72FA61B X-CRM114-Status: GOOD ( 19.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the only STMMAC platform driver using the DW XPCS code is the Intel mGBE device driver. (It can be determined by finding all the drivers having the stmmac_mdio_bus_data::has_xpcs flag set.) At the same time the low-level platform driver masks out the DW XPCS MDIO-address from being auto-detected as PHY by the MDIO subsystem core. Seeing the PCS MDIO ID is known the procedure of the DW XPCS device creation can be simplified by dropping the loop over all the MDIO IDs. From now the DW XPCS device descriptor will be created for the pre-defined MDIO-bus address. Note besides this shall speed up a bit the Intel mGBE probing. Signed-off-by: Serge Semin --- Changelog v2: - This is a new patch introduced on v2 stage of the review. --- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 15 ++++----------- include/linux/stmmac.h | 1 + 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 56649edb18cd..e60b7e955c35 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -586,6 +586,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { plat->mdio_bus_data->has_xpcs = true; + plat->mdio_bus_data->xpcs_addr = INTEL_MGBE_XPCS_ADDR; plat->mdio_bus_data->default_an_inband = true; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index aa43117134d3..807789d7309a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -499,8 +499,7 @@ int stmmac_pcs_setup(struct net_device *ndev) { struct dw_xpcs *xpcs = NULL; struct stmmac_priv *priv; - int ret = -ENODEV; - int mode, addr; + int addr, mode, ret; priv = netdev_priv(ndev); mode = priv->plat->phy_interface; @@ -509,15 +508,9 @@ int stmmac_pcs_setup(struct net_device *ndev) ret = priv->plat->pcs_init(priv); } else if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { - /* Try to probe the XPCS by scanning all addresses */ - for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_mdiodev(priv->mii, addr, mode); - if (IS_ERR(xpcs)) - continue; - - ret = 0; - break; - } + addr = priv->plat->mdio_bus_data->xpcs_addr; + xpcs = xpcs_create_mdiodev(priv->mii, addr, mode); + ret = PTR_ERR_OR_ZERO(xpcs); } else { return 0; } diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index f337286623bb..a11b850d3672 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -83,6 +83,7 @@ struct stmmac_priv; struct stmmac_mdio_bus_data { unsigned int phy_mask; unsigned int has_xpcs; + unsigned int xpcs_addr; unsigned int default_an_inband; int *irqs; int probed_phy_irq;