aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/arm64/iort.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 606af87c425f..5b9e8dc29c09 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -680,6 +680,24 @@ static const struct iommu_ops *iort_iommu_xlate(struct device *dev,
680 return ret ? NULL : ops; 680 return ret ? NULL : ops;
681} 681}
682 682
683static int nc_dma_get_range(struct device *dev, u64 *size)
684{
685 struct acpi_iort_node *node;
686 struct acpi_iort_named_component *ncomp;
687
688 node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT,
689 iort_match_node_callback, dev);
690 if (!node)
691 return -ENODEV;
692
693 ncomp = (struct acpi_iort_named_component *)node->node_data;
694
695 *size = ncomp->memory_address_limit >= 64 ? U64_MAX :
696 1ULL<<ncomp->memory_address_limit;
697
698 return 0;
699}
700
683/** 701/**
684 * iort_dma_setup() - Set-up device DMA parameters. 702 * iort_dma_setup() - Set-up device DMA parameters.
685 * 703 *
@@ -708,24 +726,26 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size)
708 726
709 size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1); 727 size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1);
710 728
711 if (dev_is_pci(dev)) { 729 if (dev_is_pci(dev))
712 ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size); 730 ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size);
713 if (!ret) { 731 else
714 msb = fls64(dmaaddr + size - 1); 732 ret = nc_dma_get_range(dev, &size);
715 /* 733
716 * Round-up to the power-of-two mask or set 734 if (!ret) {
717 * the mask to the whole 64-bit address space 735 msb = fls64(dmaaddr + size - 1);
718 * in case the DMA region covers the full 736 /*
719 * memory window. 737 * Round-up to the power-of-two mask or set
720 */ 738 * the mask to the whole 64-bit address space
721 mask = msb == 64 ? U64_MAX : (1ULL << msb) - 1; 739 * in case the DMA region covers the full
722 /* 740 * memory window.
723 * Limit coherent and dma mask based on size 741 */
724 * retrieved from firmware. 742 mask = msb == 64 ? U64_MAX : (1ULL << msb) - 1;
725 */ 743 /*
726 dev->coherent_dma_mask = mask; 744 * Limit coherent and dma mask based on size
727 *dev->dma_mask = mask; 745 * retrieved from firmware.
728 } 746 */
747 dev->coherent_dma_mask = mask;
748 *dev->dma_mask = mask;
729 } 749 }
730 750
731 *dma_addr = dmaaddr; 751 *dma_addr = dmaaddr;