mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	Trivial fix to remove the following sparse warnings: arch/powerpc/kernel/module_32.c:112:74: warning: Using plain integer as NULL pointer arch/powerpc/kernel/module_32.c:117:74: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:1155:28: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:1230:20: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:1385:36: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:1752:23: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:2084:19: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:2110:32: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:2167:19: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:2183:19: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:277:20: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/setup.c:155:67: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/setup.c:247:27: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/setup.c:249:27: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/setup.c:252:37: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:127:21: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:148:21: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:44:21: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:57:21: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:87:21: warning: Using plain integer as NULL pointer arch/powerpc/kernel/btext.c:160:31: warning: Using plain integer as NULL pointer arch/powerpc/kernel/btext.c:167:22: warning: Using plain integer as NULL pointer arch/powerpc/kernel/btext.c:274:21: warning: Using plain integer as NULL pointer arch/powerpc/kernel/btext.c:285:31: warning: Using plain integer as NULL pointer arch/powerpc/include/asm/hugetlb.h:204:16: warning: Using plain integer as NULL pointer arch/powerpc/mm/ppc_mmu_32.c:170:21: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/pci.c:1227:23: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/pci.c:65:24: warning: Using plain integer as NULL pointer Also use `--fix` command line option from `script/checkpatch --strict` to remove the following: CHECK: Comparison to NULL could be written "!dispDeviceBase" #72: FILE: arch/powerpc/kernel/btext.c:160: + if (dispDeviceBase == NULL) CHECK: Comparison to NULL could be written "!vbase" #80: FILE: arch/powerpc/kernel/btext.c:167: + if (vbase == NULL) CHECK: Comparison to NULL could be written "!base" #89: FILE: arch/powerpc/kernel/btext.c:274: + if (base == NULL) CHECK: Comparison to NULL could be written "!dispDeviceBase" #98: FILE: arch/powerpc/kernel/btext.c:285: + if (dispDeviceBase == NULL) CHECK: Comparison to NULL could be written "strstr" #117: FILE: arch/powerpc/kernel/module_32.c:117: + if (strstr(secstrings + sechdrs[i].sh_name, ".debug") != NULL) CHECK: Comparison to NULL could be written "!Hash" #130: FILE: arch/powerpc/mm/ppc_mmu_32.c:170: + if (Hash == NULL) CHECK: Comparison to NULL could be written "Hash" #143: FILE: arch/powerpc/mm/tlb_hash32.c:44: + if (Hash != NULL) { CHECK: Comparison to NULL could be written "!Hash" #152: FILE: arch/powerpc/mm/tlb_hash32.c:57: + if (Hash == NULL) { CHECK: Comparison to NULL could be written "!Hash" #161: FILE: arch/powerpc/mm/tlb_hash32.c:87: + if (Hash == NULL) { CHECK: Comparison to NULL could be written "!Hash" #170: FILE: arch/powerpc/mm/tlb_hash32.c:127: + if (Hash == NULL) { CHECK: Comparison to NULL could be written "!Hash" #179: FILE: arch/powerpc/mm/tlb_hash32.c:148: + if (Hash == NULL) { ERROR: space required after that ';' (ctx:VxV) #192: FILE: arch/powerpc/platforms/powermac/pci.c:65: + for (; node != NULL;node = node->sibling) { CHECK: Comparison to NULL could be written "node" #192: FILE: arch/powerpc/platforms/powermac/pci.c:65: + for (; node != NULL;node = node->sibling) { CHECK: Comparison to NULL could be written "!region" #201: FILE: arch/powerpc/platforms/powermac/pci.c:1227: + if (region == NULL) CHECK: Comparison to NULL could be written "of_get_property" #214: FILE: arch/powerpc/platforms/powermac/setup.c:155: + if (of_get_property(np, "cache-unified", NULL) != NULL && dc) { CHECK: Comparison to NULL could be written "!np" #223: FILE: arch/powerpc/platforms/powermac/setup.c:247: + if (np == NULL) CHECK: Comparison to NULL could be written "np" #226: FILE: arch/powerpc/platforms/powermac/setup.c:249: + if (np != NULL) { CHECK: Comparison to NULL could be written "l2cr" #230: FILE: arch/powerpc/platforms/powermac/setup.c:252: + if (l2cr != NULL) { CHECK: Comparison to NULL could be written "via" #243: FILE: drivers/macintosh/via-pmu.c:277: + if (via != NULL) CHECK: Comparison to NULL could be written "current_req" #252: FILE: drivers/macintosh/via-pmu.c:1155: + if (current_req != NULL) { CHECK: Comparison to NULL could be written "!req" #261: FILE: drivers/macintosh/via-pmu.c:1230: + if (req == NULL || pmu_state != idle CHECK: Comparison to NULL could be written "!req" #270: FILE: drivers/macintosh/via-pmu.c:1385: + if (req == NULL) { CHECK: Comparison to NULL could be written "!pp" #288: FILE: drivers/macintosh/via-pmu.c:2084: + if (pp == NULL) CHECK: Comparison to NULL could be written "!pp" #297: FILE: drivers/macintosh/via-pmu.c:2110: + if (count < 1 || pp == NULL) CHECK: Comparison to NULL could be written "!pp" #306: FILE: drivers/macintosh/via-pmu.c:2167: + if (pp == NULL) CHECK: Comparison to NULL could be written "pp" #315: FILE: drivers/macintosh/via-pmu.c:2183: + if (pp != NULL) { Link: https://github.com/linuxppc/linux/issues/37 Signed-off-by: Mathieu Malaterre <malat@debian.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
		
			
				
	
	
		
			173 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			173 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * This file contains the routines for TLB flushing.
 | 
						|
 * On machines where the MMU uses a hash table to store virtual to
 | 
						|
 * physical translations, these routines flush entries from the
 | 
						|
 * hash table also.
 | 
						|
 *  -- paulus
 | 
						|
 *
 | 
						|
 *  Derived from arch/ppc/mm/init.c:
 | 
						|
 *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
 | 
						|
 *
 | 
						|
 *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
 | 
						|
 *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
 | 
						|
 *    Copyright (C) 1996 Paul Mackerras
 | 
						|
 *
 | 
						|
 *  Derived from "arch/i386/mm/init.c"
 | 
						|
 *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
 | 
						|
 *
 | 
						|
 *  This program is free software; you can redistribute it and/or
 | 
						|
 *  modify it under the terms of the GNU General Public License
 | 
						|
 *  as published by the Free Software Foundation; either version
 | 
						|
 *  2 of the License, or (at your option) any later version.
 | 
						|
 *
 | 
						|
 */
 | 
						|
 | 
						|
#include <linux/kernel.h>
 | 
						|
#include <linux/mm.h>
 | 
						|
#include <linux/init.h>
 | 
						|
#include <linux/highmem.h>
 | 
						|
#include <linux/pagemap.h>
 | 
						|
#include <linux/export.h>
 | 
						|
 | 
						|
#include <asm/tlbflush.h>
 | 
						|
#include <asm/tlb.h>
 | 
						|
 | 
						|
#include "mmu_decl.h"
 | 
						|
 | 
						|
/*
 | 
						|
 * Called when unmapping pages to flush entries from the TLB/hash table.
 | 
						|
 */
 | 
						|
void flush_hash_entry(struct mm_struct *mm, pte_t *ptep, unsigned long addr)
 | 
						|
{
 | 
						|
	unsigned long ptephys;
 | 
						|
 | 
						|
	if (Hash) {
 | 
						|
		ptephys = __pa(ptep) & PAGE_MASK;
 | 
						|
		flush_hash_pages(mm->context.id, addr, ptephys, 1);
 | 
						|
	}
 | 
						|
}
 | 
						|
EXPORT_SYMBOL(flush_hash_entry);
 | 
						|
 | 
						|
/*
 | 
						|
 * Called at the end of a mmu_gather operation to make sure the
 | 
						|
 * TLB flush is completely done.
 | 
						|
 */
 | 
						|
void tlb_flush(struct mmu_gather *tlb)
 | 
						|
{
 | 
						|
	if (!Hash) {
 | 
						|
		/*
 | 
						|
		 * 603 needs to flush the whole TLB here since
 | 
						|
		 * it doesn't use a hash table.
 | 
						|
		 */
 | 
						|
		_tlbia();
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
/*
 | 
						|
 * TLB flushing:
 | 
						|
 *
 | 
						|
 *  - flush_tlb_mm(mm) flushes the specified mm context TLB's
 | 
						|
 *  - flush_tlb_page(vma, vmaddr) flushes one page
 | 
						|
 *  - flush_tlb_range(vma, start, end) flushes a range of pages
 | 
						|
 *  - flush_tlb_kernel_range(start, end) flushes kernel pages
 | 
						|
 *
 | 
						|
 * since the hardware hash table functions as an extension of the
 | 
						|
 * tlb as far as the linux tables are concerned, flush it too.
 | 
						|
 *    -- Cort
 | 
						|
 */
 | 
						|
 | 
						|
static void flush_range(struct mm_struct *mm, unsigned long start,
 | 
						|
			unsigned long end)
 | 
						|
{
 | 
						|
	pmd_t *pmd;
 | 
						|
	unsigned long pmd_end;
 | 
						|
	int count;
 | 
						|
	unsigned int ctx = mm->context.id;
 | 
						|
 | 
						|
	if (!Hash) {
 | 
						|
		_tlbia();
 | 
						|
		return;
 | 
						|
	}
 | 
						|
	start &= PAGE_MASK;
 | 
						|
	if (start >= end)
 | 
						|
		return;
 | 
						|
	end = (end - 1) | ~PAGE_MASK;
 | 
						|
	pmd = pmd_offset(pud_offset(pgd_offset(mm, start), start), start);
 | 
						|
	for (;;) {
 | 
						|
		pmd_end = ((start + PGDIR_SIZE) & PGDIR_MASK) - 1;
 | 
						|
		if (pmd_end > end)
 | 
						|
			pmd_end = end;
 | 
						|
		if (!pmd_none(*pmd)) {
 | 
						|
			count = ((pmd_end - start) >> PAGE_SHIFT) + 1;
 | 
						|
			flush_hash_pages(ctx, start, pmd_val(*pmd), count);
 | 
						|
		}
 | 
						|
		if (pmd_end == end)
 | 
						|
			break;
 | 
						|
		start = pmd_end + 1;
 | 
						|
		++pmd;
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
/*
 | 
						|
 * Flush kernel TLB entries in the given range
 | 
						|
 */
 | 
						|
void flush_tlb_kernel_range(unsigned long start, unsigned long end)
 | 
						|
{
 | 
						|
	flush_range(&init_mm, start, end);
 | 
						|
}
 | 
						|
EXPORT_SYMBOL(flush_tlb_kernel_range);
 | 
						|
 | 
						|
/*
 | 
						|
 * Flush all the (user) entries for the address space described by mm.
 | 
						|
 */
 | 
						|
void flush_tlb_mm(struct mm_struct *mm)
 | 
						|
{
 | 
						|
	struct vm_area_struct *mp;
 | 
						|
 | 
						|
	if (!Hash) {
 | 
						|
		_tlbia();
 | 
						|
		return;
 | 
						|
	}
 | 
						|
 | 
						|
	/*
 | 
						|
	 * It is safe to go down the mm's list of vmas when called
 | 
						|
	 * from dup_mmap, holding mmap_sem.  It would also be safe from
 | 
						|
	 * unmap_region or exit_mmap, but not from vmtruncate on SMP -
 | 
						|
	 * but it seems dup_mmap is the only SMP case which gets here.
 | 
						|
	 */
 | 
						|
	for (mp = mm->mmap; mp != NULL; mp = mp->vm_next)
 | 
						|
		flush_range(mp->vm_mm, mp->vm_start, mp->vm_end);
 | 
						|
}
 | 
						|
EXPORT_SYMBOL(flush_tlb_mm);
 | 
						|
 | 
						|
void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
 | 
						|
{
 | 
						|
	struct mm_struct *mm;
 | 
						|
	pmd_t *pmd;
 | 
						|
 | 
						|
	if (!Hash) {
 | 
						|
		_tlbie(vmaddr);
 | 
						|
		return;
 | 
						|
	}
 | 
						|
	mm = (vmaddr < TASK_SIZE)? vma->vm_mm: &init_mm;
 | 
						|
	pmd = pmd_offset(pud_offset(pgd_offset(mm, vmaddr), vmaddr), vmaddr);
 | 
						|
	if (!pmd_none(*pmd))
 | 
						|
		flush_hash_pages(mm->context.id, vmaddr, pmd_val(*pmd), 1);
 | 
						|
}
 | 
						|
EXPORT_SYMBOL(flush_tlb_page);
 | 
						|
 | 
						|
/*
 | 
						|
 * For each address in the range, find the pte for the address
 | 
						|
 * and check _PAGE_HASHPTE bit; if it is set, find and destroy
 | 
						|
 * the corresponding HPTE.
 | 
						|
 */
 | 
						|
void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 | 
						|
		     unsigned long end)
 | 
						|
{
 | 
						|
	flush_range(vma->vm_mm, start, end);
 | 
						|
}
 | 
						|
EXPORT_SYMBOL(flush_tlb_range);
 | 
						|
 | 
						|
void __init early_init_mmu(void)
 | 
						|
{
 | 
						|
}
 |