Commit 28df82eb authored by venkatesh.pallipadi@intel.com's avatar venkatesh.pallipadi@intel.com Committed by Ingo Molnar

devmem, x86: PAT Change /dev/mem mmap with O_SYNC to use UC_MINUS

All kernel mappings like ioremap(), etc uses UC_MINUS as the type. /dev/mem
mappings with /dev/mem being opened with O_SYNC however was using UC,
resulting in a conflict with /dev/mem mmap failing. This seems to be
affecting some apps (one being flashrom) which are using O_SYNC and which were
working before.

Switch /dev/mem with O_SYNC also to UC_MINUS.
Signed-off-by: default avatarVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent c15238df
...@@ -390,14 +390,6 @@ int free_memtype(u64 start, u64 end) ...@@ -390,14 +390,6 @@ int free_memtype(u64 start, u64 end)
} }
/*
* /dev/mem mmap interface. The memtype used for mapping varies:
* - Use UC for mappings with O_SYNC flag
* - Without O_SYNC flag, if there is any conflict in reserve_memtype,
* inherit the memtype from existing mapping.
* - Else use UC_MINUS memtype (for backward compatibility with existing
* X drivers.
*/
pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
unsigned long size, pgprot_t vma_prot) unsigned long size, pgprot_t vma_prot)
{ {
...@@ -435,14 +427,14 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, ...@@ -435,14 +427,14 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
unsigned long size, pgprot_t *vma_prot) unsigned long size, pgprot_t *vma_prot)
{ {
u64 offset = ((u64) pfn) << PAGE_SHIFT; u64 offset = ((u64) pfn) << PAGE_SHIFT;
unsigned long flags = _PAGE_CACHE_UC_MINUS; unsigned long flags = -1;
int retval; int retval;
if (!range_is_allowed(pfn, size)) if (!range_is_allowed(pfn, size))
return 0; return 0;
if (file->f_flags & O_SYNC) { if (file->f_flags & O_SYNC) {
flags = _PAGE_CACHE_UC; flags = _PAGE_CACHE_UC_MINUS;
} }
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
...@@ -465,13 +457,14 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, ...@@ -465,13 +457,14 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
#endif #endif
/* /*
* With O_SYNC, we can only take UC mapping. Fail if we cannot. * With O_SYNC, we can only take UC_MINUS mapping. Fail if we cannot.
*
* Without O_SYNC, we want to get * Without O_SYNC, we want to get
* - WB for WB-able memory and no other conflicting mappings * - WB for WB-able memory and no other conflicting mappings
* - UC_MINUS for non-WB-able memory with no other conflicting mappings * - UC_MINUS for non-WB-able memory with no other conflicting mappings
* - Inherit from confliting mappings otherwise * - Inherit from confliting mappings otherwise
*/ */
if (flags != _PAGE_CACHE_UC_MINUS) { if (flags != -1) {
retval = reserve_memtype(offset, offset + size, flags, NULL); retval = reserve_memtype(offset, offset + size, flags, NULL);
} else { } else {
retval = reserve_memtype(offset, offset + size, -1, &flags); retval = reserve_memtype(offset, offset + size, -1, &flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment