[PATCH v5 2/5] iommu/io-pgtable: Move Apple DART support to its own file

Hector Martin marcan at marcan.st
Thu Sep 22 07:05:10 PDT 2022


On 16/09/2022 18.41, Janne Grunau wrote:
> The pte format used by the DARTs found in the Apple M1 (t8103) is not
> fully compatible with io-pgtable-arm. The 24 MSB are used for subpage
> protection (mapping only parts of page) and conflict with the address
> mask. In addition bit 1 is not available for tagging entries but disables
> subpage protection. Subpage protection could be useful to support a CPU
> granule of 4k with the fixed IOMMU page size of 16k.
> 
> The DARTs found on Apple M1 Pro/Max/Ultra use another different pte
> format which is even less compatible. To support an output address size
> of 42 bit the address is shifted down by 4. Subpage protection is
> mandatory and bit 1 signifies uncached mappings used by the display
> controller.
> 
> It would be advantageous to share code for all known Apple DART
> variants to support common features. The page table allocator for DARTs
> is less complex since it uses a two levels of translation table without
> support for huge pages.
> 
> Signed-off-by: Janne Grunau <j at jannau.net>
> Acked-by: Robin Murphy <robin.murphy at arm.com>
> Acked-by: Sven Peter <sven at svenpeter.dev>
> 
> ---

[...]

> +static void *__dart_alloc_pages(size_t size, gfp_t gfp,
> +				    struct io_pgtable_cfg *cfg)
> +{
> +	struct device *dev = cfg->iommu_dev;
> +	int order = get_order(size);
> +	struct page *p;
> +
> +	VM_BUG_ON((gfp & __GFP_HIGHMEM));
> +	p = alloc_pages(gfp | __GFP_ZERO, order);
> +	if (!p)
> +		return NULL;
> +
> +	return page_address(p);
> +}

This throws a warning:

drivers/iommu/io-pgtable-dart.c: In function ‘__dart_alloc_pages’:
drivers/iommu/io-pgtable-dart.c:112:24: warning: unused variable ‘dev’
[-Wunused-variable]
  112 |         struct device *dev = cfg->iommu_dev;
      |                        ^~~

The fix is trivial, of course.

- Hector



More information about the linux-arm-kernel mailing list