Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10d8ab2c authored by Lorenzo Pieralisi's avatar Lorenzo Pieralisi Committed by Rafael J. Wysocki
Browse files

ACPI/IORT: Add IORT named component memory address limits



IORT named components provide firmware configuration describing
how many address bits a given device is capable of generating
to address memory.

Add code to the kernel to retrieve memory address limits
configuration for IORT named components and configure DMA masks
accordingly.

Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: default avatarWill Deacon <will.deacon@arm.com>
Tested-by: default avatarNate Watterson <nwatters@codeaurora.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 7ad42639
Loading
Loading
Loading
Loading
+37 −17
Original line number Diff line number Diff line
@@ -680,6 +680,24 @@ static const struct iommu_ops *iort_iommu_xlate(struct device *dev,
	return ret ? NULL : ops;
}

static int nc_dma_get_range(struct device *dev, u64 *size)
{
	struct acpi_iort_node *node;
	struct acpi_iort_named_component *ncomp;

	node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT,
			      iort_match_node_callback, dev);
	if (!node)
		return -ENODEV;

	ncomp = (struct acpi_iort_named_component *)node->node_data;

	*size = ncomp->memory_address_limit >= 64 ? U64_MAX :
			1ULL<<ncomp->memory_address_limit;

	return 0;
}

/**
 * iort_dma_setup() - Set-up device DMA parameters.
 *
@@ -708,8 +726,11 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size)

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

	if (dev_is_pci(dev)) {
	if (dev_is_pci(dev))
		ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size);
	else
		ret = nc_dma_get_range(dev, &size);

	if (!ret) {
		msb = fls64(dmaaddr + size - 1);
		/*
@@ -726,7 +747,6 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size)
		dev->coherent_dma_mask = mask;
		*dev->dma_mask = mask;
	}
	}

	*dma_addr = dmaaddr;
	*dma_size = size;