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

PCI: endpoint: Use of_dma_configure() to set initial DMA mask

Use of_dma_configure() to set the initial DMA mask of EPF device. This
helps to get rid of "Coherent DMA mask 0x0 (pfn 0x0-0x1) covers a smaller
range of system memory than the DMA zone pfn" warning in certain platforms
like TI's K2G resulting in coherent DMA mask not being set.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Kishon Vijay Abraham I and committed by
Bjorn Helgaas
64c1a02a 16f73eb0

+9 -2
+9 -2
drivers/pci/endpoint/pci-epc-core.c
··· 21 21 #include <linux/dma-mapping.h> 22 22 #include <linux/slab.h> 23 23 #include <linux/module.h> 24 + #include <linux/of_device.h> 24 25 25 26 #include <linux/pci-epc.h> 26 27 #include <linux/pci-epf.h> ··· 371 370 int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) 372 371 { 373 372 unsigned long flags; 373 + struct device *dev = epc->dev.parent; 374 374 375 375 if (epf->epc) 376 376 return -EBUSY; ··· 383 381 return -EINVAL; 384 382 385 383 epf->epc = epc; 386 - dma_set_coherent_mask(&epf->dev, epc->dev.coherent_dma_mask); 387 - epf->dev.dma_mask = epc->dev.dma_mask; 384 + if (dev->of_node) { 385 + of_dma_configure(&epf->dev, dev->of_node); 386 + } else { 387 + dma_set_coherent_mask(&epf->dev, epc->dev.coherent_dma_mask); 388 + epf->dev.dma_mask = epc->dev.dma_mask; 389 + } 388 390 389 391 spin_lock_irqsave(&epc->lock, flags); 390 392 list_add_tail(&epf->list, &epc->pci_epf); ··· 506 500 dma_set_coherent_mask(&epc->dev, dev->coherent_dma_mask); 507 501 epc->dev.class = pci_epc_class; 508 502 epc->dev.dma_mask = dev->dma_mask; 503 + epc->dev.parent = dev; 509 504 epc->ops = ops; 510 505 511 506 ret = dev_set_name(&epc->dev, "%s", dev_name(dev));