aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/cpc925_edac.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-03-28 18:37:59 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-06-11 12:23:44 -0400
commitfd63312dfe70b8279618b4d77dc951b6e309ffa2 (patch)
treea6a4012398f8977d7059d3dd6e85c120c4fc50fd /drivers/edac/cpc925_edac.c
parent452a6bf955ee1842361742833e40e046287308f4 (diff)
edac: Move grain/dtype/edac_type calculus to be out of channel loop
The 3e7bddc changeset (edac: move dimm properties to struct memset_info) moved the calculus inside a loop. However, at those stuff are common to all channels, on several drivers, it is better to put the calculus outside the loop, to optimize the code. Reported-by: Aristeu Rozanski Filho <arozansk@redhat.com> Reviewed-by: Aristeu Rozanski <arozansk@redhat.com> Cc: Mark Gross <mark.gross@intel.com> Cc: Doug Thompson <norsk5@yahoo.com> Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Michal Marek <mmarek@suse.cz> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/edac/cpc925_edac.c')
-rw-r--r--drivers/edac/cpc925_edac.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
index 9488723f813..3510aa44629 100644
--- a/drivers/edac/cpc925_edac.c
+++ b/drivers/edac/cpc925_edac.c
@@ -330,8 +330,9 @@ static void cpc925_init_csrows(struct mem_ctl_info *mci)
330 struct cpc925_mc_pdata *pdata = mci->pvt_info; 330 struct cpc925_mc_pdata *pdata = mci->pvt_info;
331 struct csrow_info *csrow; 331 struct csrow_info *csrow;
332 struct dimm_info *dimm; 332 struct dimm_info *dimm;
333 enum dev_type dtype;
333 int index, j; 334 int index, j;
334 u32 mbmr, mbbar, bba; 335 u32 mbmr, mbbar, bba, grain;
335 unsigned long row_size, nr_pages, last_nr_pages = 0; 336 unsigned long row_size, nr_pages, last_nr_pages = 0;
336 337
337 get_total_mem(pdata); 338 get_total_mem(pdata);
@@ -355,37 +356,36 @@ static void cpc925_init_csrows(struct mem_ctl_info *mci)
355 csrow->last_page = csrow->first_page + nr_pages - 1; 356 csrow->last_page = csrow->first_page + nr_pages - 1;
356 last_nr_pages = csrow->last_page + 1; 357 last_nr_pages = csrow->last_page + 1;
357 358
359 switch (csrow->nr_channels) {
360 case 1: /* Single channel */
361 grain = 32; /* four-beat burst of 32 bytes */
362 break;
363 case 2: /* Dual channel */
364 default:
365 grain = 64; /* four-beat burst of 64 bytes */
366 break;
367 }
368 switch ((mbmr & MBMR_MODE_MASK) >> MBMR_MODE_SHIFT) {
369 case 6: /* 0110, no way to differentiate X8 VS X16 */
370 case 5: /* 0101 */
371 case 8: /* 1000 */
372 dtype = DEV_X16;
373 break;
374 case 7: /* 0111 */
375 case 9: /* 1001 */
376 dtype = DEV_X8;
377 break;
378 default:
379 dtype = DEV_UNKNOWN;
380 break;
381 }
358 for (j = 0; j < csrow->nr_channels; j++) { 382 for (j = 0; j < csrow->nr_channels; j++) {
359 dimm = csrow->channels[j].dimm; 383 dimm = csrow->channels[j].dimm;
360
361 dimm->nr_pages = nr_pages / csrow->nr_channels; 384 dimm->nr_pages = nr_pages / csrow->nr_channels;
362 dimm->mtype = MEM_RDDR; 385 dimm->mtype = MEM_RDDR;
363 dimm->edac_mode = EDAC_SECDED; 386 dimm->edac_mode = EDAC_SECDED;
364 387 dimm->grain = grain;
365 switch (csrow->nr_channels) { 388 dimm->dtype = dtype;
366 case 1: /* Single channel */
367 dimm->grain = 32; /* four-beat burst of 32 bytes */
368 break;
369 case 2: /* Dual channel */
370 default:
371 dimm->grain = 64; /* four-beat burst of 64 bytes */
372 break;
373 }
374
375 switch ((mbmr & MBMR_MODE_MASK) >> MBMR_MODE_SHIFT) {
376 case 6: /* 0110, no way to differentiate X8 VS X16 */
377 case 5: /* 0101 */
378 case 8: /* 1000 */
379 dimm->dtype = DEV_X16;
380 break;
381 case 7: /* 0111 */
382 case 9: /* 1001 */
383 dimm->dtype = DEV_X8;
384 break;
385 default:
386 dimm->dtype = DEV_UNKNOWN;
387 break;
388 }
389 } 389 }
390 } 390 }
391} 391}