mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: zhouruizhe@resnics.com
Cc: michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 12/14] net: pch_gbe: Remove obsolete 32-bit DMA mask fallback
Date: Tue, 08 Sep 2026 11:46:30 +0000	[thread overview]
Message-ID: <178886799012.219967.9931005997243012418@kernel.org> (raw)
In-Reply-To: <20260903084339.870562-13-zhouruizhe@resnics.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:

Critical: 0 · High: 1 · Medium: 0 · Low: 0

- [High] pch_gbe (Intel EG20T / OKI ML7223/ML7831 GbE) is a 32-bit-DMA-
  only controller, but after this patch `pch_gbe_probe()` requests…

--

net: pch_gbe: Remove obsolete 32-bit DMA mask fallback

This removes the DMA_BIT_MASK(32) retry in pch_gbe_probe() and keeps only
the DMA_BIT_MASK(64) request, on the grounds that the DMA API guarantees
masks of 32 bits or wider and that retrying a narrower mask is incorrect.
The error check and dev_err() are retained.

> diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> index 88c5c52e0e38..ba3d10f9aec6 100644
> --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> @@ -2504,12 +2504,10 @@ static int pch_gbe_probe(struct pci_dev *pdev,
>  	if (ret)
>  		return ret;
>  
> -	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {
> -		ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> -		if (ret) {
> -			dev_err(&pdev->dev, "ERR: No usable DMA configuration, aborting\n");
> -			return ret;
> -		}
> +	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> +	if (ret) {
> +		dev_err(&pdev->dev, "ERR: No usable DMA configuration, aborting\n");
> +		return ret;
>  	}

[Severity: High]
Can this device actually address 64 bits?  After this change the 64-bit
request is the only mask pch_gbe_probe() ever installs, and the fallback
that used to leave the device with a 32-bit mask is gone.

The descriptors in pch_gbe.h only carry a 32-bit address:

	struct pch_gbe_rx_desc {
		u32 buffer_addr;
		...
	};

	struct pch_gbe_tx_desc {
		u32 buffer_addr;
		...
	};

and the ring registers in struct pch_gbe_regs are 32-bit with no
companion high-address register:

	u32 RX_DSC_BASE;
	u32 RX_DSC_SIZE;
	...
	u32 TX_DSC_BASE;

pch_gbe_configure_tx() narrows the coherent ring address into a u32 local
and programs it with one iowrite32():

	u32 tdba, tdlen, dctrl;
	...
	tdba = adapter->tx_ring->dma;
	tdlen = adapter->tx_ring->size - 0x10;
	iowrite32(tdba, &hw->reg->TX_DSC_BASE);
	iowrite32(tdlen, &hw->reg->TX_DSC_SIZE);
	iowrite32(tdba, &hw->reg->TX_DSC_SW_P);

pch_gbe_configure_rx() does the same with rdba, and the per-packet paths
store dma_addr_t straight into the u32 descriptor fields:

	pch_gbe_tx_queue():
		tx_desc->buffer_addr = (buffer_info->dma);

	pch_gbe_alloc_rx_buffers():
		rx_desc->buffer_addr = (buffer_info->dma);

There is no lower_32_bits()/upper_32_bits() handling anywhere in the
driver.  With a 64-bit mask declared, dma_alloc_coherent() and
dma_map_single() may return addresses above 4 GB, which are then silently
truncated into these u32 fields and registers.  Does that leave the MAC
bus-mastering to the truncated address, writing received frames into
unrelated memory, transmitting unrelated memory, or walking a bogus
descriptor ring, with nothing reported?

Since dma_direct_supported() accepts any mask of 32 bits or wider, the
64-bit request always succeeds under direct mapping, so this looks like
the live path rather than a theoretical one.  The driver is buildable for
MIPS_GENERIC and X86_32 (dma_addr_t is 64-bit with PAE) as well as
COMPILE_TEST:

	depends on PCI && (MIPS_GENERIC || X86_32 || COMPILE_TEST)

Would requesting DMA_BIT_MASK(32) here, i.e. the width the hardware
actually implements, be the right way to apply the cited
dma-api-howto guidance instead of keeping the 64-bit request?

One smaller point on the changelog.  It says the error check is retained
"so that a genuine DMA setup failure is still reported and aborts
initialization", but by the same premise quoted just above it ("The DMA
API guarantees support for masks of 32 bits or wider"), can that
dev_err()/return ret branch ever be taken for a mask of 32 bits or wider?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903084339.870562-1-zhouruizhe%40resnics.com

  reply	other threads:[~2026-09-08 11:46 UTC|newest]

Thread overview: 21+ 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-07  8:37   ` Tariq Toukan
2026-09-03  8:43 ` [PATCH net-next 09/14] net/mlx5: " Ruizhe Zhou
2026-09-07  8:40   ` Tariq Toukan
2026-09-03  8:43 ` [PATCH net-next 10/14] mlxsw: pci: " Ruizhe Zhou
2026-09-04 16:00   ` Petr Machata
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-08 11:46   ` netdev-bot+sashiko [this message]
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
2026-09-08 23:50 ` [PATCH net-next 00/14] net: Remove obsolete 32-bit DMA mask fallbacks patchwork-bot+netdevbpf

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=178886799012.219967.9931005997243012418@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.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

all inboxes | Powered by JetHome®