diff options
author | Andreas Herrmann <andreas.herrmann3@amd.com> | 2008-06-20 16:01:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-24 07:05:49 -0400 |
commit | ac97991ec9e0a05c8860f4a04f8477227b1c03f2 (patch) | |
tree | 6f5872949a2dce1e69c762b727e4ef757659cf86 /arch/x86/mm | |
parent | bcc643dc287cb732e96a1685ac130c3ae8b1c960 (diff) |
x86: pat.c choose more crisp variable names
- parse/ml => entry (within list_for_each and friends)
- new_entry => new
- ret_type => new_type (to avoid confusion with req_type)
(... to make it more readable...)
Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Cc: Suresh B Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r-- | arch/x86/mm/pat.c | 127 |
1 files changed, 62 insertions, 65 deletions
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 5bbc22efe4e5..a6507bfb12a7 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -188,37 +188,34 @@ static unsigned long pat_x_mtrr_type(u64 start, u64 end, unsigned long req_type) | |||
188 | * req_type will have a special case value '-1', when requester want to inherit | 188 | * req_type will have a special case value '-1', when requester want to inherit |
189 | * the memory type from mtrr (if WB), existing PAT, defaulting to UC_MINUS. | 189 | * the memory type from mtrr (if WB), existing PAT, defaulting to UC_MINUS. |
190 | * | 190 | * |
191 | * If ret_type is NULL, function will return an error if it cannot reserve the | 191 | * If new_type is NULL, function will return an error if it cannot reserve the |
192 | * region with req_type. If ret_type is non-null, function will return | 192 | * region with req_type. If new_type is non-NULL, function will return |
193 | * available type in ret_type in case of no error. In case of any error | 193 | * available type in new_type in case of no error. In case of any error |
194 | * it will return a negative return value. | 194 | * it will return a negative return value. |
195 | */ | 195 | */ |
196 | int reserve_memtype(u64 start, u64 end, unsigned long req_type, | 196 | int reserve_memtype(u64 start, u64 end, unsigned long req_type, |
197 | unsigned long *ret_type) | 197 | unsigned long *new_type) |
198 | { | 198 | { |
199 | struct memtype *new_entry = NULL; | 199 | struct memtype *new, *entry; |
200 | struct memtype *parse; | ||
201 | unsigned long actual_type; | 200 | unsigned long actual_type; |
202 | int err = 0; | 201 | int err = 0; |
203 | 202 | ||
204 | /* Only track when pat_enabled */ | 203 | /* Only track when pat_enabled */ |
205 | if (!pat_enabled) { | 204 | if (!pat_enabled) { |
206 | /* This is identical to page table setting without PAT */ | 205 | /* This is identical to page table setting without PAT */ |
207 | if (ret_type) { | 206 | if (new_type) { |
208 | if (req_type == -1) { | 207 | if (req_type == -1) |
209 | *ret_type = _PAGE_CACHE_WB; | 208 | *new_type = _PAGE_CACHE_WB; |
210 | } else { | 209 | else |
211 | *ret_type = req_type & _PAGE_CACHE_MASK; | 210 | *new_type = req_type & _PAGE_CACHE_MASK; |
212 | } | ||
213 | } | 211 | } |
214 | return 0; | 212 | return 0; |
215 | } | 213 | } |
216 | 214 | ||
217 | /* Low ISA region is always mapped WB in page table. No need to track */ | 215 | /* Low ISA region is always mapped WB in page table. No need to track */ |
218 | if (is_ISA_range(start, end - 1)) { | 216 | if (is_ISA_range(start, end - 1)) { |
219 | if (ret_type) | 217 | if (new_type) |
220 | *ret_type = _PAGE_CACHE_WB; | 218 | *new_type = _PAGE_CACHE_WB; |
221 | |||
222 | return 0; | 219 | return 0; |
223 | } | 220 | } |
224 | 221 | ||
@@ -243,65 +240,65 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type, | |||
243 | actual_type = pat_x_mtrr_type(start, end, req_type); | 240 | actual_type = pat_x_mtrr_type(start, end, req_type); |
244 | } | 241 | } |
245 | 242 | ||
246 | new_entry = kmalloc(sizeof(struct memtype), GFP_KERNEL); | 243 | new = kmalloc(sizeof(struct memtype), GFP_KERNEL); |
247 | if (!new_entry) | 244 | if (!new) |
248 | return -ENOMEM; | 245 | return -ENOMEM; |
249 | 246 | ||
250 | new_entry->start = start; | 247 | new->start = start; |
251 | new_entry->end = end; | 248 | new->end = end; |
252 | new_entry->type = actual_type; | 249 | new->type = actual_type; |
253 | 250 | ||
254 | if (ret_type) | 251 | if (new_type) |
255 | *ret_type = actual_type; | 252 | *new_type = actual_type; |
256 | 253 | ||
257 | spin_lock(&memtype_lock); | 254 | spin_lock(&memtype_lock); |
258 | 255 | ||
259 | /* Search for existing mapping that overlaps the current range */ | 256 | /* Search for existing mapping that overlaps the current range */ |
260 | list_for_each_entry(parse, &memtype_list, nd) { | 257 | list_for_each_entry(entry, &memtype_list, nd) { |
261 | struct memtype *saved_ptr; | 258 | struct memtype *saved_ptr; |
262 | 259 | ||
263 | if (parse->start >= end) { | 260 | if (entry->start >= end) { |
264 | dprintk("New Entry\n"); | 261 | dprintk("New Entry\n"); |
265 | list_add(&new_entry->nd, parse->nd.prev); | 262 | list_add(&new->nd, entry->nd.prev); |
266 | new_entry = NULL; | 263 | new = NULL; |
267 | break; | 264 | break; |
268 | } | 265 | } |
269 | 266 | ||
270 | if (start <= parse->start && end >= parse->start) { | 267 | if (start <= entry->start && end >= entry->start) { |
271 | if (actual_type != parse->type && ret_type) { | 268 | if (actual_type != entry->type && new_type) { |
272 | actual_type = parse->type; | 269 | actual_type = entry->type; |
273 | *ret_type = actual_type; | 270 | *new_type = actual_type; |
274 | new_entry->type = actual_type; | 271 | new->type = actual_type; |
275 | } | 272 | } |
276 | 273 | ||
277 | if (actual_type != parse->type) { | 274 | if (actual_type != entry->type) { |
278 | printk( | 275 | printk( |
279 | KERN_INFO "%s:%d conflicting memory types %Lx-%Lx %s<->%s\n", | 276 | KERN_INFO "%s:%d conflicting memory types %Lx-%Lx %s<->%s\n", |
280 | current->comm, current->pid, | 277 | current->comm, current->pid, |
281 | start, end, | 278 | start, end, |
282 | cattr_name(actual_type), | 279 | cattr_name(actual_type), |
283 | cattr_name(parse->type)); | 280 | cattr_name(entry->type)); |
284 | err = -EBUSY; | 281 | err = -EBUSY; |
285 | break; | 282 | break; |
286 | } | 283 | } |
287 | 284 | ||
288 | saved_ptr = parse; | 285 | saved_ptr = entry; |
289 | /* | 286 | /* |
290 | * Check to see whether the request overlaps more | 287 | * Check to see whether the request overlaps more |
291 | * than one entry in the list | 288 | * than one entry in the list |
292 | */ | 289 | */ |
293 | list_for_each_entry_continue(parse, &memtype_list, nd) { | 290 | list_for_each_entry_continue(entry, &memtype_list, nd) { |
294 | if (end <= parse->start) { | 291 | if (end <= entry->start) { |
295 | break; | 292 | break; |
296 | } | 293 | } |
297 | 294 | ||
298 | if (actual_type != parse->type) { | 295 | if (actual_type != entry->type) { |
299 | printk( | 296 | printk( |
300 | KERN_INFO "%s:%d conflicting memory types %Lx-%Lx %s<->%s\n", | 297 | KERN_INFO "%s:%d conflicting memory types %Lx-%Lx %s<->%s\n", |
301 | current->comm, current->pid, | 298 | current->comm, current->pid, |
302 | start, end, | 299 | start, end, |
303 | cattr_name(actual_type), | 300 | cattr_name(actual_type), |
304 | cattr_name(parse->type)); | 301 | cattr_name(entry->type)); |
305 | err = -EBUSY; | 302 | err = -EBUSY; |
306 | break; | 303 | break; |
307 | } | 304 | } |
@@ -314,46 +311,46 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type, | |||
314 | dprintk("Overlap at 0x%Lx-0x%Lx\n", | 311 | dprintk("Overlap at 0x%Lx-0x%Lx\n", |
315 | saved_ptr->start, saved_ptr->end); | 312 | saved_ptr->start, saved_ptr->end); |
316 | /* No conflict. Go ahead and add this new entry */ | 313 | /* No conflict. Go ahead and add this new entry */ |
317 | list_add(&new_entry->nd, saved_ptr->nd.prev); | 314 | list_add(&new->nd, saved_ptr->nd.prev); |
318 | new_entry = NULL; | 315 | new = NULL; |
319 | break; | 316 | break; |
320 | } | 317 | } |
321 | 318 | ||
322 | if (start < parse->end) { | 319 | if (start < entry->end) { |
323 | if (actual_type != parse->type && ret_type) { | 320 | if (actual_type != entry->type && new_type) { |
324 | actual_type = parse->type; | 321 | actual_type = entry->type; |
325 | *ret_type = actual_type; | 322 | *new_type = actual_type; |
326 | new_entry->type = actual_type; | 323 | new->type = actual_type; |
327 | } | 324 | } |
328 | 325 | ||
329 | if (actual_type != parse->type) { | 326 | if (actual_type != entry->type) { |
330 | printk( | 327 | printk( |
331 | KERN_INFO "%s:%d conflicting memory types %Lx-%Lx %s<->%s\n", | 328 | KERN_INFO "%s:%d conflicting memory types %Lx-%Lx %s<->%s\n", |
332 | current->comm, current->pid, | 329 | current->comm, current->pid, |
333 | start, end, | 330 | start, end, |
334 | cattr_name(actual_type), | 331 | cattr_name(actual_type), |
335 | cattr_name(parse->type)); | 332 | cattr_name(entry->type)); |
336 | err = -EBUSY; | 333 | err = -EBUSY; |
337 | break; | 334 | break; |
338 | } | 335 | } |
339 | 336 | ||
340 | saved_ptr = parse; | 337 | saved_ptr = entry; |
341 | /* | 338 | /* |
342 | * Check to see whether the request overlaps more | 339 | * Check to see whether the request overlaps more |
343 | * than one entry in the list | 340 | * than one entry in the list |
344 | */ | 341 | */ |
345 | list_for_each_entry_continue(parse, &memtype_list, nd) { | 342 | list_for_each_entry_continue(entry, &memtype_list, nd) { |
346 | if (end <= parse->start) { | 343 | if (end <= entry->start) { |
347 | break; | 344 | break; |
348 | } | 345 | } |
349 | 346 | ||
350 | if (actual_type != parse->type) { | 347 | if (actual_type != entry->type) { |
351 | printk( | 348 | printk( |
352 | KERN_INFO "%s:%d conflicting memory types %Lx-%Lx %s<->%s\n", | 349 | KERN_INFO "%s:%d conflicting memory types %Lx-%Lx %s<->%s\n", |
353 | current->comm, current->pid, | 350 | current->comm, current->pid, |
354 | start, end, | 351 | start, end, |
355 | cattr_name(actual_type), | 352 | cattr_name(actual_type), |
356 | cattr_name(parse->type)); | 353 | cattr_name(entry->type)); |
357 | err = -EBUSY; | 354 | err = -EBUSY; |
358 | break; | 355 | break; |
359 | } | 356 | } |
@@ -366,8 +363,8 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type, | |||
366 | dprintk("Overlap at 0x%Lx-0x%Lx\n", | 363 | dprintk("Overlap at 0x%Lx-0x%Lx\n", |
367 | saved_ptr->start, saved_ptr->end); | 364 | saved_ptr->start, saved_ptr->end); |
368 | /* No conflict. Go ahead and add this new entry */ | 365 | /* No conflict. Go ahead and add this new entry */ |
369 | list_add(&new_entry->nd, &saved_ptr->nd); | 366 | list_add(&new->nd, &saved_ptr->nd); |
370 | new_entry = NULL; | 367 | new = NULL; |
371 | break; | 368 | break; |
372 | } | 369 | } |
373 | } | 370 | } |
@@ -375,24 +372,24 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type, | |||
375 | if (err) { | 372 | if (err) { |
376 | printk(KERN_INFO | 373 | printk(KERN_INFO |
377 | "reserve_memtype failed 0x%Lx-0x%Lx, track %s, req %s\n", | 374 | "reserve_memtype failed 0x%Lx-0x%Lx, track %s, req %s\n", |
378 | start, end, cattr_name(new_entry->type), | 375 | start, end, cattr_name(new->type), |
379 | cattr_name(req_type)); | 376 | cattr_name(req_type)); |
380 | kfree(new_entry); | 377 | kfree(new); |
381 | spin_unlock(&memtype_lock); | 378 | spin_unlock(&memtype_lock); |
382 | return err; | 379 | return err; |
383 | } | 380 | } |
384 | 381 | ||
385 | if (new_entry) { | 382 | if (new) { |
386 | /* No conflict. Not yet added to the list. Add to the tail */ | 383 | /* No conflict. Not yet added to the list. Add to the tail */ |
387 | list_add_tail(&new_entry->nd, &memtype_list); | 384 | list_add_tail(&new->nd, &memtype_list); |
388 | dprintk("New Entry\n"); | 385 | dprintk("New Entry\n"); |
389 | } | 386 | } |
390 | 387 | ||
391 | if (ret_type) { | 388 | if (new_type) { |
392 | dprintk( | 389 | dprintk( |
393 | "reserve_memtype added 0x%Lx-0x%Lx, track %s, req %s, ret %s\n", | 390 | "reserve_memtype added 0x%Lx-0x%Lx, track %s, req %s, ret %s\n", |
394 | start, end, cattr_name(actual_type), | 391 | start, end, cattr_name(actual_type), |
395 | cattr_name(req_type), cattr_name(*ret_type)); | 392 | cattr_name(req_type), cattr_name(*new_type)); |
396 | } else { | 393 | } else { |
397 | dprintk( | 394 | dprintk( |
398 | "reserve_memtype added 0x%Lx-0x%Lx, track %s, req %s\n", | 395 | "reserve_memtype added 0x%Lx-0x%Lx, track %s, req %s\n", |
@@ -406,7 +403,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type, | |||
406 | 403 | ||
407 | int free_memtype(u64 start, u64 end) | 404 | int free_memtype(u64 start, u64 end) |
408 | { | 405 | { |
409 | struct memtype *ml; | 406 | struct memtype *entry; |
410 | int err = -EINVAL; | 407 | int err = -EINVAL; |
411 | 408 | ||
412 | /* Only track when pat_enabled */ | 409 | /* Only track when pat_enabled */ |
@@ -419,10 +416,10 @@ int free_memtype(u64 start, u64 end) | |||
419 | return 0; | 416 | return 0; |
420 | 417 | ||
421 | spin_lock(&memtype_lock); | 418 | spin_lock(&memtype_lock); |
422 | list_for_each_entry(ml, &memtype_list, nd) { | 419 | list_for_each_entry(entry, &memtype_list, nd) { |
423 | if (ml->start == start && ml->end == end) { | 420 | if (entry->start == start && entry->end == end) { |
424 | list_del(&ml->nd); | 421 | list_del(&entry->nd); |
425 | kfree(ml); | 422 | kfree(entry); |
426 | err = 0; | 423 | err = 0; |
427 | break; | 424 | break; |
428 | } | 425 | } |