2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* This file contains the routines for flushing entries from the
|
|
|
|
* TLB and MMU hash table.
|
|
|
|
*
|
|
|
|
* Derived from arch/ppc64/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
|
|
|
|
*
|
|
|
|
* Dave Engebretsen <engebret@us.ibm.com>
|
|
|
|
* Rework for PPC64 port.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-11-07 00:06:55 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/percpu.h>
|
|
|
|
#include <linux/hardirq.h>
|
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
#include <asm/tlb.h>
|
2005-11-07 00:06:55 +00:00
|
|
|
#include <asm/bug.h>
|
2017-07-27 06:24:53 +00:00
|
|
|
#include <asm/pte-walk.h>
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-08-13 07:02:04 +00:00
|
|
|
#include <trace/events/thp.h>
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
|
|
|
|
|
|
|
|
/*
|
2007-04-10 07:09:37 +00:00
|
|
|
* A linux PTE was changed and the corresponding hash table entry
|
|
|
|
* neesd to be flushed. This function will either perform the flush
|
|
|
|
* immediately or will batch it up if the current CPU has an active
|
|
|
|
* batch on it.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2007-04-10 07:09:37 +00:00
|
|
|
void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
|
|
|
|
pte_t *ptep, unsigned long pte, int huge)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-09-10 02:52:50 +00:00
|
|
|
unsigned long vpn;
|
2011-02-24 10:47:32 +00:00
|
|
|
struct ppc64_tlb_batch *batch = &get_cpu_var(ppc64_tlb_batch);
|
2012-09-10 02:52:50 +00:00
|
|
|
unsigned long vsid;
|
2006-06-15 00:45:18 +00:00
|
|
|
unsigned int psize;
|
2007-10-11 10:37:10 +00:00
|
|
|
int ssize;
|
2007-04-10 07:09:37 +00:00
|
|
|
real_pte_t rpte;
|
2005-09-20 03:52:50 +00:00
|
|
|
int i;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
i = batch->index;
|
|
|
|
|
2007-05-08 06:27:28 +00:00
|
|
|
/* Get page size (maybe move back to caller).
|
|
|
|
*
|
|
|
|
* NOTE: when using special 64K mappings in 4K environment like
|
|
|
|
* for SPEs, we obtain the page size from the slice, which thus
|
|
|
|
* must still exist (and thus the VMA not reused) at the time
|
|
|
|
* of this call
|
|
|
|
*/
|
2005-11-07 00:06:55 +00:00
|
|
|
if (huge) {
|
|
|
|
#ifdef CONFIG_HUGETLB_PAGE
|
2009-06-28 06:26:10 +00:00
|
|
|
psize = get_slice_psize(mm, addr);
|
2010-02-08 20:09:03 +00:00
|
|
|
/* Mask the address for the correct page size */
|
|
|
|
addr &= ~((1UL << mmu_psize_defs[psize].shift) - 1);
|
2005-11-07 00:06:55 +00:00
|
|
|
#else
|
|
|
|
BUG();
|
2007-05-08 06:27:28 +00:00
|
|
|
psize = pte_pagesize_index(mm, addr, pte); /* shutup gcc */
|
2005-11-07 00:06:55 +00:00
|
|
|
#endif
|
2010-02-08 20:09:03 +00:00
|
|
|
} else {
|
2007-05-08 06:27:28 +00:00
|
|
|
psize = pte_pagesize_index(mm, addr, pte);
|
2010-02-08 20:09:03 +00:00
|
|
|
/* Mask the address for the standard page size. If we
|
|
|
|
* have a 64k page kernel, but the hardware does not
|
|
|
|
* support 64k pages, this might be different from the
|
|
|
|
* hardware page size encoded in the slice table. */
|
|
|
|
addr &= PAGE_MASK;
|
|
|
|
}
|
2005-11-07 00:06:55 +00:00
|
|
|
|
2009-10-26 19:24:31 +00:00
|
|
|
|
2007-04-10 07:09:37 +00:00
|
|
|
/* Build full vaddr */
|
|
|
|
if (!is_kernel_addr(addr)) {
|
2007-10-11 10:37:10 +00:00
|
|
|
ssize = user_segment_size(addr);
|
|
|
|
vsid = get_vsid(mm->context.id, addr, ssize);
|
|
|
|
} else {
|
|
|
|
vsid = get_kernel_vsid(addr, mmu_kernel_ssize);
|
|
|
|
ssize = mmu_kernel_ssize;
|
|
|
|
}
|
2013-03-13 03:34:54 +00:00
|
|
|
WARN_ON(vsid == 0);
|
2012-09-10 02:52:50 +00:00
|
|
|
vpn = hpt_vpn(addr, vsid, ssize);
|
2007-04-10 07:09:37 +00:00
|
|
|
rpte = __real_pte(__pte(pte), ptep);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if we have an active batch on this CPU. If not, just
|
2017-05-25 07:28:32 +00:00
|
|
|
* flush now and return.
|
2007-04-10 07:09:37 +00:00
|
|
|
*/
|
|
|
|
if (!batch->active) {
|
2017-05-25 07:28:32 +00:00
|
|
|
flush_hash_page(vpn, rpte, psize, ssize, mm_is_thread_local(mm));
|
2011-02-24 10:47:32 +00:00
|
|
|
put_cpu_var(ppc64_tlb_batch);
|
2007-04-10 07:09:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* This can happen when we are in the middle of a TLB batch and
|
|
|
|
* we encounter memory pressure (eg copy_page_range when it tries
|
|
|
|
* to allocate a new pte). If we have to reclaim memory and end
|
|
|
|
* up scanning and resetting referenced bits then our batch context
|
|
|
|
* will change mid stream.
|
2005-11-07 00:06:55 +00:00
|
|
|
*
|
|
|
|
* We also need to ensure only one page size is present in a given
|
|
|
|
* batch
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2007-10-11 10:37:10 +00:00
|
|
|
if (i != 0 && (mm != batch->mm || batch->psize != psize ||
|
|
|
|
batch->ssize != ssize)) {
|
2007-04-10 07:09:37 +00:00
|
|
|
__flush_tlb_pending(batch);
|
2005-04-16 22:20:36 +00:00
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
if (i == 0) {
|
|
|
|
batch->mm = mm;
|
2005-11-07 00:06:55 +00:00
|
|
|
batch->psize = psize;
|
2007-10-11 10:37:10 +00:00
|
|
|
batch->ssize = ssize;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-04-10 07:09:37 +00:00
|
|
|
batch->pte[i] = rpte;
|
2012-09-10 02:52:50 +00:00
|
|
|
batch->vpn[i] = vpn;
|
2005-04-16 22:20:36 +00:00
|
|
|
batch->index = ++i;
|
|
|
|
if (i >= PPC64_TLB_BATCH_NR)
|
2007-04-10 07:09:37 +00:00
|
|
|
__flush_tlb_pending(batch);
|
2011-02-24 10:47:32 +00:00
|
|
|
put_cpu_var(ppc64_tlb_batch);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-04-10 07:09:37 +00:00
|
|
|
/*
|
|
|
|
* This function is called when terminating an mmu batch or when a batch
|
|
|
|
* is full. It will perform the flush of all the entries currently stored
|
|
|
|
* in a batch.
|
|
|
|
*
|
|
|
|
* Must be called from within some kind of spinlock/non-preempt region...
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
void __flush_tlb_pending(struct ppc64_tlb_batch *batch)
|
|
|
|
{
|
2017-07-24 04:28:01 +00:00
|
|
|
int i, local;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
i = batch->index;
|
2017-07-24 04:28:01 +00:00
|
|
|
local = mm_is_thread_local(batch->mm);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (i == 1)
|
2012-09-10 02:52:50 +00:00
|
|
|
flush_hash_page(batch->vpn[0], batch->pte[0],
|
2007-10-11 10:37:10 +00:00
|
|
|
batch->psize, batch->ssize, local);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2005-09-20 03:52:50 +00:00
|
|
|
flush_hash_range(i, local);
|
2005-04-16 22:20:36 +00:00
|
|
|
batch->index = 0;
|
|
|
|
}
|
|
|
|
|
2016-04-29 13:26:04 +00:00
|
|
|
void hash__tlb_flush(struct mmu_gather *tlb)
|
2009-07-23 23:15:28 +00:00
|
|
|
{
|
2011-05-25 00:11:48 +00:00
|
|
|
struct ppc64_tlb_batch *tlbbatch = &get_cpu_var(ppc64_tlb_batch);
|
2009-07-23 23:15:28 +00:00
|
|
|
|
|
|
|
/* If there's a TLB batch pending, then we must flush it because the
|
|
|
|
* pages are going to be freed and we really don't want to have a CPU
|
|
|
|
* access a freed page because it has a stale TLB
|
|
|
|
*/
|
|
|
|
if (tlbbatch->index)
|
|
|
|
__flush_tlb_pending(tlbbatch);
|
|
|
|
|
2011-05-25 00:11:48 +00:00
|
|
|
put_cpu_var(ppc64_tlb_batch);
|
2009-07-23 23:15:28 +00:00
|
|
|
}
|
|
|
|
|
[POWERPC] Rewrite IO allocation & mapping on powerpc64
This rewrites pretty much from scratch the handling of MMIO and PIO
space allocations on powerpc64. The main goals are:
- Get rid of imalloc and use more common code where possible
- Simplify the current mess so that PIO space is allocated and
mapped in a single place for PCI bridges
- Handle allocation constraints of PIO for all bridges including
hot plugged ones within the 2GB space reserved for IO ports,
so that devices on hotplugged busses will now work with drivers
that assume IO ports fit in an int.
- Cleanup and separate tracking of the ISA space in the reserved
low 64K of IO space. No ISA -> Nothing mapped there.
I booted a cell blade with IDE on PIO and MMIO and a dual G5 so
far, that's it :-)
With this patch, all allocations are done using the code in
mm/vmalloc.c, though we use the low level __get_vm_area with
explicit start/stop constraints in order to manage separate
areas for vmalloc/vmap, ioremap, and PCI IOs.
This greatly simplifies a lot of things, as you can see in the
diffstat of that patch :-)
A new pair of functions pcibios_map/unmap_io_space() now replace
all of the previous code that used to manipulate PCI IOs space.
The allocation is done at mapping time, which is now called from
scan_phb's, just before the devices are probed (instead of after,
which is by itself a bug fix). The only other caller is the PCI
hotplug code for hot adding PCI-PCI bridges (slots).
imalloc is gone, as is the "sub-allocation" thing, but I do beleive
that hotplug should still work in the sense that the space allocation
is always done by the PHB, but if you unmap a child bus of this PHB
(which seems to be possible), then the code should properly tear
down all the HPTE mappings for that area of the PHB allocated IO space.
I now always reserve the first 64K of IO space for the bridge with
the ISA bus on it. I have moved the code for tracking ISA in a separate
file which should also make it smarter if we ever are capable of
hot unplugging or re-plugging an ISA bridge.
This should have a side effect on platforms like powermac where VGA IOs
will no longer work. This is done on purpose though as they would have
worked semi-randomly before. The idea at this point is to isolate drivers
that might need to access those and fix them by providing a proper
function to obtain an offset to the legacy IOs of a given bus.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-06-04 05:15:36 +00:00
|
|
|
/**
|
|
|
|
* __flush_hash_table_range - Flush all HPTEs for a given address range
|
|
|
|
* from the hash table (and the TLB). But keeps
|
|
|
|
* the linux PTEs intact.
|
|
|
|
*
|
|
|
|
* @mm : mm_struct of the target address space (generally init_mm)
|
|
|
|
* @start : starting address
|
|
|
|
* @end : ending address (not included in the flush)
|
|
|
|
*
|
|
|
|
* This function is mostly to be used by some IO hotplug code in order
|
|
|
|
* to remove all hash entries from a given address range used to map IO
|
|
|
|
* space on a removed PCI-PCI bidge without tearing down the full mapping
|
|
|
|
* since 64K pages may overlap with other bridges when using 64K pages
|
|
|
|
* with 4K HW pages on IO space.
|
|
|
|
*
|
2013-05-21 03:49:35 +00:00
|
|
|
* Because of that usage pattern, it is implemented for small size rather
|
|
|
|
* than speed.
|
[POWERPC] Rewrite IO allocation & mapping on powerpc64
This rewrites pretty much from scratch the handling of MMIO and PIO
space allocations on powerpc64. The main goals are:
- Get rid of imalloc and use more common code where possible
- Simplify the current mess so that PIO space is allocated and
mapped in a single place for PCI bridges
- Handle allocation constraints of PIO for all bridges including
hot plugged ones within the 2GB space reserved for IO ports,
so that devices on hotplugged busses will now work with drivers
that assume IO ports fit in an int.
- Cleanup and separate tracking of the ISA space in the reserved
low 64K of IO space. No ISA -> Nothing mapped there.
I booted a cell blade with IDE on PIO and MMIO and a dual G5 so
far, that's it :-)
With this patch, all allocations are done using the code in
mm/vmalloc.c, though we use the low level __get_vm_area with
explicit start/stop constraints in order to manage separate
areas for vmalloc/vmap, ioremap, and PCI IOs.
This greatly simplifies a lot of things, as you can see in the
diffstat of that patch :-)
A new pair of functions pcibios_map/unmap_io_space() now replace
all of the previous code that used to manipulate PCI IOs space.
The allocation is done at mapping time, which is now called from
scan_phb's, just before the devices are probed (instead of after,
which is by itself a bug fix). The only other caller is the PCI
hotplug code for hot adding PCI-PCI bridges (slots).
imalloc is gone, as is the "sub-allocation" thing, but I do beleive
that hotplug should still work in the sense that the space allocation
is always done by the PHB, but if you unmap a child bus of this PHB
(which seems to be possible), then the code should properly tear
down all the HPTE mappings for that area of the PHB allocated IO space.
I now always reserve the first 64K of IO space for the bridge with
the ISA bus on it. I have moved the code for tracking ISA in a separate
file which should also make it smarter if we ever are capable of
hot unplugging or re-plugging an ISA bridge.
This should have a side effect on platforms like powermac where VGA IOs
will no longer work. This is done on purpose though as they would have
worked semi-randomly before. The idea at this point is to isolate drivers
that might need to access those and fix them by providing a proper
function to obtain an offset to the legacy IOs of a given bus.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-06-04 05:15:36 +00:00
|
|
|
*/
|
|
|
|
void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
|
|
|
|
unsigned long end)
|
|
|
|
{
|
2015-10-09 03:02:21 +00:00
|
|
|
bool is_thp;
|
2013-06-20 09:00:18 +00:00
|
|
|
int hugepage_shift;
|
[POWERPC] Rewrite IO allocation & mapping on powerpc64
This rewrites pretty much from scratch the handling of MMIO and PIO
space allocations on powerpc64. The main goals are:
- Get rid of imalloc and use more common code where possible
- Simplify the current mess so that PIO space is allocated and
mapped in a single place for PCI bridges
- Handle allocation constraints of PIO for all bridges including
hot plugged ones within the 2GB space reserved for IO ports,
so that devices on hotplugged busses will now work with drivers
that assume IO ports fit in an int.
- Cleanup and separate tracking of the ISA space in the reserved
low 64K of IO space. No ISA -> Nothing mapped there.
I booted a cell blade with IDE on PIO and MMIO and a dual G5 so
far, that's it :-)
With this patch, all allocations are done using the code in
mm/vmalloc.c, though we use the low level __get_vm_area with
explicit start/stop constraints in order to manage separate
areas for vmalloc/vmap, ioremap, and PCI IOs.
This greatly simplifies a lot of things, as you can see in the
diffstat of that patch :-)
A new pair of functions pcibios_map/unmap_io_space() now replace
all of the previous code that used to manipulate PCI IOs space.
The allocation is done at mapping time, which is now called from
scan_phb's, just before the devices are probed (instead of after,
which is by itself a bug fix). The only other caller is the PCI
hotplug code for hot adding PCI-PCI bridges (slots).
imalloc is gone, as is the "sub-allocation" thing, but I do beleive
that hotplug should still work in the sense that the space allocation
is always done by the PHB, but if you unmap a child bus of this PHB
(which seems to be possible), then the code should properly tear
down all the HPTE mappings for that area of the PHB allocated IO space.
I now always reserve the first 64K of IO space for the bridge with
the ISA bus on it. I have moved the code for tracking ISA in a separate
file which should also make it smarter if we ever are capable of
hot unplugging or re-plugging an ISA bridge.
This should have a side effect on platforms like powermac where VGA IOs
will no longer work. This is done on purpose though as they would have
worked semi-randomly before. The idea at this point is to isolate drivers
that might need to access those and fix them by providing a proper
function to obtain an offset to the legacy IOs of a given bus.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-06-04 05:15:36 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
start = _ALIGN_DOWN(start, PAGE_SIZE);
|
|
|
|
end = _ALIGN_UP(end, PAGE_SIZE);
|
|
|
|
|
|
|
|
BUG_ON(!mm->pgd);
|
|
|
|
|
|
|
|
/* Note: Normally, we should only ever use a batch within a
|
|
|
|
* PTE locked section. This violates the rule, but will work
|
|
|
|
* since we don't actually modify the PTEs, we just flush the
|
|
|
|
* hash while leaving the PTEs intact (including their reference
|
|
|
|
* to being hashed). This is not the most performance oriented
|
|
|
|
* way to do things but is fine for our needs here.
|
|
|
|
*/
|
|
|
|
local_irq_save(flags);
|
|
|
|
arch_enter_lazy_mmu_mode();
|
|
|
|
for (; start < end; start += PAGE_SIZE) {
|
2017-07-27 06:24:53 +00:00
|
|
|
pte_t *ptep = find_current_mm_pte(mm->pgd, start, &is_thp,
|
|
|
|
&hugepage_shift);
|
[POWERPC] Rewrite IO allocation & mapping on powerpc64
This rewrites pretty much from scratch the handling of MMIO and PIO
space allocations on powerpc64. The main goals are:
- Get rid of imalloc and use more common code where possible
- Simplify the current mess so that PIO space is allocated and
mapped in a single place for PCI bridges
- Handle allocation constraints of PIO for all bridges including
hot plugged ones within the 2GB space reserved for IO ports,
so that devices on hotplugged busses will now work with drivers
that assume IO ports fit in an int.
- Cleanup and separate tracking of the ISA space in the reserved
low 64K of IO space. No ISA -> Nothing mapped there.
I booted a cell blade with IDE on PIO and MMIO and a dual G5 so
far, that's it :-)
With this patch, all allocations are done using the code in
mm/vmalloc.c, though we use the low level __get_vm_area with
explicit start/stop constraints in order to manage separate
areas for vmalloc/vmap, ioremap, and PCI IOs.
This greatly simplifies a lot of things, as you can see in the
diffstat of that patch :-)
A new pair of functions pcibios_map/unmap_io_space() now replace
all of the previous code that used to manipulate PCI IOs space.
The allocation is done at mapping time, which is now called from
scan_phb's, just before the devices are probed (instead of after,
which is by itself a bug fix). The only other caller is the PCI
hotplug code for hot adding PCI-PCI bridges (slots).
imalloc is gone, as is the "sub-allocation" thing, but I do beleive
that hotplug should still work in the sense that the space allocation
is always done by the PHB, but if you unmap a child bus of this PHB
(which seems to be possible), then the code should properly tear
down all the HPTE mappings for that area of the PHB allocated IO space.
I now always reserve the first 64K of IO space for the bridge with
the ISA bus on it. I have moved the code for tracking ISA in a separate
file which should also make it smarter if we ever are capable of
hot unplugging or re-plugging an ISA bridge.
This should have a side effect on platforms like powermac where VGA IOs
will no longer work. This is done on purpose though as they would have
worked semi-randomly before. The idea at this point is to isolate drivers
that might need to access those and fix them by providing a proper
function to obtain an offset to the legacy IOs of a given bus.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-06-04 05:15:36 +00:00
|
|
|
unsigned long pte;
|
|
|
|
|
|
|
|
if (ptep == NULL)
|
|
|
|
continue;
|
|
|
|
pte = pte_val(*ptep);
|
2015-10-09 03:02:21 +00:00
|
|
|
if (is_thp)
|
2015-03-25 09:11:57 +00:00
|
|
|
trace_hugepage_invalidate(start, pte);
|
2016-04-29 13:25:45 +00:00
|
|
|
if (!(pte & H_PAGE_HASHPTE))
|
[POWERPC] Rewrite IO allocation & mapping on powerpc64
This rewrites pretty much from scratch the handling of MMIO and PIO
space allocations on powerpc64. The main goals are:
- Get rid of imalloc and use more common code where possible
- Simplify the current mess so that PIO space is allocated and
mapped in a single place for PCI bridges
- Handle allocation constraints of PIO for all bridges including
hot plugged ones within the 2GB space reserved for IO ports,
so that devices on hotplugged busses will now work with drivers
that assume IO ports fit in an int.
- Cleanup and separate tracking of the ISA space in the reserved
low 64K of IO space. No ISA -> Nothing mapped there.
I booted a cell blade with IDE on PIO and MMIO and a dual G5 so
far, that's it :-)
With this patch, all allocations are done using the code in
mm/vmalloc.c, though we use the low level __get_vm_area with
explicit start/stop constraints in order to manage separate
areas for vmalloc/vmap, ioremap, and PCI IOs.
This greatly simplifies a lot of things, as you can see in the
diffstat of that patch :-)
A new pair of functions pcibios_map/unmap_io_space() now replace
all of the previous code that used to manipulate PCI IOs space.
The allocation is done at mapping time, which is now called from
scan_phb's, just before the devices are probed (instead of after,
which is by itself a bug fix). The only other caller is the PCI
hotplug code for hot adding PCI-PCI bridges (slots).
imalloc is gone, as is the "sub-allocation" thing, but I do beleive
that hotplug should still work in the sense that the space allocation
is always done by the PHB, but if you unmap a child bus of this PHB
(which seems to be possible), then the code should properly tear
down all the HPTE mappings for that area of the PHB allocated IO space.
I now always reserve the first 64K of IO space for the bridge with
the ISA bus on it. I have moved the code for tracking ISA in a separate
file which should also make it smarter if we ever are capable of
hot unplugging or re-plugging an ISA bridge.
This should have a side effect on platforms like powermac where VGA IOs
will no longer work. This is done on purpose though as they would have
worked semi-randomly before. The idea at this point is to isolate drivers
that might need to access those and fix them by providing a proper
function to obtain an offset to the legacy IOs of a given bus.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-06-04 05:15:36 +00:00
|
|
|
continue;
|
2015-10-09 03:02:21 +00:00
|
|
|
if (unlikely(is_thp))
|
2014-08-13 07:02:00 +00:00
|
|
|
hpte_do_hugepage_flush(mm, start, (pmd_t *)ptep, pte);
|
2013-06-20 09:00:18 +00:00
|
|
|
else
|
2015-10-09 03:02:21 +00:00
|
|
|
hpte_need_flush(mm, start, ptep, pte, hugepage_shift);
|
[POWERPC] Rewrite IO allocation & mapping on powerpc64
This rewrites pretty much from scratch the handling of MMIO and PIO
space allocations on powerpc64. The main goals are:
- Get rid of imalloc and use more common code where possible
- Simplify the current mess so that PIO space is allocated and
mapped in a single place for PCI bridges
- Handle allocation constraints of PIO for all bridges including
hot plugged ones within the 2GB space reserved for IO ports,
so that devices on hotplugged busses will now work with drivers
that assume IO ports fit in an int.
- Cleanup and separate tracking of the ISA space in the reserved
low 64K of IO space. No ISA -> Nothing mapped there.
I booted a cell blade with IDE on PIO and MMIO and a dual G5 so
far, that's it :-)
With this patch, all allocations are done using the code in
mm/vmalloc.c, though we use the low level __get_vm_area with
explicit start/stop constraints in order to manage separate
areas for vmalloc/vmap, ioremap, and PCI IOs.
This greatly simplifies a lot of things, as you can see in the
diffstat of that patch :-)
A new pair of functions pcibios_map/unmap_io_space() now replace
all of the previous code that used to manipulate PCI IOs space.
The allocation is done at mapping time, which is now called from
scan_phb's, just before the devices are probed (instead of after,
which is by itself a bug fix). The only other caller is the PCI
hotplug code for hot adding PCI-PCI bridges (slots).
imalloc is gone, as is the "sub-allocation" thing, but I do beleive
that hotplug should still work in the sense that the space allocation
is always done by the PHB, but if you unmap a child bus of this PHB
(which seems to be possible), then the code should properly tear
down all the HPTE mappings for that area of the PHB allocated IO space.
I now always reserve the first 64K of IO space for the bridge with
the ISA bus on it. I have moved the code for tracking ISA in a separate
file which should also make it smarter if we ever are capable of
hot unplugging or re-plugging an ISA bridge.
This should have a side effect on platforms like powermac where VGA IOs
will no longer work. This is done on purpose though as they would have
worked semi-randomly before. The idea at this point is to isolate drivers
that might need to access those and fix them by providing a proper
function to obtain an offset to the legacy IOs of a given bus.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-06-04 05:15:36 +00:00
|
|
|
}
|
|
|
|
arch_leave_lazy_mmu_mode();
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
2013-06-20 09:00:15 +00:00
|
|
|
|
|
|
|
void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd, unsigned long addr)
|
|
|
|
{
|
|
|
|
pte_t *pte;
|
|
|
|
pte_t *start_pte;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
addr = _ALIGN_DOWN(addr, PMD_SIZE);
|
|
|
|
/* Note: Normally, we should only ever use a batch within a
|
|
|
|
* PTE locked section. This violates the rule, but will work
|
|
|
|
* since we don't actually modify the PTEs, we just flush the
|
|
|
|
* hash while leaving the PTEs intact (including their reference
|
|
|
|
* to being hashed). This is not the most performance oriented
|
|
|
|
* way to do things but is fine for our needs here.
|
|
|
|
*/
|
|
|
|
local_irq_save(flags);
|
|
|
|
arch_enter_lazy_mmu_mode();
|
|
|
|
start_pte = pte_offset_map(pmd, addr);
|
|
|
|
for (pte = start_pte; pte < start_pte + PTRS_PER_PTE; pte++) {
|
|
|
|
unsigned long pteval = pte_val(*pte);
|
2016-04-29 13:25:45 +00:00
|
|
|
if (pteval & H_PAGE_HASHPTE)
|
2013-06-20 09:00:15 +00:00
|
|
|
hpte_need_flush(mm, addr, pte, pteval, 0);
|
|
|
|
addr += PAGE_SIZE;
|
[POWERPC] Rewrite IO allocation & mapping on powerpc64
This rewrites pretty much from scratch the handling of MMIO and PIO
space allocations on powerpc64. The main goals are:
- Get rid of imalloc and use more common code where possible
- Simplify the current mess so that PIO space is allocated and
mapped in a single place for PCI bridges
- Handle allocation constraints of PIO for all bridges including
hot plugged ones within the 2GB space reserved for IO ports,
so that devices on hotplugged busses will now work with drivers
that assume IO ports fit in an int.
- Cleanup and separate tracking of the ISA space in the reserved
low 64K of IO space. No ISA -> Nothing mapped there.
I booted a cell blade with IDE on PIO and MMIO and a dual G5 so
far, that's it :-)
With this patch, all allocations are done using the code in
mm/vmalloc.c, though we use the low level __get_vm_area with
explicit start/stop constraints in order to manage separate
areas for vmalloc/vmap, ioremap, and PCI IOs.
This greatly simplifies a lot of things, as you can see in the
diffstat of that patch :-)
A new pair of functions pcibios_map/unmap_io_space() now replace
all of the previous code that used to manipulate PCI IOs space.
The allocation is done at mapping time, which is now called from
scan_phb's, just before the devices are probed (instead of after,
which is by itself a bug fix). The only other caller is the PCI
hotplug code for hot adding PCI-PCI bridges (slots).
imalloc is gone, as is the "sub-allocation" thing, but I do beleive
that hotplug should still work in the sense that the space allocation
is always done by the PHB, but if you unmap a child bus of this PHB
(which seems to be possible), then the code should properly tear
down all the HPTE mappings for that area of the PHB allocated IO space.
I now always reserve the first 64K of IO space for the bridge with
the ISA bus on it. I have moved the code for tracking ISA in a separate
file which should also make it smarter if we ever are capable of
hot unplugging or re-plugging an ISA bridge.
This should have a side effect on platforms like powermac where VGA IOs
will no longer work. This is done on purpose though as they would have
worked semi-randomly before. The idea at this point is to isolate drivers
that might need to access those and fix them by providing a proper
function to obtain an offset to the legacy IOs of a given bus.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-06-04 05:15:36 +00:00
|
|
|
}
|
|
|
|
arch_leave_lazy_mmu_mode();
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|