lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7f81c9f1-a061-4269-96cd-ecdaa6137c72@bootlin.com>
Date: Tue, 18 Nov 2025 14:48:46 +0100
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
 Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>
Cc: Alexandre Torgue <alexandre.torgue@...s.st.com>,
 Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
 <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, linux-arm-kernel@...ts.infradead.org,
 linux-stm32@...md-mailman.stormreply.com,
 Maxime Coquelin <mcoquelin.stm32@...il.com>, netdev@...r.kernel.org,
 Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net-next] net: stmmac: dwc-qos-eth: simplify switch() in
 dwc_eth_dwmac_config_dt()



On 18/11/2025 12:18, Russell King (Oracle) wrote:
> Simplify the the switch() statement in dwc_eth_dwmac_config_dt().
> Although this is not speed-critical, simplifying it can make it more
> readable. This also drastically improves the code emitted by the
> compiler.
> 
> On aarch64, with the original code, the compiler loads registers with
> every possible value, and then has a tree of test-and-branch statements
> to work out which register to store. With the simplified code, the
> compiler can load a register with '4' and shift it appropriately.
> 
> This shrinks the text size on aarch64 from 4289 bytes to 4153 bytes,
> a reduction of 3%.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>

Reviewed-by: Maxime Chevallier <maxime.chevallier@...tlin.com>

Maxime

> ---
>  .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 26 +++----------------
>  1 file changed, 3 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> index c7cd6497d42d..e6d5893c5905 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> @@ -84,29 +84,9 @@ static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
>  	device_property_read_u32(dev, "snps,burst-map", &burst_map);
>  
>  	/* converts burst-map bitmask to burst array */
> -	for (bit_index = 0; bit_index < 7; bit_index++) {
> -		if (burst_map & (1 << bit_index)) {
> -			switch (bit_index) {
> -			case 0:
> -			plat_dat->axi->axi_blen[a_index] = 4; break;
> -			case 1:
> -			plat_dat->axi->axi_blen[a_index] = 8; break;
> -			case 2:
> -			plat_dat->axi->axi_blen[a_index] = 16; break;
> -			case 3:
> -			plat_dat->axi->axi_blen[a_index] = 32; break;
> -			case 4:
> -			plat_dat->axi->axi_blen[a_index] = 64; break;
> -			case 5:
> -			plat_dat->axi->axi_blen[a_index] = 128; break;
> -			case 6:
> -			plat_dat->axi->axi_blen[a_index] = 256; break;
> -			default:
> -			break;
> -			}
> -			a_index++;
> -		}
> -	}
> +	for (bit_index = 0; bit_index < 7; bit_index++)
> +		if (burst_map & (1 << bit_index))
> +			plat_dat->axi->axi_blen[a_index++] = 4 << bit_index;
>  
>  	/* dwc-qos needs GMAC4, AAL, TSO and PMT */
>  	plat_dat->core_type = DWMAC_CORE_GMAC4;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ