@@ -412,9 +412,65 @@ 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
- static void disable_aer (void * pdev )
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 )
416
421
{
417
- pci_disable_pcie_error_reporting (pdev );
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 ;
418
474
}
419
475
420
476
static void free_event_buf (void * buf )
@@ -733,12 +789,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
733
789
if (rc )
734
790
return rc ;
735
791
736
- if (cxlds -> regs .ras ) {
737
- pci_enable_pcie_error_reporting (pdev );
738
- rc = devm_add_action_or_reset (& pdev -> dev , disable_aer , pdev );
739
- if (rc )
740
- return rc ;
741
- }
792
+ rc = cxl_pci_ras_unmask (pdev );
793
+ if (rc )
794
+ dev_dbg (& pdev -> dev , "No RAS reporting unmasked\n" );
795
+
742
796
pci_save_state (pdev );
743
797
744
798
return rc ;
0 commit comments