All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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.