aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAristeu Rozanski <aris@redhat.com>2014-06-02 14:15:25 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-06-26 14:46:33 -0400
commitdbc954ddddaaff0183a21dbd736ec10ca01e9f1a (patch)
treef99933db1111f770e98b044a94990c353f2251ec
parentb976bcf249f4d3b28963e67b5194bc2690da260c (diff)
sb_edac: search devices using product id
This patch changes the way devices are searched by using product id instead of device/function numbers. Tested in a Sandy Bridge and a Ivy Bridge machine to make sure everything works properly. Cc: Tony Luck <tony.luck@intel.com> Signed-off-by: Aristeu Rozanski <aris@redhat.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/edac/sb_edac.c352
1 files changed, 137 insertions, 215 deletions
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index c99c595adc2b..3411f502a374 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -311,8 +311,6 @@ struct sbridge_channel {
311}; 311};
312 312
313struct pci_id_descr { 313struct pci_id_descr {
314 int dev;
315 int func;
316 int dev_id; 314 int dev_id;
317 int optional; 315 int optional;
318}; 316};
@@ -360,31 +358,29 @@ struct sbridge_pvt {
360 u64 tolm, tohm; 358 u64 tolm, tohm;
361}; 359};
362 360
363#define PCI_DESCR(device, function, device_id, opt) \ 361#define PCI_DESCR(device_id, opt) \
364 .dev = (device), \ 362 .dev_id = (device_id), \
365 .func = (function), \
366 .dev_id = (device_id), \
367 .optional = opt 363 .optional = opt
368 364
369static const struct pci_id_descr pci_dev_descr_sbridge[] = { 365static const struct pci_id_descr pci_dev_descr_sbridge[] = {
370 /* Processor Home Agent */ 366 /* Processor Home Agent */
371 { PCI_DESCR(14, 0, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_HA0, 0) }, 367 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_HA0, 0) },
372 368
373 /* Memory controller */ 369 /* Memory controller */
374 { PCI_DESCR(15, 0, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA, 0) }, 370 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA, 0) },
375 { PCI_DESCR(15, 1, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_RAS, 0) }, 371 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_RAS, 0) },
376 { PCI_DESCR(15, 2, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD0, 0) }, 372 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD0, 0) },
377 { PCI_DESCR(15, 3, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD1, 0) }, 373 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD1, 0) },
378 { PCI_DESCR(15, 4, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD2, 0) }, 374 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD2, 0) },
379 { PCI_DESCR(15, 5, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD3, 0) }, 375 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD3, 0) },
380 { PCI_DESCR(17, 0, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_DDRIO, 1) }, 376 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_DDRIO, 1) },
381 377
382 /* System Address Decoder */ 378 /* System Address Decoder */
383 { PCI_DESCR(12, 6, PCI_DEVICE_ID_INTEL_SBRIDGE_SAD0, 0) }, 379 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_SAD0, 0) },
384 { PCI_DESCR(12, 7, PCI_DEVICE_ID_INTEL_SBRIDGE_SAD1, 0) }, 380 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_SAD1, 0) },
385 381
386 /* Broadcast Registers */ 382 /* Broadcast Registers */
387 { PCI_DESCR(13, 6, PCI_DEVICE_ID_INTEL_SBRIDGE_BR, 0) }, 383 { PCI_DESCR(PCI_DEVICE_ID_INTEL_SBRIDGE_BR, 0) },
388}; 384};
389 385
390#define PCI_ID_TABLE_ENTRY(A) { .descr=A, .n_devs = ARRAY_SIZE(A) } 386#define PCI_ID_TABLE_ENTRY(A) { .descr=A, .n_devs = ARRAY_SIZE(A) }
@@ -421,34 +417,34 @@ static const struct pci_id_table pci_dev_descr_sbridge_table[] = {
421 417
422static const struct pci_id_descr pci_dev_descr_ibridge[] = { 418static const struct pci_id_descr pci_dev_descr_ibridge[] = {
423 /* Processor Home Agent */ 419 /* Processor Home Agent */
424 { PCI_DESCR(14, 0, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0, 0) }, 420 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0, 0) },
425 421
426 /* Memory controller */ 422 /* Memory controller */
427 { PCI_DESCR(15, 0, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TA, 0) }, 423 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TA, 0) },
428 { PCI_DESCR(15, 1, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_RAS, 0) }, 424 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_RAS, 0) },
429 { PCI_DESCR(15, 2, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD0, 0) }, 425 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD0, 0) },
430 { PCI_DESCR(15, 3, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD1, 0) }, 426 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD1, 0) },
431 { PCI_DESCR(15, 4, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD2, 0) }, 427 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD2, 0) },
432 { PCI_DESCR(15, 5, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD3, 0) }, 428 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD3, 0) },
433 429
434 /* System Address Decoder */ 430 /* System Address Decoder */
435 { PCI_DESCR(22, 0, PCI_DEVICE_ID_INTEL_IBRIDGE_SAD, 0) }, 431 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_SAD, 0) },
436 432
437 /* Broadcast Registers */ 433 /* Broadcast Registers */
438 { PCI_DESCR(22, 1, PCI_DEVICE_ID_INTEL_IBRIDGE_BR0, 1) }, 434 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_BR0, 1) },
439 { PCI_DESCR(22, 2, PCI_DEVICE_ID_INTEL_IBRIDGE_BR1, 0) }, 435 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_BR1, 0) },
440 436
441 /* Optional, mode 2HA */ 437 /* Optional, mode 2HA */
442 { PCI_DESCR(28, 0, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1, 1) }, 438 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1, 1) },
443#if 0 439#if 0
444 { PCI_DESCR(29, 0, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TA, 1) }, 440 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TA, 1) },
445 { PCI_DESCR(29, 1, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_RAS, 1) }, 441 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_RAS, 1) },
446#endif 442#endif
447 { PCI_DESCR(29, 2, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TAD0, 1) }, 443 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TAD0, 1) },
448 { PCI_DESCR(29, 3, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TAD1, 1) }, 444 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TAD1, 1) },
449 445
450 { PCI_DESCR(17, 0, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_1HA_DDRIO0, 1) }, 446 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_1HA_DDRIO0, 1) },
451 { PCI_DESCR(17, 4, PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_2HA_DDRIO0, 1) }, 447 { PCI_DESCR(PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_2HA_DDRIO0, 1) },
452}; 448};
453 449
454static const struct pci_id_table pci_dev_descr_ibridge_table[] = { 450static const struct pci_id_table pci_dev_descr_ibridge_table[] = {
@@ -631,44 +627,38 @@ static inline u8 sad_pkg_ha(u8 pkg)
631/**************************************************************************** 627/****************************************************************************
632 Memory check routines 628 Memory check routines
633 ****************************************************************************/ 629 ****************************************************************************/
634static struct pci_dev *get_pdev_slot_func(u8 bus, unsigned slot, 630static struct pci_dev *get_pdev_same_bus(u8 bus, u32 id)
635 unsigned func)
636{ 631{
637 struct sbridge_dev *sbridge_dev = get_sbridge_dev(bus); 632 struct pci_dev *pdev = NULL;
638 int i;
639
640 if (!sbridge_dev)
641 return NULL;
642
643 for (i = 0; i < sbridge_dev->n_devs; i++) {
644 if (!sbridge_dev->pdev[i])
645 continue;
646 633
647 if (PCI_SLOT(sbridge_dev->pdev[i]->devfn) == slot && 634 do {
648 PCI_FUNC(sbridge_dev->pdev[i]->devfn) == func) { 635 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, id, pdev);
649 edac_dbg(1, "Associated %02x.%02x.%d with %p\n", 636 if (pdev && pdev->bus->number == bus)
650 bus, slot, func, sbridge_dev->pdev[i]); 637 break;
651 return sbridge_dev->pdev[i]; 638 } while (pdev);
652 }
653 }
654 639
655 return NULL; 640 return pdev;
656} 641}
657 642
658/** 643/**
659 * check_if_ecc_is_active() - Checks if ECC is active 644 * check_if_ecc_is_active() - Checks if ECC is active
660 * bus: Device bus 645 * bus: Device bus
661 */ 646 */
662static int check_if_ecc_is_active(const u8 bus) 647static int check_if_ecc_is_active(const u8 bus, enum type type)
663{ 648{
664 struct pci_dev *pdev = NULL; 649 struct pci_dev *pdev = NULL;
665 u32 mcmtr; 650 u32 mcmtr, id;
666 651
667 pdev = get_pdev_slot_func(bus, 15, 0); 652 if (type == IVY_BRIDGE)
653 id = PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TA;
654 else
655 id = PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA;
656
657 pdev = get_pdev_same_bus(bus, id);
668 if (!pdev) { 658 if (!pdev) {
669 sbridge_printk(KERN_ERR, "Couldn't find PCI device " 659 sbridge_printk(KERN_ERR, "Couldn't find PCI device "
670 "%2x.%02d.%d!!!\n", 660 "%04x:%04x! on bus %02d\n",
671 bus, 15, 0); 661 PCI_VENDOR_ID_INTEL, id, bus);
672 return -ENODEV; 662 return -ENODEV;
673 } 663 }
674 664
@@ -1279,13 +1269,11 @@ static int sbridge_get_onedevice(struct pci_dev **prev,
1279{ 1269{
1280 struct sbridge_dev *sbridge_dev; 1270 struct sbridge_dev *sbridge_dev;
1281 const struct pci_id_descr *dev_descr = &table->descr[devno]; 1271 const struct pci_id_descr *dev_descr = &table->descr[devno];
1282
1283 struct pci_dev *pdev = NULL; 1272 struct pci_dev *pdev = NULL;
1284 u8 bus = 0; 1273 u8 bus = 0;
1285 1274
1286 sbridge_printk(KERN_DEBUG, 1275 sbridge_printk(KERN_DEBUG,
1287 "Seeking for: dev %02x.%d PCI ID %04x:%04x\n", 1276 "Seeking for: PCI ID %04x:%04x\n",
1288 dev_descr->dev, dev_descr->func,
1289 PCI_VENDOR_ID_INTEL, dev_descr->dev_id); 1277 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
1290 1278
1291 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 1279 pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
@@ -1300,12 +1288,12 @@ static int sbridge_get_onedevice(struct pci_dev **prev,
1300 if (dev_descr->optional) 1288 if (dev_descr->optional)
1301 return 0; 1289 return 0;
1302 1290
1291 /* if the HA wasn't found */
1303 if (devno == 0) 1292 if (devno == 0)
1304 return -ENODEV; 1293 return -ENODEV;
1305 1294
1306 sbridge_printk(KERN_INFO, 1295 sbridge_printk(KERN_INFO,
1307 "Device not found: dev %02x.%d PCI ID %04x:%04x\n", 1296 "Device not found: %04x:%04x\n",
1308 dev_descr->dev, dev_descr->func,
1309 PCI_VENDOR_ID_INTEL, dev_descr->dev_id); 1297 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
1310 1298
1311 /* End of list, leave */ 1299 /* End of list, leave */
@@ -1325,9 +1313,7 @@ static int sbridge_get_onedevice(struct pci_dev **prev,
1325 1313
1326 if (sbridge_dev->pdev[devno]) { 1314 if (sbridge_dev->pdev[devno]) {
1327 sbridge_printk(KERN_ERR, 1315 sbridge_printk(KERN_ERR,
1328 "Duplicated device for " 1316 "Duplicated device for %04x:%04x\n",
1329 "dev %02x:%d.%d PCI ID %04x:%04x\n",
1330 bus, dev_descr->dev, dev_descr->func,
1331 PCI_VENDOR_ID_INTEL, dev_descr->dev_id); 1317 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
1332 pci_dev_put(pdev); 1318 pci_dev_put(pdev);
1333 return -ENODEV; 1319 return -ENODEV;
@@ -1335,30 +1321,15 @@ static int sbridge_get_onedevice(struct pci_dev **prev,
1335 1321
1336 sbridge_dev->pdev[devno] = pdev; 1322 sbridge_dev->pdev[devno] = pdev;
1337 1323
1338 /* Sanity check */
1339 if (unlikely(PCI_SLOT(pdev->devfn) != dev_descr->dev ||
1340 PCI_FUNC(pdev->devfn) != dev_descr->func)) {
1341 sbridge_printk(KERN_ERR,
1342 "Device PCI ID %04x:%04x "
1343 "has dev %02x:%d.%d instead of dev %02x:%02x.%d\n",
1344 PCI_VENDOR_ID_INTEL, dev_descr->dev_id,
1345 bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
1346 bus, dev_descr->dev, dev_descr->func);
1347 return -ENODEV;
1348 }
1349
1350 /* Be sure that the device is enabled */ 1324 /* Be sure that the device is enabled */
1351 if (unlikely(pci_enable_device(pdev) < 0)) { 1325 if (unlikely(pci_enable_device(pdev) < 0)) {
1352 sbridge_printk(KERN_ERR, 1326 sbridge_printk(KERN_ERR,
1353 "Couldn't enable " 1327 "Couldn't enable %04x:%04x\n",
1354 "dev %02x:%d.%d PCI ID %04x:%04x\n",
1355 bus, dev_descr->dev, dev_descr->func,
1356 PCI_VENDOR_ID_INTEL, dev_descr->dev_id); 1328 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
1357 return -ENODEV; 1329 return -ENODEV;
1358 } 1330 }
1359 1331
1360 edac_dbg(0, "Detected dev %02x:%d.%d PCI ID %04x:%04x\n", 1332 edac_dbg(0, "Detected %04x:%04x\n",
1361 bus, dev_descr->dev, dev_descr->func,
1362 PCI_VENDOR_ID_INTEL, dev_descr->dev_id); 1333 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
1363 1334
1364 /* 1335 /*
@@ -1375,8 +1346,7 @@ static int sbridge_get_onedevice(struct pci_dev **prev,
1375 1346
1376/* 1347/*
1377 * sbridge_get_all_devices - Find and perform 'get' operation on the MCH's 1348 * sbridge_get_all_devices - Find and perform 'get' operation on the MCH's
1378 * device/functions we want to reference for this driver. 1349 * devices we want to reference for this driver.
1379 * Need to 'get' device 16 func 1 and func 2.
1380 * @num_mc: pointer to the memory controllers count, to be incremented in case 1350 * @num_mc: pointer to the memory controllers count, to be incremented in case
1381 * of success. 1351 * of success.
1382 * @table: model specific table 1352 * @table: model specific table
@@ -1416,79 +1386,51 @@ static int sbridge_mci_bind_devs(struct mem_ctl_info *mci,
1416{ 1386{
1417 struct sbridge_pvt *pvt = mci->pvt_info; 1387 struct sbridge_pvt *pvt = mci->pvt_info;
1418 struct pci_dev *pdev; 1388 struct pci_dev *pdev;
1419 int i, func, slot; 1389 int i;
1420 1390
1421 for (i = 0; i < sbridge_dev->n_devs; i++) { 1391 for (i = 0; i < sbridge_dev->n_devs; i++) {
1422 pdev = sbridge_dev->pdev[i]; 1392 pdev = sbridge_dev->pdev[i];
1423 if (!pdev) 1393 if (!pdev)
1424 continue; 1394 continue;
1425 slot = PCI_SLOT(pdev->devfn); 1395
1426 func = PCI_FUNC(pdev->devfn); 1396 switch (pdev->device) {
1427 switch (slot) { 1397 case PCI_DEVICE_ID_INTEL_SBRIDGE_SAD0:
1428 case 12: 1398 pvt->pci_sad0 = pdev;
1429 switch (func) {
1430 case 6:
1431 pvt->pci_sad0 = pdev;
1432 break;
1433 case 7:
1434 pvt->pci_sad1 = pdev;
1435 break;
1436 default:
1437 goto error;
1438 }
1439 break; 1399 break;
1440 case 13: 1400 case PCI_DEVICE_ID_INTEL_SBRIDGE_SAD1:
1441 switch (func) { 1401 pvt->pci_sad1 = pdev;
1442 case 6:
1443 pvt->pci_br0 = pdev;
1444 break;
1445 default:
1446 goto error;
1447 }
1448 break; 1402 break;
1449 case 14: 1403 case PCI_DEVICE_ID_INTEL_SBRIDGE_BR:
1450 switch (func) { 1404 pvt->pci_br0 = pdev;
1451 case 0:
1452 pvt->pci_ha0 = pdev;
1453 break;
1454 default:
1455 goto error;
1456 }
1457 break; 1405 break;
1458 case 15: 1406 case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_HA0:
1459 switch (func) { 1407 pvt->pci_ha0 = pdev;
1460 case 0:
1461 pvt->pci_ta = pdev;
1462 break;
1463 case 1:
1464 pvt->pci_ras = pdev;
1465 break;
1466 case 2:
1467 case 3:
1468 case 4:
1469 case 5:
1470 pvt->pci_tad[func - 2] = pdev;
1471 break;
1472 default:
1473 goto error;
1474 }
1475 break; 1408 break;
1476 case 17: 1409 case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA:
1477 switch (func) { 1410 pvt->pci_ta = pdev;
1478 case 0: 1411 break;
1479 pvt->pci_ddrio = pdev; 1412 case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_RAS:
1480 break; 1413 pvt->pci_ras = pdev;
1481 default: 1414 break;
1482 goto error; 1415 case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD0:
1483 } 1416 case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD1:
1417 case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD2:
1418 case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD3:
1419 {
1420 int id = pdev->device - PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD0;
1421 pvt->pci_tad[id] = pdev;
1422 }
1423 break;
1424 case PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_DDRIO:
1425 pvt->pci_ddrio = pdev;
1484 break; 1426 break;
1485 default: 1427 default:
1486 goto error; 1428 goto error;
1487 } 1429 }
1488 1430
1489 edac_dbg(0, "Associated PCI %02x.%02d.%d with dev = %p\n", 1431 edac_dbg(0, "Associated PCI %02x:%02x, bus %d with dev = %p\n",
1432 pdev->vendor, pdev->device,
1490 sbridge_dev->bus, 1433 sbridge_dev->bus,
1491 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
1492 pdev); 1434 pdev);
1493 } 1435 }
1494 1436
@@ -1508,9 +1450,8 @@ enodev:
1508 return -ENODEV; 1450 return -ENODEV;
1509 1451
1510error: 1452error:
1511 sbridge_printk(KERN_ERR, "Device %d, function %d " 1453 sbridge_printk(KERN_ERR, "Unexpected device %02x:%02x\n",
1512 "is out of the expected range\n", 1454 PCI_VENDOR_ID_INTEL, pdev->device);
1513 slot, func);
1514 return -EINVAL; 1455 return -EINVAL;
1515} 1456}
1516 1457
@@ -1519,7 +1460,7 @@ static int ibridge_mci_bind_devs(struct mem_ctl_info *mci,
1519{ 1460{
1520 struct sbridge_pvt *pvt = mci->pvt_info; 1461 struct sbridge_pvt *pvt = mci->pvt_info;
1521 struct pci_dev *pdev, *tmp; 1462 struct pci_dev *pdev, *tmp;
1522 int i, func, slot; 1463 int i;
1523 bool mode_2ha = false; 1464 bool mode_2ha = false;
1524 1465
1525 tmp = pci_get_device(PCI_VENDOR_ID_INTEL, 1466 tmp = pci_get_device(PCI_VENDOR_ID_INTEL,
@@ -1533,79 +1474,60 @@ static int ibridge_mci_bind_devs(struct mem_ctl_info *mci,
1533 pdev = sbridge_dev->pdev[i]; 1474 pdev = sbridge_dev->pdev[i];
1534 if (!pdev) 1475 if (!pdev)
1535 continue; 1476 continue;
1536 slot = PCI_SLOT(pdev->devfn);
1537 func = PCI_FUNC(pdev->devfn);
1538 1477
1539 switch (slot) { 1478 switch (pdev->device) {
1540 case 14: 1479 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0:
1541 if (func == 0) { 1480 pvt->pci_ha0 = pdev;
1542 pvt->pci_ha0 = pdev; 1481 break;
1543 break; 1482 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TA:
1544 } 1483 pvt->pci_ta = pdev;
1545 goto error; 1484 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_RAS:
1546 case 15: 1485 pvt->pci_ras = pdev;
1547 switch (func) { 1486 break;
1548 case 0: 1487 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD2:
1549 pvt->pci_ta = pdev; 1488 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD3:
1550 break; 1489 /* if we have 2 HAs active, channels 2 and 3
1551 case 1: 1490 * are in other device */
1552 pvt->pci_ras = pdev; 1491 if (mode_2ha)
1553 break;
1554 case 4:
1555 case 5:
1556 /* if we have 2 HAs active, channels 2 and 3
1557 * are in other device */
1558 if (mode_2ha)
1559 break;
1560 /* fall through */
1561 case 2:
1562 case 3:
1563 pvt->pci_tad[func - 2] = pdev;
1564 break; 1492 break;
1565 default: 1493 /* fall through */
1566 goto error; 1494 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD0:
1567 } 1495 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD1:
1496 {
1497 int id = pdev->device - PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TAD0;
1498 pvt->pci_tad[id] = pdev;
1499 }
1568 break; 1500 break;
1569 case 17: 1501 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_2HA_DDRIO0:
1570 if (func == 4) { 1502 pvt->pci_ddrio = pdev;
1503 break;
1504 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_1HA_DDRIO0:
1505 if (!mode_2ha)
1571 pvt->pci_ddrio = pdev; 1506 pvt->pci_ddrio = pdev;
1572 break;
1573 } else if (func == 0) {
1574 if (!mode_2ha)
1575 pvt->pci_ddrio = pdev;
1576 break;
1577 }
1578 goto error;
1579 case 22:
1580 switch (func) {
1581 case 0:
1582 pvt->pci_sad0 = pdev;
1583 break;
1584 case 1:
1585 pvt->pci_br0 = pdev;
1586 break;
1587 case 2:
1588 pvt->pci_br1 = pdev;
1589 break;
1590 default:
1591 goto error;
1592 }
1593 break; 1507 break;
1594 case 28: 1508 case PCI_DEVICE_ID_INTEL_IBRIDGE_SAD:
1595 if (func == 0) { 1509 pvt->pci_sad0 = pdev;
1596 pvt->pci_ha1 = pdev; 1510 break;
1597 break; 1511 case PCI_DEVICE_ID_INTEL_IBRIDGE_BR0:
1598 } 1512 pvt->pci_br0 = pdev;
1599 goto error; 1513 break;
1600 case 29: 1514 case PCI_DEVICE_ID_INTEL_IBRIDGE_BR1:
1515 pvt->pci_br1 = pdev;
1516 break;
1517 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1:
1518 pvt->pci_ha1 = pdev;
1519 break;
1520 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TAD0:
1521 case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TAD1:
1522 {
1523 int id = pdev->device - PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA1_TAD0 + 2;
1524
1601 /* we shouldn't have this device if we have just one 1525 /* we shouldn't have this device if we have just one
1602 * HA present */ 1526 * HA present */
1603 WARN_ON(!mode_2ha); 1527 WARN_ON(!mode_2ha);
1604 if (func == 2 || func == 3) { 1528 pvt->pci_tad[id] = pdev;
1605 pvt->pci_tad[func] = pdev; 1529 }
1606 break; 1530 break;
1607 }
1608 goto error;
1609 default: 1531 default:
1610 goto error; 1532 goto error;
1611 } 1533 }
@@ -1634,8 +1556,8 @@ enodev:
1634 1556
1635error: 1557error:
1636 sbridge_printk(KERN_ERR, 1558 sbridge_printk(KERN_ERR,
1637 "Device %d, function %d is out of the expected range\n", 1559 "Unexpected device %02x:%02x\n", PCI_VENDOR_ID_INTEL,
1638 slot, func); 1560 pdev->device);
1639 return -EINVAL; 1561 return -EINVAL;
1640} 1562}
1641 1563
@@ -1952,7 +1874,7 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
1952 int rc; 1874 int rc;
1953 1875
1954 /* Check the number of active and not disabled channels */ 1876 /* Check the number of active and not disabled channels */
1955 rc = check_if_ecc_is_active(sbridge_dev->bus); 1877 rc = check_if_ecc_is_active(sbridge_dev->bus, type);
1956 if (unlikely(rc < 0)) 1878 if (unlikely(rc < 0))
1957 return rc; 1879 return rc;
1958 1880