Re:Re: [PATCH net-next 13/14] net: renesas: rswitch: Remove obsolete 32-bit DMA mask fallback

From: 周睿哲

Date: Thu Sep 03 2026 - 09:38:35 EST




Hi Geert,
Thanks for the fast feedback!
My last reply got glitched up by the mail client so I resend this instead. 
Hope this won't cause too much trouble. If you did receive my last reply
and everything looks fine please igore this.

From: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Date: 2026-09-03 17:43:03
To: Ruizhe Zhou <zhouruizhe@xxxxxxxxxxx>
Cc: Andrew Lunn <andrew+netdev@xxxxxxx>,"David S. Miller" <davem@xxxxxxxxxxxxx>,Eric Dumazet <edumazet@xxxxxxxxxx>,Jakub Kicinski <kuba@xxxxxxxxxx>,Paolo Abeni <pabeni@xxxxxxxxxx>,netdev@xxxxxxxxxxxxxxx,linux-kernel@xxxxxxxxxxxxxxx,Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>,linux-renesas-soc@xxxxxxxxxxxxxxx
Subject: Re: [PATCH net-next 13/14] net: renesas: rswitch: Remove obsolete 32-bit DMA mask fallback>Hi Ruizhe,
>
>Thanks for your patch!
>
>On Thu, 3 Sept 2026 at 11:27, Ruizhe Zhou <zhouruizhe@xxxxxxxxxxx> wrote:
>> The DMA API guarantees support for masks of 32 bits or wider and
>
>Really?
>
>> explicitly identifies retrying a 32-bit mask after a wider request as
>> incorrect:
>> https://docs.kernel.org/core-api/dma-api-howto.html#dma-addressing-capabilities
>

>AFAIUI, that is only true iff the wider request is DMA_BIT_MASK(64).

At that specific link I will quote this: " dma_set_mask_and_coherent() will never return failure when bigger than 32."
So yes, I believe this applies for all masks > 32.

>>> Remove the obsolete fallback while retaining the error check so that a
>> genuine DMA setup failure still aborts initialization.
>

>Have you tested this on actual hardware, with/without IOMMU support?


No I haven't as I stated in the cover letter. But I also believe what is important
here is this change is trying to point out that a failed >32bit
mask dma call is fundamentally not correctable by trying a smaller mask.
The mask passed to the DMA API describes the highest address a device can
reach. It asks the DMA layer to keep mappings within that limit; it is not
a probe asking the platform which addressing mode the device should use.
A wider mask includes every address permitted by a 32-bit mask, including
addresses from a platform that only produces 32-bit DMA addresses. The links
I provided in the cover letter explain that.

>
>> Signed-off-by: Ruizhe Zhou <zhouruizhe@xxxxxxxxxxx>
>> ---
>> drivers/net/ethernet/renesas/rswitch_main.c | 7 ++-----
>> 1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethernet/renesas/rswitch_main.c
>> index 755232994fcc..64b821ca02f8 100644
>> --- a/drivers/net/ethernet/renesas/rswitch_main.c
>> +++ b/drivers/net/ethernet/renesas/rswitch_main.c
>> @@ -2162,11 +2162,8 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
>> return -ENOMEM;
>>
>> ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40));
>> - if (ret < 0) {
>> - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>> - if (ret < 0)
>> - return ret;
>> - }
>> + if (ret)
>> + return ret;
>>
>> priv->gwca.index = AGENT_INDEX_GWCA;
>> priv->gwca.num_queues = min(RSWITCH_NUM_PORTS * NUM_QUEUES_PER_NDEV,
>
>Gr{oetje,eeting}s,
>
> Geert
>
>--
>Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
>
>In personal conversations with technical people, I call myself a hacker. But
>when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>