* [PATCH] cleanup hardcoding __pa/__va macros etc.
@ 2006-09-24 5:39 girish
2006-09-24 7:15 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (FWD) girish
2006-09-24 15:26 ` [PATCH] cleanup hardcoding __pa/__va macros etc Atsushi Nemoto
0 siblings, 2 replies; 20+ messages in thread
From: girish @ 2006-09-24 5:39 UTC (permalink / raw)
To: linux-mips
hello.
here is a patch to cleanup some hard coded lines.
plese let me know if these are valid changes.
thanks.
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/arch/mips/mm/dma-noncoherent.c
linux/arch/mips/mm/dma-noncoherent.c
--- linux-vanilla/arch/mips/mm/dma-noncoherent.c 2006-09-24
12:22:46.000000000 +0900
+++ linux/arch/mips/mm/dma-noncoherent.c 2006-09-24 12:20:35.000000000 +0900
@@ -334,7 +334,7 @@ EXPORT_SYMBOL(pci_dac_page_to_dma);
struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
dma64_addr_t dma_addr)
{
- return mem_map + (dma_addr >> PAGE_SHIFT);
+ return pfn_to_page (dma_addr >> PAGE_SHIFT);
}
EXPORT_SYMBOL(pci_dac_dma_to_page);
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/arch/mips/mm/init.c linux/arch/mips/mm/init.c
--- linux-vanilla/arch/mips/mm/init.c 2006-09-24 12:22:46.000000000 +0900
+++ linux/arch/mips/mm/init.c 2006-09-24 14:23:56.000000000 +0900
@@ -155,24 +155,22 @@ void __init paging_init(void)
low = max_low_pfn;
high = highend_pfn;
-#ifdef CONFIG_ISA
- if (low < max_dma)
+ if (low < max_dma) {
zones_size[ZONE_DMA] = low;
- else {
+ } else {
zones_size[ZONE_DMA] = max_dma;
zones_size[ZONE_NORMAL] = low - max_dma;
}
-#else
- zones_size[ZONE_DMA] = low;
-#endif
+
#ifdef CONFIG_HIGHMEM
if (cpu_has_dc_aliases) {
printk(KERN_WARNING "This processor doesn't support highmem.");
if (high - low)
printk(" %ldk highmem ignored", high - low);
printk("\n");
- } else
- zones_size[ZONE_HIGHMEM] = high - low;
+ } else {
+ zones_size[ZONE_HIGHMEM] = high - highstart_pfn;
+ }
#endif
free_area_init(zones_size);
@@ -233,7 +231,7 @@ void __init mem_init(void)
#ifdef CONFIG_HIGHMEM
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
- struct page *page = mem_map + tmp;
+ struct page *page = pfn_to_page(tmp);
if (!page_is_ram(tmp)) {
SetPageReserved(page);
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/include/asm-mips/dma.h linux/include/asm-mips/dma.h
--- linux-vanilla/include/asm-mips/dma.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/dma.h 2006-09-24 14:14:28.000000000 +0900
@@ -87,8 +87,13 @@
/* Horrible hack to have a correct DMA window on IP22 */
#include <asm/sgi/mc.h>
#define MAX_DMA_ADDRESS (PAGE_OFFSET + SGIMC_SEG0_BADDR + 0x01000000)
-#else
+#elif defined(CONFIG_ISA)
#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
+#else
+#ifndef PLAT_MAX_DMA_SIZE
+#define PLAT_MAX_DMA_SIZE 0x10000000 /* 256MB: true for most
of the MIPS32 systems */
+#endif
+#define MAX_DMA_ADDRESS (PAGE_OFFSET + PLAT_MAX_DMA_SIZE)
#endif
/* 8237 DMA controllers */
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/include/asm-mips/io.h linux/include/asm-mips/io.h
--- linux-vanilla/include/asm-mips/io.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/io.h 2006-09-24 12:40:12.000000000 +0900
@@ -116,7 +116,7 @@ static inline void set_io_port_base(unsi
*/
static inline unsigned long virt_to_phys(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return (unsigned long) __pa(address);
}
/*
@@ -133,7 +133,7 @@ static inline unsigned long virt_to_phys
*/
static inline void * phys_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return (void *) __va(address);
}
/*
@@ -141,12 +141,12 @@ static inline void * phys_to_virt(unsign
*/
static inline unsigned long isa_virt_to_bus(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return (unsigned long) __pa(address);
}
static inline void * isa_bus_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return (void *) __va(address);
}
#define isa_page_to_bus page_to_phys
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/include/asm-mips/page.h linux/include/asm-mips/page.h
--- linux-vanilla/include/asm-mips/page.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/page.h 2006-09-24 14:00:53.000000000 +0900
@@ -134,8 +134,13 @@ typedef struct { unsigned long pgprot; }
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
-#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#define UNMAPLIMIT (UNCAC_BASE - CAC_BASE) /*HIGHMEM_START*/
+#define ISMAPPED(x) (KSEGX((x)) > UNMAPLIMIT)
+#define ___pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __pa(x) (ISMAPPED(x) ? (x) : ___pa(x))
+
+#define ___va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#define __va(x) (ISMAPPED(x) ? (x) : ___va(x))
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH] cleanup hardcoding __pa/__va macros etc. (FWD)
2006-09-24 5:39 [PATCH] cleanup hardcoding __pa/__va macros etc girish
@ 2006-09-24 7:15 ` girish
2006-09-24 15:26 ` [PATCH] cleanup hardcoding __pa/__va macros etc Atsushi Nemoto
1 sibling, 0 replies; 20+ messages in thread
From: girish @ 2006-09-24 7:15 UTC (permalink / raw)
To: linux-mips@linux-mips.org
[forwarding to: linux-mips@linux-mips.org]
hello.
here is a patch to cleanup some hard coded lines.
plese let me know if these are valid changes.
thanks.
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/arch/mips/mm/dma-noncoherent.c
linux/arch/mips/mm/dma-noncoherent.c
--- linux-vanilla/arch/mips/mm/dma-noncoherent.c 2006-09-24
12:22:46.000000000 +0900
+++ linux/arch/mips/mm/dma-noncoherent.c 2006-09-24 12:20:35.000000000 +0900
@@ -334,7 +334,7 @@ EXPORT_SYMBOL(pci_dac_page_to_dma);
struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
dma64_addr_t dma_addr)
{
- return mem_map + (dma_addr >> PAGE_SHIFT);
+ return pfn_to_page (dma_addr >> PAGE_SHIFT);
}
EXPORT_SYMBOL(pci_dac_dma_to_page);
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/arch/mips/mm/init.c linux/arch/mips/mm/init.c
--- linux-vanilla/arch/mips/mm/init.c 2006-09-24 12:22:46.000000000 +0900
+++ linux/arch/mips/mm/init.c 2006-09-24 14:23:56.000000000 +0900
@@ -155,24 +155,22 @@ void __init paging_init(void)
low = max_low_pfn;
high = highend_pfn;
-#ifdef CONFIG_ISA
- if (low < max_dma)
+ if (low < max_dma) {
zones_size[ZONE_DMA] = low;
- else {
+ } else {
zones_size[ZONE_DMA] = max_dma;
zones_size[ZONE_NORMAL] = low - max_dma;
}
-#else
- zones_size[ZONE_DMA] = low;
-#endif
+
#ifdef CONFIG_HIGHMEM
if (cpu_has_dc_aliases) {
printk(KERN_WARNING "This processor doesn't support highmem.");
if (high - low)
printk(" %ldk highmem ignored", high - low);
printk("\n");
- } else
- zones_size[ZONE_HIGHMEM] = high - low;
+ } else {
+ zones_size[ZONE_HIGHMEM] = high - highstart_pfn;
+ }
#endif
free_area_init(zones_size);
@@ -233,7 +231,7 @@ void __init mem_init(void)
#ifdef CONFIG_HIGHMEM
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
- struct page *page = mem_map + tmp;
+ struct page *page = pfn_to_page(tmp);
if (!page_is_ram(tmp)) {
SetPageReserved(page);
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/include/asm-mips/dma.h linux/include/asm-mips/dma.h
--- linux-vanilla/include/asm-mips/dma.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/dma.h 2006-09-24 14:14:28.000000000 +0900
@@ -87,8 +87,13 @@
/* Horrible hack to have a correct DMA window on IP22 */
#include <asm/sgi/mc.h>
#define MAX_DMA_ADDRESS (PAGE_OFFSET + SGIMC_SEG0_BADDR + 0x01000000)
-#else
+#elif defined(CONFIG_ISA)
#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
+#else
+#ifndef PLAT_MAX_DMA_SIZE
+#define PLAT_MAX_DMA_SIZE 0x10000000 /* 256MB: true for most
of the MIPS32 systems */
+#endif
+#define MAX_DMA_ADDRESS (PAGE_OFFSET + PLAT_MAX_DMA_SIZE)
#endif
/* 8237 DMA controllers */
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/include/asm-mips/io.h linux/include/asm-mips/io.h
--- linux-vanilla/include/asm-mips/io.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/io.h 2006-09-24 12:40:12.000000000 +0900
@@ -116,7 +116,7 @@ static inline void set_io_port_base(unsi
*/
static inline unsigned long virt_to_phys(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return (unsigned long) __pa(address);
}
/*
@@ -133,7 +133,7 @@ static inline unsigned long virt_to_phys
*/
static inline void * phys_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return (void *) __va(address);
}
/*
@@ -141,12 +141,12 @@ static inline void * phys_to_virt(unsign
*/
static inline unsigned long isa_virt_to_bus(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return (unsigned long) __pa(address);
}
static inline void * isa_bus_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return (void *) __va(address);
}
#define isa_page_to_bus page_to_phys
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla/include/asm-mips/page.h linux/include/asm-mips/page.h
--- linux-vanilla/include/asm-mips/page.h 2006-09-24 12:23:34.000000000
+0900
+++ linux/include/asm-mips/page.h 2006-09-24 14:00:53.000000000 +0900
@@ -134,8 +134,13 @@ typedef struct { unsigned long pgprot; }
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
-#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#define UNMAPLIMIT (UNCAC_BASE - CAC_BASE) /*HIGHMEM_START*/
+#define ISMAPPED(x) (KSEGX((x)) > UNMAPLIMIT)
+#define ___pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __pa(x) (ISMAPPED(x) ? (x) : ___pa(x))
+
+#define ___va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#define __va(x) (ISMAPPED(x) ? (x) : ___va(x))
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
------ End of Forwarded Message
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc.
2006-09-24 5:39 [PATCH] cleanup hardcoding __pa/__va macros etc girish
2006-09-24 7:15 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (FWD) girish
@ 2006-09-24 15:26 ` Atsushi Nemoto
2006-09-25 14:51 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2) girish
1 sibling, 1 reply; 20+ messages in thread
From: Atsushi Nemoto @ 2006-09-24 15:26 UTC (permalink / raw)
To: girishvg; +Cc: linux-mips
On Sun, 24 Sep 2006 14:39:38 +0900, girish <girishvg@gmail.com> wrote:
> --- linux-vanilla/include/asm-mips/page.h 2006-09-24 12:23:34.000000000 +0900
> +++ linux/include/asm-mips/page.h 2006-09-24 14:00:53.000000000 +0900
> @@ -134,8 +134,13 @@ typedef struct { unsigned long pgprot; }
> /* to align the pointer to the (next) page boundary */
> #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
>
> -#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
> -#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
> +#define UNMAPLIMIT (UNCAC_BASE - CAC_BASE) /*HIGHMEM_START*/
> +#define ISMAPPED(x) (KSEGX((x)) > UNMAPLIMIT)
> +#define ___pa(x) ((unsigned long) (x) - PAGE_OFFSET)
> +#define __pa(x) (ISMAPPED(x) ? (x) : ___pa(x))
> +
> +#define ___va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
> +#define __va(x) (ISMAPPED(x) ? (x) : ___va(x))
>
> #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
This part looks broken for 64-bit kernel.
For other parts, it would be better to keep correct indentation level.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
2006-09-24 15:26 ` [PATCH] cleanup hardcoding __pa/__va macros etc Atsushi Nemoto
@ 2006-09-25 14:51 ` girish
2006-09-25 15:43 ` Atsushi Nemoto
0 siblings, 1 reply; 20+ messages in thread
From: girish @ 2006-09-25 14:51 UTC (permalink / raw)
To: linux-mips@linux-mips.org; +Cc: girish, Atsushi Nemoto
[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]
Here is the patch again, attached as a text file. I don't have idea how
these macros should be on a 64bit machine, so I just left them as it is.
Could you please verify these macros again?
On 9/25/06 12:26 AM, "Atsushi Nemoto" <anemo@mba.ocn.ne.jp> wrote:
> On Sun, 24 Sep 2006 14:39:38 +0900, girish <girishvg@gmail.com> wrote:
>> --- linux-vanilla/include/asm-mips/page.h 2006-09-24 12:23:34.000000000 +0900
>> +++ linux/include/asm-mips/page.h 2006-09-24 14:00:53.000000000 +0900
>> @@ -134,8 +134,13 @@ typedef struct { unsigned long pgprot; }
>> /* to align the pointer to the (next) page boundary */
>> #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
>>
>> -#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
>> -#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
>> +#define UNMAPLIMIT (UNCAC_BASE - CAC_BASE) /*HIGHMEM_START*/
>> +#define ISMAPPED(x) (KSEGX((x)) > UNMAPLIMIT)
>> +#define ___pa(x) ((unsigned long) (x) - PAGE_OFFSET)
>> +#define __pa(x) (ISMAPPED(x) ? (x) : ___pa(x))
>> +
>> +#define ___va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
>> +#define __va(x) (ISMAPPED(x) ? (x) : ___va(x))
>>
>> #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
>
> This part looks broken for 64-bit kernel.
>
> For other parts, it would be better to keep correct indentation level.
>
> ---
> Atsushi Nemoto
[-- Attachment #2: patch-basicfix-20060925 --]
[-- Type: application/octet-stream, Size: 4643 bytes --]
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/arch/mips/mm/dma-noncoherent.c linux/arch/mips/mm/dma-noncoherent.c
--- linux-vanilla/arch/mips/mm/dma-noncoherent.c 2006-09-24 12:22:46.000000000 +0900
+++ linux/arch/mips/mm/dma-noncoherent.c 2006-09-25 22:38:38.000000000 +0900
@@ -334,7 +334,7 @@ EXPORT_SYMBOL(pci_dac_page_to_dma);
struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
dma64_addr_t dma_addr)
{
- return mem_map + (dma_addr >> PAGE_SHIFT);
+ return pfn_to_page (dma_addr >> PAGE_SHIFT);
}
EXPORT_SYMBOL(pci_dac_dma_to_page);
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/arch/mips/mm/init.c linux/arch/mips/mm/init.c
--- linux-vanilla/arch/mips/mm/init.c 2006-09-24 12:22:46.000000000 +0900
+++ linux/arch/mips/mm/init.c 2006-09-25 22:43:22.000000000 +0900
@@ -155,24 +155,22 @@ void __init paging_init(void)
low = max_low_pfn;
high = highend_pfn;
-#ifdef CONFIG_ISA
- if (low < max_dma)
+ if (low < max_dma) {
zones_size[ZONE_DMA] = low;
- else {
+ } else {
zones_size[ZONE_DMA] = max_dma;
zones_size[ZONE_NORMAL] = low - max_dma;
}
-#else
- zones_size[ZONE_DMA] = low;
-#endif
+
#ifdef CONFIG_HIGHMEM
if (cpu_has_dc_aliases) {
printk(KERN_WARNING "This processor doesn't support highmem.");
if (high - low)
printk(" %ldk highmem ignored", high - low);
printk("\n");
- } else
- zones_size[ZONE_HIGHMEM] = high - low;
+ } else {
+ zones_size[ZONE_HIGHMEM] = high - highstart_pfn;
+ }
#endif
free_area_init(zones_size);
@@ -233,7 +231,7 @@ void __init mem_init(void)
#ifdef CONFIG_HIGHMEM
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
- struct page *page = mem_map + tmp;
+ struct page *page = pfn_to_page(tmp);
if (!page_is_ram(tmp)) {
SetPageReserved(page);
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/dma.h linux/include/asm-mips/dma.h
--- linux-vanilla/include/asm-mips/dma.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/dma.h 2006-09-25 22:45:28.000000000 +0900
@@ -87,8 +87,13 @@
/* Horrible hack to have a correct DMA window on IP22 */
#include <asm/sgi/mc.h>
#define MAX_DMA_ADDRESS (PAGE_OFFSET + SGIMC_SEG0_BADDR + 0x01000000)
-#else
+#elif defined(CONFIG_ISA)
#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
+#else
+#ifndef PLAT_MAX_DMA_SIZE
+#define PLAT_MAX_DMA_SIZE 0x10000000 /* 256MB: true for most of the MIPS32 systems */
+#endif
+#define MAX_DMA_ADDRESS (PAGE_OFFSET + PLAT_MAX_DMA_SIZE)
#endif
/* 8237 DMA controllers */
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/io.h linux/include/asm-mips/io.h
--- linux-vanilla/include/asm-mips/io.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/io.h 2006-09-25 22:51:31.000000000 +0900
@@ -116,7 +116,7 @@ static inline void set_io_port_base(unsi
*/
static inline unsigned long virt_to_phys(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return (unsigned long) __pa(address);
}
/*
@@ -133,7 +133,7 @@ static inline unsigned long virt_to_phys
*/
static inline void * phys_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return (void *) __va(address);
}
/*
@@ -141,12 +141,12 @@ static inline void * phys_to_virt(unsign
*/
static inline unsigned long isa_virt_to_bus(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return (unsigned long) __pa(address);
}
static inline void * isa_bus_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return (void *) __va(address);
}
#define isa_page_to_bus page_to_phys
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/page.h linux/include/asm-mips/page.h
--- linux-vanilla/include/asm-mips/page.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/page.h 2006-09-25 22:50:40.000000000 +0900
@@ -134,8 +134,17 @@ typedef struct { unsigned long pgprot; }
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
-#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#ifdef CONFIG_32BIT
+#define ISMAPPED(x) (KSEGX((x)) >= HIGHMEM_START && KSEGX((x)) < KSEG0)
+#else
+#define ISMAPPED(x) (0)
+#endif
+
+#define ___pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __pa(x) (ISMAPPED(x) ? (x) : ___pa(x))
+
+#define ___va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#define __va(x) (ISMAPPED(x) ? (x) : ___va(x))
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
2006-09-25 14:51 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2) girish
@ 2006-09-25 15:43 ` Atsushi Nemoto
[not found] ` <C13EBDF2.724C%girishvg@gmail.com>
0 siblings, 1 reply; 20+ messages in thread
From: Atsushi Nemoto @ 2006-09-25 15:43 UTC (permalink / raw)
To: girishvg; +Cc: linux-mips
On Mon, 25 Sep 2006 23:51:46 +0900, girish <girishvg@gmail.com> wrote:
> Here is the patch again, attached as a text file. I don't have idea how
> these macros should be on a 64bit machine, so I just left them as it is.
> Could you please verify these macros again?
Well, I should ask first: Why do you change __pa() and __va() ?
I can not see point of ISMAPPED() testing. And these macros are used
quite often so they should be as fast as possible.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* FW: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
[not found] ` <C13EBDF2.724C%girishvg@gmail.com>
@ 2006-09-26 2:24 ` girish
2006-09-26 9:02 ` Atsushi Nemoto
1 sibling, 0 replies; 20+ messages in thread
From: girish @ 2006-09-26 2:24 UTC (permalink / raw)
To: linux-mips@linux-mips.org; +Cc: girish
------ Forwarded Message
From: girish <girishvg@gmail.com>
Date: Tue, 26 Sep 2006 11:22:26 +0900
To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: "linux-mips@linux-mips.org" <git-commits@linux-mips.org>
Conversation: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
Subject: Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
The idea is to differentiate the Kseg0/Kseg1 segments in the physical area.
Beyond these areas lies the mapped area (or the HIGHMEM). What complicates
this matter further is their overlapping nature. The __pa()/__va() treated
all addresses mapped into PAGE_OFFSET (8000_0000) area. The effort is to
correctly differentiate these areas.
I could not think of any better solution & the only simplification I came up
with -
#ifdef CONFIG_32BIT
/* 8000_0000 & above */
#define ISMAPPEDPA(x) ((x) > KSEG0)
/* below 2000_0000 */
#define ISUNMAPPEDVA(x) ((x) < HIGHMEM_START)
#else
#define ISMAPPEDPA(x) (1)
#define ISMAPPEDVA(x) (1)
#endif
#define ___pa(x) ((unsigned long) (x) - KSEGX((x)))
#define __pa(x) (ISUNMAPPEDPA(x) ? ___pa((x)) : (x))
#define ___va(x) ((void *)((unsigned long) (x) + KSEG0))
#define __va(x) (ISUNMAPPEDVA(x) ? ___va((x)) : (x))
On 9/26/06 12:43 AM, "Atsushi Nemoto" <anemo@mba.ocn.ne.jp> wrote:
> On Mon, 25 Sep 2006 23:51:46 +0900, girish <girishvg@gmail.com> wrote:
>> Here is the patch again, attached as a text file. I don't have idea how
>> these macros should be on a 64bit machine, so I just left them as it is.
>> Could you please verify these macros again?
>
> Well, I should ask first: Why do you change __pa() and __va() ?
>
> I can not see point of ISMAPPED() testing. And these macros are used
> quite often so they should be as fast as possible.
>
> ---
> Atsushi Nemoto
------ End of Forwarded Message
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
[not found] ` <C13EBDF2.724C%girishvg@gmail.com>
2006-09-26 2:24 ` FW: " girish
@ 2006-09-26 9:02 ` Atsushi Nemoto
2006-09-26 15:20 ` girish
2006-09-28 15:01 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2) Ralf Baechle
1 sibling, 2 replies; 20+ messages in thread
From: Atsushi Nemoto @ 2006-09-26 9:02 UTC (permalink / raw)
To: girishvg; +Cc: linux-mips
On Tue, 26 Sep 2006 11:22:26 +0900, girish <girishvg@gmail.com> wrote:
> The idea is to differentiate the Kseg0/Kseg1 segments in the physical area.
> Beyond these areas lies the mapped area (or the HIGHMEM). What complicates
> this matter further is their overlapping nature. The __pa()/__va() treated
> all addresses mapped into PAGE_OFFSET (8000_0000) area. The effort is to
> correctly differentiate these areas.
Yes, __va() and __pa() are used to convert an physical address from/to
an kernel logical address (i.e. low unmapped virtual address).
I think passing another sort of addresses to them is simply wrong.
P.S.
Please do not reply to git-commits@linux-mips.org.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
2006-09-26 9:02 ` Atsushi Nemoto
@ 2006-09-26 15:20 ` girish
2006-09-26 16:35 ` Atsushi Nemoto
2006-09-28 15:01 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2) Ralf Baechle
1 sibling, 1 reply; 20+ messages in thread
From: girish @ 2006-09-26 15:20 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips@linux-mips.org, girish
>> The idea is to differentiate the Kseg0/Kseg1 segments in the physical area.
>> Beyond these areas lies the mapped area (or the HIGHMEM). What complicates
>> this matter further is their overlapping nature. The __pa()/__va() treated
>> all addresses mapped into PAGE_OFFSET (8000_0000) area. The effort is to
>> correctly differentiate these areas.
>
> Yes, __va() and __pa() are used to convert an physical address from/to
> an kernel logical address (i.e. low unmapped virtual address).
>
> I think passing another sort of addresses to them is simply wrong.
Agreed.
But, then again treating all addresses as above PAGE_OFFSET is also wrong :)
I looked at it just as a work around. These macros are called from so many
other places that if an access is made at say 4000_0000 the kernel will oops
telling it was C000_0000 access error. Now that confused me a lot! With this
change now kernel oops on 4000_0000 :)
Anyway, you may ignore __pa/__va macros.
Could you please look into other changes I proposed?
>
> P.S.
> Please do not reply to git-commits@linux-mips.org.
I am sorry. It was a stupid mistake in creating address book entry.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
2006-09-26 15:20 ` girish
@ 2006-09-26 16:35 ` Atsushi Nemoto
2006-09-26 22:06 ` girish
0 siblings, 1 reply; 20+ messages in thread
From: Atsushi Nemoto @ 2006-09-26 16:35 UTC (permalink / raw)
To: girishvg; +Cc: linux-mips
On Wed, 27 Sep 2006 00:20:30 +0900, girish <girishvg@gmail.com> wrote:
> But, then again treating all addresses as above PAGE_OFFSET is also wrong :)
It would be a design not a bug :-)
> I looked at it just as a work around. These macros are called from so many
> other places that if an access is made at say 4000_0000 the kernel will oops
> telling it was C000_0000 access error. Now that confused me a lot! With this
> change now kernel oops on 4000_0000 :)
Yes, 4000_0000, which is wrong too. And it _hides_ wrong usage of
vaddr/paddr. Bad side effect :)
> Anyway, you may ignore __pa/__va macros.
>
> Could you please look into other changes I proposed?
__pa() returns "unsigned long" and __va() returns "void *" so some
casts are also redundant.
Other parts looks good for me.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
2006-09-26 16:35 ` Atsushi Nemoto
@ 2006-09-26 22:06 ` girish
2006-09-27 15:35 ` Atsushi Nemoto
0 siblings, 1 reply; 20+ messages in thread
From: girish @ 2006-09-26 22:06 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips@linux-mips.org, girish
[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]
>> But, then again treating all addresses as above PAGE_OFFSET is also wrong :)
>
> It would be a design not a bug :-)
>
>> I looked at it just as a work around. These macros are called from so many
>> other places that if an access is made at say 4000_0000 the kernel will oops
>> telling it was C000_0000 access error. Now that confused me a lot! With this
>> change now kernel oops on 4000_0000 :)
>
> Yes, 4000_0000, which is wrong too. And it _hides_ wrong usage of
> vaddr/paddr. Bad side effect :)
>
>> Anyway, you may ignore __pa/__va macros.
>>
>> Could you please look into other changes I proposed?
>
> __pa() returns "unsigned long" and __va() returns "void *" so some
> casts are also redundant.
After removing some of the redundant casts, re-submitting the patch.
Attached the patch in a text file.
In the meantime, I couldn't find the changes suggested for SPARSEMEM support
in the main source tree. Especially the ones reviewed during month of August
([PATCH] do not count pages in holes with sparsemem ...). Could you please
resend the consolidated patch to the list? Thanks.
BTW, I have couple of more changes in mind.
.1a Currently only one PCI DMA window is supported. We need to extend that,
if the PCI controller has multiple windows. Example implementation is in
arch/powerpc.
.1b During HIGHMEM support the PCI windows are not honored correctly. A
kmap() based mapping could be provided during PCI sync. Example
implementation, again arch/powerpc. Has anybody looked into this?
.2 Has anybody tested /dev/mem and/or /dev/kmem devices on MIPS platform?
[-- Attachment #2: patch-basicfix-20060927 --]
[-- Type: application/octet-stream, Size: 4609 bytes --]
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/arch/mips/mm/dma-noncoherent.c linux/arch/mips/mm/dma-noncoherent.c
--- linux-vanilla/arch/mips/mm/dma-noncoherent.c 2006-09-24 12:22:46.000000000 +0900
+++ linux/arch/mips/mm/dma-noncoherent.c 2006-09-25 22:38:38.000000000 +0900
@@ -334,7 +334,7 @@ EXPORT_SYMBOL(pci_dac_page_to_dma);
struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
dma64_addr_t dma_addr)
{
- return mem_map + (dma_addr >> PAGE_SHIFT);
+ return pfn_to_page (dma_addr >> PAGE_SHIFT);
}
EXPORT_SYMBOL(pci_dac_dma_to_page);
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/arch/mips/mm/init.c linux/arch/mips/mm/init.c
--- linux-vanilla/arch/mips/mm/init.c 2006-09-24 12:22:46.000000000 +0900
+++ linux/arch/mips/mm/init.c 2006-09-25 22:58:15.000000000 +0900
@@ -155,24 +155,22 @@ void __init paging_init(void)
low = max_low_pfn;
high = highend_pfn;
-#ifdef CONFIG_ISA
- if (low < max_dma)
+ if (low < max_dma) {
zones_size[ZONE_DMA] = low;
- else {
+ } else {
zones_size[ZONE_DMA] = max_dma;
zones_size[ZONE_NORMAL] = low - max_dma;
}
-#else
- zones_size[ZONE_DMA] = low;
-#endif
+
#ifdef CONFIG_HIGHMEM
if (cpu_has_dc_aliases) {
printk(KERN_WARNING "This processor doesn't support highmem.");
if (high - low)
printk(" %ldk highmem ignored", high - low);
printk("\n");
- } else
- zones_size[ZONE_HIGHMEM] = high - low;
+ } else {
+ zones_size[ZONE_HIGHMEM] = high - highstart_pfn;
+ }
#endif
free_area_init(zones_size);
@@ -233,7 +231,7 @@ void __init mem_init(void)
#ifdef CONFIG_HIGHMEM
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
- struct page *page = mem_map + tmp;
+ struct page *page = pfn_to_page(tmp);
if (!page_is_ram(tmp)) {
SetPageReserved(page);
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/dma.h linux/include/asm-mips/dma.h
--- linux-vanilla/include/asm-mips/dma.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/dma.h 2006-09-25 22:45:28.000000000 +0900
@@ -87,8 +87,13 @@
/* Horrible hack to have a correct DMA window on IP22 */
#include <asm/sgi/mc.h>
#define MAX_DMA_ADDRESS (PAGE_OFFSET + SGIMC_SEG0_BADDR + 0x01000000)
-#else
+#elif defined(CONFIG_ISA)
#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
+#else
+#ifndef PLAT_MAX_DMA_SIZE
+#define PLAT_MAX_DMA_SIZE 0x10000000 /* 256MB: true for most of the MIPS32 systems */
+#endif
+#define MAX_DMA_ADDRESS (PAGE_OFFSET + PLAT_MAX_DMA_SIZE)
#endif
/* 8237 DMA controllers */
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/io.h linux/include/asm-mips/io.h
--- linux-vanilla/include/asm-mips/io.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/io.h 2006-09-27 06:45:15.000000000 +0900
@@ -116,7 +116,7 @@ static inline void set_io_port_base(unsi
*/
static inline unsigned long virt_to_phys(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return __pa(address);
}
/*
@@ -133,7 +133,7 @@ static inline unsigned long virt_to_phys
*/
static inline void * phys_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return __va(address);
}
/*
@@ -141,12 +141,12 @@ static inline void * phys_to_virt(unsign
*/
static inline unsigned long isa_virt_to_bus(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return __pa(address);
}
static inline void * isa_bus_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return __va(address);
}
#define isa_page_to_bus page_to_phys
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/page.h linux/include/asm-mips/page.h
--- linux-vanilla/include/asm-mips/page.h 2006-09-24 12:23:34.000000000 +0900
+++ linux/include/asm-mips/page.h 2006-09-27 06:46:24.000000000 +0900
@@ -134,8 +134,17 @@ typedef struct { unsigned long pgprot; }
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
-#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#ifdef CONFIG_32BIT
+#define ISMAPPED(x) (KSEGX((x)) >= HIGHMEM_START && KSEGX((x)) < KSEG0)
+#else
+#define ISMAPPED(x) (0)
+#endif
+
+#define ___pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __pa(x) (ISMAPPED(x) ? (unsigned long)(x) : ___pa(x))
+
+#define ___va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#define __va(x) (ISMAPPED(x) ? (void*)(x) : ___va(x))
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
2006-09-26 22:06 ` girish
@ 2006-09-27 15:35 ` Atsushi Nemoto
2006-09-27 16:58 ` PATCH] cleanup hardcoding __pa/__va macros etc. (take-4) girish
0 siblings, 1 reply; 20+ messages in thread
From: Atsushi Nemoto @ 2006-09-27 15:35 UTC (permalink / raw)
To: girishvg; +Cc: linux-mips
On Wed, 27 Sep 2006 07:06:10 +0900, girish <girishvg@gmail.com> wrote:
> After removing some of the redundant casts, re-submitting the patch.
> Attached the patch in a text file.
Using just plain text and adding Signed-off-by line would be preferred.
Also your patch seems against neither latest lmo nor kernel.org tree...
> In the meantime, I couldn't find the changes suggested for SPARSEMEM support
> in the main source tree. Especially the ones reviewed during month of August
> ([PATCH] do not count pages in holes with sparsemem ...). Could you please
> resend the consolidated patch to the list? Thanks.
August? I sent the patch with that title in July and applied already.
http://www.linux-mips.org/git?p=linux.git;a=commit;h=239367b4
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* PATCH] cleanup hardcoding __pa/__va macros etc. (take-4)
2006-09-27 15:35 ` Atsushi Nemoto
@ 2006-09-27 16:58 ` girish
2006-09-28 23:29 ` Ralf Baechle
0 siblings, 1 reply; 20+ messages in thread
From: girish @ 2006-09-27 16:58 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips@linux-mips.org, girish
[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]
> Using just plain text and adding Signed-off-by line would be preferred.
> Also your patch seems against neither latest lmo nor kernel.org tree...
The kernel sources I was referring to were 2.6.17-rc6.
>> In the meantime, I couldn't find the changes suggested for SPARSEMEM support
>> in the main source tree. Especially the ones reviewed during month of August
>> ([PATCH] do not count pages in holes with sparsemem ...). Could you please
>> resend the consolidated patch to the list? Thanks.
>
> August? I sent the patch with that title in July and applied already.
>
> http://www.linux-mips.org/git?p=linux.git;a=commit;h=239367b4
Again, I was referring to older sources, that is 2.6.17-rc6. I have just
upgraded reference sources to 2.6.18 as mentioned above & now I see the
changes. Thanks. In fact I am experimenting on highmem/sparsemem with
2.6.16.16 kernel sources.
Please find attached patch created from 2.6.18 (kernel.org) tree. Let me
know if this is alright.
Signed-off-by: Girish V. Gulawani <girishvg@gmail.com>
[-- Attachment #2: patch-pavafix-20060928 --]
[-- Type: application/octet-stream, Size: 4604 bytes --]
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/arch/mips/mm/dma-noncoherent.c linux/arch/mips/mm/dma-noncoherent.c
--- linux-vanilla/arch/mips/mm/dma-noncoherent.c 2006-09-20 12:42:06.000000000 +0900
+++ linux/arch/mips/mm/dma-noncoherent.c 2006-09-28 01:14:01.000000000 +0900
@@ -333,7 +333,7 @@ EXPORT_SYMBOL(pci_dac_page_to_dma);
struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
dma64_addr_t dma_addr)
{
- return mem_map + (dma_addr >> PAGE_SHIFT);
+ return pfn_to_page (dma_addr >> PAGE_SHIFT);
}
EXPORT_SYMBOL(pci_dac_dma_to_page);
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/arch/mips/mm/init.c linux/arch/mips/mm/init.c
--- linux-vanilla/arch/mips/mm/init.c 2006-09-20 12:42:06.000000000 +0900
+++ linux/arch/mips/mm/init.c 2006-09-28 01:16:20.000000000 +0900
@@ -180,24 +180,22 @@ void __init paging_init(void)
low = max_low_pfn;
high = highend_pfn;
-#ifdef CONFIG_ISA
- if (low < max_dma)
+ if (low < max_dma) }
zones_size[ZONE_DMA] = low;
- else {
+ } else {
zones_size[ZONE_DMA] = max_dma;
zones_size[ZONE_NORMAL] = low - max_dma;
}
-#else
- zones_size[ZONE_DMA] = low;
-#endif
+
#ifdef CONFIG_HIGHMEM
if (cpu_has_dc_aliases) {
printk(KERN_WARNING "This processor doesn't support highmem.");
if (high - low)
printk(" %ldk highmem ignored", high - low);
printk("\n");
- } else
- zones_size[ZONE_HIGHMEM] = high - low;
+ } else {
+ zones_size[ZONE_HIGHMEM] = high - highstart_pfn;
+ }
#endif
#ifdef CONFIG_FLATMEM
@@ -246,7 +244,7 @@ void __init mem_init(void)
#ifdef CONFIG_HIGHMEM
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
- struct page *page = mem_map + tmp;
+ struct page *page = pfn_to_page (tmp);
if (!page_is_ram(tmp)) {
SetPageReserved(page);
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/dma.h linux/include/asm-mips/dma.h
--- linux-vanilla/include/asm-mips/dma.h 2006-09-20 12:42:06.000000000 +0900
+++ linux/include/asm-mips/dma.h 2006-09-28 01:18:31.000000000 +0900
@@ -86,8 +86,13 @@
/* Horrible hack to have a correct DMA window on IP22 */
#include <asm/sgi/mc.h>
#define MAX_DMA_ADDRESS (PAGE_OFFSET + SGIMC_SEG0_BADDR + 0x01000000)
-#else
+#elif defined(CONFIG_ISA)
#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
+#else
+#ifndef PLAT_MAX_DMA_SIZE
+#define PLAT_MAX_DMA_SIZE 0x10000000 /* 256MB: true on most of the MIPS32 systems */
+#endif
+#define MAX_DMA_ADDRESS (PAGE_OFFSET + PLAT_MAX_DMA_SIZE)
#endif
/* 8237 DMA controllers */
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/io.h linux/include/asm-mips/io.h
--- linux-vanilla/include/asm-mips/io.h 2006-09-20 12:42:06.000000000 +0900
+++ linux/include/asm-mips/io.h 2006-09-28 01:20:22.000000000 +0900
@@ -115,7 +115,7 @@ static inline void set_io_port_base(unsi
*/
static inline unsigned long virt_to_phys(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return __pa(address);
}
/*
@@ -132,7 +132,7 @@ static inline unsigned long virt_to_phys
*/
static inline void * phys_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return __va(address);
}
/*
@@ -140,12 +140,12 @@ static inline void * phys_to_virt(unsign
*/
static inline unsigned long isa_virt_to_bus(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return __pa(address);
}
static inline void * isa_bus_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return __va(address);
}
#define isa_page_to_bus page_to_phys
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/page.h linux/include/asm-mips/page.h
--- linux-vanilla/include/asm-mips/page.h 2006-09-20 12:42:06.000000000 +0900
+++ linux/include/asm-mips/page.h 2006-09-28 01:26:00.000000000 +0900
@@ -129,8 +129,15 @@ typedef struct { unsigned long pgprot; }
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
-#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#ifdef CONFIG_32BIT
+#define ISMAPPED(x) (KSEGX((x)) >= HIGHMEM_START && KSEGX((x)) < KSEG0)
+#else
+#define ISMAPPED(x) (0)
+#endif
+#define ___pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __pa(x) (ISMAPPED(x) ? (unsigned long)(x) : ___pa(x))
+#define ___va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#define __va(x) (ISMAPPED(x) ? (void*)(x) : ___va(x))
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
2006-09-26 9:02 ` Atsushi Nemoto
2006-09-26 15:20 ` girish
@ 2006-09-28 15:01 ` Ralf Baechle
1 sibling, 0 replies; 20+ messages in thread
From: Ralf Baechle @ 2006-09-28 15:01 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: girishvg, linux-mips
On Tue, Sep 26, 2006 at 06:02:40PM +0900, Atsushi Nemoto wrote:
> Please do not reply to git-commits@linux-mips.org.
In fact it is impossible to mail to that address - there is on
git-commits list alias on linux-mips.org which means there is no way
spam could get to the git-commits list.
Ralf
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH] cleanup hardcoding __pa/__va macros etc. (take-4)
2006-09-27 16:58 ` PATCH] cleanup hardcoding __pa/__va macros etc. (take-4) girish
@ 2006-09-28 23:29 ` Ralf Baechle
2006-09-29 14:45 ` PATCH] cleanup hardcoding __pa/__va macros etc. (take-5) girish
0 siblings, 1 reply; 20+ messages in thread
From: Ralf Baechle @ 2006-09-28 23:29 UTC (permalink / raw)
To: girish; +Cc: Atsushi Nemoto, linux-mips@linux-mips.org
On Thu, Sep 28, 2006 at 01:58:02AM +0900, girish wrote:
> Date: Thu, 28 Sep 2006 01:58:02 +0900
> Subject: PATCH] cleanup hardcoding __pa/__va macros etc. (take-4)
> From: girish <girishvg@gmail.com>
> To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> CC: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
> girish <girishvg@gmail.com>
> Content-type: multipart/mixed;
> boundary="B_3242253489_7379959"
>
>
> > Using just plain text and adding Signed-off-by line would be preferred.
> > Also your patch seems against neither latest lmo nor kernel.org tree...
>
> The kernel sources I was referring to were 2.6.17-rc6.
>
>
> >> In the meantime, I couldn't find the changes suggested for SPARSEMEM support
> >> in the main source tree. Especially the ones reviewed during month of August
> >> ([PATCH] do not count pages in holes with sparsemem ...). Could you please
> >> resend the consolidated patch to the list? Thanks.
> >
> > August? I sent the patch with that title in July and applied already.
> >
> > http://www.linux-mips.org/git?p=linux.git;a=commit;h=239367b4
>
> Again, I was referring to older sources, that is 2.6.17-rc6. I have just
> upgraded reference sources to 2.6.18 as mentioned above & now I see the
> changes. Thanks. In fact I am experimenting on highmem/sparsemem with
> 2.6.16.16 kernel sources.
>
>
> Please find attached patch created from 2.6.18 (kernel.org) tree. Let me
> know if this is alright.
>
> Signed-off-by: Girish V. Gulawani <girishvg@gmail.com>
-#ifdef CONFIG_ISA
- if (low < max_dma)
+ if (low < max_dma) }
This doesn't quite compile.
Ralf
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH] cleanup hardcoding __pa/__va macros etc. (take-5)
2006-09-28 23:29 ` Ralf Baechle
@ 2006-09-29 14:45 ` girish
2006-09-29 17:59 ` Atsushi Nemoto
0 siblings, 1 reply; 20+ messages in thread
From: girish @ 2006-09-29 14:45 UTC (permalink / raw)
To: linux-mips; +Cc: Atsushi Nemoto, Ralf Baechle
[-- Attachment #1: Type: text/plain, Size: 1819 bytes --]
On Sep 29, 2006, at 8:29 AM, Ralf Baechle wrote:
> On Thu, Sep 28, 2006 at 01:58:02AM +0900, girish wrote:
>> Date: Thu, 28 Sep 2006 01:58:02 +0900
>> Subject: PATCH] cleanup hardcoding __pa/__va macros etc. (take-4)
>> From: girish <girishvg@gmail.com>
>> To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
>> CC: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
>> girish <girishvg@gmail.com>
>> Content-type: multipart/mixed;
>> boundary="B_3242253489_7379959"
>>
>>
>>> Using just plain text and adding Signed-off-by line would be
>>> preferred.
>>> Also your patch seems against neither latest lmo nor kernel.org
>>> tree...
>>
>> The kernel sources I was referring to were 2.6.17-rc6.
>>
>>
>>>> In the meantime, I couldn't find the changes suggested for
>>>> SPARSEMEM support
>>>> in the main source tree. Especially the ones reviewed during
>>>> month of August
>>>> ([PATCH] do not count pages in holes with sparsemem ...). Could
>>>> you please
>>>> resend the consolidated patch to the list? Thanks.
>>>
>>> August? I sent the patch with that title in July and applied
>>> already.
>>>
>>> http://www.linux-mips.org/git?p=linux.git;a=commit;h=239367b4
>>
>> Again, I was referring to older sources, that is 2.6.17-rc6. I
>> have just
>> upgraded reference sources to 2.6.18 as mentioned above & now I
>> see the
>> changes. Thanks. In fact I am experimenting on highmem/sparsemem with
>> 2.6.16.16 kernel sources.
>>
>>
>> Please find attached patch created from 2.6.18 (kernel.org) tree.
>> Let me
>> know if this is alright.
>>
>> Signed-off-by: Girish V. Gulawani <girishvg@gmail.com>
>
> -#ifdef CONFIG_ISA
> - if (low < max_dma)
> + if (low < max_dma) }
>
> This doesn't quite compile.
>
Stupid mistake. Fixed & resending.
Signed-off-by: Girish V. Gulawani <girishvg@gmail.com>
[-- Attachment #2: patch-pavafix-20060929 --]
[-- Type: application/octet-stream, Size: 4604 bytes --]
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/arch/mips/mm/dma-noncoherent.c linux/arch/mips/mm/dma-noncoherent.c
--- linux-vanilla/arch/mips/mm/dma-noncoherent.c 2006-09-20 12:42:06.000000000 +0900
+++ linux/arch/mips/mm/dma-noncoherent.c 2006-09-28 01:14:01.000000000 +0900
@@ -333,7 +333,7 @@ EXPORT_SYMBOL(pci_dac_page_to_dma);
struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
dma64_addr_t dma_addr)
{
- return mem_map + (dma_addr >> PAGE_SHIFT);
+ return pfn_to_page (dma_addr >> PAGE_SHIFT);
}
EXPORT_SYMBOL(pci_dac_dma_to_page);
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/arch/mips/mm/init.c linux/arch/mips/mm/init.c
--- linux-vanilla/arch/mips/mm/init.c 2006-09-20 12:42:06.000000000 +0900
+++ linux/arch/mips/mm/init.c 2006-09-29 23:38:04.000000000 +0900
@@ -180,24 +180,22 @@ void __init paging_init(void)
low = max_low_pfn;
high = highend_pfn;
-#ifdef CONFIG_ISA
- if (low < max_dma)
+ if (low < max_dma) {
zones_size[ZONE_DMA] = low;
- else {
+ } else {
zones_size[ZONE_DMA] = max_dma;
zones_size[ZONE_NORMAL] = low - max_dma;
}
-#else
- zones_size[ZONE_DMA] = low;
-#endif
+
#ifdef CONFIG_HIGHMEM
if (cpu_has_dc_aliases) {
printk(KERN_WARNING "This processor doesn't support highmem.");
if (high - low)
printk(" %ldk highmem ignored", high - low);
printk("\n");
- } else
- zones_size[ZONE_HIGHMEM] = high - low;
+ } else {
+ zones_size[ZONE_HIGHMEM] = high - highstart_pfn;
+ }
#endif
#ifdef CONFIG_FLATMEM
@@ -246,7 +244,7 @@ void __init mem_init(void)
#ifdef CONFIG_HIGHMEM
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
- struct page *page = mem_map + tmp;
+ struct page *page = pfn_to_page (tmp);
if (!page_is_ram(tmp)) {
SetPageReserved(page);
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/dma.h linux/include/asm-mips/dma.h
--- linux-vanilla/include/asm-mips/dma.h 2006-09-20 12:42:06.000000000 +0900
+++ linux/include/asm-mips/dma.h 2006-09-28 01:18:31.000000000 +0900
@@ -86,8 +86,13 @@
/* Horrible hack to have a correct DMA window on IP22 */
#include <asm/sgi/mc.h>
#define MAX_DMA_ADDRESS (PAGE_OFFSET + SGIMC_SEG0_BADDR + 0x01000000)
-#else
+#elif defined(CONFIG_ISA)
#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
+#else
+#ifndef PLAT_MAX_DMA_SIZE
+#define PLAT_MAX_DMA_SIZE 0x10000000 /* 256MB: true on most of the MIPS32 systems */
+#endif
+#define MAX_DMA_ADDRESS (PAGE_OFFSET + PLAT_MAX_DMA_SIZE)
#endif
/* 8237 DMA controllers */
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/io.h linux/include/asm-mips/io.h
--- linux-vanilla/include/asm-mips/io.h 2006-09-20 12:42:06.000000000 +0900
+++ linux/include/asm-mips/io.h 2006-09-28 01:20:22.000000000 +0900
@@ -115,7 +115,7 @@ static inline void set_io_port_base(unsi
*/
static inline unsigned long virt_to_phys(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return __pa(address);
}
/*
@@ -132,7 +132,7 @@ static inline unsigned long virt_to_phys
*/
static inline void * phys_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return __va(address);
}
/*
@@ -140,12 +140,12 @@ static inline void * phys_to_virt(unsign
*/
static inline unsigned long isa_virt_to_bus(volatile void * address)
{
- return (unsigned long)address - PAGE_OFFSET;
+ return __pa(address);
}
static inline void * isa_bus_to_virt(unsigned long address)
{
- return (void *)(address + PAGE_OFFSET);
+ return __va(address);
}
#define isa_page_to_bus page_to_phys
diff -uprN -X linux-vanilla/Documentation/dontdiff linux-vanilla/include/asm-mips/page.h linux/include/asm-mips/page.h
--- linux-vanilla/include/asm-mips/page.h 2006-09-20 12:42:06.000000000 +0900
+++ linux/include/asm-mips/page.h 2006-09-28 01:26:00.000000000 +0900
@@ -129,8 +129,15 @@ typedef struct { unsigned long pgprot; }
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
-#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#ifdef CONFIG_32BIT
+#define ISMAPPED(x) (KSEGX((x)) >= HIGHMEM_START && KSEGX((x)) < KSEG0)
+#else
+#define ISMAPPED(x) (0)
+#endif
+#define ___pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __pa(x) (ISMAPPED(x) ? (unsigned long)(x) : ___pa(x))
+#define ___va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#define __va(x) (ISMAPPED(x) ? (void*)(x) : ___va(x))
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
[-- Attachment #3: Type: text/plain, Size: 2 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH] cleanup hardcoding __pa/__va macros etc. (take-5)
2006-09-29 14:45 ` PATCH] cleanup hardcoding __pa/__va macros etc. (take-5) girish
@ 2006-09-29 17:59 ` Atsushi Nemoto
2006-09-29 18:33 ` girish
0 siblings, 1 reply; 20+ messages in thread
From: Atsushi Nemoto @ 2006-09-29 17:59 UTC (permalink / raw)
To: girishvg; +Cc: linux-mips, ralf
On Fri, 29 Sep 2006 23:45:12 +0900, girish <girishvg@gmail.com> wrote:
> >> Please find attached patch created from 2.6.18 (kernel.org) tree.
> >> Let me
> >> know if this is alright.
> >>
> >> Signed-off-by: Girish V. Gulawani <girishvg@gmail.com>
> >
> > -#ifdef CONFIG_ISA
> > - if (low < max_dma)
> > + if (low < max_dma) }
> >
> > This doesn't quite compile.
> >
>
> Stupid mistake. Fixed & resending.
Looks good to me, except for page.h part.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH] cleanup hardcoding __pa/__va macros etc. (take-5)
2006-09-29 17:59 ` Atsushi Nemoto
@ 2006-09-29 18:33 ` girish
2006-10-01 14:52 ` Atsushi Nemoto
0 siblings, 1 reply; 20+ messages in thread
From: girish @ 2006-09-29 18:33 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips, ralf
On Sep 30, 2006, at 2:59 AM, Atsushi Nemoto wrote:
> On Fri, 29 Sep 2006 23:45:12 +0900, girish <girishvg@gmail.com> wrote:
>>>> Please find attached patch created from 2.6.18 (kernel.org) tree.
>>>> Let me
>>>> know if this is alright.
>>>>
>>>> Signed-off-by: Girish V. Gulawani <girishvg@gmail.com>
>>>
>>> -#ifdef CONFIG_ISA
>>> - if (low < max_dma)
>>> + if (low < max_dma) }
>>>
>>> This doesn't quite compile.
>>>
>>
>> Stupid mistake. Fixed & resending.
>
> Looks good to me, except for page.h part.
I agree, but as of now, I do not have any better solution. If & when
I will implement kernel page table for memory above 2000_0000, I plan
to give it a through mapping. That is to say, 4000_0000 physical
mapped to 4000_0000 virtual. In that case the page.h __pa/__va macros
stand a chance (^_^;)
If somebody has already done kernel page table implementation, could
you please pass on the relevant patch? Thanks.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH] cleanup hardcoding __pa/__va macros etc. (take-5)
2006-09-29 18:33 ` girish
@ 2006-10-01 14:52 ` Atsushi Nemoto
2006-10-01 14:57 ` girish
0 siblings, 1 reply; 20+ messages in thread
From: Atsushi Nemoto @ 2006-10-01 14:52 UTC (permalink / raw)
To: girishvg; +Cc: linux-mips, ralf
On Sat, 30 Sep 2006 03:33:01 +0900, girish <girishvg@gmail.com> wrote:
> > Looks good to me, except for page.h part.
>
> I agree, but as of now, I do not have any better solution. If & when
> I will implement kernel page table for memory above 2000_0000, I plan
> to give it a through mapping. That is to say, 4000_0000 physical
> mapped to 4000_0000 virtual. In that case the page.h __pa/__va macros
> stand a chance (^_^;)
No. 4000_0000 physical is never mapped to 4000_0000 virtual. The low
2GB of virtual address space are used for user mapping.
> If somebody has already done kernel page table implementation, could
> you please pass on the relevant patch? Thanks.
If you have a 64-bit CPU, you can use a 64-bit kernel which gives you
large XKPHYS area. If not, and your CPU does not have D-cache
aliasing, you can use CONFIG_HIGHMEM which are using kernel page table
already. Otherwise you are out of luck for now unfortunately.
Anyway, you do not have to change __pa() and __va().
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH] cleanup hardcoding __pa/__va macros etc. (take-5)
2006-10-01 14:52 ` Atsushi Nemoto
@ 2006-10-01 14:57 ` girish
2006-10-01 15:09 ` Atsushi Nemoto
0 siblings, 1 reply; 20+ messages in thread
From: girish @ 2006-10-01 14:57 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips, ralf
On Oct 1, 2006, at 11:52 PM, Atsushi Nemoto wrote:
> On Sat, 30 Sep 2006 03:33:01 +0900, girish <girishvg@gmail.com> wrote:
>>> Looks good to me, except for page.h part.
>>
>> I agree, but as of now, I do not have any better solution. If & when
>> I will implement kernel page table for memory above 2000_0000, I plan
>> to give it a through mapping. That is to say, 4000_0000 physical
>> mapped to 4000_0000 virtual. In that case the page.h __pa/__va macros
>> stand a chance (^_^;)
>
> No. 4000_0000 physical is never mapped to 4000_0000 virtual. The low
> 2GB of virtual address space are used for user mapping.
Can't I provide Kernel mapping via swapper_pg_dir to 4000_0000?
>
>> If somebody has already done kernel page table implementation, could
>> you please pass on the relevant patch? Thanks.
>
> If you have a 64-bit CPU, you can use a 64-bit kernel which gives you
> large XKPHYS area. If not, and your CPU does not have D-cache
> aliasing, you can use CONFIG_HIGHMEM which are using kernel page table
> already. Otherwise you are out of luck for now unfortunately.
We poor 32bit users!
I have, to some extent, already incorporated highmem (1GB) through
HIGHMEM + SPARSEMEM combination.
> Anyway, you do not have to change __pa() and __va().
>
> ---
> Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH] cleanup hardcoding __pa/__va macros etc. (take-5)
2006-10-01 14:57 ` girish
@ 2006-10-01 15:09 ` Atsushi Nemoto
0 siblings, 0 replies; 20+ messages in thread
From: Atsushi Nemoto @ 2006-10-01 15:09 UTC (permalink / raw)
To: girishvg; +Cc: linux-mips, ralf
On Sun, 1 Oct 2006 23:57:03 +0900, girish <girishvg@gmail.com> wrote:
> > No. 4000_0000 physical is never mapped to 4000_0000 virtual. The low
> > 2GB of virtual address space are used for user mapping.
>
> Can't I provide Kernel mapping via swapper_pg_dir to 4000_0000?
Yes. I do not think it is possible.
> I have, to some extent, already incorporated highmem (1GB) through
> HIGHMEM + SPARSEMEM combination.
So using __pa() and __va() for HIGHMEM page is wrong. If there were
such usages, please fix them instead.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2006-10-01 15:07 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-24 5:39 [PATCH] cleanup hardcoding __pa/__va macros etc girish
2006-09-24 7:15 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (FWD) girish
2006-09-24 15:26 ` [PATCH] cleanup hardcoding __pa/__va macros etc Atsushi Nemoto
2006-09-25 14:51 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2) girish
2006-09-25 15:43 ` Atsushi Nemoto
[not found] ` <C13EBDF2.724C%girishvg@gmail.com>
2006-09-26 2:24 ` FW: " girish
2006-09-26 9:02 ` Atsushi Nemoto
2006-09-26 15:20 ` girish
2006-09-26 16:35 ` Atsushi Nemoto
2006-09-26 22:06 ` girish
2006-09-27 15:35 ` Atsushi Nemoto
2006-09-27 16:58 ` PATCH] cleanup hardcoding __pa/__va macros etc. (take-4) girish
2006-09-28 23:29 ` Ralf Baechle
2006-09-29 14:45 ` PATCH] cleanup hardcoding __pa/__va macros etc. (take-5) girish
2006-09-29 17:59 ` Atsushi Nemoto
2006-09-29 18:33 ` girish
2006-10-01 14:52 ` Atsushi Nemoto
2006-10-01 14:57 ` girish
2006-10-01 15:09 ` Atsushi Nemoto
2006-09-28 15:01 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2) Ralf Baechle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.