Re: [PATCH net-next 10/14] mlxsw: pci: Remove obsolete 32-bit DMA mask fallback

From: Petr Machata

Date: Fri Sep 04 2026 - 13:24:12 EST


Ruizhe Zhou <zhouruizhe@xxxxxxxxxxx> writes:

> The DMA API guarantees support for masks of 32 bits or wider and
> explicitly identifies retrying a 32-bit mask after a 64-bit request as
> incorrect:
> https://docs.kernel.org/core-api/dma-api-howto.html#dma-addressing-capabilities
>
> Remove the obsolete fallback while retaining the error check so that a
> genuine DMA setup failure is still reported and aborts initialization.
> Update the error message to identify the combined streaming and coherent
> DMA mask operation.
>
> Signed-off-by: Ruizhe Zhou <zhouruizhe@xxxxxxxxxxx>

Doco: "dma_set_mask_and_coherent() never return fail when DMA_BIT_MASK(64)."

Checking code, the only way that I see that dma_set_mask_and_coherent()
returns error is if dma_supported() returns 0. This could happen if:

- use_dma_iommu() fails, but that doesn't consider mask, so retrying
with 32 doesn't help.

- if ops->dma_supported fails. But I checked several architectures where
mlxsw could even theoretically be relevant, and it's basically always
some mask > X type of expression, so retrying with a smaller mask does
not help.

- The fallback of dma_direct_supported() is like that as well.

So yeah. I think this is correct.

Reviewed-by: Petr Machata <petrm@xxxxxxxxxx>

> ---
> drivers/net/ethernet/mellanox/mlxsw/pci.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
> index bfe3268dfdc1..dceb69945d26 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
> @@ -2429,11 +2429,8 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>
> err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> if (err) {
> - err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
> - if (err) {
> - dev_err(&pdev->dev, "dma_set_mask failed\n");
> - goto err_pci_set_dma_mask;
> - }
> + dev_err(&pdev->dev, "dma_set_mask_and_coherent failed\n");
> + goto err_pci_set_dma_mask;
> }
>
> if (pci_resource_len(pdev, 0) < MLXSW_PCI_BAR0_SIZE) {