回复:[PATCH v23 net-next 02/12] net/nebula-matrix: add core driver architecture and HW layer initializat ion
"Illusion Wang" <[email protected]> Wed, 05 Aug 2026 10:26:31 +0800
| Newsgroups | gmane.linux.documentation,gmane.linux.network,gmane.linux.kernel |
|---|---|
| Message-ID | <21f3dc71-fe1e-4f9a-a2a6-0840f25bdeec.Illusion.Wang@nebula-matrix.com> |
Review comments for V22
>On Thu, 23 Jul 2026 12:00:54 +0800 illusion.wang wrote:
>> + 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
>> + 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.
>> + }
>> + 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);