Skip to contentSkip to conversation

ARC: mm: retire support for aliasing VIPT D$

PATCH In review Vineet Gupta 2 participants 3 messages Aug 13, 2023 – Aug 14, 2023 Synopsys ARC architecture

lore
Share & tools
lore

Vineet Gupta

author maintainer
#0 lore raw

PATCH 1/1 ARC: mm: retire support for aliasing VIPT D$

Legacy ARC700 processors (first generation of MMU enabled ARC cores) has VIPT cached which could be configured such that they could alias. I added the VIPT aliasing support, with all the cache flush overhead to support all but 1 silicon. That is long bygone and we can remove the complexity and maintenance burden of that unneeded code.

This also helps streamline support for new features such as generic folio work.

---
 arch/arc/Kconfig                  |   5 --
 arch/arc/include/asm/cacheflush.h |  43 ----------
 arch/arc/mm/cache.c               | 125 ++----------------------------
 arch/arc/mm/mmap.c                |  21 +----
 arch/arc/mm/tlb.c                 |  17 ++--
 5 files changed, 14 insertions(+), 197 deletions(-)
arch/arc/Kconfig +0 -5
index 96cf8720bb93..a03da8391430 100644
@@ -46,7 +46,6 @@ config ARC
 	select OF
 	select OF_EARLY_FLATTREE
 	select PCI_SYSCALL if PCI
-	select PERF_USE_VMALLOC if ARC_CACHE_VIPT_ALIASING
 	select HAVE_ARCH_JUMP_LABEL if ISA_ARCV2 && !CPU_ENDIAN_BE32
 	select TRACE_IRQFLAGS_SUPPORT
 
@@ -229,10 +228,6 @@ config ARC_CACHE_PAGES
 	  Note that Global I/D ENABLE + Per Page DISABLE works but corollary
 	  Global DISABLE + Per Page ENABLE won't work
 
-config ARC_CACHE_VIPT_ALIASING
-	bool "Support VIPT Aliasing D$"
-	depends on ARC_HAS_DCACHE && ISA_ARCOMPACT
-
 endif #ARC_CACHE
 
 config ARC_HAS_ICCM
arch/arc/include/asm/cacheflush.h +0 -43

59 lines not on this page · raw message

arch/arc/mm/cache.c +6 -119

164 lines not on this page · raw message

arch/arc/mm/mmap.c +3 -18
index fce5fa2b4f52..3c1c7ae73292 100644
@@ -14,10 +14,6 @@
 
 #include <asm/cacheflush.h>
 
-#define COLOUR_ALIGN(addr, pgoff)			\
-	((((addr) + SHMLBA - 1) & ~(SHMLBA - 1)) +	\
-	 (((pgoff) << PAGE_SHIFT) & (SHMLBA - 1)))
-
 /*
  * Ensure that shared mappings are correctly aligned to
  * avoid aliasing issues with VIPT caches.
@@ -31,21 +27,13 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 {
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma;
-	int do_align = 0;
-	int aliasing = cache_is_vipt_aliasing();
 	struct vm_unmapped_area_info info;
 
-	/*
-	 * We only need to do colour alignment if D cache aliases.
-	 */
-	if (aliasing)
-		do_align = filp || (flags & MAP_SHARED);
-
 	/*
 	 * We enforce the MAP_FIXED case.
 	 */
 	if (flags & MAP_FIXED) {
-		if (aliasing && flags & MAP_SHARED &&
+		if (flags & MAP_SHARED &&
 		    (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1))
 			return -EINVAL;
 		return addr;
@@ -55,10 +43,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 		return -ENOMEM;
 
 	if (addr) {
-		if (do_align)
-			addr = COLOUR_ALIGN(addr, pgoff);
-		else
-			addr = PAGE_ALIGN(addr);
+		addr = PAGE_ALIGN(addr);
 
 		vma = find_vma(mm, addr);
 		if (TASK_SIZE - len >= addr &&
@@ -70,7 +55,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	info.length = len;
 	info.low_limit = mm->mmap_base;
 	info.high_limit = TASK_SIZE;
-	info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
+	info.align_mask = 0;
 	info.align_offset = pgoff << PAGE_SHIFT;
 	return vm_unmapped_area(&info);
 }
arch/arc/mm/tlb.c +5 -12
index 2a3105a682c3..b53ad03ae564 100644
@@ -476,22 +476,15 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long vaddr_unaligned,
 
 	create_tlb(vma, vaddr, ptep);
 
-	if (page == ZERO_PAGE(0)) {
+	if (page == ZERO_PAGE(0))
 		return;
-	}
 
 	/*
-	 * Exec page : Independent of aliasing/page-color considerations,
-	 *	       since icache doesn't snoop dcache on ARC, any dirty
-	 *	       K-mapping of a code page needs to be wback+inv so that
-	 *	       icache fetch by userspace sees code correctly.
-	 * !EXEC page: If K-mapping is NOT congruent to U-mapping, flush it
-	 *	       so userspace sees the right data.
-	 *  (Avoids the flush for Non-exec + congruent mapping case)
+	 * For executable pages, since icache doesn't snoop dcache, any
+	 * dirty K-mapping of a code page needs to be wback+inv so that
+	 * icache fetch by userspace sees code correctly.
 	 */
-	if ((vma->vm_flags & VM_EXEC) ||
-	     addr_not_cache_congruent(paddr, vaddr)) {
-
+	if (vma->vm_flags & VM_EXEC) {
 		int dirty = !test_and_set_bit(PG_dc_clean, &page->flags);
 		if (dirty) {
 			/* wback + inv dcache lines (K-mapping) */
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
#1 lore raw
Quoted 9 lines · On Sun, 13 Aug 2023 12:25:43 -0700 Vineet Gupta <[email protected]> wrote:

Legacy ARC700 processors (first generation of MMU enabled ARC cores) has VIPT cached which could be configured such that they could alias. I added the VIPT aliasing support, with all the cache flush overhead to support all but 1 silicon. That is long bygone and we can remove the complexity and maintenance burden of that unneeded code.

This also helps streamline support for new features such as generic folio work.

This of course messes up Matthew's "arc: implement the new page table range API". Are you or Matthew up for redoing that patch?

Alternatively, can you redo this patch on top of Matthew's patch (ie, against mm-unstable or linux-next)?

Thanks.

_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

author maintainer
#2 lore raw
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Sun, 13 Aug 2023 12:25:43 -0700 Vineet Gupta <[email protected]> wrote:

Legacy ARC700 processors (first generation of MMU enabled ARC cores) has VIPT cached which could be configured such that they could alias. I added the VIPT aliasing support, with all the cache flush overhead to support all but 1 silicon. That is long bygone and we can remove the complexity and maintenance burden of that unneeded code.

Quoted 8 lines
Quoted 3 lines

This also helps streamline support for new features such as generic folio work.

This of course messes up Matthew's "arc: implement the new page table range API". Are you or Matthew up for redoing that patch?

Alternatively, can you redo this patch on top of Matthew's patch (ie, against mm-unstable or linux-next)?

Yeah I'll let Matthew's code get merged and redo mine once that is upstream to avoid conflicts in transition.

Thx,
-Vineet

_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc