ia64/linux-2.6.18-xen.hg

view drivers/mtd/maps/alchemy-flash.c @ 897:329ea0ccb344

balloon: try harder to balloon up under memory pressure.

Currently if the balloon driver is unable to increase the guest's
reservation it assumes the failure was due to reaching its full
allocation, gives up on the ballooning operation and records the limit
it reached as the "hard limit". The driver will not try again until
the target is set again (even to the same value).

However it is possible that ballooning has in fact failed due to
memory pressure in the host and therefore it is desirable to keep
attempting to reach the target in case memory becomes available. The
most likely scenario is that some guests are ballooning down while
others are ballooning up and therefore there is temporary memory
pressure while things stabilise. You would not expect a well behaved
toolstack to ask a domain to balloon to more than its allocation nor
would you expect it to deliberately over-commit memory by setting
balloon targets which exceed the total host memory.

This patch drops the concept of a hard limit and causes the balloon
driver to retry increasing the reservation on a timer in the same
manner as when decreasing the reservation.

Also if we partially succeed in increasing the reservation
(i.e. receive less pages than we asked for) then we may as well keep
those pages rather than returning them to Xen.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 14:01:20 2009 +0100 (2009-06-05)
parents 831230e53067
children
line source
1 /*
2 * Flash memory access on AMD Alchemy evaluation boards
3 *
4 * $Id: alchemy-flash.c,v 1.2 2005/11/07 11:14:26 gleixner Exp $
5 *
6 * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com>
7 *
8 */
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/map.h>
17 #include <linux/mtd/partitions.h>
19 #include <asm/io.h>
21 #ifdef DEBUG_RW
22 #define DBG(x...) printk(x)
23 #else
24 #define DBG(x...)
25 #endif
27 #ifdef CONFIG_MIPS_PB1000
28 #define BOARD_MAP_NAME "Pb1000 Flash"
29 #define BOARD_FLASH_SIZE 0x00800000 /* 8MB */
30 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
31 #endif
33 #ifdef CONFIG_MIPS_PB1500
34 #define BOARD_MAP_NAME "Pb1500 Flash"
35 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
36 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
37 #endif
39 #ifdef CONFIG_MIPS_PB1100
40 #define BOARD_MAP_NAME "Pb1100 Flash"
41 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
42 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
43 #endif
45 #ifdef CONFIG_MIPS_PB1550
46 #define BOARD_MAP_NAME "Pb1550 Flash"
47 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
48 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
49 #endif
51 #ifdef CONFIG_MIPS_PB1200
52 #define BOARD_MAP_NAME "Pb1200 Flash"
53 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
54 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
55 #endif
57 #ifdef CONFIG_MIPS_DB1000
58 #define BOARD_MAP_NAME "Db1000 Flash"
59 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
60 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
61 #endif
63 #ifdef CONFIG_MIPS_DB1500
64 #define BOARD_MAP_NAME "Db1500 Flash"
65 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
66 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
67 #endif
69 #ifdef CONFIG_MIPS_DB1100
70 #define BOARD_MAP_NAME "Db1100 Flash"
71 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
72 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
73 #endif
75 #ifdef CONFIG_MIPS_DB1550
76 #define BOARD_MAP_NAME "Db1550 Flash"
77 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
78 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
79 #endif
81 #ifdef CONFIG_MIPS_DB1200
82 #define BOARD_MAP_NAME "Db1200 Flash"
83 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
84 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
85 #endif
87 #ifdef CONFIG_MIPS_HYDROGEN3
88 #define BOARD_MAP_NAME "Hydrogen3 Flash"
89 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
90 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
91 #define USE_LOCAL_ACCESSORS /* why? */
92 #endif
94 #ifdef CONFIG_MIPS_BOSPORUS
95 #define BOARD_MAP_NAME "Bosporus Flash"
96 #define BOARD_FLASH_SIZE 0x01000000 /* 16MB */
97 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
98 #endif
100 #ifdef CONFIG_MIPS_MIRAGE
101 #define BOARD_MAP_NAME "Mirage Flash"
102 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
103 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
104 #define USE_LOCAL_ACCESSORS /* why? */
105 #endif
107 static struct map_info alchemy_map = {
108 .name = BOARD_MAP_NAME,
109 };
111 static struct mtd_partition alchemy_partitions[] = {
112 {
113 .name = "User FS",
114 .size = BOARD_FLASH_SIZE - 0x00400000,
115 .offset = 0x0000000
116 },{
117 .name = "YAMON",
118 .size = 0x0100000,
119 .offset = MTDPART_OFS_APPEND,
120 .mask_flags = MTD_WRITEABLE
121 },{
122 .name = "raw kernel",
123 .size = (0x300000 - 0x40000), /* last 256KB is yamon env */
124 .offset = MTDPART_OFS_APPEND,
125 }
126 };
128 static struct mtd_info *mymtd;
130 int __init alchemy_mtd_init(void)
131 {
132 struct mtd_partition *parts;
133 int nb_parts = 0;
134 unsigned long window_addr;
135 unsigned long window_size;
137 /* Default flash buswidth */
138 alchemy_map.bankwidth = BOARD_FLASH_WIDTH;
140 window_addr = 0x20000000 - BOARD_FLASH_SIZE;
141 window_size = BOARD_FLASH_SIZE;
142 #ifdef CONFIG_MIPS_MIRAGE_WHY
143 /* Boot ROM flash bank only; no user bank */
144 window_addr = 0x1C000000;
145 window_size = 0x04000000;
146 /* USERFS from 0x1C00 0000 to 0x1FC00000 */
147 alchemy_partitions[0].size = 0x03C00000;
148 #endif
150 /*
151 * Static partition definition selection
152 */
153 parts = alchemy_partitions;
154 nb_parts = ARRAY_SIZE(alchemy_partitions);
155 alchemy_map.size = window_size;
157 /*
158 * Now let's probe for the actual flash. Do it here since
159 * specific machine settings might have been set above.
160 */
161 printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
162 alchemy_map.bankwidth*8);
163 alchemy_map.virt = ioremap(window_addr, window_size);
164 mymtd = do_map_probe("cfi_probe", &alchemy_map);
165 if (!mymtd) {
166 iounmap(alchemy_map.virt);
167 return -ENXIO;
168 }
169 mymtd->owner = THIS_MODULE;
171 add_mtd_partitions(mymtd, parts, nb_parts);
172 return 0;
173 }
175 static void __exit alchemy_mtd_cleanup(void)
176 {
177 if (mymtd) {
178 del_mtd_partitions(mymtd);
179 map_destroy(mymtd);
180 iounmap(alchemy_map.virt);
181 }
182 }
184 module_init(alchemy_mtd_init);
185 module_exit(alchemy_mtd_cleanup);
187 MODULE_AUTHOR("Embedded Alley Solutions, Inc");
188 MODULE_DESCRIPTION(BOARD_MAP_NAME " MTD driver");
189 MODULE_LICENSE("GPL");