From: girish <girishvg@gmail.com>
To: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Cc: girish <girishvg@gmail.com>, Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Subject: Re: [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2)
Date: Mon, 25 Sep 2006 23:51:46 +0900 [thread overview]
Message-ID: <C13E1C13.6FDC%girishvg@gmail.com> (raw)
In-Reply-To: <20060925.002616.126574366.anemo@mba.ocn.ne.jp>
[-- 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)
next prev parent reply other threads:[~2006-09-25 14:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` girish [this message]
2006-09-25 15:43 ` [PATCH] cleanup hardcoding __pa/__va macros etc. (take-2) 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C13E1C13.6FDC%girishvg@gmail.com \
--to=girishvg@gmail.com \
--cc=anemo@mba.ocn.ne.jp \
--cc=linux-mips@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.