[PATCH net-next 4/4] net: ethernet: mtk_eth_soc: optimize dma ring address/index calculation

Felix Fietkau nbd at nbd.name
Tue Oct 15 06:07:50 PDT 2024


On 15.10.24 14:54, Andrew Lunn wrote:
> On Tue, Oct 15, 2024 at 01:09:38PM +0200, Felix Fietkau wrote:
>> Since DMA descriptor sizes are all power of 2, we can avoid costly integer
>> division in favor or simple shifts.
> 
> Could a BUILD_BUG_ON() be added to validate this?

Not sure if that would be useful. I can't put the BUILD_BUG_ON in the 
initializer macro, so I could only add it for the individual dma 
descriptor structs.
Since the size of those structs will not be changed (otherwise it would 
immediately visibly break with existing hw), the remaining possibility 
would be adding new structs that violate this expectation. However, 
those would then not be covered by the BUILD_BUG_ON.

> Do you have some benchmark data for this series? It would be good to
> add to a patch 0/4.

No, I just ran basic tests that everything still works well and looked 
at the assembly diff to ensure that the generated code seems sane.

- Felix



More information about the linux-arm-kernel mailing list