* [PATCH v2] /dev/mem: use phys_addr_t for physical addresses
@ 2012-09-12 18:05 Cyril Chemparathy
2012-09-12 18:15 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Chemparathy @ 2012-09-12 18:05 UTC (permalink / raw)
To: linux-arm-kernel
This patch fixes the /dev/mem driver to use phys_addr_t for physical
addresses. This is required on PAE systems, especially those that run
entirely out of >4G physical memory space.
Signed-off-by: Cyril Chemparathy <cyril@ti•com>
---
arch/arm/include/asm/io.h | 2 +-
arch/arm/mm/mmap.c | 2 +-
arch/ia64/include/asm/io.h | 2 +-
arch/ia64/kernel/efi.c | 2 +-
arch/sh/include/asm/io.h | 2 +-
arch/sh/mm/mmap.c | 2 +-
drivers/char/mem.c | 10 +++++-----
7 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 35c1ed8..f52a93d 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -374,7 +374,7 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
#ifdef CONFIG_MMU
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
-extern int valid_phys_addr_range(unsigned long addr, size_t size);
+extern int valid_phys_addr_range(phys_addr_t addr, size_t size);
extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
extern int devmem_is_allowed(unsigned long pfn);
#endif
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index ce8cb19..89f2b7f 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -279,7 +279,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
* You really shouldn't be using read() or write() on /dev/mem. This
* might go away in the future.
*/
-int valid_phys_addr_range(unsigned long addr, size_t size)
+int valid_phys_addr_range(phys_addr_t addr, size_t size)
{
if (addr < PHYS_OFFSET)
return 0;
diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h
index 2c26321..74a7cc3 100644
--- a/arch/ia64/include/asm/io.h
+++ b/arch/ia64/include/asm/io.h
@@ -90,7 +90,7 @@ phys_to_virt (unsigned long address)
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
extern u64 kern_mem_attribute (unsigned long phys_addr, unsigned long size);
-extern int valid_phys_addr_range (unsigned long addr, size_t count); /* efi.c */
+extern int valid_phys_addr_range (phys_addr_t addr, size_t count); /* efi.c */
extern int valid_mmap_phys_addr_range (unsigned long pfn, size_t count);
/*
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c
index d37bbd4..f034563 100644
--- a/arch/ia64/kernel/efi.c
+++ b/arch/ia64/kernel/efi.c
@@ -870,7 +870,7 @@ kern_mem_attribute (unsigned long phys_addr, unsigned long size)
EXPORT_SYMBOL(kern_mem_attribute);
int
-valid_phys_addr_range (unsigned long phys_addr, unsigned long size)
+valid_phys_addr_range (phys_addr_t phys_addr, unsigned long size)
{
u64 attr;
diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index 0cf60a6..c4302a5 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -382,7 +382,7 @@ static inline int iounmap_fixed(void __iomem *addr) { return -EINVAL; }
#define xlate_dev_kmem_ptr(p) p
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
-int valid_phys_addr_range(unsigned long addr, size_t size);
+int valid_phys_addr_range(phys_addr_t addr, size_t size);
int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
#endif /* __KERNEL__ */
diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
index afeb710..80bf494 100644
--- a/arch/sh/mm/mmap.c
+++ b/arch/sh/mm/mmap.c
@@ -238,7 +238,7 @@ bottomup:
* You really shouldn't be using read() or write() on /dev/mem. This
* might go away in the future.
*/
-int valid_phys_addr_range(unsigned long addr, size_t count)
+int valid_phys_addr_range(phys_addr_t addr, size_t count)
{
if (addr < __MEMORY_START)
return 0;
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 0537903..c6fa3bc 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -48,7 +48,7 @@ static inline unsigned long size_inside_page(unsigned long start,
}
#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
-static inline int valid_phys_addr_range(unsigned long addr, size_t count)
+static inline int valid_phys_addr_range(phys_addr_t addr, size_t count)
{
return addr + count <= __pa(high_memory);
}
@@ -96,7 +96,7 @@ void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr)
static ssize_t read_mem(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
- unsigned long p = *ppos;
+ phys_addr_t p = *ppos;
ssize_t read, sz;
char *ptr;
@@ -153,7 +153,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
static ssize_t write_mem(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
- unsigned long p = *ppos;
+ phys_addr_t p = *ppos;
ssize_t written, sz;
unsigned long copied;
void *ptr;
@@ -226,7 +226,7 @@ int __weak phys_mem_access_prot_allowed(struct file *file,
*
*/
#ifdef pgprot_noncached
-static int uncached_access(struct file *file, unsigned long addr)
+static int uncached_access(struct file *file, phys_addr_t addr)
{
#if defined(CONFIG_IA64)
/*
@@ -258,7 +258,7 @@ static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
unsigned long size, pgprot_t vma_prot)
{
#ifdef pgprot_noncached
- unsigned long offset = pfn << PAGE_SHIFT;
+ phys_addr_t offset = pfn << PAGE_SHIFT;
if (uncached_access(file, offset))
return pgprot_noncached(vma_prot);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v2] /dev/mem: use phys_addr_t for physical addresses
2012-09-12 18:05 [PATCH v2] /dev/mem: use phys_addr_t for physical addresses Cyril Chemparathy
@ 2012-09-12 18:15 ` Greg KH
2012-09-12 22:54 ` Cyril Chemparathy
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2012-09-12 18:15 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Sep 12, 2012 at 02:05:58PM -0400, Cyril Chemparathy wrote:
> This patch fixes the /dev/mem driver to use phys_addr_t for physical
> addresses. This is required on PAE systems, especially those that run
> entirely out of >4G physical memory space.
What is the symptom if this patch is not applied? Does it need to be
backported to older kernels? If so, which ones?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] /dev/mem: use phys_addr_t for physical addresses
2012-09-12 18:15 ` Greg KH
@ 2012-09-12 22:54 ` Cyril Chemparathy
0 siblings, 0 replies; 3+ messages in thread
From: Cyril Chemparathy @ 2012-09-12 22:54 UTC (permalink / raw)
To: linux-arm-kernel
Greg,
On 9/12/2012 2:15 PM, Greg KH wrote:
> On Wed, Sep 12, 2012 at 02:05:58PM -0400, Cyril Chemparathy wrote:
>> This patch fixes the /dev/mem driver to use phys_addr_t for physical
>> addresses. This is required on PAE systems, especially those that run
>> entirely out of >4G physical memory space.
>
> What is the symptom if this patch is not applied? Does it need to be
> backported to older kernels? If so, which ones?
>
As far as I can tell, this change only benefits platforms where lowmem
lies outside the 32-bit addressable range. On the ARM based KeyStone
platform, all of our memory is located above the 4GB limit at
0x8:0000:0000. On this platform, trying to read lowmem breaks as follows:
# dd if==/dev/mem of=/dev/null bs==4k count=1 skip=8388608
dd: /dev/mem: Bad address
Assuming that we are unique in this regard (i.e. lowmem outside 4GB), I
don't see any reason to backport this to earlier kernels.
--
Thanks
- Cyril
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-12 22:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-12 18:05 [PATCH v2] /dev/mem: use phys_addr_t for physical addresses Cyril Chemparathy
2012-09-12 18:15 ` Greg KH
2012-09-12 22:54 ` Cyril Chemparathy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox