Skip to content

Commit bf6c9fa

Browse files
ktbowman-amddjbw
authored andcommitted
cxl/pci: Update CXL error logging to use RAS register address
The CXL error handler currently only logs endpoint RAS status. The CXL topology includes several components providing RAS details to be logged during error handling.[1] Update the current handler's RAS logging to use a RAS register address. Also, update the error handler function names to be consistent with correctable and uncorrectable RAS. This will allow for adding support to log other CXL component's RAS details in the future. [1] CXL3.0 Table 8-22 CXL_Capability_ID Assignment Co-developed-by: Robert Richter <rrichter@amd.com> Signed-off-by: Terry Bowman <terry.bowman@amd.com> Signed-off-by: Robert Richter <rrichter@amd.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/20231018171713.1883517-14-rrichter@amd.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 6777877 commit bf6c9fa

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

drivers/cxl/core/pci.c

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -646,32 +646,36 @@ void read_cdat_data(struct cxl_port *port)
646646
}
647647
EXPORT_SYMBOL_NS_GPL(read_cdat_data, CXL);
648648

649-
void cxl_cor_error_detected(struct pci_dev *pdev)
649+
static void __cxl_handle_cor_ras(struct cxl_dev_state *cxlds,
650+
void __iomem *ras_base)
650651
{
651-
struct cxl_dev_state *cxlds = pci_get_drvdata(pdev);
652652
void __iomem *addr;
653653
u32 status;
654654

655-
if (!cxlds->regs.ras)
655+
if (!ras_base)
656656
return;
657657

658-
addr = cxlds->regs.ras + CXL_RAS_CORRECTABLE_STATUS_OFFSET;
658+
addr = ras_base + CXL_RAS_CORRECTABLE_STATUS_OFFSET;
659659
status = readl(addr);
660660
if (status & CXL_RAS_CORRECTABLE_STATUS_MASK) {
661661
writel(status & CXL_RAS_CORRECTABLE_STATUS_MASK, addr);
662662
trace_cxl_aer_correctable_error(cxlds->cxlmd, status);
663663
}
664664
}
665-
EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, CXL);
665+
666+
static void cxl_handle_endpoint_cor_ras(struct cxl_dev_state *cxlds)
667+
{
668+
return __cxl_handle_cor_ras(cxlds, cxlds->regs.ras);
669+
}
666670

667671
/* CXL spec rev3.0 8.2.4.16.1 */
668-
static void header_log_copy(struct cxl_dev_state *cxlds, u32 *log)
672+
static void header_log_copy(void __iomem *ras_base, u32 *log)
669673
{
670674
void __iomem *addr;
671675
u32 *log_addr;
672676
int i, log_u32_size = CXL_HEADERLOG_SIZE / sizeof(u32);
673677

674-
addr = cxlds->regs.ras + CXL_RAS_HEADER_LOG_OFFSET;
678+
addr = ras_base + CXL_RAS_HEADER_LOG_OFFSET;
675679
log_addr = log;
676680

677681
for (i = 0; i < log_u32_size; i++) {
@@ -685,39 +689,45 @@ static void header_log_copy(struct cxl_dev_state *cxlds, u32 *log)
685689
* Log the state of the RAS status registers and prepare them to log the
686690
* next error status. Return 1 if reset needed.
687691
*/
688-
static bool cxl_report_and_clear(struct cxl_dev_state *cxlds)
692+
static bool __cxl_handle_ras(struct cxl_dev_state *cxlds,
693+
void __iomem *ras_base)
689694
{
690695
u32 hl[CXL_HEADERLOG_SIZE_U32];
691696
void __iomem *addr;
692697
u32 status;
693698
u32 fe;
694699

695-
if (!cxlds->regs.ras)
700+
if (!ras_base)
696701
return false;
697702

698-
addr = cxlds->regs.ras + CXL_RAS_UNCORRECTABLE_STATUS_OFFSET;
703+
addr = ras_base + CXL_RAS_UNCORRECTABLE_STATUS_OFFSET;
699704
status = readl(addr);
700705
if (!(status & CXL_RAS_UNCORRECTABLE_STATUS_MASK))
701706
return false;
702707

703708
/* If multiple errors, log header points to first error from ctrl reg */
704709
if (hweight32(status) > 1) {
705710
void __iomem *rcc_addr =
706-
cxlds->regs.ras + CXL_RAS_CAP_CONTROL_OFFSET;
711+
ras_base + CXL_RAS_CAP_CONTROL_OFFSET;
707712

708713
fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK,
709714
readl(rcc_addr)));
710715
} else {
711716
fe = status;
712717
}
713718

714-
header_log_copy(cxlds, hl);
719+
header_log_copy(ras_base, hl);
715720
trace_cxl_aer_uncorrectable_error(cxlds->cxlmd, status, fe, hl);
716721
writel(status & CXL_RAS_UNCORRECTABLE_STATUS_MASK, addr);
717722

718723
return true;
719724
}
720725

726+
static bool cxl_handle_endpoint_ras(struct cxl_dev_state *cxlds)
727+
{
728+
return __cxl_handle_ras(cxlds, cxlds->regs.ras);
729+
}
730+
721731
#ifdef CONFIG_PCIEAER_CXL
722732

723733
void cxl_setup_parent_dport(struct device *host, struct cxl_dport *dport)
@@ -733,6 +743,14 @@ EXPORT_SYMBOL_NS_GPL(cxl_setup_parent_dport, CXL);
733743

734744
#endif
735745

746+
void cxl_cor_error_detected(struct pci_dev *pdev)
747+
{
748+
struct cxl_dev_state *cxlds = pci_get_drvdata(pdev);
749+
750+
cxl_handle_endpoint_cor_ras(cxlds);
751+
}
752+
EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, CXL);
753+
736754
pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
737755
pci_channel_state_t state)
738756
{
@@ -747,7 +765,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
747765
* chance the situation is recoverable dump the status of the RAS
748766
* capability registers and bounce the active state of the memdev.
749767
*/
750-
ue = cxl_report_and_clear(cxlds);
768+
ue = cxl_handle_endpoint_ras(cxlds);
751769

752770
switch (state) {
753771
case pci_channel_io_normal:

0 commit comments

Comments
 (0)