提交 3e548079 编写于 作者: R Russell King

DMA-API: net: brocade/bna/bnad.c: fix 32-bit DMA mask handling

The fallback to 32-bit DMA mask is rather odd:
	if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
	    !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
		*using_dac = true;
	} else {
		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
		if (err) {
			err = dma_set_coherent_mask(&pdev->dev,
						    DMA_BIT_MASK(32));
			if (err)
				goto release_regions;
		}

This means we only try and set the coherent DMA mask if we failed to
set a 32-bit DMA mask, and only if both fail do we fail the driver.
Adjust this so that if either setting fails, we fail the driver - and
thereby end up properly setting both the DMA mask and the coherent
DMA mask in the fallback case.
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
上级 4aa806b7
...@@ -3300,17 +3300,12 @@ bnad_pci_init(struct bnad *bnad, ...@@ -3300,17 +3300,12 @@ bnad_pci_init(struct bnad *bnad,
err = pci_request_regions(pdev, BNAD_NAME); err = pci_request_regions(pdev, BNAD_NAME);
if (err) if (err)
goto disable_device; goto disable_device;
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) && if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {
!dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
*using_dac = true; *using_dac = true;
} else { } else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (err) { if (err)
err = dma_set_coherent_mask(&pdev->dev, goto release_regions;
DMA_BIT_MASK(32));
if (err)
goto release_regions;
}
*using_dac = false; *using_dac = false;
} }
pci_set_master(pdev); pci_set_master(pdev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册