mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
x86, PAT: Remove duplicate memtype reserve in pci mmap
pci mmap code was doing memtype reserve for a while now. Recently we added memtype tracking in remap_pfn_range, and pci code indirectly calls remap_pfn_range. So, we don't need seperate tracking in pci code anymore. Which means a patch that removes ~50 lines of code :-). Also, recently we found out that the pci tracking is not working as we expect it to work in some cases. Specifically, userlevel X mmap of pci, with some recent version of X, is having a problem with vm_page_prot getting reset. The pci tracking uses vm_page_prot to pass on the protection type from parent to child during fork. a) Parent does a pci mmap b) We look at PAT and get either UC_MINUS or WC mapping for parent c) Store that mapping type in vma vm_page_prot for future use d) This thread does a fork e) Fork results in mmap_ops ->open for the child process f) We get the vm_page_prot from vma and reserve that type for the child process But, between c) and e) above, the vma vm_page_prot is getting reset to zero. This results in PAT reserve failing at the time of fork as in here. http://marc.info/?l=linux-kernel&m=123858163103240&w=2 This cleanup makes the above problem go away as we do not depend on vm_page_prot in our PAT code anymore. Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
78609a812e
commit
5a3ae27605
@ -258,24 +258,7 @@ void pcibios_set_master(struct pci_dev *dev)
|
||||
pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
|
||||
}
|
||||
|
||||
static void pci_unmap_page_range(struct vm_area_struct *vma)
|
||||
{
|
||||
u64 addr = (u64)vma->vm_pgoff << PAGE_SHIFT;
|
||||
free_memtype(addr, addr + vma->vm_end - vma->vm_start);
|
||||
}
|
||||
|
||||
static void pci_track_mmap_page_range(struct vm_area_struct *vma)
|
||||
{
|
||||
u64 addr = (u64)vma->vm_pgoff << PAGE_SHIFT;
|
||||
unsigned long flags = pgprot_val(vma->vm_page_prot)
|
||||
& _PAGE_CACHE_MASK;
|
||||
|
||||
reserve_memtype(addr, addr + vma->vm_end - vma->vm_start, flags, NULL);
|
||||
}
|
||||
|
||||
static struct vm_operations_struct pci_mmap_ops = {
|
||||
.open = pci_track_mmap_page_range,
|
||||
.close = pci_unmap_page_range,
|
||||
.access = generic_access_phys,
|
||||
};
|
||||
|
||||
@ -283,11 +266,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
|
||||
enum pci_mmap_state mmap_state, int write_combine)
|
||||
{
|
||||
unsigned long prot;
|
||||
u64 addr = vma->vm_pgoff << PAGE_SHIFT;
|
||||
unsigned long len = vma->vm_end - vma->vm_start;
|
||||
unsigned long flags;
|
||||
unsigned long new_flags;
|
||||
int retval;
|
||||
|
||||
/* I/O space cannot be accessed via normal processor loads and
|
||||
* stores on this platform.
|
||||
@ -308,30 +286,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
|
||||
|
||||
vma->vm_page_prot = __pgprot(prot);
|
||||
|
||||
flags = pgprot_val(vma->vm_page_prot) & _PAGE_CACHE_MASK;
|
||||
retval = reserve_memtype(addr, addr + len, flags, &new_flags);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
if (flags != new_flags) {
|
||||
if (!is_new_memtype_allowed(flags, new_flags)) {
|
||||
free_memtype(addr, addr+len);
|
||||
return -EINVAL;
|
||||
}
|
||||
flags = new_flags;
|
||||
vma->vm_page_prot = __pgprot(
|
||||
(pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK) |
|
||||
flags);
|
||||
}
|
||||
|
||||
if (((vma->vm_pgoff < max_low_pfn_mapped) ||
|
||||
(vma->vm_pgoff >= (1UL<<(32 - PAGE_SHIFT)) &&
|
||||
vma->vm_pgoff < max_pfn_mapped)) &&
|
||||
ioremap_change_attr((unsigned long)__va(addr), len, flags)) {
|
||||
free_memtype(addr, addr + len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
|
||||
vma->vm_end - vma->vm_start,
|
||||
vma->vm_page_prot))
|
||||
|
Loading…
Reference in New Issue
Block a user