From f148bb792311fc16fbdc470dd446870a1322b937 Mon Sep 17 00:00:00 2001 From: Mengting Lu Date: Mon, 8 Dec 2025 11:00:04 +0800 Subject: [PATCH] anolis: driver/cxl: enable DSA Poison reporting support for AliSCM devices ANBZ: #27535 When the DSA accesses the poison in the AliSCM, a SIGBUS signal is needed to report to the user thread, which is not supported on the GNR. This is custom support for AliSCM devices. Signed-off-by: Mengting Lu --- drivers/cxl/core/mbox.c | 10 ++++++++++ drivers/cxl/cxlmem.h | 2 -- drivers/cxl/cxlpci.h | 37 +++++++++++++++++++++++++++++++++++++ drivers/cxl/pci.c | 35 ----------------------------------- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 8f512d59da73..d7e19b511553 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -919,6 +919,16 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd, evt->gen_media.type, evt->gen_media.transaction_type); + // Enable DSA Poison reporting support for AliSCM devices + struct pci_dev *pdev = to_pci_dev(cxlds->dev); + + if (cxl_pci_quirk_lookup(pdev, cxl_quirk_list)) { + u64 pfn = PHYS_PFN(hpa); + + if (pfn_valid(pfn)) + memory_failure_queue(pfn, MF_MUST_KILL|MF_ACTION_REQUIRED); + } + trace_cxl_general_media(cxlmd, type, cxlr, hpa, &evt->gen_media); } else if (event_type == CXL_CPER_EVENT_DRAM) { diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 9c4f94e3a1c9..f690f17b07aa 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -873,6 +873,4 @@ struct seq_file; struct dentry *cxl_debugfs_create_dir(const char *dir); void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds); -#define PCI_VENDOR_ID_ALISCM 0x2042 - #endif /* __CXL_MEM_H__ */ diff --git a/drivers/cxl/cxlpci.h b/drivers/cxl/cxlpci.h index 0fa4799ea316..c7f611929e38 100644 --- a/drivers/cxl/cxlpci.h +++ b/drivers/cxl/cxlpci.h @@ -93,4 +93,41 @@ void read_cdat_data(struct cxl_port *port); void cxl_cor_error_detected(struct pci_dev *pdev); pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, pci_channel_state_t state); + +#define PCI_VENDOR_ID_ALISCM 0x2042 + +struct cxl_pci_quirk { + u16 vendor; + u16 device; +}; + +static const struct cxl_pci_quirk cxl_quirk_list[] = { + { 0x2042, 0x0ddb}, /* aliscm1.0 */ + { } /* END */ +}; + +static inline const struct cxl_pci_quirk * +cxl_pci_quirk_lookup_id(u16 vendor, u16 device, + const struct cxl_pci_quirk *list) +{ + const struct cxl_pci_quirk *q; + + for (q = list; q->vendor || q->device; q++) { + if (q->vendor != vendor) + continue; + if (!q->device || device == q->device) + return q; + } + return NULL; +} + +static inline const struct cxl_pci_quirk * +cxl_pci_quirk_lookup(struct pci_dev *pci, const struct cxl_pci_quirk *list) +{ + if (!pci) + return NULL; + return cxl_pci_quirk_lookup_id(pci->vendor, + pci->device, + list); +} #endif /* __CXL_PCI_H__ */ diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 2968c8b9fd30..ce92ed4946fd 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -197,41 +197,6 @@ static void cxl_mbox_scan_media_work(struct work_struct *work) mutex_unlock(&mds->mbox_mutex); } -struct cxl_pci_quirk { - u16 vendor; - u16 device; -}; - -static const struct cxl_pci_quirk cxl_quirk_list[] = { - { 0x2042, 0x0ddb}, /* aliscm1.0 */ - { } /* END */ -}; - -const struct cxl_pci_quirk * -cxl_pci_quirk_lookup_id(u16 vendor, u16 device, - const struct cxl_pci_quirk *list) -{ - const struct cxl_pci_quirk *q; - - for (q = list; q->vendor || q->device; q++) { - if (q->vendor != vendor) - continue; - if (!q->device || device == q->device) - return q; - } - return NULL; -} - -const struct cxl_pci_quirk * -cxl_pci_quirk_lookup(struct pci_dev *pci, const struct cxl_pci_quirk *list) -{ - if (!pci) - return NULL; - return cxl_pci_quirk_lookup_id(pci->vendor, - pci->device, - list); -} - /** * __cxl_pci_mbox_send_cmd() - Execute a mailbox command * @mds: The memory device driver data -- Gitee