Re: [PATCH] NTB: Set dma mask and dma coherent mask to NTB devices

From: Logan Gunthorpe
Date: Thu Nov 30 2017 - 17:17:05 EST




On 30/11/17 02:39 PM, Serge Semin wrote:
diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index f0788aae05c9..3cfa46876239 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -1020,6 +1020,10 @@ static int amd_ntb_init_pci(struct amd_ntb_dev *ndev,
goto err_dma_mask;
dev_warn(&pdev->dev, "Cannot DMA consistent highmem\n");
}
+ rc = dma_coerce_mask_and_coherent(&ndev->ntb.dev,
+ dma_get_mask(&pdev->dev));
+ if (rc)
+ goto err_dma_mask;

I can't say I understand fully what this is solving. Perhaps you could explain it a little further in the commit message.

In any case, to me, it looks like it would be better in ntb_register_device() instead of every single driver.


diff --git a/drivers/ntb/ntb.c b/drivers/ntb/ntb.c
index 03b80d89b980..79e50a5f8902 100644
--- a/drivers/ntb/ntb.c
+++ b/drivers/ntb/ntb.c
@@ -112,7 +112,6 @@ int ntb_register_device(struct ntb_dev *ntb)
init_completion(&ntb->released);
- memset(&ntb->dev, 0, sizeof(ntb->dev));
ntb->dev.bus = &ntb_bus;
ntb->dev.parent = &ntb->pdev->dev;
ntb->dev.release = ntb_dev_release;


This is unrelated to above. I agree it should probably be removed but I'd suggest it should be in its own commit with its own justification.

Thanks,

Logan