@@ -412,6 +412,67 @@ static bool is_cxl_restricted(struct pci_dev *pdev)
412
412
return pci_pcie_type (pdev ) == PCI_EXP_TYPE_RC_END ;
413
413
}
414
414
415
+ /*
416
+ * CXL v3.0 6.2.3 Table 6-4
417
+ * The table indicates that if PCIe Flit Mode is set, then CXL is in 256B flits
418
+ * mode, otherwise it's 68B flits mode.
419
+ */
420
+ static bool cxl_pci_flit_256 (struct pci_dev * pdev )
421
+ {
422
+ u16 lnksta2 ;
423
+
424
+ pcie_capability_read_word (pdev , PCI_EXP_LNKSTA2 , & lnksta2 );
425
+ return lnksta2 & PCI_EXP_LNKSTA2_FLIT ;
426
+ }
427
+
428
+ static int cxl_pci_ras_unmask (struct pci_dev * pdev )
429
+ {
430
+ struct pci_host_bridge * host_bridge = pci_find_host_bridge (pdev -> bus );
431
+ struct cxl_dev_state * cxlds = pci_get_drvdata (pdev );
432
+ void __iomem * addr ;
433
+ u32 orig_val , val , mask ;
434
+ u16 cap ;
435
+ int rc ;
436
+
437
+ if (!cxlds -> regs .ras ) {
438
+ dev_dbg (& pdev -> dev , "No RAS registers.\n" );
439
+ return 0 ;
440
+ }
441
+
442
+ /* BIOS has CXL error control */
443
+ if (!host_bridge -> native_cxl_error )
444
+ return - ENXIO ;
445
+
446
+ rc = pcie_capability_read_word (pdev , PCI_EXP_DEVCTL , & cap );
447
+ if (rc )
448
+ return rc ;
449
+
450
+ if (cap & PCI_EXP_DEVCTL_URRE ) {
451
+ addr = cxlds -> regs .ras + CXL_RAS_UNCORRECTABLE_MASK_OFFSET ;
452
+ orig_val = readl (addr );
453
+
454
+ mask = CXL_RAS_UNCORRECTABLE_MASK_MASK ;
455
+ if (!cxl_pci_flit_256 (pdev ))
456
+ mask &= ~CXL_RAS_UNCORRECTABLE_MASK_F256B_MASK ;
457
+ val = orig_val & ~mask ;
458
+ writel (val , addr );
459
+ dev_dbg (& pdev -> dev ,
460
+ "Uncorrectable RAS Errors Mask: %#x -> %#x\n" ,
461
+ orig_val , val );
462
+ }
463
+
464
+ if (cap & PCI_EXP_DEVCTL_CERE ) {
465
+ addr = cxlds -> regs .ras + CXL_RAS_CORRECTABLE_MASK_OFFSET ;
466
+ orig_val = readl (addr );
467
+ val = orig_val & ~CXL_RAS_CORRECTABLE_MASK_MASK ;
468
+ writel (val , addr );
469
+ dev_dbg (& pdev -> dev , "Correctable RAS Errors Mask: %#x -> %#x\n" ,
470
+ orig_val , val );
471
+ }
472
+
473
+ return 0 ;
474
+ }
475
+
415
476
static int cxl_pci_probe (struct pci_dev * pdev , const struct pci_device_id * id )
416
477
{
417
478
struct cxl_register_map map ;
@@ -489,6 +550,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
489
550
if (IS_ERR (cxlmd ))
490
551
return PTR_ERR (cxlmd );
491
552
553
+ rc = cxl_pci_ras_unmask (pdev );
554
+ if (rc )
555
+ dev_dbg (& pdev -> dev , "No RAS reporting unmasked\n" );
556
+
492
557
pci_save_state (pdev );
493
558
494
559
return rc ;
0 commit comments