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, ¶m);
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, ¶m);