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
167167 #define ARM_LPAE_MAIR_ATTR_MASK 0xff
168168 #define ARM_LPAE_MAIR_ATTR_DEVICE 0x04
169169 #define ARM_LPAE_MAIR_ATTR_NC 0x44
170+#define ARM_LPAE_MAIR_ATTR_INC_OWBRWA 0xf4
170171 #define ARM_LPAE_MAIR_ATTR_WBRWA 0xff
171172 #define ARM_LPAE_MAIR_ATTR_IDX_NC 0
172173 #define ARM_LPAE_MAIR_ATTR_IDX_CACHE 1
173174 #define ARM_LPAE_MAIR_ATTR_IDX_DEV 2
175+#define ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE 3
174176
175177 #define ARM_MALI_LPAE_TTBR_ADRMODE_TABLE (3u << 0)
176178 #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
470472 else if (prot & IOMMU_CACHE)
471473 pte |= (ARM_LPAE_MAIR_ATTR_IDX_CACHE
472474 << 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);
473478 }
474479
475480 if (prot & IOMMU_NOEXEC)
@@ -857,7 +862,9 @@ arm_64_lpae_alloc_pgtable_s1(struct io_pgtable_cfg *cfg, void *cookie) · 381 unmodified lines
857862 (ARM_LPAE_MAIR_ATTR_WBRWA
858863 << ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_CACHE)) |
859864 (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));
861868
862869 cfg->arm_lpae_s1_cfg.mair[0] = reg;
863870 cfg->arm_lpae_s1_cfg.mair[1] = 0;
include/linux/iommu.h+6−0
@@ -41,6 +41,12 @@ · 40 unmodified lines
4141 * if the IOMMU page table format is equivalent.
4242 */
4343 #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)
4450
4551 struct iommu_ops;
4652 struct 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