Netdev List
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Ruizhe Zhou <zhouruizhe@resnics.com>
Cc: Ido Schimmel <idosch@nvidia.com>, Petr Machata <petrm@nvidia.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next 10/14] mlxsw: pci: Remove obsolete 32-bit DMA mask fallback
Date: Fri, 4 Sep 2026 18:00:24 +0200	[thread overview]
Message-ID: <8733vpypk7.fsf@pmachata.org> (raw)
In-Reply-To: <20260903084339.870562-11-zhouruizhe@resnics.com> (Ruizhe Zhou's message of "Thu, 3 Sep 2026 16:43:35 +0800")

Ruizhe Zhou <zhouruizhe@resnics.com> 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@resnics.com>

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@nvidia.com>

> ---
>  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) {

  reply	other threads:[~2026-09-04 16:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  8:43 [PATCH net-next 00/14] net: Remove obsolete 32-bit DMA mask fallbacks Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 01/14] net: atlantic: Remove obsolete 32-bit DMA mask fallback Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 02/14] net: alx: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 03/14] net: systemport: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 04/14] bnxt_en: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 05/14] enic: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 06/14] net: hns3: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 07/14] fm10k: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 08/14] net/mlx4: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 09/14] net/mlx5: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 10/14] mlxsw: pci: " Ruizhe Zhou
2026-09-04 16:00   ` Petr Machata [this message]
2026-09-03  8:43 ` [PATCH net-next 11/14] eth: fbnic: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 12/14] net: pch_gbe: " Ruizhe Zhou
2026-09-03  8:43 ` [PATCH net-next 13/14] net: renesas: rswitch: " Ruizhe Zhou
2026-09-03  9:43   ` Geert Uytterhoeven
2026-09-03  8:43 ` [PATCH net-next 14/14] net: niu: " Ruizhe Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8733vpypk7.fsf@pmachata.org \
    --to=petrm@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=zhouruizhe@resnics.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox