History

iommu/io-pgtable-arm: Add support to use system cache

Few Qualcomm platforms such as, sdm845 have an additional outer cache called as System cache, aka. Last level cache (LLC) that allows non-coherent devices to upgrade to using caching. This cache sits right before the DDR, and is tightly coupled with the memory controller. The clients using this cache request their slices from this system cache, make it active, and can then start using it. There is a fundamental assumption that non-coherent devices can't access caches. This change adds an exception where they *can* use some level of cache despite still being non-coherent overall. The coherent devices that use cacheable memory, and CPU make use of this system cache by default. Looking at memory types, we have following - a) Normal uncached :- MAIR 0x44, inner non-cacheable, outer non-cacheable; b) Normal cached :- MAIR 0xff, inner read write-back non-transient, outer read write-back non-transient; attribute setting for coherenet I/O devices. and, for non-coherent i/o devices that can allocate in system cache another type gets added - c) Normal sys-cached :- MAIR 0xf4, inner non-cacheable, outer read write-back non-transient Coherent I/O devices use system cache by marking the memory as normal cached. Non-coherent I/O devices should mark the memory as normal sys-cached in page tables to use system cache.

Vivek Gautam committed 7 years ago

Commit 90ec7a71 parent d25f6ea2 files · +14 −1Browse files

Unified · Split

2 files
  1. drivers/iommu/io-pgtable-arm.c +8 −1
  2. include/linux/iommu.h +6 −0
drivers/iommu/io-pgtable-arm.c+8−1
@@ -167,10 +167,12 @@ · 166 unmodified lines
167#define ARM_LPAE_MAIR_ATTR_MASK 0xff167#define ARM_LPAE_MAIR_ATTR_MASK 0xff
168#define ARM_LPAE_MAIR_ATTR_DEVICE 0x04168#define ARM_LPAE_MAIR_ATTR_DEVICE 0x04
169#define ARM_LPAE_MAIR_ATTR_NC 0x44169#define ARM_LPAE_MAIR_ATTR_NC 0x44
170#define ARM_LPAE_MAIR_ATTR_INC_OWBRWA 0xf4
170#define ARM_LPAE_MAIR_ATTR_WBRWA 0xff171#define ARM_LPAE_MAIR_ATTR_WBRWA 0xff
171#define ARM_LPAE_MAIR_ATTR_IDX_NC 0172#define ARM_LPAE_MAIR_ATTR_IDX_NC 0
172#define ARM_LPAE_MAIR_ATTR_IDX_CACHE 1173#define ARM_LPAE_MAIR_ATTR_IDX_CACHE 1
173#define ARM_LPAE_MAIR_ATTR_IDX_DEV 2174#define ARM_LPAE_MAIR_ATTR_IDX_DEV 2
175#define ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE 3
174 176
175#define ARM_MALI_LPAE_TTBR_ADRMODE_TABLE (3u << 0)177#define ARM_MALI_LPAE_TTBR_ADRMODE_TABLE (3u << 0)
176#define ARM_MALI_LPAE_TTBR_READ_INNER BIT(2)178#define ARM_MALI_LPAE_TTBR_READ_INNER BIT(2)
@@ -470,6 +472,9 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data, · 293 unmodified lines
470 else if (prot & IOMMU_CACHE)472 else if (prot & IOMMU_CACHE)
471 pte |= (ARM_LPAE_MAIR_ATTR_IDX_CACHE473 pte |= (ARM_LPAE_MAIR_ATTR_IDX_CACHE
472 << ARM_LPAE_PTE_ATTRINDX_SHIFT);474 << ARM_LPAE_PTE_ATTRINDX_SHIFT);
475 else if (prot & IOMMU_QCOM_SYS_CACHE)
476 pte |= (ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE
477 << ARM_LPAE_PTE_ATTRINDX_SHIFT);
473 }478 }
474 479
475 if (prot & IOMMU_NOEXEC)480 if (prot & IOMMU_NOEXEC)
@@ -857,7 +862,9 @@ arm_64_lpae_alloc_pgtable_s1(struct io_pgtable_cfg *cfg, void *cookie) · 381 unmodified lines
857 (ARM_LPAE_MAIR_ATTR_WBRWA862 (ARM_LPAE_MAIR_ATTR_WBRWA
858 << ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_CACHE)) |863 << ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_CACHE)) |
859 (ARM_LPAE_MAIR_ATTR_DEVICE864 (ARM_LPAE_MAIR_ATTR_DEVICE
860 << ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_DEV));865 << ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_DEV)) |
866 (ARM_LPAE_MAIR_ATTR_INC_OWBRWA
867 << ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE));
861 868
862 cfg->arm_lpae_s1_cfg.mair[0] = reg;869 cfg->arm_lpae_s1_cfg.mair[0] = reg;
863 cfg->arm_lpae_s1_cfg.mair[1] = 0;870 cfg->arm_lpae_s1_cfg.mair[1] = 0;
include/linux/iommu.h+6−0
@@ -41,6 +41,12 @@ · 40 unmodified lines
41 * if the IOMMU page table format is equivalent.41 * if the IOMMU page table format is equivalent.
42 */42 */
43#define IOMMU_PRIV (1 << 5)43#define IOMMU_PRIV (1 << 5)
44/*
45 * Non-coherent masters on few Qualcomm SoCs can use this page protection flag
46 * to set correct cacheability attributes to use an outer level of cache -
47 * last level cache, aka system cache.
48 */
49#define IOMMU_QCOM_SYS_CACHE (1 << 6)
44 50
45struct iommu_ops;51struct iommu_ops;
46struct iommu_group;52struct iommu_group;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t