回复:[PATCH v23 net-next 02/12] net/nebula-matrix: add core driver architecture and HW layer initialization

From
Illusion Wang <Illusion.Wang@nebula-matrix.com>
Date
2026-08-05 02:26:44
Also in
linux-doc, lkml
Reply to
illusion.wang, 2026-07-31
Review comments for V22
On Thu, 23 Jul 2026 12:00:54 +0800 illusion.wang wrote:
quoted
+ err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
+ if (err) {
+  dev_dbg(dev, "Configure DMA 64 bit mask failed, err = %d\n",
+   err);
+  dma_32_err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
+  if (dma_32_err) {
Read the documentation for the DMA API, dma_set_mask_and_coherent()
is guaranteed to succeed in some cases..
As documented:
dma_set_mask_and_coherent() never return fail when DMA_BIT_MASK(64). Typical
error code like::

	/* Wrong code */
	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)))
		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))

dma_set_mask_and_coherent() will never return failure when bigger than 32.
So typical code like::

	/* Recommended code */
	if (support_64bit)
		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
	else
		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));

Review comments for V23
quoted
+	err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
+	if (err) {
+		dev_dbg(dev, "Configure DMA 64 bit mask failed, err = %d\n",
+			err);
+		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
If the 64-bit mask configuration fails in nbl_probe(), and this 32-bit
fallback also fails, does probe succeed anyway leaving the device with an
unconfigured or invalid DMA mask?
Since the return value of the fallback dma_set_mask_and_coherent() is
ignored, the probe path will continue without a valid DMA mask configuration,
which could cause subsequent DMA operations to fail or misbehave silently.
quoted
+	}
+	pci_set_master(pdev);
+
+	adapter = nbl_core_init(pdev, &param);
So My fix implementation is OK?
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (ret) {
	dev_err(&pdev->dev, "Set 64bit DMA mask failed %d, device cannot work\n", ret);
	goto err_out;
}
...
pci_set_master(pdev);
adapter = nbl_core_init(pdev, &param);
Thread (16 messages) 16 messages, 2 authors, last reply 2026-08-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help