Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1003611lqj; Mon, 3 Jun 2024 07:31:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWydh+AV06LwH3u9BLuGQE7F6x+rvX60gdAUWBiFp2jjLEkbOGhA7aLJZcje+1Tk9v0NT3GDsmql24j0M9qUKv9RROVazGzNWnRnHpBTw== X-Google-Smtp-Source: AGHT+IGetC8zDdhqwsEa4D2QsljINBmSsTxnWYQubqHTrsjP2LX26v8JLq1cv6/T7YXHxSNFxc+V X-Received: by 2002:a17:906:22d2:b0:a68:f83b:2545 with SMTP id a640c23a62f3a-a68f83b261dmr254856066b.45.1717425103315; Mon, 03 Jun 2024 07:31:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717425103; cv=pass; d=google.com; s=arc-20160816; b=AE57Nsmzx5lFzUdhN//IB/E/GExlRfj/klA+ZrpTfasJ7RcBg997ksKD05IXa9zf9x d0wazstFGNyL56wN4KGsbJXMGu3XZSuwqu0UY87Av8b8UOEKFjEm/d52gT7UBSYS/rXY gtnNt8hfbSb8dvjv83SS66nE9w681rO4wxWY578avbXWXeguuMj5gXTSylObbj/MKJQR HOIOC4+7zoTNQBsRkkhyk8dsV1LQDeIXGAZU4aj0VJD820Az5884QCso8P2Adj4TrPjF qncq4euOTjZ6REJAhw7lbPSLYX9rZkJM6aX4dyFLFT5fNt3w4bA1w147p+jZV/EcsZat D+4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=D1FOb8+LRm3aTJoqLkva7vJcqtsDNNOiof4KFRfCgww=; fh=hg15hbRSaiKSTsb3xpwEnUU8sCo2BBX3mV4xiSwTCqo=; b=i5dMIKxvWNrvLhyZfauJH450ALGZgQvsm+YC7eUG7SzKOh4V0isugXSXFP8OvhmCat d7lEGwWba00Mq0AQFUAQgPv3UmoGeMwwgq+1kt5/if3otwTrmbqKg/Q6yukX3hrg63Iu ++jMJPVDmG/sVZDMIQUgGfsK/x6P2UlLDTCAokhuirvayXD201UyseF+1xY1W+C8vSrb KIhZcJHlNkQl5ogDstjfYIQXZ/XnN7X5u1q4YasCfq3jtgOGvwSXB+lwt5hHfvGDIw/h +Bw0ejIE/h9ajsKQnz9H+SHUE+sCQLffcJHLjC4vXnzV4Ms0iepitOJfFzY8v6CQf4MS fX+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=U5JsTJpK; arc=pass (i=1 spf=pass spfdomain=denx.de dkim=pass dkdomain=denx.de dmarc=pass fromdomain=denx.de); spf=pass (google.com: domain of linux-kernel+bounces-199296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a67e6f036b7si420232066b.150.2024.06.03.07.31.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 07:31:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=U5JsTJpK; arc=pass (i=1 spf=pass spfdomain=denx.de dkim=pass dkdomain=denx.de dmarc=pass fromdomain=denx.de); spf=pass (google.com: domain of linux-kernel+bounces-199296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0195F1F21D2D for ; Mon, 3 Jun 2024 14:31:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 713FC13666D; Mon, 3 Jun 2024 14:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="U5JsTJpK" Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB9A9134406; Mon, 3 Jun 2024 14:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.214.62.61 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717425018; cv=none; b=IjQuYv9L9JPWHYQWATivkT6bDwE/s28rYiTOGUvLcx0thXLqmvt9Sc8p2keWCjEjhuilhrkAbarkb0HoVp0smMhDSokw+g+L9Jf/FE6/erqNdVrw4erWbjC0BUtTbymjjX3iv9Lqx8uu7hsE6kogw+DRgQlSMf0+C4TLHmLk5Dc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717425018; c=relaxed/simple; bh=ca3PFMqvf2PEgoAA0VG4VlDQamgfG44SJn7TGmIqUT8=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=Qg96lQVlrSesoc1C4NHmM2wjeSJTPJ6no4ynXaHygDMwJ9EPTtAW/j3X0bxxlgb6zYnO5ZzAKx6aWFI7k7i3EKYquF6EQVirgzK0QIz89nS/rvbop4KFelVR5vXMFaH4i1XXu6IJg6Mlv2ov9j/PjDKzYpXDFpSZqD+9ndogOEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de; spf=pass smtp.mailfrom=denx.de; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b=U5JsTJpK; arc=none smtp.client-ip=85.214.62.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=denx.de Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id E7E2D88308; Mon, 3 Jun 2024 16:30:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1717425015; bh=D1FOb8+LRm3aTJoqLkva7vJcqtsDNNOiof4KFRfCgww=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=U5JsTJpKB9XrS+tOJLOdQnsrjPnXzbEKxTliEtCsqgl9KiPEoZiH/ruyYK8A4xR6w 6BTejiu4wQw10P32WDrayv4apql6SINcNU1zBEL1UleFpWvNjsXYUWPagQhgFk1d7C AOnA5FvELgXNYWpNKVmVbPMvFUvBhKE3FNFkFO46G1s3+Keqj69pNyCis9vnebE+Po QgJ8ePGlpDpOea5a0C3f+LEQF70txG3PZy1lQ4PqAlIjg1X4ztyN/N1vGSXaUIVHNp o1J7lMtU3Se4D24YoY8YTLAaEg06HeQdXRgkQrCEMt6L1j1I9L/B6n/KE25YxFMyM0 t+0qPGhF12zDQ== Message-ID: Date: Mon, 3 Jun 2024 16:27:06 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Marek Vasut Subject: Re: [PATCH v3 02/11] net: stmmac: dwmac-stm32: Separate out external clock rate validation To: Christophe Roullier , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue , Richard Cochran , Jose Abreu , Liam Girdwood , Mark Brown , Sai Krishna Gajula Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240603092757.71902-1-christophe.roullier@foss.st.com> <20240603092757.71902-3-christophe.roullier@foss.st.com> Content-Language: en-US In-Reply-To: <20240603092757.71902-3-christophe.roullier@foss.st.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 6/3/24 11:27 AM, Christophe Roullier wrote: > From: Marek Vasut > > Pull the external clock frequency validation into a separate function, > to avoid conflating it with external clock DT property decoding and > clock mux register configuration. This should make the code easier to > read and understand. > > This does change the code behavior slightly. The clock mux PMCR register > setting now depends solely on the DT properties which configure the clock > mux between external clock and internal RCC generated clock. The mux PMCR > register settings no longer depend on the supplied clock frequency, that > supplied clock frequency is now only validated, and if the clock frequency > is invalid for a mode, it is rejected. > > Previously, the code would switch the PMCR register clock mux to internal > RCC generated clock if external clock couldn't provide suitable frequency, > without checking whether the RCC generated clock frequency is correct. Such > behavior is risky at best, user should have configured their clock correctly > in the first place, so this behavior is removed here. > > Signed-off-by: Marek Vasut > --- > .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 54 +++++++++++++++---- > 1 file changed, 44 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > index c92dfc4ecf570..43340a5573c64 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > @@ -157,25 +157,57 @@ static int stm32_dwmac_init(struct plat_stmmacenet_data *plat_dat, bool resume) > return stm32_dwmac_clk_enable(dwmac, resume); > } > > +static int stm32mp1_validate_ethck_rate(struct plat_stmmacenet_data *plat_dat) > +{ > + struct stm32_dwmac *dwmac = plat_dat->bsp_priv; > + const u32 clk_rate = clk_get_rate(dwmac->clk_eth_ck); From Sai in Re: [net-next,RFC,PATCH 1/5] net: stmmac: dwmac-stm32: Separate out external clock rate validation Please check reverse x-mass tree is followed for these variables, if possible. > + switch (plat_dat->mac_interface) { > + case PHY_INTERFACE_MODE_MII: > + if (clk_rate == ETH_CK_F_25M) > + return 0; > + break; > + case PHY_INTERFACE_MODE_GMII: > + if (clk_rate == ETH_CK_F_25M) > + return 0; > + break; From Sai in Re: [net-next,RFC,PATCH 1/5] net: stmmac: dwmac-stm32: Separate out external clock rate validation Please check, whether we can combine the two cases.. > + case PHY_INTERFACE_MODE_RMII: > + if (clk_rate == ETH_CK_F_25M || clk_rate == ETH_CK_F_50M) > + return 0; > + break; > + case PHY_INTERFACE_MODE_RGMII: > + case PHY_INTERFACE_MODE_RGMII_ID: > + case PHY_INTERFACE_MODE_RGMII_RXID: > + case PHY_INTERFACE_MODE_RGMII_TXID: > + if (clk_rate == ETH_CK_F_25M || clk_rate == ETH_CK_F_125M) > + return 0; > + break; > + default: > + break; > + } > + > + dev_err(dwmac->dev, "Mode %s does not match eth-ck frequency %d Hz", > + phy_modes(plat_dat->mac_interface), clk_rate); > + return -EINVAL; > +} [...]