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

"Illusion Wang" <[email protected]>
Newsgroups org.kernel.vger.netdev,org.kernel.vger.linux-doc,org.kernel.vger.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, &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);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.