Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp971079lqd; Thu, 25 Apr 2024 02:07:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUIUliT8db6ClAzIdk4EGxfSws7RNyWKv2v4iLufmwOQghL4Nil/HExlSbPEHNcpsGG55Ilr17k9q4RXJvUST0spLAYQ/4LSb11575tiA== X-Google-Smtp-Source: AGHT+IGsO+Mb+MbldPnvfljPSo2B3fLvJL+kzZPn16hVGW+w92pFYop/QJIq6Keo0m/LpRfddpfb X-Received: by 2002:a05:6a21:2787:b0:1a9:d6e2:66e9 with SMTP id rn7-20020a056a21278700b001a9d6e266e9mr4518857pzb.28.1714036073615; Thu, 25 Apr 2024 02:07:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714036073; cv=pass; d=google.com; s=arc-20160816; b=fd3gooJMXApSHeFKIVoPKaKtszgoAAuXFgFhGzP9sN0QmC4TU5hPXZxq7DRFAxguOy WHwOmxCoN33EyXOJ0i9+RVqh1bo7T418ZjZy7qfLamufVUkQPo7Azv22OjWoNhEMz6FD 8r/hg6Rl1chWXSuXDLhcSR0taVqZGgLqiq0nv3a3anmezEaa4cLzAxcRL/ayTYn4Mino 1YCZG1bs4M+bdVKPTMtGHBL9RreaSzNztfbzih+ZwrIziHLrhJjxw0QH2MGEdvbCKGf1 ckoTkiOtiiJskq1an8PwuMYrwin2Dr9dOYyi2gZXCLuJsmaBU1tMwREGc3WVbR249cqn 7LhQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=tvACK5git9WpWSrstT0kGFb7bKtSP7Oj9178I7kw6ME=; fh=xZWgcigVLRj7l9WT5wQbagScbcgrVpl4CAe9fw6OkI4=; b=PRU4cRRAnnJUY+m6/aKFzSrDVWLHoZeF6NnqdVKKnW+u6ZqmZFtHjG1l/QyJqgS1+J wCP+8dvMLXfF7lkUIkF2wC9m39vX1uqY+eXu5R1IsgHdSh3npV1NAzMVeHdsYOVtGwiV cTaZ2hCPIN3ILWwluniwcCPIRoDVUnflwQhmG/rBcGEf0dC3QBBdxxVyfwJu7IxRuzvv XJs93noWFkOoYPcDCIrlthQorDD2bDpNtwddsKXNyQvXy1fOTdhzCLqTgni7qdpyxel0 PD0pKJnNvmlLYdMYprArrRJbO5uACzCCRrz6yvYBeOyIa/KRsZuE+2c/O8/aavswUV3+ XALA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=BgY5Mwnj; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-158232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158232-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id it2-20020a056a00458200b006eac4da49b3si12837538pfb.308.2024.04.25.02.07.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 02:07:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=BgY5Mwnj; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-158232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158232-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8E15FB2521B for ; Thu, 25 Apr 2024 09:03:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A146884E10; Thu, 25 Apr 2024 09:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="BgY5Mwnj" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B56A183CCD; Thu, 25 Apr 2024 09:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714035757; cv=none; b=je3X372SLTRmRNWYFdupzxPMYqrjdVp5f0e+vMTjrHQWAgB4+TQRSdFN1OtwqxjYvH7e2dN7ble+HgyF8uHsDVh0zbWuA9vSjebL3TJU/etzbOI6y7hNZNa3tcS/4HvZHN+0/NmACc0JZMOS+91CHMfJPfsAT99VOZEh8sz84zg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714035757; c=relaxed/simple; bh=c3h0CFxr96J3TcWHTpu0zjTw6cRVNTcbISj/ySXaJRQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TQseNIrKyShS2FDaCwelmCWv5qv4nT7TgU2V0rUwDpT5WcwIvOSc/yKsBoARMN2MCD9DjxblN3ZkutSRkv8y1u88FlFBeVI4keg/JyBQRjfIju+ScfMl/fkXJwEwEVh4RqirZRa/J9C2PyZ4JAsllpDVYcxuXf5WLMPMSjSDgAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=BgY5Mwnj; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tvACK5git9WpWSrstT0kGFb7bKtSP7Oj9178I7kw6ME=; b=BgY5Mwnj2I06U3tZLcTSnD0qEp HSfXf05N1JTTR7Mkd/4ep9P+YimNnkYcd2TQ2IcjY02wxn056O+0FN2JdtBR6EAfTwSQs4bWXWODB fxmXsbYkxGt9qQlH/fdrWaIdvz1KrIMmxcjWTV5xQ85D+RT1d4RAOK14rMUEejSGX7IuNcSNnckaH KKDL3KobcVNDFZChxcq8sCZ03wyYKROEG9LgXx83Mkt/xz11jVsDpnn8JOh2GK+7K6Ubatrd9+ThQ D1FarkpP2G0qZVdRGAKLn6Oxe62dZE1AeVQOSxDrD5+rTzDycy5qo0IAtbbejq3u559KNqx6D1U/g wy/F+Fuw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:58892) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rzuzU-00077v-2p; Thu, 25 Apr 2024 10:02:05 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rzuzO-0005Td-Gu; Thu, 25 Apr 2024 10:01:58 +0100 Date: Thu, 25 Apr 2024 10:01:58 +0100 From: "Russell King (Oracle)" To: Sky Huang Cc: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Daniel Golle , Qingfang Deng , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Steven Liu Subject: Re: [PATCH 3/3] net: phy: mediatek: add support for built-in 2.5G ethernet PHY on MT7988 Message-ID: References: <20240425023325.15586-1-SkyLake.Huang@mediatek.com> <20240425023325.15586-4-SkyLake.Huang@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240425023325.15586-4-SkyLake.Huang@mediatek.com> Sender: Russell King (Oracle) On Thu, Apr 25, 2024 at 10:33:25AM +0800, Sky Huang wrote: > +static int mt7988_2p5ge_phy_config_init(struct phy_device *phydev) > +{ > + int ret, i; > + const struct firmware *fw; > + struct device *dev = &phydev->mdio.dev; > + struct device_node *np; > + void __iomem *pmb_addr; > + void __iomem *md32_en_cfg_base; > + struct mtk_i2p5ge_phy_priv *priv = phydev->priv; > + u16 reg; > + struct pinctrl *pinctrl; > + > + if (!priv->fw_loaded) { > + np = of_find_compatible_node(NULL, NULL, "mediatek,2p5gphy-fw"); > + if (!np) > + return -ENOENT; > + pmb_addr = of_iomap(np, 0); > + if (!pmb_addr) > + return -ENOMEM; > + md32_en_cfg_base = of_iomap(np, 1); > + if (!md32_en_cfg_base) > + return -ENOMEM; Wouldn't it be better to do this in the probe function rather than here? > + > + ret = request_firmware(&fw, MT7988_2P5GE_PMB, dev); > + if (ret) { > + dev_err(dev, "failed to load firmware: %s, ret: %d\n", > + MT7988_2P5GE_PMB, ret); > + return ret; > + } This will block for userspace while holding phydev->lock and the RTNL. That blocks much of the networking APIs, which is not a good idea. If you have a number of these PHYs, then the RTNL will serialise the loading of firmware. > + > + reg = readw(md32_en_cfg_base); > + if (reg & MD32_EN) { > + phy_set_bits(phydev, 0, BIT(15)); This is probably the BMCR, so if it is, please use the established definitions. > + usleep_range(10000, 11000); > + } > + phy_set_bits(phydev, 0, BIT(11)); This also looks like it's probably the BMCR. > + > + /* Write magic number to safely stall MCU */ > + phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x800e, 0x1100); > + phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x800f, 0x00df); > + > + for (i = 0; i < fw->size - 1; i += 4) > + writel(*((uint32_t *)(fw->data + i)), pmb_addr + i); > + release_firmware(fw); > + > + writew(reg & ~MD32_EN, md32_en_cfg_base); > + writew(reg | MD32_EN, md32_en_cfg_base); > + phy_set_bits(phydev, 0, BIT(15)); And also probably the BMCR. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!