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: <15a39258ece1eee5f42ef6d244befd88f9671a08@linux.dev>
Date: Sun, 29 Jun 2025 14:54:19 +0000
From: "Frank Wunderlich" <frank.wunderlich@...ux.dev>
To: "Andrew Lunn" <andrew@...n.ch>, "Daniel Golle" <daniel@...rotopia.org>
Cc: "Sky Huang" <skylake.huang@...iatek.com>, netdev@...r.kernel.org, "Sean
 Wang" <sean.wang@...iatek.com>, linux-mediatek@...ts.infradead.org,
 linux-kernel@...r.kernel.org, "Andrew Lunn" <andrew+netdev@...n.ch>,
 "Eric Dumazet" <edumazet@...gle.com>, "Matthias Brugger"
 <matthias.bgg@...il.com>, linux-arm-kernel@...ts.infradead.org, "Bo-Cun
 Chen" <bc-bocun.chen@...iatek.com>, "Eric Woudstra"
 <ericwouds@...il.com>, "Elad Yifee" <eladwf@...il.com>, "Jakub Kicinski"
 <kuba@...nel.org>, "Paolo Abeni" <pabeni@...hat.com>, "Lorenzo Bianconi"
 <lorenzo@...nel.org>, "David S. Miller" <davem@...emloft.net>,
 "AngeloGioacchino Del Regno" <angelogioacchino.delregno@...labora.com>,
 "Felix Fietkau" <nbd@....name>
Subject: Re: [PATCH net/next 3/3] net: ethernet: mtk_eth_soc: use genpool
 allocator for SRAM

Hi Andrew,

> Gesendet: Samstag, 28. Juni 2025 um 10:13
> Von: "Andrew Lunn" <andrew@...n.ch>
> Betreff: Re: [PATCH net/next 3/3] net: ethernet: mtk_eth_soc: use genpool allocator for SRAM
>
> > +static void *mtk_dma_ring_alloc(struct mtk_eth *eth, size_t size,
> > +				dma_addr_t *dma_handle)
> > +{
> > +	void *dma_ring;
> > +
> > +	if (WARN_ON(mtk_use_legacy_sram(eth)))
> > +		return -ENOMEM;
> > +
> > +	if (eth->sram_pool) {
> > +		dma_ring = (void *)gen_pool_alloc(eth->sram_pool, size);
> > +		if (!dma_ring)
> > +			return dma_ring;
> > +		*dma_handle = gen_pool_virt_to_phys(eth->sram_pool, (unsigned long)dma_ring);
> 
> I don't particularly like all the casting backwards and forwards
> between unsigned long and void *. These two APIs are not really
> compatible with each other. So any sort of wrapping is going to be
> messy.
> 
> Maybe define a cookie union:
> 
> struct mtk_dma_cookie {
> 	union {
> 		unsigned long gen_pool;
> 		void *coherent;
> 	}
> }
> 
> Only dma_handle appears to be used by the rest of the code, so only
> the _alloc and _free need to know about the union.

do you mean use the union only for the casts or using it globally for all the access
to the dma struct (and so changing the return type of the alloc function)?

first i made here [1]

second was tried by daniel and is much more change.

OT: btw. have you took a look in the PCS decision case [1]?

regards Frank

[1] https://github.com/frank-w/BPI-Router-Linux/commit/ea963012375e4ac98947a703b5eaf21fdf221ee1
[2] https://lore.kernel.org/netdev/24c4dfe9-ae3a-4126-b4ec-baac7754a669@linux.dev/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ