Re: [PATCH net v4 3/3] net: stmmac: Specify hardware capability value when FIFO size isn't specified

From: Steven Price
Date: Fri Jan 31 2025 - 10:54:35 EST


On 31/01/2025 15:29, Andrew Lunn wrote:
> On Fri, Jan 31, 2025 at 03:03:11PM +0000, Steven Price wrote:
>> On 31/01/2025 14:47, Andrew Lunn wrote:
>>>>> I'm guessing, but in your setup, i assume the value is never written
>>>>> to a register, hence 0 is O.K. e.g. dwmac1000_dma_operation_mode_rx(),
>>>>> the fifosz value is used to determine if flow control can be used, but
>>>>> is otherwise ignored.
>>>>
>>>> I haven't traced the code, but that fits my assumptions too.
>>>
>>> I could probably figure it out using code review, but do you know
>>> which set of DMA operations your hardware uses? A quick look at
>>> dwmac-rk.c i see:
>>>
>>> /* If the stmmac is not already selected as gmac4,
>>> * then make sure we fallback to gmac.
>>> */
>>> if (!plat_dat->has_gmac4)
>>> plat_dat->has_gmac = true;
>>
>> has_gmac4 is false on this board, so has_gmac will be set to true here.
>
> Thanks. Looking in hwif.c, that means dwmac1000_dma_ops are used.
>
> dwmac1000_dma_operation_mode_rx() just does a check:
>
> if (rxfifosz < 4096) {
> csr6 &= ~DMA_CONTROL_EFC;
>
> but otherwise does not use the value.
>
> dwmac1000_dma_operation_mode_tx() appears to completely ignore fifosz.
>
> So i would say all zero is valid for has_gmac == true, but you might
> gain flow control if a value was passed.
>
> A quick look at dwmac100_dma_operation_mode_tx() suggests fifosz is
> also ignored, and dwmac100_dma_operation_mode_rx() does not exist. So
> all 0 is also valid for gmac == false, gmac4 == false, and xgmac ==
> false.
>
> dwmac4_dma_rx_chan_op_mode() does use the value to determine mtl_rx_op
> which gets written to a register. So gmac4 == true looks to need
> values. dwxgmac2_dma_rx_mode() is the same, so xgmac = true also need
> valid values.
>
> Could you cook up a fix based on this?

The below works for me, I haven't got the hardware to actually test the
gmac4/xgmac paths:

----8<----