Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mips: mm: convert __flush_dcache_pages() to __flush_dcache_folio_pages()

Let's make it clearer that we are operating within a single folio by
providing both the folio and the page.

This implies that for flush_dcache_folio() we'll now avoid one more
page->folio lookup, and that we can safely drop the "nth_page" usage.

While at it, drop the "extern" from the function declaration.

Link: https://lkml.kernel.org/r/20250901150359.867252-22-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand and committed by
Andrew Morton
b71ddc9e d99c5754

+11 -8
+7 -4
arch/mips/include/asm/cacheflush.h
··· 50 50 extern void (*flush_cache_range)(struct vm_area_struct *vma, 51 51 unsigned long start, unsigned long end); 52 52 extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn); 53 - extern void __flush_dcache_pages(struct page *page, unsigned int nr); 53 + void __flush_dcache_folio_pages(struct folio *folio, struct page *page, unsigned int nr); 54 54 55 55 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 56 56 static inline void flush_dcache_folio(struct folio *folio) 57 57 { 58 58 if (cpu_has_dc_aliases) 59 - __flush_dcache_pages(&folio->page, folio_nr_pages(folio)); 59 + __flush_dcache_folio_pages(folio, folio_page(folio, 0), 60 + folio_nr_pages(folio)); 60 61 else if (!cpu_has_ic_fills_f_dc) 61 62 folio_set_dcache_dirty(folio); 62 63 } ··· 65 64 66 65 static inline void flush_dcache_page(struct page *page) 67 66 { 67 + struct folio *folio = page_folio(page); 68 + 68 69 if (cpu_has_dc_aliases) 69 - __flush_dcache_pages(page, 1); 70 + __flush_dcache_folio_pages(folio, page, 1); 70 71 else if (!cpu_has_ic_fills_f_dc) 71 - folio_set_dcache_dirty(page_folio(page)); 72 + folio_set_dcache_dirty(folio); 72 73 } 73 74 74 75 #define flush_dcache_mmap_lock(mapping) do { } while (0)
+4 -4
arch/mips/mm/cache.c
··· 99 99 return 0; 100 100 } 101 101 102 - void __flush_dcache_pages(struct page *page, unsigned int nr) 102 + void __flush_dcache_folio_pages(struct folio *folio, struct page *page, 103 + unsigned int nr) 103 104 { 104 - struct folio *folio = page_folio(page); 105 105 struct address_space *mapping = folio_flush_mapping(folio); 106 106 unsigned long addr; 107 107 unsigned int i; ··· 117 117 * get faulted into the tlb (and thus flushed) anyways. 118 118 */ 119 119 for (i = 0; i < nr; i++) { 120 - addr = (unsigned long)kmap_local_page(nth_page(page, i)); 120 + addr = (unsigned long)kmap_local_page(page + i); 121 121 flush_data_cache_page(addr); 122 122 kunmap_local((void *)addr); 123 123 } 124 124 } 125 - EXPORT_SYMBOL(__flush_dcache_pages); 125 + EXPORT_SYMBOL(__flush_dcache_folio_pages); 126 126 127 127 void __flush_anon_page(struct page *page, unsigned long vmaddr) 128 128 {