Skip to content

Commit 5ac65e8

Browse files
rmurphy-armChristoph Hellwig
authored andcommitted
ACPI/IORT: Support address size limit for root complexes
IORT revision D allows PCI root complex nodes to specify a memory address size limit equivalently to named components, to help describe straightforward integrations which don't really warrant a full-blown _DMA method. Now that our headers are up-to-date, plumb it in. If both _DMA and an address size limit are present, we would always expect the former to be a more specific subset of the latter (since it makes little sense for a _DMA range to involve bits which IORT says aren't wired up), thus we can save calculating an explicit intersection of the two effective masks and simply use short-circuit logic instead. Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Will Deacon <will.deacon@arm.com> Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent a551621 commit 5ac65e8

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

drivers/acpi/arm64/iort.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,24 @@ static int nc_dma_get_range(struct device *dev, u64 *size)
947947
return 0;
948948
}
949949

950+
static int rc_dma_get_range(struct device *dev, u64 *size)
951+
{
952+
struct acpi_iort_node *node;
953+
struct acpi_iort_root_complex *rc;
954+
955+
node = iort_scan_node(ACPI_IORT_NODE_PCI_ROOT_COMPLEX,
956+
iort_match_node_callback, dev);
957+
if (!node || node->revision < 1)
958+
return -ENODEV;
959+
960+
rc = (struct acpi_iort_root_complex *)node->node_data;
961+
962+
*size = rc->memory_address_limit >= 64 ? U64_MAX :
963+
1ULL<<rc->memory_address_limit;
964+
965+
return 0;
966+
}
967+
950968
/**
951969
* iort_dma_setup() - Set-up device DMA parameters.
952970
*
@@ -975,10 +993,13 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size)
975993

976994
size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1);
977995

978-
if (dev_is_pci(dev))
996+
if (dev_is_pci(dev)) {
979997
ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size);
980-
else
998+
if (ret == -ENODEV)
999+
ret = rc_dma_get_range(dev, &size);
1000+
} else {
9811001
ret = nc_dma_get_range(dev, &size);
1002+
}
9821003

9831004
if (!ret) {
9841005
msb = fls64(dmaaddr + size - 1);

0 commit comments

Comments
 (0)