Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NTB: Set dma mask and dma coherent mask to NTB devices

The dma_mask and dma_coherent_mask fields of the NTB struct device
weren't initialized in hardware drivers. In fact it should be done
instead of PCIe interface usage, since NTB clients are supposed to
use NTB API and left unaware of real hardware implementation.
In addition to that ntb_device_register() method shouldn't clear
the passed ntb_dev structure, since it dma_mask is initialized
by hardware drivers.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>

authored by

Serge Semin and committed by
Jon Mason
417cf39c b87ab219

+15 -2
+4
drivers/ntb/hw/amd/ntb_hw_amd.c
··· 1020 1020 goto err_dma_mask; 1021 1021 dev_warn(&pdev->dev, "Cannot DMA consistent highmem\n"); 1022 1022 } 1023 + rc = dma_coerce_mask_and_coherent(&ndev->ntb.dev, 1024 + dma_get_mask(&pdev->dev)); 1025 + if (rc) 1026 + goto err_dma_mask; 1023 1027 1024 1028 ndev->self_mmio = pci_iomap(pdev, 0, 0); 1025 1029 if (!ndev->self_mmio) {
+7 -1
drivers/ntb/hw/idt/ntb_hw_idt.c
··· 2426 2426 struct pci_dev *pdev = ndev->ntb.pdev; 2427 2427 int ret; 2428 2428 2429 - /* Initialize the bit mask of DMA */ 2429 + /* Initialize the bit mask of PCI/NTB DMA */ 2430 2430 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); 2431 2431 if (ret != 0) { 2432 2432 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); ··· 2446 2446 } 2447 2447 dev_warn(&pdev->dev, 2448 2448 "Cannot set consistent DMA highmem bit mask\n"); 2449 + } 2450 + ret = dma_coerce_mask_and_coherent(&ndev->ntb.dev, 2451 + dma_get_mask(&pdev->dev)); 2452 + if (ret != 0) { 2453 + dev_err(&pdev->dev, "Failed to set NTB device DMA bit mask\n"); 2454 + return ret; 2449 2455 } 2450 2456 2451 2457 /*
+4
drivers/ntb/hw/intel/ntb_hw_intel.c
··· 2334 2334 goto err_dma_mask; 2335 2335 dev_warn(&pdev->dev, "Cannot DMA consistent highmem\n"); 2336 2336 } 2337 + rc = dma_coerce_mask_and_coherent(&ndev->ntb.dev, 2338 + dma_get_mask(&pdev->dev)); 2339 + if (rc) 2340 + goto err_dma_mask; 2337 2341 2338 2342 ndev->self_mmio = pci_iomap(pdev, 0, 0); 2339 2343 if (!ndev->self_mmio) {
-1
drivers/ntb/ntb.c
··· 111 111 112 112 init_completion(&ntb->released); 113 113 114 - memset(&ntb->dev, 0, sizeof(ntb->dev)); 115 114 ntb->dev.bus = &ntb_bus; 116 115 ntb->dev.parent = &ntb->pdev->dev; 117 116 ntb->dev.release = ntb_dev_release;