diff options
Diffstat (limited to 'drivers/edac/edac_mc_sysfs.c')
-rw-r--r-- | drivers/edac/edac_mc_sysfs.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 487e03eeed26..1dc1c6ca4308 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -144,7 +144,13 @@ static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data, | |||
144 | static ssize_t csrow_size_show(struct csrow_info *csrow, char *data, | 144 | static ssize_t csrow_size_show(struct csrow_info *csrow, char *data, |
145 | int private) | 145 | int private) |
146 | { | 146 | { |
147 | return sprintf(data, "%u\n", PAGES_TO_MiB(csrow->nr_pages)); | 147 | int i; |
148 | u32 nr_pages = 0; | ||
149 | |||
150 | for (i = 0; i < csrow->nr_channels; i++) | ||
151 | nr_pages += csrow->channels[i].dimm->nr_pages; | ||
152 | |||
153 | return sprintf(data, "%u\n", PAGES_TO_MiB(nr_pages)); | ||
148 | } | 154 | } |
149 | 155 | ||
150 | static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data, | 156 | static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data, |
@@ -519,16 +525,16 @@ static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data) | |||
519 | 525 | ||
520 | static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data) | 526 | static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data) |
521 | { | 527 | { |
522 | int total_pages, csrow_idx; | 528 | int total_pages = 0, csrow_idx, j; |
523 | 529 | ||
524 | for (total_pages = csrow_idx = 0; csrow_idx < mci->nr_csrows; | 530 | for (csrow_idx = 0; csrow_idx < mci->nr_csrows; csrow_idx++) { |
525 | csrow_idx++) { | ||
526 | struct csrow_info *csrow = &mci->csrows[csrow_idx]; | 531 | struct csrow_info *csrow = &mci->csrows[csrow_idx]; |
527 | 532 | ||
528 | if (!csrow->nr_pages) | 533 | for (j = 0; j < csrow->nr_channels; j++) { |
529 | continue; | 534 | struct dimm_info *dimm = csrow->channels[j].dimm; |
530 | 535 | ||
531 | total_pages += csrow->nr_pages; | 536 | total_pages += dimm->nr_pages; |
537 | } | ||
532 | } | 538 | } |
533 | 539 | ||
534 | return sprintf(data, "%u\n", PAGES_TO_MiB(total_pages)); | 540 | return sprintf(data, "%u\n", PAGES_TO_MiB(total_pages)); |
@@ -900,7 +906,7 @@ static void edac_remove_mci_instance_attributes(struct mem_ctl_info *mci, | |||
900 | */ | 906 | */ |
901 | int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | 907 | int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) |
902 | { | 908 | { |
903 | int i; | 909 | int i, j; |
904 | int err; | 910 | int err; |
905 | struct csrow_info *csrow; | 911 | struct csrow_info *csrow; |
906 | struct kobject *kobj_mci = &mci->edac_mci_kobj; | 912 | struct kobject *kobj_mci = &mci->edac_mci_kobj; |
@@ -934,10 +940,13 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
934 | /* Make directories for each CSROW object under the mc<id> kobject | 940 | /* Make directories for each CSROW object under the mc<id> kobject |
935 | */ | 941 | */ |
936 | for (i = 0; i < mci->nr_csrows; i++) { | 942 | for (i = 0; i < mci->nr_csrows; i++) { |
943 | int nr_pages = 0; | ||
944 | |||
937 | csrow = &mci->csrows[i]; | 945 | csrow = &mci->csrows[i]; |
946 | for (j = 0; j < csrow->nr_channels; j++) | ||
947 | nr_pages += csrow->channels[j].dimm->nr_pages; | ||
938 | 948 | ||
939 | /* Only expose populated CSROWs */ | 949 | if (nr_pages > 0) { |
940 | if (csrow->nr_pages > 0) { | ||
941 | err = edac_create_csrow_object(mci, csrow, i); | 950 | err = edac_create_csrow_object(mci, csrow, i); |
942 | if (err) { | 951 | if (err) { |
943 | debugf1("%s() failure: create csrow %d obj\n", | 952 | debugf1("%s() failure: create csrow %d obj\n", |
@@ -949,10 +958,14 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
949 | 958 | ||
950 | return 0; | 959 | return 0; |
951 | 960 | ||
952 | /* CSROW error: backout what has already been registered, */ | ||
953 | fail1: | 961 | fail1: |
954 | for (i--; i >= 0; i--) { | 962 | for (i--; i >= 0; i--) { |
955 | if (mci->csrows[i].nr_pages > 0) | 963 | int nr_pages = 0; |
964 | |||
965 | csrow = &mci->csrows[i]; | ||
966 | for (j = 0; j < csrow->nr_channels; j++) | ||
967 | nr_pages += csrow->channels[j].dimm->nr_pages; | ||
968 | if (nr_pages > 0) | ||
956 | kobject_put(&mci->csrows[i].kobj); | 969 | kobject_put(&mci->csrows[i].kobj); |
957 | } | 970 | } |
958 | 971 | ||
@@ -972,14 +985,20 @@ fail0: | |||
972 | */ | 985 | */ |
973 | void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) | 986 | void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) |
974 | { | 987 | { |
975 | int i; | 988 | struct csrow_info *csrow; |
989 | int i, j; | ||
976 | 990 | ||
977 | debugf0("%s()\n", __func__); | 991 | debugf0("%s()\n", __func__); |
978 | 992 | ||
979 | /* remove all csrow kobjects */ | 993 | /* remove all csrow kobjects */ |
980 | debugf4("%s() unregister this mci kobj\n", __func__); | 994 | debugf4("%s() unregister this mci kobj\n", __func__); |
981 | for (i = 0; i < mci->nr_csrows; i++) { | 995 | for (i = 0; i < mci->nr_csrows; i++) { |
982 | if (mci->csrows[i].nr_pages > 0) { | 996 | int nr_pages = 0; |
997 | |||
998 | csrow = &mci->csrows[i]; | ||
999 | for (j = 0; j < csrow->nr_channels; j++) | ||
1000 | nr_pages += csrow->channels[j].dimm->nr_pages; | ||
1001 | if (nr_pages > 0) { | ||
983 | debugf0("%s() unreg csrow-%d\n", __func__, i); | 1002 | debugf0("%s() unreg csrow-%d\n", __func__, i); |
984 | kobject_put(&mci->csrows[i].kobj); | 1003 | kobject_put(&mci->csrows[i].kobj); |
985 | } | 1004 | } |