aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-01-27 12:12:32 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-28 18:10:57 -0400
commita7d7d2e1a07e3811dc49af2962c940fd8bbb6c8f (patch)
tree6c3ac39bf25fb7810668f57476c7b5872d5b418b /drivers
parent76e10d158efb6d4516018846f60c2ab5501900bc (diff)
edac: Create a dimm struct and move the labels into it
The way a DIMM is currently represented implies that they're linked into a per-csrow struct. However, some drivers don't see csrows, as they're ridden behind some chip like the AMB's on FBDIMM's, for example. This forced drivers to fake^Wvirtualize a csrow struct, and to create a mess under csrow/channel original's concept. Move the DIMM labels into a per-DIMM struct, and add there the real location of the socket, in terms of csrow/channel. Latter patches will modify the location to properly represent the memory architecture. All other drivers will use a per-csrow type of location. Some of those drivers will require a latter conversion, as they also fake the csrows internally. TODO: While this patch doesn't change the existing behavior, on csrows-based memory controllers, a csrow/channel pair points to a memory rank. There's a known bug at the EDAC core that allows having different labels for the same DIMM, if it has more than one rank. A latter patch is need to merge the several ranks for a DIMM into the same dimm_info struct, in order to avoid having different labels for the same DIMM. The edac_mc_alloc() will now contain a per-dimm initialization loop that will be changed by latter patches in order to match other types of memory architectures. Reviewed-by: Aristeu Rozanski <arozansk@redhat.com> Reviewed-by: Borislav Petkov <borislav.petkov@amd.com> Cc: Doug Thompson <norsk5@yahoo.com> Cc: Ranganathan Desikan <ravi@jetztechnologies.com> Cc: "Arvind R." <arvino55@gmail.com> Cc: "Niklas Söderlund" <niklas.soderlund@ericsson.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/edac/edac_mc.c47
-rw-r--r--drivers/edac/edac_mc_sysfs.c11
-rw-r--r--drivers/edac/i5100_edac.c8
-rw-r--r--drivers/edac/i7core_edac.c4
-rw-r--r--drivers/edac/i82975x_edac.c2
-rw-r--r--drivers/edac/sb_edac.c4
6 files changed, 49 insertions, 27 deletions
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index feef7733fae7..c1aae7233022 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -44,7 +44,7 @@ static void edac_mc_dump_channel(struct rank_info *chan)
44 debugf4("\tchannel = %p\n", chan); 44 debugf4("\tchannel = %p\n", chan);
45 debugf4("\tchannel->chan_idx = %d\n", chan->chan_idx); 45 debugf4("\tchannel->chan_idx = %d\n", chan->chan_idx);
46 debugf4("\tchannel->ce_count = %d\n", chan->ce_count); 46 debugf4("\tchannel->ce_count = %d\n", chan->ce_count);
47 debugf4("\tchannel->label = '%s'\n", chan->label); 47 debugf4("\tchannel->label = '%s'\n", chan->dimm->label);
48 debugf4("\tchannel->csrow = %p\n\n", chan->csrow); 48 debugf4("\tchannel->csrow = %p\n\n", chan->csrow);
49} 49}
50 50
@@ -157,6 +157,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
157 struct mem_ctl_info *mci; 157 struct mem_ctl_info *mci;
158 struct csrow_info *csi, *csrow; 158 struct csrow_info *csi, *csrow;
159 struct rank_info *chi, *chp, *chan; 159 struct rank_info *chi, *chp, *chan;
160 struct dimm_info *dimm;
160 void *pvt; 161 void *pvt;
161 unsigned size; 162 unsigned size;
162 int row, chn; 163 int row, chn;
@@ -170,7 +171,8 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
170 mci = (struct mem_ctl_info *)0; 171 mci = (struct mem_ctl_info *)0;
171 csi = edac_align_ptr(&mci[1], sizeof(*csi)); 172 csi = edac_align_ptr(&mci[1], sizeof(*csi));
172 chi = edac_align_ptr(&csi[nr_csrows], sizeof(*chi)); 173 chi = edac_align_ptr(&csi[nr_csrows], sizeof(*chi));
173 pvt = edac_align_ptr(&chi[nr_chans * nr_csrows], sz_pvt); 174 dimm = edac_align_ptr(&chi[nr_chans * nr_csrows], sizeof(*dimm));
175 pvt = edac_align_ptr(&dimm[nr_chans * nr_csrows], sz_pvt);
174 size = ((unsigned long)pvt) + sz_pvt; 176 size = ((unsigned long)pvt) + sz_pvt;
175 177
176 mci = kzalloc(size, GFP_KERNEL); 178 mci = kzalloc(size, GFP_KERNEL);
@@ -182,14 +184,22 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
182 */ 184 */
183 csi = (struct csrow_info *)(((char *)mci) + ((unsigned long)csi)); 185 csi = (struct csrow_info *)(((char *)mci) + ((unsigned long)csi));
184 chi = (struct rank_info *)(((char *)mci) + ((unsigned long)chi)); 186 chi = (struct rank_info *)(((char *)mci) + ((unsigned long)chi));
187 dimm = (struct dimm_info *)(((char *)mci) + ((unsigned long)dimm));
185 pvt = sz_pvt ? (((char *)mci) + ((unsigned long)pvt)) : NULL; 188 pvt = sz_pvt ? (((char *)mci) + ((unsigned long)pvt)) : NULL;
186 189
187 /* setup index and various internal pointers */ 190 /* setup index and various internal pointers */
188 mci->mc_idx = edac_index; 191 mci->mc_idx = edac_index;
189 mci->csrows = csi; 192 mci->csrows = csi;
193 mci->dimms = dimm;
190 mci->pvt_info = pvt; 194 mci->pvt_info = pvt;
191 mci->nr_csrows = nr_csrows; 195 mci->nr_csrows = nr_csrows;
192 196
197 /*
198 * For now, assumes that a per-csrow arrangement for dimms.
199 * This will be latter changed.
200 */
201 dimm = mci->dimms;
202
193 for (row = 0; row < nr_csrows; row++) { 203 for (row = 0; row < nr_csrows; row++) {
194 csrow = &csi[row]; 204 csrow = &csi[row];
195 csrow->csrow_idx = row; 205 csrow->csrow_idx = row;
@@ -202,6 +212,12 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
202 chan = &chp[chn]; 212 chan = &chp[chn];
203 chan->chan_idx = chn; 213 chan->chan_idx = chn;
204 chan->csrow = csrow; 214 chan->csrow = csrow;
215
216 mci->csrows[row].channels[chn].dimm = dimm;
217 dimm->csrow = row;
218 dimm->csrow_channel = chn;
219 dimm++;
220 mci->nr_dimms++;
205 } 221 }
206 } 222 }
207 223
@@ -678,6 +694,7 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
678 int row, int channel, const char *msg) 694 int row, int channel, const char *msg)
679{ 695{
680 unsigned long remapped_page; 696 unsigned long remapped_page;
697 char *label = NULL;
681 698
682 debugf3("MC%d: %s()\n", mci->mc_idx, __func__); 699 debugf3("MC%d: %s()\n", mci->mc_idx, __func__);
683 700
@@ -701,6 +718,8 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
701 return; 718 return;
702 } 719 }
703 720
721 label = mci->csrows[row].channels[channel].dimm->label;
722
704 if (edac_mc_get_log_ce()) 723 if (edac_mc_get_log_ce())
705 /* FIXME - put in DIMM location */ 724 /* FIXME - put in DIMM location */
706 edac_mc_printk(mci, KERN_WARNING, 725 edac_mc_printk(mci, KERN_WARNING,
@@ -708,7 +727,7 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
708 "0x%lx, row %d, channel %d, label \"%s\": %s\n", 727 "0x%lx, row %d, channel %d, label \"%s\": %s\n",
709 page_frame_number, offset_in_page, 728 page_frame_number, offset_in_page,
710 mci->csrows[row].grain, syndrome, row, channel, 729 mci->csrows[row].grain, syndrome, row, channel,
711 mci->csrows[row].channels[channel].label, msg); 730 label, msg);
712 731
713 mci->ce_count++; 732 mci->ce_count++;
714 mci->csrows[row].ce_count++; 733 mci->csrows[row].ce_count++;
@@ -754,6 +773,7 @@ void edac_mc_handle_ue(struct mem_ctl_info *mci,
754 char *pos = labels; 773 char *pos = labels;
755 int chan; 774 int chan;
756 int chars; 775 int chars;
776 char *label = NULL;
757 777
758 debugf3("MC%d: %s()\n", mci->mc_idx, __func__); 778 debugf3("MC%d: %s()\n", mci->mc_idx, __func__);
759 779
@@ -767,15 +787,15 @@ void edac_mc_handle_ue(struct mem_ctl_info *mci,
767 return; 787 return;
768 } 788 }
769 789
770 chars = snprintf(pos, len + 1, "%s", 790 label = mci->csrows[row].channels[0].dimm->label;
771 mci->csrows[row].channels[0].label); 791 chars = snprintf(pos, len + 1, "%s", label);
772 len -= chars; 792 len -= chars;
773 pos += chars; 793 pos += chars;
774 794
775 for (chan = 1; (chan < mci->csrows[row].nr_channels) && (len > 0); 795 for (chan = 1; (chan < mci->csrows[row].nr_channels) && (len > 0);
776 chan++) { 796 chan++) {
777 chars = snprintf(pos, len + 1, ":%s", 797 label = mci->csrows[row].channels[chan].dimm->label;
778 mci->csrows[row].channels[chan].label); 798 chars = snprintf(pos, len + 1, ":%s", label);
779 len -= chars; 799 len -= chars;
780 pos += chars; 800 pos += chars;
781 } 801 }
@@ -824,6 +844,7 @@ void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci,
824 char labels[len + 1]; 844 char labels[len + 1];
825 char *pos = labels; 845 char *pos = labels;
826 int chars; 846 int chars;
847 char *label;
827 848
828 if (csrow >= mci->nr_csrows) { 849 if (csrow >= mci->nr_csrows) {
829 /* something is wrong */ 850 /* something is wrong */
@@ -858,12 +879,12 @@ void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci,
858 mci->csrows[csrow].ue_count++; 879 mci->csrows[csrow].ue_count++;
859 880
860 /* Generate the DIMM labels from the specified channels */ 881 /* Generate the DIMM labels from the specified channels */
861 chars = snprintf(pos, len + 1, "%s", 882 label = mci->csrows[csrow].channels[channela].dimm->label;
862 mci->csrows[csrow].channels[channela].label); 883 chars = snprintf(pos, len + 1, "%s", label);
863 len -= chars; 884 len -= chars;
864 pos += chars; 885 pos += chars;
865 chars = snprintf(pos, len + 1, "-%s", 886 chars = snprintf(pos, len + 1, "-%s",
866 mci->csrows[csrow].channels[channelb].label); 887 mci->csrows[csrow].channels[channelb].dimm->label);
867 888
868 if (edac_mc_get_log_ue()) 889 if (edac_mc_get_log_ue())
869 edac_mc_printk(mci, KERN_EMERG, 890 edac_mc_printk(mci, KERN_EMERG,
@@ -885,6 +906,7 @@ EXPORT_SYMBOL(edac_mc_handle_fbd_ue);
885void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci, 906void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci,
886 unsigned int csrow, unsigned int channel, char *msg) 907 unsigned int csrow, unsigned int channel, char *msg)
887{ 908{
909 char *label = NULL;
888 910
889 /* Ensure boundary values */ 911 /* Ensure boundary values */
890 if (csrow >= mci->nr_csrows) { 912 if (csrow >= mci->nr_csrows) {
@@ -904,12 +926,13 @@ void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci,
904 return; 926 return;
905 } 927 }
906 928
929 label = mci->csrows[csrow].channels[channel].dimm->label;
930
907 if (edac_mc_get_log_ce()) 931 if (edac_mc_get_log_ce())
908 /* FIXME - put in DIMM location */ 932 /* FIXME - put in DIMM location */
909 edac_mc_printk(mci, KERN_WARNING, 933 edac_mc_printk(mci, KERN_WARNING,
910 "CE row %d, channel %d, label \"%s\": %s\n", 934 "CE row %d, channel %d, label \"%s\": %s\n",
911 csrow, channel, 935 csrow, channel, label, msg);
912 mci->csrows[csrow].channels[channel].label, msg);
913 936
914 mci->ce_count++; 937 mci->ce_count++;
915 mci->csrows[csrow].ce_count++; 938 mci->csrows[csrow].ce_count++;
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index e9a28f576d14..af66b2256640 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -170,11 +170,11 @@ static ssize_t channel_dimm_label_show(struct csrow_info *csrow,
170 char *data, int channel) 170 char *data, int channel)
171{ 171{
172 /* if field has not been initialized, there is nothing to send */ 172 /* if field has not been initialized, there is nothing to send */
173 if (!csrow->channels[channel].label[0]) 173 if (!csrow->channels[channel].dimm->label[0])
174 return 0; 174 return 0;
175 175
176 return snprintf(data, EDAC_MC_LABEL_LEN, "%s\n", 176 return snprintf(data, EDAC_MC_LABEL_LEN, "%s\n",
177 csrow->channels[channel].label); 177 csrow->channels[channel].dimm->label);
178} 178}
179 179
180static ssize_t channel_dimm_label_store(struct csrow_info *csrow, 180static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
@@ -184,8 +184,8 @@ static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
184 ssize_t max_size = 0; 184 ssize_t max_size = 0;
185 185
186 max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1); 186 max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1);
187 strncpy(csrow->channels[channel].label, data, max_size); 187 strncpy(csrow->channels[channel].dimm->label, data, max_size);
188 csrow->channels[channel].label[max_size] = '\0'; 188 csrow->channels[channel].dimm->label[max_size] = '\0';
189 189
190 return max_size; 190 return max_size;
191} 191}
@@ -952,9 +952,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
952 /* CSROW error: backout what has already been registered, */ 952 /* CSROW error: backout what has already been registered, */
953fail1: 953fail1:
954 for (i--; i >= 0; i--) { 954 for (i--; i >= 0; i--) {
955 if (csrow->nr_pages > 0) { 955 if (mci->csrows[i].nr_pages > 0)
956 kobject_put(&mci->csrows[i].kobj); 956 kobject_put(&mci->csrows[i].kobj);
957 }
958 } 957 }
959 958
960 /* remove the mci instance's attributes, if any */ 959 /* remove the mci instance's attributes, if any */
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index d500749464ea..d55e5529734c 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -433,7 +433,7 @@ static void i5100_handle_ce(struct mem_ctl_info *mci,
433 "CE chan %d, bank %u, rank %u, syndrome 0x%lx, " 433 "CE chan %d, bank %u, rank %u, syndrome 0x%lx, "
434 "cas %u, ras %u, csrow %u, label \"%s\": %s\n", 434 "cas %u, ras %u, csrow %u, label \"%s\": %s\n",
435 chan, bank, rank, syndrome, cas, ras, 435 chan, bank, rank, syndrome, cas, ras,
436 csrow, mci->csrows[csrow].channels[0].label, msg); 436 csrow, mci->csrows[csrow].channels[0].dimm->label, msg);
437 437
438 mci->ce_count++; 438 mci->ce_count++;
439 mci->csrows[csrow].ce_count++; 439 mci->csrows[csrow].ce_count++;
@@ -455,7 +455,7 @@ static void i5100_handle_ue(struct mem_ctl_info *mci,
455 "UE chan %d, bank %u, rank %u, syndrome 0x%lx, " 455 "UE chan %d, bank %u, rank %u, syndrome 0x%lx, "
456 "cas %u, ras %u, csrow %u, label \"%s\": %s\n", 456 "cas %u, ras %u, csrow %u, label \"%s\": %s\n",
457 chan, bank, rank, syndrome, cas, ras, 457 chan, bank, rank, syndrome, cas, ras,
458 csrow, mci->csrows[csrow].channels[0].label, msg); 458 csrow, mci->csrows[csrow].channels[0].dimm->label, msg);
459 459
460 mci->ue_count++; 460 mci->ue_count++;
461 mci->csrows[csrow].ue_count++; 461 mci->csrows[csrow].ue_count++;
@@ -868,8 +868,8 @@ static void __devinit i5100_init_csrows(struct mem_ctl_info *mci)
868 mci->csrows[i].channels[0].chan_idx = 0; 868 mci->csrows[i].channels[0].chan_idx = 0;
869 mci->csrows[i].channels[0].ce_count = 0; 869 mci->csrows[i].channels[0].ce_count = 0;
870 mci->csrows[i].channels[0].csrow = mci->csrows + i; 870 mci->csrows[i].channels[0].csrow = mci->csrows + i;
871 snprintf(mci->csrows[i].channels[0].label, 871 snprintf(mci->csrows[i].channels[0].dimm->label,
872 sizeof(mci->csrows[i].channels[0].label), 872 sizeof(mci->csrows[i].channels[0].dimm->label),
873 "DIMM%u", i5100_rank_to_slot(mci, chan, rank)); 873 "DIMM%u", i5100_rank_to_slot(mci, chan, rank));
874 874
875 total_pages += npages; 875 total_pages += npages;
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 85226ccf5290..df0acf02667a 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -746,8 +746,8 @@ static int get_dimm_config(const struct mem_ctl_info *mci)
746 746
747 csr->edac_mode = mode; 747 csr->edac_mode = mode;
748 csr->mtype = mtype; 748 csr->mtype = mtype;
749 snprintf(csr->channels[0].label, 749 snprintf(csr->channels[0].dimm->label,
750 sizeof(csr->channels[0].label), 750 sizeof(csr->channels[0].dimm->label),
751 "CPU#%uChannel#%u_DIMM#%u", 751 "CPU#%uChannel#%u_DIMM#%u",
752 pvt->i7core_dev->socket, i, j); 752 pvt->i7core_dev->socket, i, j);
753 753
diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
index 0cd8368f88f8..b7aca58bf9eb 100644
--- a/drivers/edac/i82975x_edac.c
+++ b/drivers/edac/i82975x_edac.c
@@ -407,7 +407,7 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
407 * [0-3] for dual-channel; i.e. csrow->nr_channels = 2 407 * [0-3] for dual-channel; i.e. csrow->nr_channels = 2
408 */ 408 */
409 for (chan = 0; chan < csrow->nr_channels; chan++) 409 for (chan = 0; chan < csrow->nr_channels; chan++)
410 strncpy(csrow->channels[chan].label, 410 strncpy(csrow->channels[chan].dimm->label,
411 labels[(index >> 1) + (chan * 2)], 411 labels[(index >> 1) + (chan * 2)],
412 EDAC_MC_LABEL_LEN); 412 EDAC_MC_LABEL_LEN);
413 413
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index a203536d90dd..95901c21d5dc 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -651,8 +651,8 @@ static int get_dimm_config(const struct mem_ctl_info *mci)
651 csr->channels[0].chan_idx = i; 651 csr->channels[0].chan_idx = i;
652 csr->channels[0].ce_count = 0; 652 csr->channels[0].ce_count = 0;
653 pvt->csrow_map[i][j] = csrow; 653 pvt->csrow_map[i][j] = csrow;
654 snprintf(csr->channels[0].label, 654 snprintf(csr->channels[0].dimm->label,
655 sizeof(csr->channels[0].label), 655 sizeof(csr->channels[0].dimm->label),
656 "CPU_SrcID#%u_Channel#%u_DIMM#%u", 656 "CPU_SrcID#%u_Channel#%u_DIMM#%u",
657 pvt->sbridge_dev->source_id, i, j); 657 pvt->sbridge_dev->source_id, i, j);
658 last_page += npages; 658 last_page += npages;