diff options
| author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-04-24 14:05:43 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-06-11 12:23:45 -0400 |
| commit | de3910eb79ac8c0f29a11224661c0ebaaf813039 (patch) | |
| tree | 44584d6691588b2c18823260be0e44f0c9872d02 /include/linux | |
| parent | e39f4ea9b01f137f9e6fa631f3e9088fb9175e91 (diff) | |
edac: change the mem allocation scheme to make Documentation/kobject.txt happy
Kernel kobjects have rigid rules: each container object should be
dynamically allocated, and can't be allocated into a single kmalloc.
EDAC never obeyed this rule: it has a single malloc function that
allocates all needed data into a single kzalloc.
As this is not accepted anymore, change the allocation schema of the
EDAC *_info structs to enforce this Kernel standard.
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Cc: Aristeu Rozanski <arozansk@redhat.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Greg K H <gregkh@linuxfoundation.org>
Cc: Borislav Petkov <borislav.petkov@amd.com>
Cc: Mark Gross <mark.gross@intel.com>
Cc: Tim Small <tim@buttersideup.com>
Cc: Ranganathan Desikan <ravi@jetztechnologies.com>
Cc: "Arvind R." <arvino55@gmail.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Egor Martovetsky <egor@pasemi.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/edac.h | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/include/linux/edac.h b/include/linux/edac.h index 64ae0c5cf62e..6677af853e30 100644 --- a/include/linux/edac.h +++ b/include/linux/edac.h | |||
| @@ -412,23 +412,21 @@ struct edac_mc_layer { | |||
| 412 | #define EDAC_MAX_LAYERS 3 | 412 | #define EDAC_MAX_LAYERS 3 |
| 413 | 413 | ||
| 414 | /** | 414 | /** |
| 415 | * EDAC_DIMM_PTR - Macro responsible to find a pointer inside a pointer array | 415 | * EDAC_DIMM_OFF - Macro responsible to get a pointer offset inside a pointer array |
| 416 | * for the element given by [layer0,layer1,layer2] position | 416 | * for the element given by [layer0,layer1,layer2] position |
| 417 | * | 417 | * |
| 418 | * @layers: a struct edac_mc_layer array, describing how many elements | 418 | * @layers: a struct edac_mc_layer array, describing how many elements |
| 419 | * were allocated for each layer | 419 | * were allocated for each layer |
| 420 | * @var: name of the var where we want to get the pointer | ||
| 421 | * (like mci->dimms) | ||
| 422 | * @n_layers: Number of layers at the @layers array | 420 | * @n_layers: Number of layers at the @layers array |
| 423 | * @layer0: layer0 position | 421 | * @layer0: layer0 position |
| 424 | * @layer1: layer1 position. Unused if n_layers < 2 | 422 | * @layer1: layer1 position. Unused if n_layers < 2 |
| 425 | * @layer2: layer2 position. Unused if n_layers < 3 | 423 | * @layer2: layer2 position. Unused if n_layers < 3 |
| 426 | * | 424 | * |
| 427 | * For 1 layer, this macro returns &var[layer0] | 425 | * For 1 layer, this macro returns &var[layer0] - &var |
| 428 | * For 2 layers, this macro is similar to allocate a bi-dimensional array | 426 | * For 2 layers, this macro is similar to allocate a bi-dimensional array |
| 429 | * and to return "&var[layer0][layer1]" | 427 | * and to return "&var[layer0][layer1] - &var" |
| 430 | * For 3 layers, this macro is similar to allocate a tri-dimensional array | 428 | * For 3 layers, this macro is similar to allocate a tri-dimensional array |
| 431 | * and to return "&var[layer0][layer1][layer2]" | 429 | * and to return "&var[layer0][layer1][layer2] - &var" |
| 432 | * | 430 | * |
| 433 | * A loop could be used here to make it more generic, but, as we only have | 431 | * A loop could be used here to make it more generic, but, as we only have |
| 434 | * 3 layers, this is a little faster. | 432 | * 3 layers, this is a little faster. |
| @@ -436,17 +434,46 @@ struct edac_mc_layer { | |||
| 436 | * a NULL is returned, causing an OOPS during the memory allocation routine, | 434 | * a NULL is returned, causing an OOPS during the memory allocation routine, |
| 437 | * with would point to the developer that he's doing something wrong. | 435 | * with would point to the developer that he's doing something wrong. |
| 438 | */ | 436 | */ |
| 439 | #define EDAC_DIMM_PTR(layers, var, nlayers, layer0, layer1, layer2) ({ \ | 437 | #define EDAC_DIMM_OFF(layers, nlayers, layer0, layer1, layer2) ({ \ |
| 440 | typeof(var) __p; \ | 438 | int __i; \ |
| 441 | if ((nlayers) == 1) \ | 439 | if ((nlayers) == 1) \ |
| 442 | __p = &var[layer0]; \ | 440 | __i = layer0; \ |
| 443 | else if ((nlayers) == 2) \ | 441 | else if ((nlayers) == 2) \ |
| 444 | __p = &var[(layer1) + ((layers[1]).size * (layer0))]; \ | 442 | __i = (layer1) + ((layers[1]).size * (layer0)); \ |
| 445 | else if ((nlayers) == 3) \ | 443 | else if ((nlayers) == 3) \ |
| 446 | __p = &var[(layer2) + ((layers[2]).size * ((layer1) + \ | 444 | __i = (layer2) + ((layers[2]).size * ((layer1) + \ |
| 447 | ((layers[1]).size * (layer0))))]; \ | 445 | ((layers[1]).size * (layer0)))); \ |
| 448 | else \ | 446 | else \ |
| 447 | __i = -EINVAL; \ | ||
| 448 | __i; \ | ||
| 449 | }) | ||
| 450 | |||
| 451 | /** | ||
| 452 | * EDAC_DIMM_PTR - Macro responsible to get a pointer inside a pointer array | ||
| 453 | * for the element given by [layer0,layer1,layer2] position | ||
| 454 | * | ||
| 455 | * @layers: a struct edac_mc_layer array, describing how many elements | ||
| 456 | * were allocated for each layer | ||
| 457 | * @var: name of the var where we want to get the pointer | ||
| 458 | * (like mci->dimms) | ||
| 459 | * @n_layers: Number of layers at the @layers array | ||
| 460 | * @layer0: layer0 position | ||
| 461 | * @layer1: layer1 position. Unused if n_layers < 2 | ||
| 462 | * @layer2: layer2 position. Unused if n_layers < 3 | ||
| 463 | * | ||
| 464 | * For 1 layer, this macro returns &var[layer0] | ||
| 465 | * For 2 layers, this macro is similar to allocate a bi-dimensional array | ||
| 466 | * and to return "&var[layer0][layer1]" | ||
| 467 | * For 3 layers, this macro is similar to allocate a tri-dimensional array | ||
| 468 | * and to return "&var[layer0][layer1][layer2]" | ||
| 469 | */ | ||
| 470 | #define EDAC_DIMM_PTR(layers, var, nlayers, layer0, layer1, layer2) ({ \ | ||
| 471 | typeof(*var) __p; \ | ||
| 472 | int ___i = EDAC_DIMM_OFF(layers, nlayers, layer0, layer1, layer2); \ | ||
| 473 | if (___i < 0) \ | ||
| 449 | __p = NULL; \ | 474 | __p = NULL; \ |
| 475 | else \ | ||
| 476 | __p = (var)[___i]; \ | ||
| 450 | __p; \ | 477 | __p; \ |
| 451 | }) | 478 | }) |
| 452 | 479 | ||
| @@ -486,8 +513,6 @@ struct dimm_info { | |||
| 486 | * patches in this series will fix this issue. | 513 | * patches in this series will fix this issue. |
| 487 | */ | 514 | */ |
| 488 | struct rank_info { | 515 | struct rank_info { |
| 489 | struct device dev; | ||
| 490 | |||
| 491 | int chan_idx; | 516 | int chan_idx; |
| 492 | struct csrow_info *csrow; | 517 | struct csrow_info *csrow; |
| 493 | struct dimm_info *dimm; | 518 | struct dimm_info *dimm; |
| @@ -513,7 +538,7 @@ struct csrow_info { | |||
| 513 | 538 | ||
| 514 | /* channel information for this csrow */ | 539 | /* channel information for this csrow */ |
| 515 | u32 nr_channels; | 540 | u32 nr_channels; |
| 516 | struct rank_info *channels; | 541 | struct rank_info **channels; |
| 517 | }; | 542 | }; |
| 518 | 543 | ||
| 519 | /* | 544 | /* |
| @@ -572,7 +597,7 @@ struct mem_ctl_info { | |||
| 572 | unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci, | 597 | unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci, |
| 573 | unsigned long page); | 598 | unsigned long page); |
| 574 | int mc_idx; | 599 | int mc_idx; |
| 575 | struct csrow_info *csrows; | 600 | struct csrow_info **csrows; |
| 576 | unsigned nr_csrows, num_cschannel; | 601 | unsigned nr_csrows, num_cschannel; |
| 577 | 602 | ||
| 578 | /* | 603 | /* |
| @@ -592,7 +617,7 @@ struct mem_ctl_info { | |||
| 592 | * DIMM info. Will eventually remove the entire csrows_info some day | 617 | * DIMM info. Will eventually remove the entire csrows_info some day |
| 593 | */ | 618 | */ |
| 594 | unsigned tot_dimms; | 619 | unsigned tot_dimms; |
| 595 | struct dimm_info *dimms; | 620 | struct dimm_info **dimms; |
| 596 | 621 | ||
| 597 | /* | 622 | /* |
| 598 | * FIXME - what about controllers on other busses? - IDs must be | 623 | * FIXME - what about controllers on other busses? - IDs must be |
