Article View: linux.kernel.netdev
Article #19652Re: [PATCH net-next v5 10/24] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation
From: Clement Leger
Date: Fri, 20 Nov 2026 06:51
Date: Fri, 20 Nov 2026 06:51
52 lines
10331 bytes
10331 bytes
On 11/20/26 01:25, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> The MDC frequency is hclk / (2 * CLKDIV + 1) on RZ/N1 as well as
> RZ/T2H and RZ/N2H. The existing calculation uses the wrong divisor
> formula and can set MDC above the requested clock-frequency.
>
> Calculate the smallest CLKDIV that keeps MDC at or below the requested
> frequency.
>
> Fixes: 888cdb892b61 ("net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> v4->v5:
> - New patch
> ---
> drivers/net/dsa/rzn1_a5psw.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
> index 7fd2652813ac..df3b3f75b489 100644
> --- a/drivers/net/dsa/rzn1_a5psw.c
> +++ b/drivers/net/dsa/rzn1_a5psw.c
> @@ -11,6 +11,7 @@
> #include <linux/if_bridge.h>
> #include <linux/if_ether.h>
> #include <linux/kernel.h>
> +#include <linux/math.h>
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_mdio.h>
> @@ -1104,7 +1105,7 @@ static int a5psw_mdio_config(struct a5psw *a5psw, u32 mdio_freq)
> u32 cfgstatus;
>
> rate = clk_get_rate(a5psw->hclk);
> - div = ((rate / mdio_freq) / 2);
> + div = DIV_ROUND_UP(DIV_ROUND_UP(rate, mdio_freq) - 1, 2);
> if (div > FIELD_MAX(A5PSW_MDIO_CFG_STATUS_CLKDIV) ||
> div < A5PSW_MDIO_CLK_DIV_MIN) {
> dev_err(a5psw->dev, "MDIO clock div %ld out of range\n", div);
LGTM,
Reviewed-by: Clément Léger <clement.leger@linux.dev>
Thanks,
Clément
Technical Details
Message-ID:
<18426bef-b231-4685-bda7-665becfc6528@linux.dev>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367718-linux-kernel-netdev=dewy.ruReferences:
<20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20261120002549.1908299-11-prabhakar.mahadev-lad.rj@bp.renesas.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367718-linux-kernel-netdev=dewy.ru From: clement.leger@linux.dev (Clement Leger) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v5 10/24] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation Date: Fri, 20 Nov 2026 07:51:58 +0100 Organization: Usenet Network Message-ID: <18426bef-b231-4685-bda7-665becfc6528@linux.dev> References: <20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20261120002549.1908299-11-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3086543"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Rpxx9cx7ffLt6DYqYzzk9lWSkPA= sha256:eIeN4tXiFCtK/sivcqxmCiVWm77+7wCliuhhzqltlAw= sha1:ClrcDdh/FTCroHnZ33QufN7ROH4= sha256:y+/DdbOQzvOImstTz/iiM+C1isPRGXaQ5LGE5tCF/Kg= Content-Language: en-US List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 89AB61158D5; Fri, 20 Nov 2026 09:52:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.15 X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WRLhAPlPyZZK; Fri, 20 Nov 2026 09:52:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-367718-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 43F4E11548D; Fri, 20 Nov 2026 09:52:06 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 6C20A6260B9; Fri, 20 Nov 2026 06:52:06 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795157525; b=fq/H5Ih5ZWVtQznCBDEjpizn9mNTB37eW6U4HHPou7/cJvJSnCGXX8y+JWigTkIjm4Qw AEsY8iu2rcaPdfgBqwgZUMKl/u7wJlGPDlWI5TMctxH4kPlVcebPYzxTignZlYgEGKXU/ gsPK/ZU9mNiPCMZGFkWo5gV1eZCnMWmuALMBPMCIXwNKnMsS/9UM28PjLOIGETsp9w3eR ZJamPASvH79whnOr6e7e7R+hJnFFNLViQIWibBo1l2PbfKY/NJsqWCU707vcJ2P7/TB/f d7WrEXPtYudR+sw9YNhOJDH7gsmwvQ/QBeDF0k4sL5c/VmY2isDoCD7pRJFAYl75RvQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795157525; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=0z0AzJNanfrVB85wgMFdgJJ5GkqCfeRb/cYUccsjyJg=; b=iRd4wjxoRUqEUa7Dmp3/4RjQmD21mXCdBMX8/PjiRZ8ex5Y1XBMQ0PA8UZDmc17/B97i bdl8l4ibhn9XFTsnRsJgsjRn749sv9X9rFwCD/NcXAOU3/w0OgcA7k7+7uXWhSxKpSoS/ NQGdxZGZW0lPSH1tS/+G2qdSUuBSclVlCbIBUDnGOkoqqzFTGjQR9OldTw5bD3WpkU2wI ZsT1sAsB3Aaw3a8MK+9b0P1fs4OE6F13knVhjRme/m5q534js4ZbbXu47MiD0EeymhWZT ER6Z4LN2oyyWN8Wi0M9Gq/ZnII4wZF4lr1hieNbiV0xV+B0XBxtf6yDrqf3oGM+Re5Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=jcMVexTx; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 246F6606A320; Fri, 20 Nov 2026 06:52:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=jcMVexTx X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.189 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795157524; b=FtgYfPh2UR3PUJ9c5zySEG7NShqJ/+NymdTXOB23SPSuuaBcKyKvis6JmCbyFtyelag+ 07VtqBh5Kq36R/HI5RiP3OcWI1Gbygp9X3hcNmp682LAsBJrB6UmYdIHtusMZYgtPMtAD 0a+wN06KEkmk/pSe3B6uv/WKEf3HezoiAKdtvzy32P3Igf+RrpPpmgLQRhXeaVtHLRKat sggS7LMm7Kf1fRbQunnzPvlZnWV9Amu8vpZTvOgIEIWhxmnNMqZ0/raJc8YPW0NBCaj0j /U6FSQr69q9tpxaxRsGviQpBo3F/jnWSjmmoCCAPjJ2Jr2vWDcmMUQyRl8i7tad575A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795157524; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=0z0AzJNanfrVB85wgMFdgJJ5GkqCfeRb/cYUccsjyJg=; b=syVHb9SzaiepQfp8s3gHQBrxuv16Cj7gB7UvUnb9kpDCuGXBXng0wvbn6QYyNzR45HHR z3eKrfior1tvav2B4r+psbMj5bxpZjXd0pM8r8orYGj9xkRkB+PkiHvxWzO2FP/4BbawF 8O9ia4srkwqcTkHXMO4rMtLHovg81qYxpF41YV3xwPm9a+5MRelawjZA/cZbE7NEu3OWH X5oJvV5rWYlYfH/AfOfDHmdoHF4alrUk1MMU6SpthvPJX11g1gT3352jIfDolfuUo1eI2 7ADocQUOdcs2gs4Ww0GBWn0Bl8IXBblR3xYAzylwg4WbA8yMVteBsgw3aYx6NKEgZOg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=jcMVexTx; arc=none smtp.remote-ip=95.215.58.189 X-Received: from mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09535606A326 for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 06:52:02 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 09535606A326 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=Ro9VE7XGMtGJmsM9mnH8HIatHqmwaoWhZDuLhhpiHfI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795157521; v=1; x=1795762321; b=jcMVexTxKDTegToAManw+obcFWicIYkyNWBbQ8bHPCWoQIHS8oeNmQEtnoc/bqLFcE+AsWYk E5gvqiIkV2ACvfJguuJ26FIkKntFy9f//Qh74GihVulthqtUrTbP1pAWX2XuMuoeTRR35PbGo5H /3N2qFbMT7WVqAGzErsSYReM= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id ef437e63efd8efa5; Fri, 20 Nov 2026 06:52:00 +0000 X-Mizu-Trace-ID: ef437e63efd8efa5 X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: Florian Fainelli <f.fainelli@gmail.com>, Ralph Siemsen <ralph.siemsen@linaro.org>, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, Prabhakar <prabhakar.csengg+renesas@gmail.com>, Biju Das <biju.das.jz@bp.renesas.com>, Fabrizio Castro <fabrizio.castro.jz@renesas.com>, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>, stable@vger.kernel.org X-In-Reply-To: <20261120002549.1908299-11-prabhakar.mahadev-lad.rj@bp.renesas.com>