CXL: Process event logs
v4 cover CXL: Process event logs
From: Ira Weiny <[email protected]>
This code has been tested with a newer qemu which allows for more events to be returned at a time as well an additional QMP event and interrupt injection. Those patches will follow once they have been cleaned up.
The series is now in 3 parts:
1) Base functionality including interrupts
2) Tracing specific events (Dynamic Capacity Event Record is defered)
3) cxl-test infrastructure for basic tests
Changes from V3
Feedback from Dan
Spit out ACPI changes for Bjorn
- Link to v3: https://lore.kernel.org/all/[email protected]/
Davidlohr Bueso (1):
cxl/mem: Wire up event interrupts
Ira Weiny (8):
PCI/CXL: Export native CXL error reporting control cxl/mem: Read, trace, and clear events on driver load cxl/mem: Trace General Media Event Record cxl/mem: Trace DRAM Event Record
cxl/mem: Trace Memory Module Event Record cxl/test: Add generic mock events
cxl/test: Add specific events
cxl/test: Simulate event log overflow
drivers/acpi/pci_root.c | 3 + drivers/cxl/core/mbox.c | 186 +++++++++++++ drivers/cxl/core/trace.h | 479 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 16 ++ drivers/cxl/cxlmem.h | 171 ++++++++++++ drivers/cxl/cxlpci.h | 6 + drivers/cxl/pci.c | 236 +++++++++++++++++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + tools/testing/cxl/test/Kbuild | 2 +- tools/testing/cxl/test/mem.c | 352 +++++++++++++++++++++++++ 11 files changed, 1452 insertions(+), 1 deletion(-)
base-commit: acb704099642bc822ef2aed223a0b8db1f7ea76e
Signature · 1 line
2.37.2
PATCH v4 1/9 PCI/CXL: Export native CXL error reporting control
From: Ira Weiny <[email protected]>
CXL _OSC Error Reporting Control is used by the OS to determine if Firmware has control of various CXL error reporting capabilities including the event logs.
Expose the result of negotiating CXL Error Reporting Control in struct pci_host_bridge for consumption by the CXL drivers.
---
Changes from V3:
New patch split out
--- drivers/acpi/pci_root.c | 3 +++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 5 insertions(+)
drivers/acpi/pci_root.c +3 -0
@@ -1047,6 +1047,9 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,if (!(root->osc_control_set &OSC_PCI_EXPRESS_DPC_CONTROL )) host_bridge->native_dpc =0 ; +if (!(root->osc_ext_control_set &OSC_CXL_ERROR_REPORTING_CONTROL )) + host_bridge->native_cxl_error =0 ; +/* * Evaluate the "PCI Boot Configuration" _DSM Function. If it * exists and returns 0, we must preserve any PCI resource
drivers/pci/probe.c +1 -0
@@ -596,6 +596,7 @@ static void pci_init_host_bridge(struct pci_host_bridge *bridge) bridge->native_ltr =1 ; bridge->native_dpc =1 ; bridge->domain_nr =PCI_DOMAIN_NR_NOT_SET ; + bridge->native_cxl_error =1 ;device_initialize (&bridge->dev); }
include/linux/pci.h +1 -0
@@ -577,6 +577,7 @@ struct pci_host_bridge { unsigned int native_pme:1; /* OS may use PCIe PME */ unsigned int native_ltr:1; /* OS may use PCIe LTR */ unsigned int native_dpc:1; /* OS may use PCIe DPC */ + unsigned int native_cxl_error:1; /* OS may use CXL RAS/Events */ unsigned int preserve_config:1; /* Preserve FW resource setup */ unsigned int size_windows:1; /* Enable root bus sizing */ unsigned int msi_domain:1; /* Bridge wants MSI domain */
Signature · 1 line
2.37.2
RE: [PATCH V4 1/9] PCI/CXL: Export native CXL error reporting control
Quoted 6 lines · ira.weiny@ wrote:
From: Ira Weiny <[email protected]>
CXL
_OSCError Reporting Control is used by the OS to determine if Firmware has control of various CXL error reporting capabilities including the event logs.
Quoted 8 lines
Expose the result of negotiating CXL Error Reporting Control in struct
pci_host_bridgefor consumption by the CXL drivers.Cc Bjorn Helgaas <[email protected]>Cc Lukas Wunner <[email protected]>Signed-off-by Ira Weiny <[email protected]>
Looks good to me,
Quoted 51 lines
---
Changes from V3:
New patch split out--- drivers/acpi/pci_root.c | 3 +++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 5 insertions(+)drivers/acpi/pci_root.c +3
-0@@ -1047,6 +1047,9 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,if (!(root->osc_control_set &OSC_PCI_EXPRESS_DPC_CONTROL )) host_bridge->native_dpc =0 ; +if (!(root->osc_ext_control_set &OSC_CXL_ERROR_REPORTING_CONTROL )) + host_bridge->native_cxl_error =0 ; +/* * Evaluate the "PCI Boot Configuration" _DSM Function. If it * exists and returns 0, we must preserve any PCI resource drivers/pci/probe.c +1
-0@@ -596,6 +596,7 @@ static void pci_init_host_bridge(struct pci_host_bridge *bridge) bridge->native_ltr =1 ; bridge->native_dpc =1 ; bridge->domain_nr =PCI_DOMAIN_NR_NOT_SET ; + bridge->native_cxl_error =1 ;device_initialize (&bridge->dev); }include/linux/pci.h +1
-0@@ -577,6 +577,7 @@ struct pci_host_bridge { unsigned int native_pme:1; /* OS may use PCIe PME */ unsigned int native_ltr:1; /* OS may use PCIe LTR */ unsigned int native_dpc:1; /* OS may use PCIe DPC */ + unsigned int native_cxl_error:1; /* OS may use CXL RAS/Events */ unsigned int preserve_config:1; /* Preserve FW resource setup */ unsigned int size_windows:1; /* Enable root bus sizing */ unsigned int msi_domain:1; /* Bridge wants MSI domain */Signature · 1 line
2.37.2
Re: [PATCH V4 1/9] PCI/CXL: Export native CXL error reporting control
In reply to [email protected]Quoted 6 lines · On Sun, 11 Dec 2022 23:06:19 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL
_OSCError Reporting Control is used by the OS to determine if Firmware has control of various CXL error reporting capabilities including the event logs.
Quoted 9 lines
Expose the result of negotiating CXL Error Reporting Control in struct
pci_host_bridgefor consumption by the CXL drivers.Cc Bjorn Helgaas <[email protected]>Cc Lukas Wunner <[email protected]>Signed-off-by Ira Weiny <[email protected]>
Quoted 47 lines
---
Changes from V3:
New patch split out--- drivers/acpi/pci_root.c | 3 +++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 5 insertions(+)drivers/acpi/pci_root.c +3
-0@@ -1047,6 +1047,9 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,if (!(root->osc_control_set &OSC_PCI_EXPRESS_DPC_CONTROL )) host_bridge->native_dpc =0 ; +if (!(root->osc_ext_control_set &OSC_CXL_ERROR_REPORTING_CONTROL )) + host_bridge->native_cxl_error =0 ; +/* * Evaluate the "PCI Boot Configuration" _DSM Function. If it * exists and returns 0, we must preserve any PCI resource drivers/pci/probe.c +1
-0@@ -596,6 +596,7 @@ static void pci_init_host_bridge(struct pci_host_bridge *bridge) bridge->native_ltr =1 ; bridge->native_dpc =1 ; bridge->domain_nr =PCI_DOMAIN_NR_NOT_SET ; + bridge->native_cxl_error =1 ;device_initialize (&bridge->dev); }include/linux/pci.h +1
-0@@ -577,6 +577,7 @@ struct pci_host_bridge { unsigned int native_pme:1; /* OS may use PCIe PME */ unsigned int native_ltr:1; /* OS may use PCIe LTR */ unsigned int native_dpc:1; /* OS may use PCIe DPC */ + unsigned int native_cxl_error:1; /* OS may use CXL RAS/Events */ unsigned int preserve_config:1; /* Preserve FW resource setup */ unsigned int size_windows:1; /* Enable root bus sizing */ unsigned int msi_domain:1; /* Bridge wants MSI domain */
Re: [PATCH V4 1/9] PCI/CXL: Export native CXL error reporting control
In reply to [email protected]Quoted 9 lines · Ira
From: Ira Weiny <[email protected]>
CXL
_OSCError Reporting Control is used by the OS to determine if Firmware has control of various CXL error reporting capabilities including the event logs.Expose the result of negotiating CXL Error Reporting Control in struct
pci_host_bridgefor consumption by the CXL drivers.
Rafael,
I should have CC'ed you on this patch. Could I get an ack on it so Dan can take it through the CXL tree?
Thanks,
Ira
Quoted 56 lines
Cc Bjorn Helgaas <[email protected]>Cc Lukas Wunner <[email protected]>Signed-off-by Ira Weiny <[email protected]>---
Changes from V3:
New patch split out--- drivers/acpi/pci_root.c | 3 +++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 5 insertions(+)drivers/acpi/pci_root.c +3
-0@@ -1047,6 +1047,9 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,if (!(root->osc_control_set &OSC_PCI_EXPRESS_DPC_CONTROL )) host_bridge->native_dpc =0 ; +if (!(root->osc_ext_control_set &OSC_CXL_ERROR_REPORTING_CONTROL )) + host_bridge->native_cxl_error =0 ; +/* * Evaluate the "PCI Boot Configuration" _DSM Function. If it * exists and returns 0, we must preserve any PCI resource drivers/pci/probe.c +1
-0@@ -596,6 +596,7 @@ static void pci_init_host_bridge(struct pci_host_bridge *bridge) bridge->native_ltr =1 ; bridge->native_dpc =1 ; bridge->domain_nr =PCI_DOMAIN_NR_NOT_SET ; + bridge->native_cxl_error =1 ;device_initialize (&bridge->dev); }include/linux/pci.h +1
-0@@ -577,6 +577,7 @@ struct pci_host_bridge { unsigned int native_pme:1; /* OS may use PCIe PME */ unsigned int native_ltr:1; /* OS may use PCIe LTR */ unsigned int native_dpc:1; /* OS may use PCIe DPC */ + unsigned int native_cxl_error:1; /* OS may use CXL RAS/Events */ unsigned int preserve_config:1; /* Preserve FW resource setup */ unsigned int size_windows:1; /* Enable root bus sizing */ unsigned int msi_domain:1; /* Bridge wants MSI domain */Signature · 1 line
2.37.2
Re: [PATCH V4 1/9] PCI/CXL: Export native CXL error reporting control
In reply to [email protected]Quoted 6 lines · On Sun, Dec 11, 2022 at 11:06:19PM -0800, [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL
_OSCError Reporting Control is used by the OS to determine if Firmware has control of various CXL error reporting capabilities including the event logs.
Quoted 8 lines
Expose the result of negotiating CXL Error Reporting Control in struct
pci_host_bridgefor consumption by the CXL drivers.Cc Bjorn Helgaas <[email protected]>Cc Lukas Wunner <[email protected]>Signed-off-by Ira Weiny <[email protected]>
FWIW, for probe.c and pci.h:
Quoted 50 lines
---
Changes from V3:
New patch split out--- drivers/acpi/pci_root.c | 3 +++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 5 insertions(+)drivers/acpi/pci_root.c +3
-0@@ -1047,6 +1047,9 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,if (!(root->osc_control_set &OSC_PCI_EXPRESS_DPC_CONTROL )) host_bridge->native_dpc =0 ; +if (!(root->osc_ext_control_set &OSC_CXL_ERROR_REPORTING_CONTROL )) + host_bridge->native_cxl_error =0 ; +/* * Evaluate the "PCI Boot Configuration" _DSM Function. If it * exists and returns 0, we must preserve any PCI resource drivers/pci/probe.c +1
-0@@ -596,6 +596,7 @@ static void pci_init_host_bridge(struct pci_host_bridge *bridge) bridge->native_ltr =1 ; bridge->native_dpc =1 ; bridge->domain_nr =PCI_DOMAIN_NR_NOT_SET ; + bridge->native_cxl_error =1 ;device_initialize (&bridge->dev); }include/linux/pci.h +1
-0@@ -577,6 +577,7 @@ struct pci_host_bridge { unsigned int native_pme:1; /* OS may use PCIe PME */ unsigned int native_ltr:1; /* OS may use PCIe LTR */ unsigned int native_dpc:1; /* OS may use PCIe DPC */ + unsigned int native_cxl_error:1; /* OS may use CXL RAS/Events */ unsigned int preserve_config:1; /* Preserve FW resource setup */ unsigned int size_windows:1; /* Enable root bus sizing */ unsigned int msi_domain:1; /* Bridge wants MSI domain */Signature · 1 line
2.37.2
PATCH v4 2/9 cxl/mem: Read, trace, and clear events on driver load
In reply to [email protected]From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
---
Changes from V3:
Dan
Split off _OSC pcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Use dev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Remove cxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without _OSC flag
--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)
drivers/cxl/core/mbox.c +136 -0
@@ -8,6 +8,7 @@#include <cxl.h> #include "core.h" +#include "trace.h" static bool cxl_raw_allow_all;
@@ -717,6 +718,140 @@ int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) }EXPORT_SYMBOL_NS_GPL (cxl_enumerate_cmds,CXL ); +static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload); +struct cxl_mbox_cmd mbox_cmd; +u16 cnt; +int rc; +int i; + +/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size); + pl_size = cxlds->payload_size; + } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size, + }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +} + +static void cxl_mem_get_records_log (struct cxl_dev_state *cxlds, +enum cxl_event_log_type type) +{ +struct cxl_get_event_payload *payload; +struct cxl_mbox_cmd mbox_cmd; +u8 log_type = type; +u16 nr_rec; + +mutex_lock (&cxlds->event.log_lock); + payload = cxlds->event.buf; + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_EVENT_RECORD , + .payload_in = &log_type, + .size_in =sizeof (log_type), + .payload_out = payload, + .size_out = cxlds->payload_size, + .min_out =struct_size (payload, records,0 ), + }; + +do { +int rc, i; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) { +dev_err_ratelimited (cxlds->dev,"Event log '%d': Failed to query event records : %d" , + type, rc); +break ; + } + + nr_rec =le16_to_cpu (payload->record_count); +if (!nr_rec) +break ; + +for (i =0 ; i < nr_rec; i++) +trace_cxl_generic_event (cxlds->dev, type, + &payload->records[i]); + +if (payload->flags &CXL_GET_EVENT_FLAG_OVERFLOW ) +trace_cxl_overflow (cxlds->dev, type, payload); + + rc =cxl_clear_event_record (cxlds, type, payload); +if (rc) { +dev_err_ratelimited (cxlds->dev,"Event log '%d': Failed to clear events : %d" , + type, rc); +break ; + } + }while (nr_rec); + +mutex_unlock (&cxlds->event.log_lock); +} + +/** +* cxl_mem_get_event_records - Get Event Records from the device +* @cxlds: The device data for the operation +* +* Retrieve all event records available on the device, report them as trace +* events, and clear them. +* +* See CXL rev 3.0 @8.2.9.2.2 Get Event Records +* See CXL rev 3.0 @8.2.9.2.3 Clear Event Records +*/ +void cxl_mem_get_event_records (struct cxl_dev_state *cxlds,u32 status) +{ +dev_dbg (cxlds->dev,"Reading event logs: %x\n" , status); + +if (status &CXLDEV_EVENT_STATUS_FATAL ) +cxl_mem_get_records_log (cxlds,CXL_EVENT_TYPE_FATAL ); +if (status &CXLDEV_EVENT_STATUS_FAIL ) +cxl_mem_get_records_log (cxlds,CXL_EVENT_TYPE_FAIL ); +if (status &CXLDEV_EVENT_STATUS_WARN ) +cxl_mem_get_records_log (cxlds,CXL_EVENT_TYPE_WARN ); +if (status &CXLDEV_EVENT_STATUS_INFO ) +cxl_mem_get_records_log (cxlds,CXL_EVENT_TYPE_INFO ); +} +EXPORT_SYMBOL_NS_GPL (cxl_mem_get_event_records,CXL ); +/** * cxl_mem_get_partition_info - Get partition info * @cxlds: The device data for the operation
@@ -868,6 +1003,7 @@ struct cxl_dev_state *cxl_dev_state_create(struct device *dev) }mutex_init (&cxlds->mbox_mutex); +mutex_init (&cxlds->event.log_lock); cxlds->dev = dev;return cxlds;
drivers/cxl/core/trace.h +120 -0
133 lines not on this page · raw message
drivers/cxl/cxl.h +12 -0
@@ -156,6 +156,18 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw)#define CXLDEV_CAP_CAP_ID_SECONDARY_MAILBOX 0x3#define CXLDEV_CAP_CAP_ID_MEMDEV 0x4000 +/* CXL 3.0 8.2.8.3.1 Event Status Register */ +#define CXLDEV_DEV_EVENT_STATUS_OFFSET 0x00 +#define CXLDEV_EVENT_STATUS_INFO BIT(0) +#define CXLDEV_EVENT_STATUS_WARN BIT(1) +#define CXLDEV_EVENT_STATUS_FAIL BIT(2) +#define CXLDEV_EVENT_STATUS_FATAL BIT(3) + +#define CXLDEV_EVENT_STATUS_ALL (CXLDEV_EVENT_STATUS_INFO | \ + CXLDEV_EVENT_STATUS_WARN | \ + CXLDEV_EVENT_STATUS_FAIL | \ + CXLDEV_EVENT_STATUS_FATAL) +/* CXL 2.0 8.2.8.4 Mailbox Registers */ #define CXLDEV_MBOX_CAPS_OFFSET 0x00#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK GENMASK(4, 0)
drivers/cxl/cxlmem.h +84 -0
120 lines not on this page · raw message
drivers/cxl/pci.c +40 -0
@@ -417,8 +417,37 @@ static void disable_aer(void *pdev)pci_disable_pcie_error_reporting (pdev); } +static void cxl_mem_free_event_buffer (void *buf) +{ +kvfree (buf); +} + +/* +* There is a single buffer for reading event logs from the mailbox. All logs +* share this buffer protected by the cxlds->event_log_lock. +*/ +static int cxl_mem_alloc_event_buf (struct cxl_dev_state *cxlds) +{ +struct cxl_get_event_payload *buf; + +dev_dbg (cxlds->dev,"Allocating event buffer size %zu\n" , + cxlds->payload_size); + + buf =kvmalloc (cxlds->payload_size,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +if (devm_add_action_or_reset (cxlds->dev, cxl_mem_free_event_buffer, + buf)) +return -ENOMEM ; + + cxlds->event.buf = buf; +return 0 ; +} +static int cxl_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { +struct pci_host_bridge *host_bridge =pci_find_host_bridge (pdev->bus);struct cxl_register_map map;struct cxl_memdev *cxlmd;struct cxl_dev_state *cxlds;
@@ -494,6 +523,17 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (IS_ERR (cxlmd))return PTR_ERR (cxlmd); + rc =cxl_mem_alloc_event_buf (cxlds); +if (rc) +return rc; + +/* +* When BIOS maintains CXL error reporting control, it will process +* event records. Only one agent can do so. +*/ +if (host_bridge->native_cxl_error) +cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); +if (cxlds->regs.ras) {pci_enable_pcie_error_reporting (pdev); rc =devm_add_action_or_reset (&pdev->dev, disable_aer, pdev);
Signature · 1 line
2.37.2
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
Quoted 450 lines · On Sun, Dec 11, 2022 at 11:06:20PM -0800, [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
Signed-off-by Ira Weiny <[email protected]>---
Changes from V3:
Dan
Split off_OSCpcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Usedev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Removecxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without_OSCflag--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)drivers/cxl/core/mbox.c +136
-0@@ -8,6 +8,7 @@#include <cxl.h> #include "core.h" +#include "trace.h" static bool cxl_raw_allow_all;@@ -717,6 +718,140 @@ int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) }EXPORT_SYMBOL_NS_GPL (cxl_enumerate_cmds,CXL ); +static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload); +struct cxl_mbox_cmd mbox_cmd; +u16 cnt; +int rc; +int i; + +/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size); + pl_size = cxlds->payload_size; + } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size, + }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +} + +static void cxl_mem_get_records_log (struct cxl_dev_state *cxlds, +enum cxl_event_log_type type) +{ +struct cxl_get_event_payload *payload; +struct cxl_mbox_cmd mbox_cmd; +u8 log_type = type; +u16 nr_rec; + +mutex_lock (&cxlds->event.log_lock); + payload = cxlds->event.buf; + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_EVENT_RECORD , + .payload_in = &log_type, + .size_in =sizeof (log_type), + .payload_out = payload, + .size_out = cxlds->payload_size, + .min_out =struct_size (payload, records,0 ), + }; + +do { +int rc, i; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) { +dev_err_ratelimited (cxlds->dev,"Event log '%d': Failed to query event records : %d" , + type, rc); +break ; + } + + nr_rec =le16_to_cpu (payload->record_count); +if (!nr_rec) +break ; + +for (i =0 ; i < nr_rec; i++) +trace_cxl_generic_event (cxlds->dev, type, + &payload->records[i]); + +if (payload->flags &CXL_GET_EVENT_FLAG_OVERFLOW ) +trace_cxl_overflow (cxlds->dev, type, payload); + + rc =cxl_clear_event_record (cxlds, type, payload); +if (rc) { +dev_err_ratelimited (cxlds->dev,"Event log '%d': Failed to clear events : %d" , + type, rc); +break ; + } + }while (nr_rec); + +mutex_unlock (&cxlds->event.log_lock); +} + +/** +* cxl_mem_get_event_records - Get Event Records from the device +* @cxlds: The device data for the operation +* +* Retrieve all event records available on the device, report them as trace +* events, and clear them. +* +* See CXL rev 3.0 @8.2.9.2.2 Get Event Records +* See CXL rev 3.0 @8.2.9.2.3 Clear Event Records +*/ +void cxl_mem_get_event_records (struct cxl_dev_state *cxlds,u32 status) +{ +dev_dbg (cxlds->dev,"Reading event logs: %x\n" , status); + +if (status &CXLDEV_EVENT_STATUS_FATAL ) +cxl_mem_get_records_log (cxlds,CXL_EVENT_TYPE_FATAL ); +if (status &CXLDEV_EVENT_STATUS_FAIL ) +cxl_mem_get_records_log (cxlds,CXL_EVENT_TYPE_FAIL ); +if (status &CXLDEV_EVENT_STATUS_WARN ) +cxl_mem_get_records_log (cxlds,CXL_EVENT_TYPE_WARN ); +if (status &CXLDEV_EVENT_STATUS_INFO ) +cxl_mem_get_records_log (cxlds,CXL_EVENT_TYPE_INFO ); +} +EXPORT_SYMBOL_NS_GPL (cxl_mem_get_event_records,CXL ); +/** * cxl_mem_get_partition_info - Get partition info * @cxlds: The device data for the operation @@ -868,6 +1003,7 @@ struct cxl_dev_state *cxl_dev_state_create(struct device *dev) }mutex_init (&cxlds->mbox_mutex); +mutex_init (&cxlds->event.log_lock); cxlds->dev = dev;return cxlds;drivers/cxl/core/trace.h +120
-0@@ -6,7 +6,9 @@#if !defined(_CXL_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ )#define _CXL_EVENTS_H +#include <asm-generic/unaligned.h> #include <cxl.h> +#include <cxlmem.h> #include <linux/tracepoint.h> #define CXL_RAS_UC_CACHE_DATA_PARITY BIT(0)@@ -103,6 +105,124 @@ TRACE_EVENT(cxl_aer_correctable_error, ) ); +#include <linux/tracepoint.h> + +#define cxl_event_log_type_str (type) \ + __print_symbolic(type, \ + { CXL_EVENT_TYPE_INFO, "Informational" }, \ + { CXL_EVENT_TYPE_WARN, "Warning" }, \ + { CXL_EVENT_TYPE_FAIL, "Failure" }, \ + { CXL_EVENT_TYPE_FATAL, "Fatal" }) + +TRACE_EVENT (cxl_overflow, + + TP_PROTO(const struct device *dev, enum cxl_event_log_type log, + struct cxl_get_event_payload *payload), + +TP_ARGS (dev, log, payload), + +TP_STRUCT__entry ( + __string(dev_name, dev_name(dev)) + __field(int, log) + __field(u64, first_ts) + __field(u64, last_ts) +__field (u16, count) + ), + +TP_fast_assign ( + __assign_str(dev_name, dev_name(dev)); + __entry->log = log; + __entry->count = le16_to_cpu(payload->overflow_err_count); + __entry->first_ts = le64_to_cpu(payload->first_overflow_timestamp); + __entry->last_ts = le64_to_cpu(payload->last_overflow_timestamp); + ), + +TP_printk ("%s: log=%s : %u records from %llu to %llu" , +__get_str (dev_name),cxl_event_log_type_str (__entry->log), + __entry->count, __entry->first_ts, __entry->last_ts) + +); + +/* +* Common Event Record Format +* CXL 3.0 section 8.2.9.2.1; Table 8-42 +*/ +#define CXL_EVENT_RECORD_FLAG_PERMANENT BIT(2) +#define CXL_EVENT_RECORD_FLAG_MAINT_NEEDED BIT(3) +#define CXL_EVENT_RECORD_FLAG_PERF_DEGRADED BIT(4) +#define CXL_EVENT_RECORD_FLAG_HW_REPLACE BIT(5) +#define show_hdr_flags (flags) __print_flags(flags, " | ", \ + { CXL_EVENT_RECORD_FLAG_PERMANENT, "PERMANENT_CONDITION" }, \ + { CXL_EVENT_RECORD_FLAG_MAINT_NEEDED, "MAINTENANCE_NEEDED" }, \ + { CXL_EVENT_RECORD_FLAG_PERF_DEGRADED, "PERFORMANCE_DEGRADED" }, \ + { CXL_EVENT_RECORD_FLAG_HW_REPLACE, "HARDWARE_REPLACEMENT_NEEDED" } \ +) + +/* +* Define macros for the common header of each CXL event. +* +* Tracepoints using these macros must do 3 things: +* +* 1) Add CXL_EVT_TP_entry to TP_STRUCT__entry +* 2) Use CXL_EVT_TP_fast_assign within TP_fast_assign; +* pass the dev, log, and CXL event header +* 3) Use CXL_EVT_TP_printk() instead of TP_printk() +* +* See the generic_event tracepoint as an example. +*/ +#define CXL_EVT_TP_entry \ + __string(dev_name, dev_name(dev)) \ + __field(int, log) \ + __field_struct(uuid_t, hdr_uuid) \ + __field(u32, hdr_flags) \ + __field(u16, hdr_handle) \ + __field(u16, hdr_related_handle) \ + __field(u64, hdr_timestamp) \ + __field(u8, hdr_length) \ + __field(u8, hdr_maint_op_class) + +#define CXL_EVT_TP_fast_assign (dev, l, hdr) \ + __assign_str(dev_name, dev_name(dev)); \ + __entry->log = (l); \ + memcpy(&__entry->hdr_uuid, &(hdr).id, sizeof(uuid_t)); \ + __entry->hdr_length = (hdr).length; \ + __entry->hdr_flags = get_unaligned_le24((hdr).flags); \ + __entry->hdr_handle = le16_to_cpu((hdr).handle); \ + __entry->hdr_related_handle = le16_to_cpu((hdr).related_handle); \ + __entry->hdr_timestamp = le64_to_cpu((hdr).timestamp); \ + __entry->hdr_maint_op_class = (hdr).maint_op_class + +#define CXL_EVT_TP_printk (fmt, ...) \ + TP_printk("%s log=%s : time=%llu uuid=%pUb len=%d flags='%s' " \ + "handle=%x related_handle=%x maint_op_class=%u" \ + " : " fmt, \ + __get_str(dev_name), cxl_event_log_type_str(__entry->log), \ + __entry->hdr_timestamp, &__entry->hdr_uuid, __entry->hdr_length,\ + show_hdr_flags(__entry->hdr_flags), __entry->hdr_handle, \ + __entry->hdr_related_handle, __entry->hdr_maint_op_class, \ + ##__VA_ARGS__) + +TRACE_EVENT (cxl_generic_event, + + TP_PROTO(const struct device *dev, enum cxl_event_log_type log, + struct cxl_event_record_raw *rec), + +TP_ARGS (dev, log, rec), + +TP_STRUCT__entry ( + CXL_EVT_TP_entry +__array (u8, data,CXL_EVENT_RECORD_DATA_LENGTH ) + ), + +TP_fast_assign ( + CXL_EVT_TP_fast_assign(dev, log, rec->hdr); + memcpy(__entry->data, &rec->data, CXL_EVENT_RECORD_DATA_LENGTH); + ), + +CXL_EVT_TP_printk ("%s" , +__print_hex (__entry->data,CXL_EVENT_RECORD_DATA_LENGTH )) +); +#endif /* _CXL_EVENTS_H */ #define TRACE_INCLUDE_FILE tracedrivers/cxl/cxl.h +12
-0@@ -156,6 +156,18 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw)#define CXLDEV_CAP_CAP_ID_SECONDARY_MAILBOX 0x3#define CXLDEV_CAP_CAP_ID_MEMDEV 0x4000 +/* CXL 3.0 8.2.8.3.1 Event Status Register */ +#define CXLDEV_DEV_EVENT_STATUS_OFFSET 0x00 +#define CXLDEV_EVENT_STATUS_INFO BIT(0) +#define CXLDEV_EVENT_STATUS_WARN BIT(1) +#define CXLDEV_EVENT_STATUS_FAIL BIT(2) +#define CXLDEV_EVENT_STATUS_FATAL BIT(3) + +#define CXLDEV_EVENT_STATUS_ALL (CXLDEV_EVENT_STATUS_INFO | \ + CXLDEV_EVENT_STATUS_WARN | \ + CXLDEV_EVENT_STATUS_FAIL | \ + CXLDEV_EVENT_STATUS_FATAL) +/* CXL 2.0 8.2.8.4 Mailbox Registers */ #define CXLDEV_MBOX_CAPS_OFFSET 0x00#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK GENMASK(4, 0)drivers/cxl/cxlmem.h +33
-0@@ -4,6 +4,7 @@#define __CXL_MEM_H__#include <uapi/linux/cxl_mem.h> #include <linux/cdev.h> +#include <linux/uuid.h> #include "cxl.h" /* CXL 2.0 8.2.8.5.1.1 Memory Device Status Register */ @@ -193,6 +194,17 @@ struct cxl_endpoint_dvsec_info {struct range dvsec_range[2 ]; }; +/** +* struct cxl_event_state - Event log driver state +* +* @event_buf: Buffer to receive event data +* @event_log_lock: Serialize event_buf and log use +*/ +struct cxl_event_state { +struct cxl_get_event_payload *buf; +struct mutex log_lock; +}; +/** * struct cxl_dev_state - The driver device state * @@ -266,12 +278,16 @@ struct cxl_dev_state {struct xarray doe_mbs; +struct cxl_event_state event; +int (*mbox_send)(struct cxl_dev_state *cxlds,struct cxl_mbox_cmd *cmd); };enum cxl_opcode {CXL_MBOX_OP_INVALID =0x0000 ,CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID , +CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 , +CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 ,CXL_MBOX_OP_GET_SUPPORTED_LOGS =0x0400 ,@@ -347,6 +363,73 @@ struct cxl_mbox_identify {u8 qos_telemetry_caps; } __packed; +/* +* Common Event Record Format +* CXL rev 3.0 section 8.2.9.2.1; Table 8-42 +*/ +struct cxl_event_record_hdr { +uuid_t id; +u8 length; +u8 flags[3 ]; +__le16 handle; +__le16 related_handle; +__le64 timestamp; +u8 maint_op_class; +u8 reserved[15 ]; +} __packed; + +#define CXL_EVENT_RECORD_DATA_LENGTH 0x50 +struct cxl_event_record_raw {
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 392
Quoted 10 lines
drivers/cxl/cxlmem.h +10
-0+struct cxl_event_record_hdr hdr; +u8 data[CXL_EVENT_RECORD_DATA_LENGTH ]; +} __packed; + +/* +* Get Event Records output payload +* CXL rev 3.0 section 8.2.9.2.2; Table 8-50 +*/ +#define CXL_GET_EVENT_FLAG_OVERFLOW BIT(0) +#define CXL_GET_EVENT_FLAG_MORE_RECORDS BIT(1)
I don't see any code consumes this more flag, is anything I miss? Device shall set this more flag when single output payload can not fit in all records
Quoted 115 lines
drivers/cxl/cxlmem.h +41
-0+struct cxl_get_event_payload { +u8 flags; +u8 reserved1; +__le16 overflow_err_count; +__le64 first_overflow_timestamp; +__le64 last_overflow_timestamp; +__le16 record_count; +u8 reserved2[10 ]; +struct cxl_event_record_raw records[]; +} __packed; + +/* +* CXL rev 3.0 section 8.2.9.2.2; Table 8-49 +*/ +enum cxl_event_log_type { +CXL_EVENT_TYPE_INFO =0x00 , +CXL_EVENT_TYPE_WARN , +CXL_EVENT_TYPE_FAIL , +CXL_EVENT_TYPE_FATAL , +CXL_EVENT_TYPE_MAX +}; + +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ]; +} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \ + sizeof(__le16)) +struct cxl_mbox_get_partition_info {__le64 active_volatile_cap;__le64 active_persistent_cap;@@ -441,6 +524,7 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds);struct cxl_dev_state *cxl_dev_state_create (struct device *dev);void set_exclusive_cxl_commands (struct cxl_dev_state *cxlds,unsigned long *cmds);void clear_exclusive_cxl_commands (struct cxl_dev_state *cxlds,unsigned long *cmds); +void cxl_mem_get_event_records (struct cxl_dev_state *cxlds,u32 status);#ifdef CONFIG_CXL_SUSPEND void cxl_mem_active_inc (void );void cxl_mem_active_dec (void );drivers/cxl/pci.c +40
-0@@ -417,8 +417,37 @@ static void disable_aer(void *pdev)pci_disable_pcie_error_reporting (pdev); } +static void cxl_mem_free_event_buffer (void *buf) +{ +kvfree (buf); +} + +/* +* There is a single buffer for reading event logs from the mailbox. All logs +* share this buffer protected by the cxlds->event_log_lock. +*/ +static int cxl_mem_alloc_event_buf (struct cxl_dev_state *cxlds) +{ +struct cxl_get_event_payload *buf; + +dev_dbg (cxlds->dev,"Allocating event buffer size %zu\n" , + cxlds->payload_size); + + buf =kvmalloc (cxlds->payload_size,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +if (devm_add_action_or_reset (cxlds->dev, cxl_mem_free_event_buffer, + buf)) +return -ENOMEM ; + + cxlds->event.buf = buf; +return 0 ; +} +static int cxl_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { +struct pci_host_bridge *host_bridge =pci_find_host_bridge (pdev->bus);struct cxl_register_map map;struct cxl_memdev *cxlmd;struct cxl_dev_state *cxlds;@@ -494,6 +523,17 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (IS_ERR (cxlmd))return PTR_ERR (cxlmd); + rc =cxl_mem_alloc_event_buf (cxlds); +if (rc) +return rc; + +/* +* When BIOS maintains CXL error reporting control, it will process +* event records. Only one agent can do so. +*/ +if (host_bridge->native_cxl_error) +cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); +if (cxlds->regs.ras) {pci_enable_pcie_error_reporting (pdev); rc =devm_add_action_or_reset (&pdev->dev, disable_aer, pdev);Signature · 1 line
2.37.2
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
Quoted 3 lines · johnny
Quoted 2 lines · On Sun, Dec 11, 2022 at 11:06:20PM -0800, [email protected] wrote:
From: Ira Weiny <[email protected]>
[snip]
Quoted 7 lines
Quoted 7 lines
drivers/cxl/cxlmem.h +7
-0+ +#define CXL_EVENT_RECORD_DATA_LENGTH 0x50 +struct cxl_event_record_raw { +struct cxl_event_record_hdr hdr; +u8 data[CXL_EVENT_RECORD_DATA_LENGTH ]; +} __packed; +
Quoted 8 lines
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 392
Quoted 6 lines
drivers/cxl/cxlmem.h +6
-0+/* +* Get Event Records output payload +* CXL rev 3.0 section 8.2.9.2.2; Table 8-50 +*/ +#define CXL_GET_EVENT_FLAG_OVERFLOW BIT(0) +#define CXL_GET_EVENT_FLAG_MORE_RECORDS BIT(1)I don't see any code consumes this more flag, is anything I miss? Device shall set this more flag when single output payload can not fit in all records
I should have removed this flag and put something in the cover letter. I left it in for completeness but you are correct it is unused.
We determined back in V1 that the more bit was useless in this particular looping of Get Events Records.[1]
The net-net is that if the driver does not see the number of records go to 0 it can't be sure it will get an interrupt for the next set of events. Therefore it loops until it sees the number of records go to 0.
Ira
[1] https://lore.kernel.org/all/Y4blpk%2FesXJMe79Y@iweiny-desk3/
Quoted 116 lines
Quoted 115 lines
drivers/cxl/cxlmem.h +41
-0+struct cxl_get_event_payload { +u8 flags; +u8 reserved1; +__le16 overflow_err_count; +__le64 first_overflow_timestamp; +__le64 last_overflow_timestamp; +__le16 record_count; +u8 reserved2[10 ]; +struct cxl_event_record_raw records[]; +} __packed; + +/* +* CXL rev 3.0 section 8.2.9.2.2; Table 8-49 +*/ +enum cxl_event_log_type { +CXL_EVENT_TYPE_INFO =0x00 , +CXL_EVENT_TYPE_WARN , +CXL_EVENT_TYPE_FAIL , +CXL_EVENT_TYPE_FATAL , +CXL_EVENT_TYPE_MAX +}; + +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ]; +} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \ + sizeof(__le16)) +struct cxl_mbox_get_partition_info {__le64 active_volatile_cap;__le64 active_persistent_cap;@@ -441,6 +524,7 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds);struct cxl_dev_state *cxl_dev_state_create (struct device *dev);void set_exclusive_cxl_commands (struct cxl_dev_state *cxlds,unsigned long *cmds);void clear_exclusive_cxl_commands (struct cxl_dev_state *cxlds,unsigned long *cmds); +void cxl_mem_get_event_records (struct cxl_dev_state *cxlds,u32 status);#ifdef CONFIG_CXL_SUSPEND void cxl_mem_active_inc (void );void cxl_mem_active_dec (void );drivers/cxl/pci.c +40
-0@@ -417,8 +417,37 @@ static void disable_aer(void *pdev)pci_disable_pcie_error_reporting (pdev); } +static void cxl_mem_free_event_buffer (void *buf) +{ +kvfree (buf); +} + +/* +* There is a single buffer for reading event logs from the mailbox. All logs +* share this buffer protected by the cxlds->event_log_lock. +*/ +static int cxl_mem_alloc_event_buf (struct cxl_dev_state *cxlds) +{ +struct cxl_get_event_payload *buf; + +dev_dbg (cxlds->dev,"Allocating event buffer size %zu\n" , + cxlds->payload_size); + + buf =kvmalloc (cxlds->payload_size,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +if (devm_add_action_or_reset (cxlds->dev, cxl_mem_free_event_buffer, + buf)) +return -ENOMEM ; + + cxlds->event.buf = buf; +return 0 ; +} +static int cxl_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { +struct pci_host_bridge *host_bridge =pci_find_host_bridge (pdev->bus);struct cxl_register_map map;struct cxl_memdev *cxlmd;struct cxl_dev_state *cxlds;@@ -494,6 +523,17 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (IS_ERR (cxlmd))return PTR_ERR (cxlmd); + rc =cxl_mem_alloc_event_buf (cxlds); +if (rc) +return rc; + +/* +* When BIOS maintains CXL error reporting control, it will process +* event records. Only one agent can do so. +*/ +if (host_bridge->native_cxl_error) +cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); +if (cxlds->regs.ras) {pci_enable_pcie_error_reporting (pdev); rc =devm_add_action_or_reset (&pdev->dev, disable_aer, pdev);Signature · 1 line
2.37.2
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
In reply to [email protected]Quoted 28 lines · On Sun, 11 Dec 2022 23:06:20 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
Quoted 8 lines
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
Signed-off-by Ira Weiny <[email protected]>
A few things noticed inline. I've tightened the QEMU code to reject the case of the input payload claims to be bigger than the mailbox size and hacked the size down to 256 bytes so it triggers the problem highlighted below.
Quoted 43 lines
---
Changes from V3:
Dan
Split off_OSCpcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Usedev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Removecxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without_OSCflag--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)drivers/cxl/core/mbox.c +15
-0+static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload); +struct cxl_mbox_cmd mbox_cmd; +u16 cnt; +int rc; +int i; +
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 745
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size); + pl_size = cxlds->payload_size; + } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size,
This payload size should be whatever we need to store the records, not the max size possible. Particularly as that size is currently bigger than the mailbox might be.
It shouldn't fail (I think) simply because a later version of the spec might add more to this message and things should still work, but definitely not good practice to tell the hardware this is much longer than it actually is.
Quoted 31 lines
drivers/cxl/core/mbox.c +31
-0+ }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +}
...
Quoted 4 lines
drivers/cxl/cxlmem.h +0
-0
...
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 425
Quoted 12 lines
drivers/cxl/cxlmem.h +12
-0+ +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ];
Doesn't fit in the smallest possible payload buffer. It's 526 bytes long. Payload buffer might be 256 bytes in total. (8.2.8.4.3 Mailbox capabilities)
Lazy approach, make this smaller and do more loops when clearing. If we want to optimize this later can expand it to this size.
Quoted 7 lines
drivers/cxl/cxlmem.h +7
-0+} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \ + sizeof(__le16)) +
...
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
Quoted 38 lines · Jonathan Cameron
Quoted 35 lines · On Sun, 11 Dec 2022 23:06:20 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
Quoted 6 lines
Quoted 1 line
Signed-off-by Ira Weiny <[email protected]>A few things noticed inline. I've tightened the QEMU code to reject the case of the input payload claims to be bigger than the mailbox size and hacked the size down to 256 bytes so it triggers the problem highlighted below.
I'm not sure what you did here.
Quoted 40 lines
Quoted 40 lines
---
Changes from V3:
Dan
Split off_OSCpcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Usedev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Removecxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without_OSCflag--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)drivers/cxl/core/mbox.c +11
-0+static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload); +struct cxl_mbox_cmd mbox_cmd;
Quoted 8 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 739
Quoted 8 lines
drivers/cxl/core/mbox.c +8
-0+u16 cnt; +int rc; +int i; + +/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size); + pl_size = cxlds->payload_size;
pl_size is only the max size possible if that size was smaller than the size of the record [sizeof(payload) above].
Quoted 10 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 745
Quoted 6 lines
drivers/cxl/core/mbox.c +6
-0+ } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size,This payload size should be whatever we need to store the records, not the max size possible. Particularly as that size is currently bigger than the mailbox might be.
But the above check and set ensures that does not happen.
Quoted 4 lines
It shouldn't fail (I think) simply because a later version of the spec might add more to this message and things should still work, but definitely not good practice to tell the hardware this is much longer than it actually is.
I don't follow.
The full payload is going to be sent even if we are just clearing 1 record which is inefficient but it should never overflow the hardware because it is limited by the check above.
So why would this be a problem?
Quoted 61 lines
Quoted 33 lines
drivers/cxl/core/mbox.c +31
-0+ }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +}...
Quoted 4 lines
drivers/cxl/cxlmem.h +0
-0...
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 425
Quoted 12 lines
drivers/cxl/cxlmem.h +12
-0+ +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ];Doesn't fit in the smallest possible payload buffer. It's 526 bytes long. Payload buffer might be 256 bytes in total. (8.2.8.4.3 Mailbox capabilities)
Quoted 2 lines
Lazy approach, make this smaller and do more loops when clearing. If we want to optimize this later can expand it to this size.
I agree but the code already checks for and adjusts this on the fly based on cxlds->payload_size?
+ /* Payload size may limit the max handles */
+ if (pl_size > cxlds->payload_size) {
+ max_handles = CXL_CLEAR_EVENT_LIMIT_HANDLES(cxlds->payload_size);
+ pl_size = cxlds->payload_size;
+ }
Why is this not ok? [Other than being potentially inefficient.]
Do you have a patch to qemu which causes this?
Ira
Quoted 10 lines
Quoted 7 lines
drivers/cxl/cxlmem.h +7
-0+} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \ + sizeof(__le16)) +...
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
Quoted 39 lines · On Fri, 16 Dec 2022 13:54:01 -0800 Ira Weiny <[email protected]> wrote:
Quoted 38 lines · Jonathan Cameron
Quoted 35 lines · On Sun, 11 Dec 2022 23:06:20 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Ira Weiny <[email protected]>A few things noticed inline. I've tightened the QEMU code to reject the case of the input payload claims to be bigger than the mailbox size and hacked the size down to 256 bytes so it triggers the problem highlighted below.
I'm not sure what you did here.
Nor am I. I think this might have been a case of chasing the undersized length bug in QEMU because it was the CXL 3.0 issue and misunderstanding one of the debug prints I got.
Friday silliness. Sorry about that!
However, the over sized payload communicated to the hardware is still a potential problem. See below.
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
---
Changes from V3:
Dan
Split off_OSCpcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Usedev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Removecxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without_OSCflag--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)drivers/cxl/core/mbox.c +10
-0+static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload);
Quoted 8 lines
Quoted 8 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 738
Quoted 8 lines
drivers/cxl/core/mbox.c +8
-0+struct cxl_mbox_cmd mbox_cmd; +u16 cnt; +int rc; +int i; + +/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size);
Definition of that is more complex than it needs to be - see below.
Quoted 4 lines
Quoted 1 line
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 739
Quoted 1 line
drivers/cxl/core/mbox.c +1
-0+ pl_size = cxlds->payload_size;
pl_sizeis only the max size possible if that size was smaller than the size of the record [sizeof(payload) above].
Sorry. For some reason my eyes skipped over this completely. So we are fine for all my comments on overflowing. On plus side will now check if that happens in QEMU and return an error which we weren't doing before.
Quoted 19 lines
Quoted 11 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 745
Quoted 7 lines
drivers/cxl/core/mbox.c +6
-0+ } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size,This payload size should be whatever we need to store the records, not the max size possible. Particularly as that size is currently bigger than the mailbox might be.
But the above check and set ensures that does not happen.
Quoted 4 lines
It shouldn't fail (I think) simply because a later version of the spec might add more to this message and things should still work, but definitely not good practice to tell the hardware this is much longer than it actually is.
Quoted 7 lines
I don't follow.
The full payload is going to be sent even if we are just clearing 1 record which is inefficient but it should never overflow the hardware because it is limited by the check above.
So why would this be a problem?
I'm struggling to find a clear spec statement on if this allowed, so the following is a thought experiment. There is language in definition of the "invalid payload length" error code "The input payload length is not valid for the specified command", but it doesn't go into what counts as valid.
What you have looks fine because a device can't fail on the basis it's told the payload is longer than it expects, because you might be sending a CXL 4.0 spec payload that is backwards compatible with CXL 3.0 - hence the fact the sizes don't match up with that expected can't be considered an error.
So far so good... However, we may have a situation not dissimilar to the change in record length for the set event interrupt policy payload between CXL 2.0 and CXL 3.0. The only way the endpoint knows what version of message it got is because the record is 4 bytes or 5 bytes. If we have extra stuff on the end of this record in future the end point can assume that it is a new version of the spec and interpret what is in that payload space.
Say the future structure looks like
struct cxl_mbox_clear_event_payload_future {
u8 event_log; /* enum cxl_event_log_type */
u8 clear_flags;
u8 nr_recs;
u8 reserved[3];
__le16 handle[nr_recs];
__le16 otherdata[nr_recs];
}Endpoint receiving your 'overly long payload' will assume all those otherdata fields are 0, not necessarily the same as non present.
For the set event interrupt policy, if we sent an overlong payload like you've done here with assumption of the CXL 2.0 spec we would be turning off the DCD interrupt rather that doing nothing (unlikely to be a problem in that particularly case as that one doesn't have a FW Interrupt option - but that's more luck than design).
I'm not sure why we'd have extra stuff for this payload, but it 'might' happen'.
Quoted 75 lines
Quoted 63 lines
Quoted 35 lines
drivers/cxl/core/mbox.c +31
-0+ }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +}...
Quoted 4 lines
drivers/cxl/cxlmem.h +0
-0...
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 425
Quoted 12 lines
drivers/cxl/cxlmem.h +12
-0+ +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ];Doesn't fit in the smallest possible payload buffer. It's 526 bytes long. Payload buffer might be 256 bytes in total. (8.2.8.4.3 Mailbox capabilities)
Quoted 2 lines
Lazy approach, make this smaller and do more loops when clearing. If we want to optimize this later can expand it to this size.
I agree but the code already checks for and adjusts this on the fly based on
cxlds->payload_size?+ /* Payload size may limit the max handles */
+ if (pl_size>cxlds->payload_size) {
+max_handles=CXL_CLEAR_EVENT_LIMIT_HANDLES(cxlds->payload_size);
+pl_size=cxlds->payload_size;
+ }
Quoted 3 lines
Why is this not ok? [Other than being potentially inefficient.]
Do you have a patch to qemu which causes this?
Two issues crossing I think on my side and me thinking this one was obviously the problem when it wasn't.
Quoted 8 lines
Ira
Quoted 5 lines
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 430
Quoted 5 lines
drivers/cxl/cxlmem.h +5
-0+} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \
Could use offsetof() to simplify this
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
drivers/cxl/cxlmem.h +2
-0+ sizeof(__le16)) +...
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
Quoted 49 lines · Jonathan Cameron
Quoted 46 lines · On Fri, 16 Dec 2022 13:54:01 -0800 Ira Weiny <[email protected]> wrote:
Quoted 44 lines · Jonathan Cameron
Quoted 28 lines · On Sun, 11 Dec 2022 23:06:20 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
Quoted 8 lines
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
Signed-off-by Ira Weiny <[email protected]>A few things noticed inline. I've tightened the QEMU code to reject the case of the input payload claims to be bigger than the mailbox size and hacked the size down to 256 bytes so it triggers the problem highlighted below.
Quoted 7 lines
Quoted 1 line
I'm not sure what you did here.
Nor am I. I think this might have been a case of chasing the undersized length bug in QEMU because it was the CXL 3.0 issue and misunderstanding one of the debug prints I got.
Friday silliness. Sorry about that!
NP but you did have me going. I've vowed to actually understand the spec better going forward! :-D
Quoted 3 lines
However, the over sized payload communicated to the hardware is still a potential problem. See below.
I don't see where there is an oversized payload used either...
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
---
Changes from V3:
Dan
Split off_OSCpcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Usedev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Removecxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without_OSCflag--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)drivers/cxl/core/mbox.c +0
-0
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 730
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload);
This line ensures the payload is only ever the size of the definition per the 3.0 spec.
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 738
Quoted 8 lines
drivers/cxl/core/mbox.c +8
-0+struct cxl_mbox_cmd mbox_cmd; +u16 cnt; +int rc; +int i; + +/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size);Definition of that is more complex than it needs to be - see below.
Then this ensures it is truncated if needed.
Quoted 36 lines
Quoted 5 lines
Quoted 2 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 739
Quoted 2 lines
drivers/cxl/core/mbox.c +1
-0+ pl_size = cxlds->payload_size;
pl_sizeis only the max size possible if that size was smaller than the size of the record [sizeof(payload) above].Sorry. For some reason my eyes skipped over this completely. So we are fine for all my comments on overflowing. On plus side will now check if that happens in QEMU and return an error which we weren't doing before.
Quoted 25 lines
Quoted 11 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 745
Quoted 7 lines
drivers/cxl/core/mbox.c +6
-0+ } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size,This payload size should be whatever we need to store the records, not the max size possible. Particularly as that size is currently bigger than the mailbox might be.
But the above check and set ensures that does not happen.
Quoted 4 lines
It shouldn't fail (I think) simply because a later version of the spec might add more to this message and things should still work, but definitely not good practice to tell the hardware this is much longer than it actually is.
I don't follow.
The full payload is going to be sent even if we are just clearing 1 record which is inefficient but it should never overflow the hardware because it is limited by the check above.
Quoted 5 lines
Quoted 1 line
So why would this be a problem?
I'm struggling to find a clear spec statement on if this allowed, so the following is a thought experiment. There is language in definition of the "invalid payload length" error code "The input payload length is not valid for the specified command", but it doesn't go into what counts as valid.
I think the only thing which makes sense is if the payload length is smaller than:
Header + nr_recs * 2
Anything up to
header + (0xff * 2) should be fine per the 3.0 spec.
Quoted 14 lines
What you have looks fine because a device can't fail on the basis it's told the payload is longer than it expects, because you might be sending a CXL 4.0 spec payload that is backwards compatible with CXL 3.0 - hence the fact the sizes don't match up with that expected can't be considered an error.
So far so good... However, we may have a situation not dissimilar to the change in record length for the set event interrupt policy payload between CXL 2.0 and CXL 3.0. The only way the endpoint knows what version of message it got is because the record is 4 bytes or 5 bytes. If we have extra stuff on the end of this record in future the end point can assume that it is a new version of the spec and interpret what is in that payload space.Say the future structure looks like
Quoted 7 lines
struct cxl_mbox_clear_event_payload_future {
u8 event_log; /* enum cxl_event_log_type */
u8 clear_flags;
u8 nr_recs;
u8 reserved[3];
__le16 handle[nr_recs];
__le16 otherdata[nr_recs];otherdata should be ignored by a 3.0 device.
a theoretical 4.0 device should handle otherdata not being there per some flag in the flags field I would suppose... That would have to be determined if this payload were extended. Otherwise this software will fail no matter what.
Other mailbox commands do not 0 out from the command size to 1M either.
Quoted 4 lines
}
Endpoint receiving your 'overly long payload' will assume all those otherdata fields are 0, not necessarily the same as non present.
But it is not 'overly long'. It is only the length of the current spec. See above.
Quoted 6 lines
For the set event interrupt policy, if we sent an overlong payload like you've done here with assumption of the CXL 2.0 spec we would be turning off the DCD interrupt rather that doing nothing (unlikely to be a problem in that particularly case as that one doesn't have a FW Interrupt option - but that's more luck than design).
I'm not sure why we'd have extra stuff for this payload, but it 'might' happen'.
I'll have to check but I don't think I set the payload long in that message. It too should be sizeof(<set event int policy>)
Quoted 76 lines
Quoted 76 lines
Quoted 64 lines
Quoted 36 lines
drivers/cxl/core/mbox.c +31
-0+ }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +}...
Quoted 4 lines
drivers/cxl/cxlmem.h +0
-0...
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 425
Quoted 12 lines
drivers/cxl/cxlmem.h +12
-0+ +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ];Doesn't fit in the smallest possible payload buffer. It's 526 bytes long. Payload buffer might be 256 bytes in total. (8.2.8.4.3 Mailbox capabilities)
Quoted 2 lines
Lazy approach, make this smaller and do more loops when clearing. If we want to optimize this later can expand it to this size.
I agree but the code already checks for and adjusts this on the fly based on
cxlds->payload_size?+ /* Payload size may limit the max handles */
+ if (pl_size>cxlds->payload_size) {
+max_handles=CXL_CLEAR_EVENT_LIMIT_HANDLES(cxlds->payload_size);
+pl_size=cxlds->payload_size;
+ }
Quoted 6 lines
Quoted 3 lines
Why is this not ok? [Other than being potentially inefficient.]
Do you have a patch to qemu which causes this?
Two issues crossing I think on my side and me thinking this one was obviously the problem when it wasn't.
My fault also for not at least throwing my Qemu test code out there. I've been busy with some things today. I'll try and get those changes cleaned up and at least another RFC set out ASAP.
Quoted 11 lines
Quoted 9 lines
Ira
Quoted 5 lines
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 430
Quoted 5 lines
drivers/cxl/cxlmem.h +5
-0+} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \Could use
offsetof()to simplify this
True. How about I submit a clean up patch to follow? I don't think this is broken.
Ira
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
drivers/cxl/cxlmem.h +2
-0+ sizeof(__le16)) +...
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
Quoted 58 lines · On Sat, 17 Dec 2022 16:21:05 -0800 Ira Weiny <[email protected]> wrote:
Quoted 49 lines · Jonathan Cameron
Quoted 46 lines · On Fri, 16 Dec 2022 13:54:01 -0800 Ira Weiny <[email protected]> wrote:
Quoted 44 lines · Jonathan Cameron
Quoted 28 lines · On Sun, 11 Dec 2022 23:06:20 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
Quoted 8 lines
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
Signed-off-by Ira Weiny <[email protected]>A few things noticed inline. I've tightened the QEMU code to reject the case of the input payload claims to be bigger than the mailbox size and hacked the size down to 256 bytes so it triggers the problem highlighted below.
Quoted 7 lines
Quoted 1 line
I'm not sure what you did here.
Nor am I. I think this might have been a case of chasing the undersized length bug in QEMU because it was the CXL 3.0 issue and misunderstanding one of the debug prints I got.
Friday silliness. Sorry about that!
Quoted 8 lines
NP but you did have me going. I've vowed to actually understand the spec better going forward! :-D
Quoted 3 lines
However, the over sized payload communicated to the hardware is still a potential problem. See below.
I don't see where there is an oversized payload used either...
We write a payload size into the mailbox register that includes much more than the payload we are sending.
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
---
Changes from V3:
Dan
Split off_OSCpcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Usedev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Removecxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without_OSCflag--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)drivers/cxl/core/mbox.c +0
-0
Quoted 13 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 730
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload);This line ensures the payload is only ever the size of the definition per the 3.0 spec.
It doesn't (see later). It ensures it is the size of the maximum payload. The size should be 6 + 2 * total (truncated as necesxary) as that's the actual payload size.
Quoted 56 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 738
Quoted 9 lines
drivers/cxl/core/mbox.c +8
-0+struct cxl_mbox_cmd mbox_cmd; +u16 cnt; +int rc; +int i; + +/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size);Definition of that is more complex than it needs to be - see below.
Then this ensures it is truncated if needed.
Quoted 36 lines
Quoted 5 lines
Quoted 2 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 739
Quoted 2 lines
drivers/cxl/core/mbox.c +1
-0+ pl_size = cxlds->payload_size;
pl_sizeis only the max size possible if that size was smaller than the size of the record [sizeof(payload) above].Sorry. For some reason my eyes skipped over this completely. So we are fine for all my comments on overflowing. On plus side will now check if that happens in QEMU and return an error which we weren't doing before.
Quoted 25 lines
Quoted 11 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 745
Quoted 7 lines
drivers/cxl/core/mbox.c +6
-0+ } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size,This payload size should be whatever we need to store the records, not the max size possible. Particularly as that size is currently bigger than the mailbox might be.
But the above check and set ensures that does not happen.
Quoted 4 lines
It shouldn't fail (I think) simply because a later version of the spec might add more to this message and things should still work, but definitely not good practice to tell the hardware this is much longer than it actually is.
I don't follow.
The full payload is going to be sent even if we are just clearing 1 record which is inefficient but it should never overflow the hardware because it is limited by the check above.
Quoted 5 lines
Quoted 1 line
So why would this be a problem?
I'm struggling to find a clear spec statement on if this allowed, so the following is a thought experiment. There is language in definition of the "invalid payload length" error code "The input payload length is not valid for the specified command", but it doesn't go into what counts as valid.
Quoted 8 lines
I think the only thing which makes sense is if the payload length is smaller than:
Header +
nr_recs* 2Anything up to
header + (0xff * 2) should be fine per the 3.0 spec.
nr_recs is in the structure, so the it could check that (the whole argument about future specs is to say that the device shouldn't enforce that limit even though it can know the structure is longer than expected).
Quoted 23 lines
Quoted 15 lines
What you have looks fine because a device can't fail on the basis it's told the payload is longer than it expects, because you might be sending a CXL 4.0 spec payload that is backwards compatible with CXL 3.0 - hence the fact the sizes don't match up with that expected can't be considered an error.
So far so good... However, we may have a situation not dissimilar to the change in record length for the set event interrupt policy payload between CXL 2.0 and CXL 3.0. The only way the endpoint knows what version of message it got is because the record is 4 bytes or 5 bytes. If we have extra stuff on the end of this record in future the end point can assume that it is a new version of the spec and interpret what is in that payload space.Say the future structure looks like
Quoted 7 lines
struct cxl_mbox_clear_event_payload_future { u8 event_log; /* enum cxl_event_log_type */ u8 clear_flags; u8 nr_recs; u8 reserved[3]; __le16 handle[nr_recs]; __le16 otherdata[nr_recs];
Quoted 5 lines
otherdata should be ignored by a 3.0 device.
a theoretical 4.0 device should handle otherdata not being there per some flag in the flags field I would suppose... That would have to be determined if this payload were extended. Otherwise this software will fail no matter what.
A flag isn't required though obviously nice to have. Length should be enough. We already have a version of this with you sending a CXL 2.0 command to a potentially CXL 3.0 device and not checking if DCD is supported before doing so (which I think is fine).
Quoted 10 lines
Other mailbox commands do not 0 out from the command size to 1M either.
Quoted 4 lines
}
Endpoint receiving your 'overly long payload' will assume all those otherdata fields are 0, not necessarily the same as non present.
But it is not 'overly long'. It is only the length of the current spec. See above.
This is where we disagree. The current spec says:
Table 8-36: Input payload size for Clear Event Records is 8+ (the size for when you are clearing one record)
- Side note this is potentially wrong as a clear all wouldn't have event record handles, so I think it should be 6+.
Table 8-51 has
* Number of event record handles
* Event record handles
and no defined reserved space after that Event Record handles. Hence the size is precisely Header + nr_records * 2, not more. Not directly relevant but any record handles that are 0 are treated as invalid handles (error returned).
(this also aligns with what Jonny raised)
Quoted 10 lines
Quoted 7 lines
For the set event interrupt policy, if we sent an overlong payload like you've done here with assumption of the CXL 2.0 spec we would be turning off the DCD interrupt rather that doing nothing (unlikely to be a problem in that particularly case as that one doesn't have a FW Interrupt option - but that's more luck than design).
I'm not sure why we'd have extra stuff for this payload, but it 'might' happen'.
I'll have to check but I don't think I set the payload long in that message. It too should be sizeof(<set event int policy>)
You haven't. the illustration there was about the fact that it is 4 bytes in your implementation (which is fine as that is the CXL 2.0 message) and 5 bytes in CXL 3.0 which you'll upgrade to when you add DCD support.
Quoted 100 lines
Quoted 77 lines
Quoted 77 lines
Quoted 65 lines
Quoted 37 lines
drivers/cxl/core/mbox.c +31
-0+ }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +}...
Quoted 4 lines
drivers/cxl/cxlmem.h +0
-0...
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 425
Quoted 12 lines
drivers/cxl/cxlmem.h +12
-0+ +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ];Doesn't fit in the smallest possible payload buffer. It's 526 bytes long. Payload buffer might be 256 bytes in total. (8.2.8.4.3 Mailbox capabilities)
Quoted 2 lines
Lazy approach, make this smaller and do more loops when clearing. If we want to optimize this later can expand it to this size.
I agree but the code already checks for and adjusts this on the fly based on
cxlds->payload_size?+ /* Payload size may limit the max handles */
+ if (pl_size>cxlds->payload_size) {
+max_handles=CXL_CLEAR_EVENT_LIMIT_HANDLES(cxlds->payload_size);
+pl_size=cxlds->payload_size;
+ }Quoted 6 lines
Quoted 3 lines
Why is this not ok? [Other than being potentially inefficient.]
Do you have a patch to qemu which causes this?
Two issues crossing I think on my side and me thinking this one was obviously the problem when it wasn't.
My fault also for not at least throwing my Qemu test code out there. I've been busy with some things today. I'll try and get those changes cleaned up and at least another RFC set out ASAP.
Quoted 11 lines
Quoted 9 lines
Ira
Quoted 5 lines
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 430
Quoted 5 lines
drivers/cxl/cxlmem.h +5
-0+} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \Could use
offsetof()to simplify this
Quoted 2 lines
True. How about I submit a clean up patch to follow? I don't think this is broken.
I think you'll be changing the patch anyway - so might as well fix this up too :)
Jonathan
Quoted 10 lines
Ira
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
drivers/cxl/cxlmem.h +2
-0+ sizeof(__le16)) +...
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
In reply to Ira WeinyQuoted 118 lines · Ira Weiny
Quoted 38 lines · Jonathan Cameron
Quoted 35 lines · On Sun, 11 Dec 2022 23:06:20 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
Quoted 6 lines
Quoted 1 line
Signed-off-by Ira Weiny <[email protected]>A few things noticed inline. I've tightened the QEMU code to reject the case of the input payload claims to be bigger than the mailbox size and hacked the size down to 256 bytes so it triggers the problem highlighted below.
I'm not sure what you did here.
Quoted 40 lines
Quoted 40 lines
---
Changes from V3:
Dan
Split off_OSCpcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Usedev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Removecxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without_OSCflag--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)drivers/cxl/core/mbox.c +11
-0+static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload); +struct cxl_mbox_cmd mbox_cmd;Quoted 8 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 739
Quoted 8 lines
drivers/cxl/core/mbox.c +8
-0+u16 cnt; +int rc; +int i; + +/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size); + pl_size = cxlds->payload_size;
pl_sizeis only the max size possible if that size was smaller than the size of the record [sizeof(payload) above].Quoted 10 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 745
Quoted 6 lines
drivers/cxl/core/mbox.c +6
-0+ } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size,This payload size should be whatever we need to store the records, not the max size possible. Particularly as that size is currently bigger than the mailbox might be.
But the above check and set ensures that does not happen.
Quoted 4 lines
It shouldn't fail (I think) simply because a later version of the spec might add more to this message and things should still work, but definitely not good practice to tell the hardware this is much longer than it actually is.
Quoted 8 lines
I don't follow.
The full payload is going to be sent even if we are just clearing 1 record which is inefficient but it should never overflow the hardware because it is limited by the check above.
So why would this be a problem?
per spec3.0, Event Record Handles field is "A list of Event Record Handles the host has consumed and the device shall now remove from its internal Event Log store.". Extra unused handle list does not folow above description. And also spec mentions "All event record handles shall be nonzero value. A value of 0 shall be treated by the device as an invalid handle.". So if there is value 0 in extra unused handles, device shall return invalid handle error code
Quoted 90 lines
Quoted 61 lines
Quoted 33 lines
drivers/cxl/core/mbox.c +31
-0+ }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +}...
Quoted 4 lines
drivers/cxl/cxlmem.h +0
-0...
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 425
Quoted 12 lines
drivers/cxl/cxlmem.h +12
-0+ +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ];Doesn't fit in the smallest possible payload buffer. It's 526 bytes long. Payload buffer might be 256 bytes in total. (8.2.8.4.3 Mailbox capabilities)
Quoted 2 lines
Lazy approach, make this smaller and do more loops when clearing. If we want to optimize this later can expand it to this size.
I agree but the code already checks for and adjusts this on the fly based on
cxlds->payload_size?+ /* Payload size may limit the max handles */
+ if (pl_size>cxlds->payload_size) {
+max_handles=CXL_CLEAR_EVENT_LIMIT_HANDLES(cxlds->payload_size);
+pl_size=cxlds->payload_size;
+ }Why is this not ok? [Other than being potentially inefficient.]
Do you have a patch to qemu which causes this?
Ira
Quoted 10 lines
Quoted 7 lines
drivers/cxl/cxlmem.h +7
-0+} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \ + sizeof(__le16)) +...
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
Quoted 128 lines · On Sun, 18 Dec 2022 08:25:34 +0800 johnny <[email protected]> wrote:
Quoted 118 lines · Ira Weiny
Quoted 38 lines · Jonathan Cameron
Quoted 35 lines · On Sun, 11 Dec 2022 23:06:20 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
CXL devices have multiple event logs which can be queried for CXL event records. Devices are required to support the storage of at least one event record in each event log type.
Devices track event log overflow by incrementing a counter and tracking the time of the first and last overflow event seen.
Software queries events via the Get Event Record mailbox command; CXL rev 3.0 section 8.2.9.2.2 and clears events via CXL rev 3.0 section 8.2.9.2.3 Clear Event Records mailbox command.
If the result of negotiating CXL Error Reporting Control is OS control, read and clear all event logs on driver load.
Ensure a clean slate of events by reading and clearing the events on driver load.
The status register is not used because a device may continue to trigger events and the only requirement is to empty the log at least once. This allows for the required transition from empty to non-empty for interrupt generation. Handling of interrupts is in a follow on patch.
The device can return up to 1MB worth of event records per query. Allocate a shared large buffer to handle the max number of records based on the mailbox payload size.
This patch traces a raw event record and leaves specific event record type tracing to subsequent patches. Macros are created to aid in tracing the common CXL Event header fields.
Each record is cleared explicitly. A clear all bit is specified but is only valid when the log overflows.
Quoted 6 lines
Quoted 1 line
Signed-off-by Ira Weiny <[email protected]>A few things noticed inline. I've tightened the QEMU code to reject the case of the input payload claims to be bigger than the mailbox size and hacked the size down to 256 bytes so it triggers the problem highlighted below.
I'm not sure what you did here.
Quoted 40 lines
Quoted 40 lines
---
Changes from V3:
Dan
Split off_OSCpcie bits
Use existing style for host bridge flag in that patch
Clean up event processing loop
Usedev_err_ratelimited()
Clean up version change log
Delete 'EVENT LOG OVERFLOW'
Removecxl_clear_event_logs()
Add comment for native cxl control
Fail driver load on event buf allocation failure Comment why events are not processed without_OSCflag--- drivers/cxl/core/mbox.c | 136 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/trace.h | 120 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 12 ++++ drivers/cxl/cxlmem.h | 84 ++++++++++++++++++++++++ drivers/cxl/pci.c | 40 ++++++++++++ 5 files changed, 392 insertions(+)drivers/cxl/core/mbox.c +11
-0+static int cxl_clear_event_record (struct cxl_dev_state *cxlds, +enum cxl_event_log_type log, +struct cxl_get_event_payload *get_pl) +{ +struct cxl_mbox_clear_event_payload payload = { + .event_log = log, + }; +u16 total =le16_to_cpu (get_pl->record_count); +u8 max_handles =CXL_CLEAR_EVENT_MAX_HANDLES ; +size_t pl_size =sizeof (payload); +struct cxl_mbox_cmd mbox_cmd;Quoted 8 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 739
Quoted 8 lines
drivers/cxl/core/mbox.c +8
-0+u16 cnt; +int rc; +int i; + +/* Payload size may limit the max handles */ +if (pl_size > cxlds->payload_size) { + max_handles =CXL_CLEAR_EVENT_LIMIT_HANDLES (cxlds->payload_size); + pl_size = cxlds->payload_size;
pl_sizeis only the max size possible if that size was smaller than the size of the record [sizeof(payload) above].Quoted 10 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 745
Quoted 6 lines
drivers/cxl/core/mbox.c +6
-0+ } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size,This payload size should be whatever we need to store the records, not the max size possible. Particularly as that size is currently bigger than the mailbox might be.
But the above check and set ensures that does not happen.
Quoted 4 lines
It shouldn't fail (I think) simply because a later version of the spec might add more to this message and things should still work, but definitely not good practice to tell the hardware this is much longer than it actually is.
Quoted 8 lines
I don't follow.
The full payload is going to be sent even if we are just clearing 1 record which is inefficient but it should never overflow the hardware because it is limited by the check above.
So why would this be a problem?
Quoted 6 lines
per spec3.0, Event Record Handles field is "A list of Event Record Handles the host has consumed and the device shall now remove from its internal Event Log store.". Extra unused handle list does not folow above description. And also spec mentions "All event record handles shall be nonzero value. A value of 0 shall be treated by the device as an invalid handle.". So if there is value 0 in extra unused handles, device shall return invalid handle error code
I don't think we call into that particular corner as the number of event record handles is set correctly. Otherwise I agree this isn't following the spec - though I think key here is that it won't be broken against CXL 3.0 devices (with that rather roundabout argument that a CXL 3.0 devices should handle later spec messages as those should be backwards compatible) but it might be broken against CXL 3.0+ ones that interpret the 0s at the end as having meaning.
Thanks,
Jonathan
Quoted 93 lines
Quoted 92 lines
Quoted 63 lines
Quoted 35 lines
drivers/cxl/core/mbox.c +31
-0+ }; + +/* +* Clear Event Records uses u8 for the handle cnt while Get Event +* Record can return up to 0xffff records. +*/ + i =0 ; +for (cnt =0 ; cnt < total; cnt++) { + payload.handle[i++] = get_pl->records[cnt].hdr.handle; +dev_dbg (cxlds->dev,"Event log '%d': Clearing %u\n" , + log,le16_to_cpu (payload.handle[i])); + +if (i == max_handles) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + i =0 ; + } + } + +/* Clear what is left if any */ +if (i) { + payload.nr_recs = i; + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +return rc; + } + +return 0 ; +}...
Quoted 4 lines
drivers/cxl/cxlmem.h +0
-0...
drivers/cxl/cxlmem.h struct cxl_mbox_identify { · line 425
Quoted 12 lines
drivers/cxl/cxlmem.h +12
-0+ +/* +* Clear Event Records input payload +* CXL rev 3.0 section 8.2.9.2.3; Table 8-51 +*/ +#define CXL_CLEAR_EVENT_MAX_HANDLES (0xff) +struct cxl_mbox_clear_event_payload { +u8 event_log;/* enum cxl_event_log_type */ +u8 clear_flags; +u8 nr_recs; +u8 reserved[3 ]; +__le16 handle[CXL_CLEAR_EVENT_MAX_HANDLES ];Doesn't fit in the smallest possible payload buffer. It's 526 bytes long. Payload buffer might be 256 bytes in total. (8.2.8.4.3 Mailbox capabilities)
Quoted 2 lines
Lazy approach, make this smaller and do more loops when clearing. If we want to optimize this later can expand it to this size.
I agree but the code already checks for and adjusts this on the fly based on
cxlds->payload_size?+ /* Payload size may limit the max handles */
+ if (pl_size>cxlds->payload_size) {
+max_handles=CXL_CLEAR_EVENT_LIMIT_HANDLES(cxlds->payload_size);
+pl_size=cxlds->payload_size;
+ }Why is this not ok? [Other than being potentially inefficient.]
Do you have a patch to qemu which causes this?
Ira
Quoted 10 lines
Quoted 7 lines
drivers/cxl/cxlmem.h +7
-0+} __packed; +#define CXL_CLEAR_EVENT_LIMIT_HANDLES (payload_size) \ + (((payload_size) - \ + (sizeof(struct cxl_mbox_clear_event_payload) - \ + (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \ + sizeof(__le16)) +...
Re: [PATCH V4 2/9] cxl/mem: Read, trace, and clear events on driver load
Quoted 3 lines · Jonathan Cameron
On Sun, 18 Dec 2022 08:25:34 +0800
johnny <[email protected]> wrote:
[snip]
Quoted 35 lines
Quoted 28 lines
Quoted 19 lines
Quoted 11 lines
drivers/cxl/core/mbox.c int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) · line 745
Quoted 7 lines
drivers/cxl/core/mbox.c +6
-0+ } + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_CLEAR_EVENT_RECORD , + .payload_in = &payload, + .size_in = pl_size,This payload size should be whatever we need to store the records, not the max size possible. Particularly as that size is currently bigger than the mailbox might be.
But the above check and set ensures that does not happen.
Quoted 4 lines
It shouldn't fail (I think) simply because a later version of the spec might add more to this message and things should still work, but definitely not good practice to tell the hardware this is much longer than it actually is.
Quoted 8 lines
I don't follow.
The full payload is going to be sent even if we are just clearing 1 record which is inefficient but it should never overflow the hardware because it is limited by the check above.
So why would this be a problem?
Quoted 6 lines
per spec3.0, Event Record Handles field is "A list of Event Record Handles the host has consumed and the device shall now remove from its internal Event Log store.". Extra unused handle list does not folow above description. And also spec mentions "All event record handles shall be nonzero value. A value of 0 shall be treated by the device as an invalid handle.". So if there is value 0 in extra unused handles, device shall return invalid handle error code
Quoted 6 lines
I don't think we call into that particular corner as the number of event record handles is set correctly. Otherwise I agree this isn't following the spec - though I think key here is that it won't be broken against CXL 3.0 devices (with that rather roundabout argument that a CXL 3.0 devices should handle later spec messages as those should be backwards compatible) but it might be broken against CXL 3.0+ ones that interpret the 0s at the end as having meaning.
I'm respining this to add the pci_set_master() anyway. So I'm going to change this as well. I really don't see how hardware would go off anything but the number of records to process the handles I could see some overly strict firmware wanting to validate the size being exactly equal to the number specified rather than just less than (which is what I would anticipate an issue with).
Dan has agreed to land the movement of the trace point definition to drivers/cxl patch I need to cxl/next. After that I will rebase and send out.
Ira
Quoted 5 lines
Thanks,
Jonathan
PATCH v4 3/9 cxl/mem: Wire up event interrupts
In reply to [email protected]From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
---
Changes from V3:
Adjust based on changes in patch 1
Consolidate event setup into cxl_event_config() Consistently use cxl_event_* for function names Remove cxl_event_int_is_msi()
Ensure DCD log is ignored in status
Simplify event status loop logic
Dan
Fail driver load if the irq's are not allocated move cxl_event_config_msgnums() to pci.c s/CXL_PCI_REQUIRED_VECTORS/CXL_PCI_DEFAULT_MAX_VECTORS s/devm_kmalloc/devm_kzalloc
Fix up pci_alloc_irq_vectors() comment
Pass pdev to cxl_alloc_irq_vectors()
Check FW irq policy prior to configuration
Jonathan
Use FIELD_GET instead of manual masking
--- drivers/cxl/cxl.h | 4 + drivers/cxl/cxlmem.h | 19 ++++ drivers/cxl/cxlpci.h | 6 ++ drivers/cxl/pci.c | 208 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 231 insertions(+), 6 deletions(-)
drivers/cxl/cxl.h +4 -0
@@ -168,6 +168,10 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw) CXLDEV_EVENT_STATUS_FAIL | \ CXLDEV_EVENT_STATUS_FATAL) +/* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 */ +#define CXLDEV_EVENT_INT_MODE_MASK GENMASK(1, 0) +#define CXLDEV_EVENT_INT_MSGNUM_MASK GENMASK(7, 4) +/* CXL 2.0 8.2.8.4 Mailbox Registers */ #define CXLDEV_MBOX_CAPS_OFFSET 0x00#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK GENMASK(4, 0)
drivers/cxl/cxlmem.h +19 -0
@@ -194,6 +194,23 @@ struct cxl_endpoint_dvsec_info {struct range dvsec_range[2 ]; }; +/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ +enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings; +} __packed; +/** * struct cxl_event_state - Event log driver state *
@@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,
drivers/cxl/cxlpci.h +6 -0
@@ -53,6 +53,12 @@#define CXL_DVSEC_REG_LOCATOR_BLOCK_ID_MASK GENMASK(15, 8)#define CXL_DVSEC_REG_LOCATOR_BLOCK_OFF_LOW_MASK GENMASK(31, 16) +/* +* NOTE: Currently all the functions which are enabled for CXL require their +* vectors to be in the first 16. Use this as the default max. +*/ +#define CXL_PCI_DEFAULT_MAX_VECTORS 16 +/* Register Block Identifier (RBI) */ enum cxl_regloc_type {CXL_REGLOC_RBI_EMPTY =0 ,
drivers/cxl/pci.c +202 -6
226 lines not on this page · raw message
Signature · 1 line
2.37.2
RE: [PATCH V4 3/9] cxl/mem: Wire up event interrupts
Quoted 128 lines · ira.weiny@ wrote:
From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
Cc Bjorn Helgaas <[email protected]>Cc Jonathan Cameron <[email protected]>Co-developed-by Ira Weiny <[email protected]>Signed-off-by Ira Weiny <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>---
Changes from V3:
Adjust based on changes in patch 1
Consolidate event setup intocxl_event_config()Consistently use cxl_event_* for function names Removecxl_event_int_is_msi()
Ensure DCD log is ignored in status
Simplify event status loop logic
Dan
Fail driver load if the irq's are not allocated movecxl_event_config_msgnums()topci.cs/CXL_PCI_REQUIRED_VECTORS/CXL_PCI_DEFAULT_MAX_VECTORS s/devm_kmalloc/devm_kzalloc
Fix uppci_alloc_irq_vectors()comment
Pass pdev tocxl_alloc_irq_vectors()
Check FW irq policy prior to configuration
Jonathan
UseFIELD_GETinstead of manual masking--- drivers/cxl/cxl.h | 4 + drivers/cxl/cxlmem.h | 19 ++++ drivers/cxl/cxlpci.h | 6 ++ drivers/cxl/pci.c | 208 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 231 insertions(+), 6 deletions(-)drivers/cxl/cxl.h +4
-0@@ -168,6 +168,10 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw) CXLDEV_EVENT_STATUS_FAIL | \ CXLDEV_EVENT_STATUS_FATAL) +/* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 */ +#define CXLDEV_EVENT_INT_MODE_MASK GENMASK(1, 0) +#define CXLDEV_EVENT_INT_MSGNUM_MASK GENMASK(7, 4) +/* CXL 2.0 8.2.8.4 Mailbox Registers */ #define CXLDEV_MBOX_CAPS_OFFSET 0x00#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK GENMASK(4, 0)drivers/cxl/cxlmem.h +19
-0@@ -194,6 +194,23 @@ struct cxl_endpoint_dvsec_info {struct range dvsec_range[2 ]; }; +/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ +enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings; +} __packed; +/** * struct cxl_event_state - Event log driver state * @@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,drivers/cxl/cxlpci.h +6
-0@@ -53,6 +53,12 @@#define CXL_DVSEC_REG_LOCATOR_BLOCK_ID_MASK GENMASK(15, 8)#define CXL_DVSEC_REG_LOCATOR_BLOCK_OFF_LOW_MASK GENMASK(31, 16) +/* +* NOTE: Currently all the functions which are enabled for CXL require their +* vectors to be in the first 16. Use this as the default max. +*/ +#define CXL_PCI_DEFAULT_MAX_VECTORS 16 +/* Register Block Identifier (RBI) */ enum cxl_regloc_type {CXL_REGLOC_RBI_EMPTY =0 ,drivers/cxl/pci.c +0
-0
drivers/cxl/pci.c static int cxl_mem_alloc_event_buf(struct cxl_dev_state *cxlds) · line 453
Quoted 9 lines
drivers/cxl/pci.c +6
-0@@ -445,6 +445,201 @@ static int cxl_mem_alloc_event_buf(struct cxl_dev_state *cxlds)return 0 ; } +static int cxl_alloc_irq_vectors (struct pci_dev *pdev) +{ +int nvecs; + +/* +* CXL requires MSI/MSIX support.
Spec reference please.
"Per CXL 3.0 3.1.1 CXL.io Endpoint a function on a CXL device must not generate INTx messages if that function participates in CXL.cache or CXL.mem."
Quoted 84 lines
drivers/cxl/pci.c +84
-0+* +* Additionally pci_alloc_irq_vectors() handles calling +* pci_free_irq_vectors() automatically despite not being called +* pcim_*. See pci_setup_msi_context(). +*/ + nvecs =pci_alloc_irq_vectors (pdev,1 ,CXL_PCI_DEFAULT_MAX_VECTORS , +PCI_IRQ_MSIX |PCI_IRQ_MSI ); +if (nvecs <1 ) { +dev_dbg (&pdev->dev,"Failed to alloc irq vectors: %d\n" , nvecs); +return -ENXIO ; + } +return 0 ; +} + +struct cxl_dev_id { +struct cxl_dev_state *cxlds; +}; + +static irqreturn_t cxl_event_thread (int irq,void *id) +{ +struct cxl_dev_id *dev_id = id; +struct cxl_dev_state *cxlds = dev_id->cxlds; +u32 status; + +do { +/* +* CXL 3.0 8.2.8.3.1: The lower 32 bits are the status; +* ignore the reserved upper 32 bits +*/ + status =readl (cxlds->regs.status +CXLDEV_DEV_EVENT_STATUS_OFFSET ); +/* Ignore logs unknown to the driver */ + status &=CXLDEV_EVENT_STATUS_ALL ; +if (!status) +break ; +cxl_mem_get_event_records (cxlds, status); +cond_resched (); + }while (status); + +return IRQ_HANDLED ; +} + +static int cxl_event_req_irq (struct cxl_dev_state *cxlds,u8 setting) +{ +struct device *dev = cxlds->dev; +struct pci_dev *pdev =to_pci_dev (dev); +struct cxl_dev_id *dev_id; +int irq; + +if (FIELD_GET (CXLDEV_EVENT_INT_MODE_MASK , setting) !=CXL_INT_MSI_MSIX ) +return -ENXIO ; + +/* dev_id must be globally unique and must contain the cxlds */ + dev_id =devm_kzalloc (dev,sizeof (*dev_id),GFP_KERNEL ); +if (!dev_id) +return -ENOMEM ; + dev_id->cxlds = cxlds; + + irq =pci_irq_vector (pdev, +FIELD_GET (CXLDEV_EVENT_INT_MSGNUM_MASK , setting)); +if (irq <0 ) +return irq; + +return devm_request_threaded_irq (dev, irq,NULL , cxl_event_thread, +IRQF_SHARED ,NULL , dev_id); +} + +static int cxl_event_get_int_policy (struct cxl_dev_state *cxlds, +struct cxl_event_interrupt_policy *policy) +{ +struct cxl_mbox_cmd mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_EVT_INT_POLICY , + .payload_out = policy, + .size_out =sizeof (*policy), + }; +int rc; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc <0 ) +dev_err (cxlds->dev,"Failed to get event interrupt policy : %d" , + rc); + +return rc; +} +
drivers/cxl/pci.c static int cxl_mem_alloc_event_buf(struct cxl_dev_state *cxlds) · line 547
Quoted 10 lines
drivers/cxl/pci.c +10
-0+static int cxl_event_config_msgnums (struct cxl_dev_state *cxlds, +struct cxl_event_interrupt_policy *policy) +{ +struct cxl_mbox_cmd mbox_cmd; +int rc; + + policy->info_settings =CXL_INT_MSI_MSIX ; + policy->warn_settings =CXL_INT_MSI_MSIX ; + policy->failure_settings =CXL_INT_MSI_MSIX ; + policy->fatal_settings =CXL_INT_MSI_MSIX ;
I prefer this syntax for command payload initialization if only because it 0-fills all fields:
drivers/cxl/pci.c +6 -4
@@ -541,10 +541,12 @@ static int cxl_event_config_msgnums(struct cxl_dev_state *cxlds,struct cxl_mbox_cmd mbox_cmd;int rc; - policy->info_settings =CXL_INT_MSI_MSIX ; - policy->warn_settings =CXL_INT_MSI_MSIX ; - policy->failure_settings =CXL_INT_MSI_MSIX ; - policy->fatal_settings =CXL_INT_MSI_MSIX ; + *policy = (struct cxl_event_interrupt_policy ) { + .info_settings =CXL_INT_MSI_MSIX , + .warn_settings =CXL_INT_MSI_MSIX , + .failure_settings =CXL_INT_MSI_MSIX , + .fatal_settings =CXL_INT_MSI_MSIX , + }; mbox_cmd = (struct cxl_mbox_cmd ) { .opcode =CXL_MBOX_OP_SET_EVT_INT_POLICY ,
...but that can be a follow-on fixup because I am not seeing much else to need respinning this patch.
Quoted 112 lines
drivers/cxl/pci.c +99
-0+ + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_SET_EVT_INT_POLICY , + .payload_in = policy, + .size_in =sizeof (*policy), + }; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc <0 ) { +dev_err (cxlds->dev,"Failed to set event interrupt policy : %d" , + rc); +return rc; + } + +/* Retrieve final interrupt settings */ +return cxl_event_get_int_policy (cxlds, policy); +} + +static int cxl_event_irqsetup (struct cxl_dev_state *cxlds) +{ +struct cxl_event_interrupt_policy policy; +int rc; + + rc =cxl_event_config_msgnums (cxlds, &policy); +if (rc) +return rc; + + rc =cxl_event_req_irq (cxlds, policy.info_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Info log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.warn_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Warn log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.failure_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Failure log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.fatal_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Fatal log\n" ); +return rc; + } + +return 0 ; +} + +static bool cxl_event_int_is_fw (u8 setting) +{ +u8 mode =FIELD_GET (CXLDEV_EVENT_INT_MODE_MASK , setting); + +return mode ==CXL_INT_FW ; +} + +static int cxl_event_config (struct pci_host_bridge *host_bridge, +struct cxl_dev_state *cxlds) +{ +struct cxl_event_interrupt_policy policy; +int rc; + +/* +* When BIOS maintains CXL error reporting control, it will process +* event records. Only one agent can do so. +*/ +if (!host_bridge->native_cxl_error) +return 0 ; + + rc =cxl_event_get_int_policy (cxlds, &policy); +if (rc) +return rc; + +if (cxl_event_int_is_fw (policy.info_settings) || +cxl_event_int_is_fw (policy.warn_settings) || +cxl_event_int_is_fw (policy.failure_settings) || +cxl_event_int_is_fw (policy.fatal_settings)) { +dev_err (cxlds->dev,"FW still in control of Event Logs despite _OSC settings\n" ); +return -EBUSY ; + } + + rc =cxl_event_irqsetup (cxlds); +if (rc) +return rc; + +cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); + +return 0 ; +} +static int cxl_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct pci_host_bridge *host_bridge =pci_find_host_bridge (pdev->bus);@@ -519,6 +714,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; + rc =cxl_alloc_irq_vectors (pdev); +if (rc) +return rc; + cxlmd =devm_cxl_add_memdev (cxlds);if (IS_ERR (cxlmd))return PTR_ERR (cxlmd);@@ -527,12 +726,9 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc;
drivers/cxl/pci.c static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 731
Quoted 10 lines
drivers/cxl/pci.c +3
-6-/* -* When BIOS maintains CXL error reporting control, it will process -* event records. Only one agent can do so. -*/ -if (host_bridge->native_cxl_error) -cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); + rc =cxl_event_config (host_bridge, cxlds); +if (rc) +return rc;
In the future, it would help me if these kinds of policy changes mid patch set, if they cannot be avoided, are at least declared in the changelog. It saps some reviewer resources to invalidate previous understanding within the same review session.
Re: [PATCH V4 3/9] cxl/mem: Wire up event interrupts
In reply to [email protected]Quoted 35 lines · On Sun, 11 Dec 2022 23:06:21 -0800 [email protected] wrote:
From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
Cc Bjorn Helgaas <[email protected]>Cc Jonathan Cameron <[email protected]>Co-developed-by Ira Weiny <[email protected]>Signed-off-by Ira Weiny <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>drivers/cxl/cxlmem.h +5
-0+/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/
drivers/cxl/cxlmem.h struct cxl_endpoint_dvsec_info { · line 211
Quoted 10 lines
drivers/cxl/cxlmem.h +10
-0+enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings;
This is an issue for your QEMU code which has this set at 5 bytes. Guess our handling of record lengths needs updating now we have two different spec versions to support and hence these can have multiple lengths.
Btw, do you have an updated version of the QEMU patches you can share? I was planning on just doing the AER type RAS stuff for the first pull this cycle but given this set means we never reach that code I probably need to do QEMU support for this and the stuff to support those all in one go - otherwise no one will be able to test it :) We rather optimistically have the OSC set to say the OS can have control of these, but upstream code doesn't emulate anything yet. Oops. Should have pretended the hardware was handling them until we had this support in place in QEMU.
Jonathan
Quoted 14 lines
drivers/cxl/cxlmem.h +4
-0+} __packed; +/** * struct cxl_event_state - Event log driver state * @@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,
Re: [PATCH V4 3/9] cxl/mem: Wire up event interrupts
Quoted 53 lines · On Fri, 16 Dec 2022 14:24:38 +0000 Jonathan Cameron…
Quoted 35 lines · On Sun, 11 Dec 2022 23:06:21 -0800 [email protected] wrote:
From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
Cc Bjorn Helgaas <[email protected]>Cc Jonathan Cameron <[email protected]>Co-developed-by Ira Weiny <[email protected]>Signed-off-by Ira Weiny <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>drivers/cxl/cxlmem.h +5
-0+/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ drivers/cxl/cxlmem.h struct cxl_endpoint_dvsec_info { · line 211
Quoted 10 lines
drivers/cxl/cxlmem.h +10
-0+enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings;This is an issue for your QEMU code which has this set at 5 bytes. Guess our handling of record lengths needs updating now we have two different spec versions to support and hence these can have multiple lengths.
Quoted 1 line
Btw, do you have an updated version of the QEMU patches you can share?
Note that I'm happy to take your QEMU series forwards, just don't want to duplicate stuff you have already done!
Jonathan
Quoted 24 lines
I was planning on just doing the AER type RAS stuff for the first pull this cycle but given this set means we never reach that code I probably need to do QEMU support for this and the stuff to support those all in one go - otherwise no one will be able to test it :) We rather optimistically have the OSC set to say the OS can have control of these, but upstream code doesn't emulate anything yet. Oops. Should have pretended the hardware was handling them until we had this support in place in QEMU.
Jonathan
Quoted 14 lines
drivers/cxl/cxlmem.h +4
-0+} __packed; +/** * struct cxl_event_state - Event log driver state * @@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,
Re: [PATCH V4 3/9] cxl/mem: Wire up event interrupts
Quoted 56 lines · Jonathan Cameron
Quoted 53 lines · On Fri, 16 Dec 2022 14:24:38 +0000 Jonathan Cameron…
Quoted 35 lines · On Sun, 11 Dec 2022 23:06:21 -0800 [email protected] wrote:
From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
Cc Bjorn Helgaas <[email protected]>Cc Jonathan Cameron <[email protected]>Co-developed-by Ira Weiny <[email protected]>Signed-off-by Ira Weiny <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>drivers/cxl/cxlmem.h +5
-0+/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ drivers/cxl/cxlmem.h struct cxl_endpoint_dvsec_info { · line 211
Quoted 10 lines
drivers/cxl/cxlmem.h +10
-0+enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings;This is an issue for your QEMU code which has this set at 5 bytes. Guess our handling of record lengths needs updating now we have two different spec versions to support and hence these can have multiple lengths.
Quoted 4 lines
Quoted 1 line
Btw, do you have an updated version of the QEMU patches you can share?
Note that I'm happy to take your QEMU series forwards, just don't want to duplicate stuff you have already done!
I do have updates to handle more than 3 records at a time which I was polishing until I saw your review.
I was getting all geared up to respin the patches but I'm not sure there is an issue now that I look at it.
I'm still investigating.
Ira
Quoted 28 lines
Jonathan
Quoted 24 lines
I was planning on just doing the AER type RAS stuff for the first pull this cycle but given this set means we never reach that code I probably need to do QEMU support for this and the stuff to support those all in one go - otherwise no one will be able to test it :) We rather optimistically have the OSC set to say the OS can have control of these, but upstream code doesn't emulate anything yet. Oops. Should have pretended the hardware was handling them until we had this support in place in QEMU.
Jonathan
Quoted 14 lines
drivers/cxl/cxlmem.h +4
-0+} __packed; +/** * struct cxl_event_state - Event log driver state * @@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,
Re: [PATCH V4 3/9] cxl/mem: Wire up event interrupts
Quoted 57 lines · On Fri, 16 Dec 2022 13:28:36 -0800 Ira Weiny <[email protected]> wrote:
Quoted 56 lines · Jonathan Cameron
Quoted 53 lines · On Fri, 16 Dec 2022 14:24:38 +0000 Jonathan Cameron…
Quoted 35 lines · On Sun, 11 Dec 2022 23:06:21 -0800 [email protected] wrote:
From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
Cc Bjorn Helgaas <[email protected]>Cc Jonathan Cameron <[email protected]>Co-developed-by Ira Weiny <[email protected]>Signed-off-by Ira Weiny <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>drivers/cxl/cxlmem.h +5
-0+/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ drivers/cxl/cxlmem.h struct cxl_endpoint_dvsec_info { · line 211
Quoted 10 lines
drivers/cxl/cxlmem.h +10
-0+enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings;This is an issue for your QEMU code which has this set at 5 bytes. Guess our handling of record lengths needs updating now we have two different spec versions to support and hence these can have multiple lengths.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Btw, do you have an updated version of the QEMU patches you can share?
Note that I'm happy to take your QEMU series forwards, just don't want to duplicate stuff you have already done!
I do have updates to handle more than 3 records at a time which I was polishing until I saw your review.
Great. I'll work on other stuff in the meantime and hopefully we can get all the error emulation upstream this QEMU cycle.
Quoted 36 lines
I was getting all geared up to respin the patches but I'm not sure there is an issue now that I look at it.
I'm still investigating.
Ira
Quoted 28 lines
Jonathan
Quoted 24 lines
I was planning on just doing the AER type RAS stuff for the first pull this cycle but given this set means we never reach that code I probably need to do QEMU support for this and the stuff to support those all in one go - otherwise no one will be able to test it :) We rather optimistically have the OSC set to say the OS can have control of these, but upstream code doesn't emulate anything yet. Oops. Should have pretended the hardware was handling them until we had this support in place in QEMU.
Jonathan
Quoted 14 lines
drivers/cxl/cxlmem.h +4
-0+} __packed; +/** * struct cxl_event_state - Event log driver state * @@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,
Re: [PATCH V4 3/9] cxl/mem: Wire up event interrupts
In reply to [email protected]Quoted 20 lines · On Sun, 11 Dec 2022 23:06:21 -0800 [email protected] wrote:
From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
Quoted 8 lines
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
Cc Bjorn Helgaas <[email protected]>Cc Jonathan Cameron <[email protected]>Co-developed-by Ira Weiny <[email protected]>Signed-off-by Ira Weiny <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>
Sometimes it feels like we go around in circles as I'm sure we've fixed this at least 3 times now in different sets that got dropped (was definitely in the DOE interrupt support set and was controversial ;)
Nothing in this patch set calls pci_set_master() so no interrupts will even be delivered. I don't think there are any sets in flight that would fix that.
Jonathan
Quoted 328 lines
---
Changes from V3:
Adjust based on changes in patch 1
Consolidate event setup intocxl_event_config()Consistently use cxl_event_* for function names Removecxl_event_int_is_msi()
Ensure DCD log is ignored in status
Simplify event status loop logic
Dan
Fail driver load if the irq's are not allocated movecxl_event_config_msgnums()topci.cs/CXL_PCI_REQUIRED_VECTORS/CXL_PCI_DEFAULT_MAX_VECTORS s/devm_kmalloc/devm_kzalloc
Fix uppci_alloc_irq_vectors()comment
Pass pdev tocxl_alloc_irq_vectors()
Check FW irq policy prior to configuration
Jonathan
UseFIELD_GETinstead of manual masking--- drivers/cxl/cxl.h | 4 + drivers/cxl/cxlmem.h | 19 ++++ drivers/cxl/cxlpci.h | 6 ++ drivers/cxl/pci.c | 208 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 231 insertions(+), 6 deletions(-)drivers/cxl/cxl.h +4
-0@@ -168,6 +168,10 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw) CXLDEV_EVENT_STATUS_FAIL | \ CXLDEV_EVENT_STATUS_FATAL) +/* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 */ +#define CXLDEV_EVENT_INT_MODE_MASK GENMASK(1, 0) +#define CXLDEV_EVENT_INT_MSGNUM_MASK GENMASK(7, 4) +/* CXL 2.0 8.2.8.4 Mailbox Registers */ #define CXLDEV_MBOX_CAPS_OFFSET 0x00#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK GENMASK(4, 0)drivers/cxl/cxlmem.h +19
-0@@ -194,6 +194,23 @@ struct cxl_endpoint_dvsec_info {struct range dvsec_range[2 ]; }; +/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ +enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings; +} __packed; +/** * struct cxl_event_state - Event log driver state * @@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,drivers/cxl/cxlpci.h +6
-0@@ -53,6 +53,12 @@#define CXL_DVSEC_REG_LOCATOR_BLOCK_ID_MASK GENMASK(15, 8)#define CXL_DVSEC_REG_LOCATOR_BLOCK_OFF_LOW_MASK GENMASK(31, 16) +/* +* NOTE: Currently all the functions which are enabled for CXL require their +* vectors to be in the first 16. Use this as the default max. +*/ +#define CXL_PCI_DEFAULT_MAX_VECTORS 16 +/* Register Block Identifier (RBI) */ enum cxl_regloc_type {CXL_REGLOC_RBI_EMPTY =0 ,drivers/cxl/pci.c +202
-6@@ -445,6 +445,201 @@ static int cxl_mem_alloc_event_buf(struct cxl_dev_state *cxlds)return 0 ; } +static int cxl_alloc_irq_vectors (struct pci_dev *pdev) +{ +int nvecs; + +/* +* CXL requires MSI/MSIX support. +* +* Additionally pci_alloc_irq_vectors() handles calling +* pci_free_irq_vectors() automatically despite not being called +* pcim_*. See pci_setup_msi_context(). +*/ + nvecs =pci_alloc_irq_vectors (pdev,1 ,CXL_PCI_DEFAULT_MAX_VECTORS , +PCI_IRQ_MSIX |PCI_IRQ_MSI ); +if (nvecs <1 ) { +dev_dbg (&pdev->dev,"Failed to alloc irq vectors: %d\n" , nvecs); +return -ENXIO ; + } +return 0 ; +} + +struct cxl_dev_id { +struct cxl_dev_state *cxlds; +}; + +static irqreturn_t cxl_event_thread (int irq,void *id) +{ +struct cxl_dev_id *dev_id = id; +struct cxl_dev_state *cxlds = dev_id->cxlds; +u32 status; + +do { +/* +* CXL 3.0 8.2.8.3.1: The lower 32 bits are the status; +* ignore the reserved upper 32 bits +*/ + status =readl (cxlds->regs.status +CXLDEV_DEV_EVENT_STATUS_OFFSET ); +/* Ignore logs unknown to the driver */ + status &=CXLDEV_EVENT_STATUS_ALL ; +if (!status) +break ; +cxl_mem_get_event_records (cxlds, status); +cond_resched (); + }while (status); + +return IRQ_HANDLED ; +} + +static int cxl_event_req_irq (struct cxl_dev_state *cxlds,u8 setting) +{ +struct device *dev = cxlds->dev; +struct pci_dev *pdev =to_pci_dev (dev); +struct cxl_dev_id *dev_id; +int irq; + +if (FIELD_GET (CXLDEV_EVENT_INT_MODE_MASK , setting) !=CXL_INT_MSI_MSIX ) +return -ENXIO ; + +/* dev_id must be globally unique and must contain the cxlds */ + dev_id =devm_kzalloc (dev,sizeof (*dev_id),GFP_KERNEL ); +if (!dev_id) +return -ENOMEM ; + dev_id->cxlds = cxlds; + + irq =pci_irq_vector (pdev, +FIELD_GET (CXLDEV_EVENT_INT_MSGNUM_MASK , setting)); +if (irq <0 ) +return irq; + +return devm_request_threaded_irq (dev, irq,NULL , cxl_event_thread, +IRQF_SHARED ,NULL , dev_id); +} + +static int cxl_event_get_int_policy (struct cxl_dev_state *cxlds, +struct cxl_event_interrupt_policy *policy) +{ +struct cxl_mbox_cmd mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_EVT_INT_POLICY , + .payload_out = policy, + .size_out =sizeof (*policy), + }; +int rc; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc <0 ) +dev_err (cxlds->dev,"Failed to get event interrupt policy : %d" , + rc); + +return rc; +} + +static int cxl_event_config_msgnums (struct cxl_dev_state *cxlds, +struct cxl_event_interrupt_policy *policy) +{ +struct cxl_mbox_cmd mbox_cmd; +int rc; + + policy->info_settings =CXL_INT_MSI_MSIX ; + policy->warn_settings =CXL_INT_MSI_MSIX ; + policy->failure_settings =CXL_INT_MSI_MSIX ; + policy->fatal_settings =CXL_INT_MSI_MSIX ; + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_SET_EVT_INT_POLICY , + .payload_in = policy, + .size_in =sizeof (*policy), + }; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc <0 ) { +dev_err (cxlds->dev,"Failed to set event interrupt policy : %d" , + rc); +return rc; + } + +/* Retrieve final interrupt settings */ +return cxl_event_get_int_policy (cxlds, policy); +} + +static int cxl_event_irqsetup (struct cxl_dev_state *cxlds) +{ +struct cxl_event_interrupt_policy policy; +int rc; + + rc =cxl_event_config_msgnums (cxlds, &policy); +if (rc) +return rc; + + rc =cxl_event_req_irq (cxlds, policy.info_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Info log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.warn_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Warn log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.failure_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Failure log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.fatal_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Fatal log\n" ); +return rc; + } + +return 0 ; +} + +static bool cxl_event_int_is_fw (u8 setting) +{ +u8 mode =FIELD_GET (CXLDEV_EVENT_INT_MODE_MASK , setting); + +return mode ==CXL_INT_FW ; +} + +static int cxl_event_config (struct pci_host_bridge *host_bridge, +struct cxl_dev_state *cxlds) +{ +struct cxl_event_interrupt_policy policy; +int rc; + +/* +* When BIOS maintains CXL error reporting control, it will process +* event records. Only one agent can do so. +*/ +if (!host_bridge->native_cxl_error) +return 0 ; + + rc =cxl_event_get_int_policy (cxlds, &policy); +if (rc) +return rc; + +if (cxl_event_int_is_fw (policy.info_settings) || +cxl_event_int_is_fw (policy.warn_settings) || +cxl_event_int_is_fw (policy.failure_settings) || +cxl_event_int_is_fw (policy.fatal_settings)) { +dev_err (cxlds->dev,"FW still in control of Event Logs despite _OSC settings\n" ); +return -EBUSY ; + } + + rc =cxl_event_irqsetup (cxlds); +if (rc) +return rc; + +cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); + +return 0 ; +} +static int cxl_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct pci_host_bridge *host_bridge =pci_find_host_bridge (pdev->bus);@@ -519,6 +714,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; + rc =cxl_alloc_irq_vectors (pdev); +if (rc) +return rc; + cxlmd =devm_cxl_add_memdev (cxlds);if (IS_ERR (cxlmd))return PTR_ERR (cxlmd);@@ -527,12 +726,9 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; -/* -* When BIOS maintains CXL error reporting control, it will process -* event records. Only one agent can do so. -*/ -if (host_bridge->native_cxl_error) -cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); + rc =cxl_event_config (host_bridge, cxlds); +if (rc) +return rc;if (cxlds->regs.ras) {pci_enable_pcie_error_reporting (pdev);
Re: [PATCH V4 3/9] cxl/mem: Wire up event interrupts
Quoted 32 lines · Jonathan Cameron
Quoted 20 lines · On Sun, 11 Dec 2022 23:06:21 -0800 [email protected] wrote:
From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
Quoted 8 lines
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
Cc Bjorn Helgaas <[email protected]>Cc Jonathan Cameron <[email protected]>Co-developed-by Ira Weiny <[email protected]>Signed-off-by Ira Weiny <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>
Quoted 3 lines
Sometimes it feels like we go around in circles as I'm sure we've fixed this at least 3 times now in different sets that got dropped (was definitely in the DOE interrupt support set and was controversial ;)
Well I certainly seem to be spinning ATM. I probably need more eggnog. ;-)
Quoted 3 lines
Nothing in this patch set calls
pci_set_master()so no interrupts will even be delivered.
Is this a bug in Qemu then? Because this _is_ tested and irqs _were_ delivered. I thought we determined that pci_set_master() was called in pcim_enable_device() but I don't see that now. :-(
What I do know is this works with Qemu. :-/
Ira
Quoted 335 lines
I don't think there are any sets in flight
that would fix that.Jonathan
Quoted 328 lines
---
Changes from V3:
Adjust based on changes in patch 1
Consolidate event setup intocxl_event_config()Consistently use cxl_event_* for function names Removecxl_event_int_is_msi()
Ensure DCD log is ignored in status
Simplify event status loop logic
Dan
Fail driver load if the irq's are not allocated movecxl_event_config_msgnums()topci.cs/CXL_PCI_REQUIRED_VECTORS/CXL_PCI_DEFAULT_MAX_VECTORS s/devm_kmalloc/devm_kzalloc
Fix uppci_alloc_irq_vectors()comment
Pass pdev tocxl_alloc_irq_vectors()
Check FW irq policy prior to configuration
Jonathan
UseFIELD_GETinstead of manual masking--- drivers/cxl/cxl.h | 4 + drivers/cxl/cxlmem.h | 19 ++++ drivers/cxl/cxlpci.h | 6 ++ drivers/cxl/pci.c | 208 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 231 insertions(+), 6 deletions(-)drivers/cxl/cxl.h +4
-0@@ -168,6 +168,10 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw) CXLDEV_EVENT_STATUS_FAIL | \ CXLDEV_EVENT_STATUS_FATAL) +/* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 */ +#define CXLDEV_EVENT_INT_MODE_MASK GENMASK(1, 0) +#define CXLDEV_EVENT_INT_MSGNUM_MASK GENMASK(7, 4) +/* CXL 2.0 8.2.8.4 Mailbox Registers */ #define CXLDEV_MBOX_CAPS_OFFSET 0x00#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK GENMASK(4, 0)drivers/cxl/cxlmem.h +19
-0@@ -194,6 +194,23 @@ struct cxl_endpoint_dvsec_info {struct range dvsec_range[2 ]; }; +/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ +enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings; +} __packed; +/** * struct cxl_event_state - Event log driver state * @@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,drivers/cxl/cxlpci.h +6
-0@@ -53,6 +53,12 @@#define CXL_DVSEC_REG_LOCATOR_BLOCK_ID_MASK GENMASK(15, 8)#define CXL_DVSEC_REG_LOCATOR_BLOCK_OFF_LOW_MASK GENMASK(31, 16) +/* +* NOTE: Currently all the functions which are enabled for CXL require their +* vectors to be in the first 16. Use this as the default max. +*/ +#define CXL_PCI_DEFAULT_MAX_VECTORS 16 +/* Register Block Identifier (RBI) */ enum cxl_regloc_type {CXL_REGLOC_RBI_EMPTY =0 ,drivers/cxl/pci.c +202
-6@@ -445,6 +445,201 @@ static int cxl_mem_alloc_event_buf(struct cxl_dev_state *cxlds)return 0 ; } +static int cxl_alloc_irq_vectors (struct pci_dev *pdev) +{ +int nvecs; + +/* +* CXL requires MSI/MSIX support. +* +* Additionally pci_alloc_irq_vectors() handles calling +* pci_free_irq_vectors() automatically despite not being called +* pcim_*. See pci_setup_msi_context(). +*/ + nvecs =pci_alloc_irq_vectors (pdev,1 ,CXL_PCI_DEFAULT_MAX_VECTORS , +PCI_IRQ_MSIX |PCI_IRQ_MSI ); +if (nvecs <1 ) { +dev_dbg (&pdev->dev,"Failed to alloc irq vectors: %d\n" , nvecs); +return -ENXIO ; + } +return 0 ; +} + +struct cxl_dev_id { +struct cxl_dev_state *cxlds; +}; + +static irqreturn_t cxl_event_thread (int irq,void *id) +{ +struct cxl_dev_id *dev_id = id; +struct cxl_dev_state *cxlds = dev_id->cxlds; +u32 status; + +do { +/* +* CXL 3.0 8.2.8.3.1: The lower 32 bits are the status; +* ignore the reserved upper 32 bits +*/ + status =readl (cxlds->regs.status +CXLDEV_DEV_EVENT_STATUS_OFFSET ); +/* Ignore logs unknown to the driver */ + status &=CXLDEV_EVENT_STATUS_ALL ; +if (!status) +break ; +cxl_mem_get_event_records (cxlds, status); +cond_resched (); + }while (status); + +return IRQ_HANDLED ; +} + +static int cxl_event_req_irq (struct cxl_dev_state *cxlds,u8 setting) +{ +struct device *dev = cxlds->dev; +struct pci_dev *pdev =to_pci_dev (dev); +struct cxl_dev_id *dev_id; +int irq; + +if (FIELD_GET (CXLDEV_EVENT_INT_MODE_MASK , setting) !=CXL_INT_MSI_MSIX ) +return -ENXIO ; + +/* dev_id must be globally unique and must contain the cxlds */ + dev_id =devm_kzalloc (dev,sizeof (*dev_id),GFP_KERNEL ); +if (!dev_id) +return -ENOMEM ; + dev_id->cxlds = cxlds; + + irq =pci_irq_vector (pdev, +FIELD_GET (CXLDEV_EVENT_INT_MSGNUM_MASK , setting)); +if (irq <0 ) +return irq; + +return devm_request_threaded_irq (dev, irq,NULL , cxl_event_thread, +IRQF_SHARED ,NULL , dev_id); +} + +static int cxl_event_get_int_policy (struct cxl_dev_state *cxlds, +struct cxl_event_interrupt_policy *policy) +{ +struct cxl_mbox_cmd mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_EVT_INT_POLICY , + .payload_out = policy, + .size_out =sizeof (*policy), + }; +int rc; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc <0 ) +dev_err (cxlds->dev,"Failed to get event interrupt policy : %d" , + rc); + +return rc; +} + +static int cxl_event_config_msgnums (struct cxl_dev_state *cxlds, +struct cxl_event_interrupt_policy *policy) +{ +struct cxl_mbox_cmd mbox_cmd; +int rc; + + policy->info_settings =CXL_INT_MSI_MSIX ; + policy->warn_settings =CXL_INT_MSI_MSIX ; + policy->failure_settings =CXL_INT_MSI_MSIX ; + policy->fatal_settings =CXL_INT_MSI_MSIX ; + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_SET_EVT_INT_POLICY , + .payload_in = policy, + .size_in =sizeof (*policy), + }; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc <0 ) { +dev_err (cxlds->dev,"Failed to set event interrupt policy : %d" , + rc); +return rc; + } + +/* Retrieve final interrupt settings */ +return cxl_event_get_int_policy (cxlds, policy); +} + +static int cxl_event_irqsetup (struct cxl_dev_state *cxlds) +{ +struct cxl_event_interrupt_policy policy; +int rc; + + rc =cxl_event_config_msgnums (cxlds, &policy); +if (rc) +return rc; + + rc =cxl_event_req_irq (cxlds, policy.info_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Info log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.warn_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Warn log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.failure_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Failure log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.fatal_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Fatal log\n" ); +return rc; + } + +return 0 ; +} + +static bool cxl_event_int_is_fw (u8 setting) +{ +u8 mode =FIELD_GET (CXLDEV_EVENT_INT_MODE_MASK , setting); + +return mode ==CXL_INT_FW ; +} + +static int cxl_event_config (struct pci_host_bridge *host_bridge, +struct cxl_dev_state *cxlds) +{ +struct cxl_event_interrupt_policy policy; +int rc; + +/* +* When BIOS maintains CXL error reporting control, it will process +* event records. Only one agent can do so. +*/ +if (!host_bridge->native_cxl_error) +return 0 ; + + rc =cxl_event_get_int_policy (cxlds, &policy); +if (rc) +return rc; + +if (cxl_event_int_is_fw (policy.info_settings) || +cxl_event_int_is_fw (policy.warn_settings) || +cxl_event_int_is_fw (policy.failure_settings) || +cxl_event_int_is_fw (policy.fatal_settings)) { +dev_err (cxlds->dev,"FW still in control of Event Logs despite _OSC settings\n" ); +return -EBUSY ; + } + + rc =cxl_event_irqsetup (cxlds); +if (rc) +return rc; + +cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); + +return 0 ; +} +static int cxl_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct pci_host_bridge *host_bridge =pci_find_host_bridge (pdev->bus);@@ -519,6 +714,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; + rc =cxl_alloc_irq_vectors (pdev); +if (rc) +return rc; + cxlmd =devm_cxl_add_memdev (cxlds);if (IS_ERR (cxlmd))return PTR_ERR (cxlmd);@@ -527,12 +726,9 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; -/* -* When BIOS maintains CXL error reporting control, it will process -* event records. Only one agent can do so. -*/ -if (host_bridge->native_cxl_error) -cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); + rc =cxl_event_config (host_bridge, cxlds); +if (rc) +return rc;if (cxlds->regs.ras) {pci_enable_pcie_error_reporting (pdev);
Re: [PATCH V4 3/9] cxl/mem: Wire up event interrupts
Quoted 40 lines · On Fri, 16 Dec 2022 13:33:43 -0800 Ira Weiny <[email protected]> wrote:
Quoted 32 lines · Jonathan Cameron
Quoted 20 lines · On Sun, 11 Dec 2022 23:06:21 -0800 [email protected] wrote:
From: Davidlohr Bueso <[email protected]>
Currently the only CXL features targeted for irq support require their message numbers to be within the first 16 entries. The device may however support less than 16 entries depending on the support it provides.
Attempt to allocate these 16 irq vectors. If the device supports less then the PCI infrastructure will allocate that number. Upon successful allocation, users can plug in their respective isr at any point thereafter.
CXL device events are signaled via interrupts. Each event log may have a different interrupt message number. These message numbers are reported in the Get Event Interrupt Policy mailbox command.
Add interrupt support for event logs. Interrupts are allocated as shared interrupts. Therefore, all or some event logs can share the same message number.
Quoted 8 lines
In addition all logs are queried on any interrupt in order of the most to least severe based on the status register.
Cc Bjorn Helgaas <[email protected]>Cc Jonathan Cameron <[email protected]>Co-developed-by Ira Weiny <[email protected]>Signed-off-by Ira Weiny <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>Quoted 3 lines
Sometimes it feels like we go around in circles as I'm sure we've fixed this at least 3 times now in different sets that got dropped (was definitely in the DOE interrupt support set and was controversial ;)
Well I certainly seem to be spinning ATM. I probably need more eggnog. ;-)
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Nothing in this patch set calls
pci_set_master()so no interrupts will even be delivered.Is this a bug in Qemu then? Because this _is_ tested and irqs _were_ delivered. I thought we determined that
pci_set_master()was called inpcim_enable_device()but I don't see that now. :-(What I do know is this works with Qemu. :-/
Without the addition of a pci_set_master() the kernel code,
I don't get any interrupts on my arm64 test setup. Only reason I realized the call was missing. Possible there is something different on x86 I guess.
Jonathan
Quoted 339 lines
Ira
Quoted 335 lines
I don't think there are any sets in flight
that would fix that.Jonathan
Quoted 328 lines
---
Changes from V3:
Adjust based on changes in patch 1
Consolidate event setup intocxl_event_config()Consistently use cxl_event_* for function names Removecxl_event_int_is_msi()
Ensure DCD log is ignored in status
Simplify event status loop logic
Dan
Fail driver load if the irq's are not allocated movecxl_event_config_msgnums()topci.cs/CXL_PCI_REQUIRED_VECTORS/CXL_PCI_DEFAULT_MAX_VECTORS s/devm_kmalloc/devm_kzalloc
Fix uppci_alloc_irq_vectors()comment
Pass pdev tocxl_alloc_irq_vectors()
Check FW irq policy prior to configuration
Jonathan
UseFIELD_GETinstead of manual masking--- drivers/cxl/cxl.h | 4 + drivers/cxl/cxlmem.h | 19 ++++ drivers/cxl/cxlpci.h | 6 ++ drivers/cxl/pci.c | 208 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 231 insertions(+), 6 deletions(-)drivers/cxl/cxl.h +4
-0@@ -168,6 +168,10 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw) CXLDEV_EVENT_STATUS_FAIL | \ CXLDEV_EVENT_STATUS_FATAL) +/* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 */ +#define CXLDEV_EVENT_INT_MODE_MASK GENMASK(1, 0) +#define CXLDEV_EVENT_INT_MSGNUM_MASK GENMASK(7, 4) +/* CXL 2.0 8.2.8.4 Mailbox Registers */ #define CXLDEV_MBOX_CAPS_OFFSET 0x00#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK GENMASK(4, 0)drivers/cxl/cxlmem.h +19
-0@@ -194,6 +194,23 @@ struct cxl_endpoint_dvsec_info {struct range dvsec_range[2 ]; }; +/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ +enum cxl_event_int_mode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 +}; +struct cxl_event_interrupt_policy { +u8 info_settings; +u8 warn_settings; +u8 failure_settings; +u8 fatal_settings; +} __packed; +/** * struct cxl_event_state - Event log driver state * @@ -288,6 +305,8 @@ enum cxl_opcode {CXL_MBOX_OP_RAW =CXL_MBOX_OP_INVALID ,CXL_MBOX_OP_GET_EVENT_RECORD =0x0100 ,CXL_MBOX_OP_CLEAR_EVENT_RECORD =0x0101 , +CXL_MBOX_OP_GET_EVT_INT_POLICY =0x0102 , +CXL_MBOX_OP_SET_EVT_INT_POLICY =0x0103 ,CXL_MBOX_OP_GET_FW_INFO =0x0200 ,CXL_MBOX_OP_ACTIVATE_FW =0x0202 , CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,drivers/cxl/cxlpci.h +6
-0@@ -53,6 +53,12 @@#define CXL_DVSEC_REG_LOCATOR_BLOCK_ID_MASK GENMASK(15, 8)#define CXL_DVSEC_REG_LOCATOR_BLOCK_OFF_LOW_MASK GENMASK(31, 16) +/* +* NOTE: Currently all the functions which are enabled for CXL require their +* vectors to be in the first 16. Use this as the default max. +*/ +#define CXL_PCI_DEFAULT_MAX_VECTORS 16 +/* Register Block Identifier (RBI) */ enum cxl_regloc_type {CXL_REGLOC_RBI_EMPTY =0 ,drivers/cxl/pci.c +202
-6@@ -445,6 +445,201 @@ static int cxl_mem_alloc_event_buf(struct cxl_dev_state *cxlds)return 0 ; } +static int cxl_alloc_irq_vectors (struct pci_dev *pdev) +{ +int nvecs; + +/* +* CXL requires MSI/MSIX support. +* +* Additionally pci_alloc_irq_vectors() handles calling +* pci_free_irq_vectors() automatically despite not being called +* pcim_*. See pci_setup_msi_context(). +*/ + nvecs =pci_alloc_irq_vectors (pdev,1 ,CXL_PCI_DEFAULT_MAX_VECTORS , +PCI_IRQ_MSIX |PCI_IRQ_MSI ); +if (nvecs <1 ) { +dev_dbg (&pdev->dev,"Failed to alloc irq vectors: %d\n" , nvecs); +return -ENXIO ; + } +return 0 ; +} + +struct cxl_dev_id { +struct cxl_dev_state *cxlds; +}; + +static irqreturn_t cxl_event_thread (int irq,void *id) +{ +struct cxl_dev_id *dev_id = id; +struct cxl_dev_state *cxlds = dev_id->cxlds; +u32 status; + +do { +/* +* CXL 3.0 8.2.8.3.1: The lower 32 bits are the status; +* ignore the reserved upper 32 bits +*/ + status =readl (cxlds->regs.status +CXLDEV_DEV_EVENT_STATUS_OFFSET ); +/* Ignore logs unknown to the driver */ + status &=CXLDEV_EVENT_STATUS_ALL ; +if (!status) +break ; +cxl_mem_get_event_records (cxlds, status); +cond_resched (); + }while (status); + +return IRQ_HANDLED ; +} + +static int cxl_event_req_irq (struct cxl_dev_state *cxlds,u8 setting) +{ +struct device *dev = cxlds->dev; +struct pci_dev *pdev =to_pci_dev (dev); +struct cxl_dev_id *dev_id; +int irq; + +if (FIELD_GET (CXLDEV_EVENT_INT_MODE_MASK , setting) !=CXL_INT_MSI_MSIX ) +return -ENXIO ; + +/* dev_id must be globally unique and must contain the cxlds */ + dev_id =devm_kzalloc (dev,sizeof (*dev_id),GFP_KERNEL ); +if (!dev_id) +return -ENOMEM ; + dev_id->cxlds = cxlds; + + irq =pci_irq_vector (pdev, +FIELD_GET (CXLDEV_EVENT_INT_MSGNUM_MASK , setting)); +if (irq <0 ) +return irq; + +return devm_request_threaded_irq (dev, irq,NULL , cxl_event_thread, +IRQF_SHARED ,NULL , dev_id); +} + +static int cxl_event_get_int_policy (struct cxl_dev_state *cxlds, +struct cxl_event_interrupt_policy *policy) +{ +struct cxl_mbox_cmd mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_EVT_INT_POLICY , + .payload_out = policy, + .size_out =sizeof (*policy), + }; +int rc; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc <0 ) +dev_err (cxlds->dev,"Failed to get event interrupt policy : %d" , + rc); + +return rc; +} + +static int cxl_event_config_msgnums (struct cxl_dev_state *cxlds, +struct cxl_event_interrupt_policy *policy) +{ +struct cxl_mbox_cmd mbox_cmd; +int rc; + + policy->info_settings =CXL_INT_MSI_MSIX ; + policy->warn_settings =CXL_INT_MSI_MSIX ; + policy->failure_settings =CXL_INT_MSI_MSIX ; + policy->fatal_settings =CXL_INT_MSI_MSIX ; + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_SET_EVT_INT_POLICY , + .payload_in = policy, + .size_in =sizeof (*policy), + }; + + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc <0 ) { +dev_err (cxlds->dev,"Failed to set event interrupt policy : %d" , + rc); +return rc; + } + +/* Retrieve final interrupt settings */ +return cxl_event_get_int_policy (cxlds, policy); +} + +static int cxl_event_irqsetup (struct cxl_dev_state *cxlds) +{ +struct cxl_event_interrupt_policy policy; +int rc; + + rc =cxl_event_config_msgnums (cxlds, &policy); +if (rc) +return rc; + + rc =cxl_event_req_irq (cxlds, policy.info_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Info log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.warn_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Warn log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.failure_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Failure log\n" ); +return rc; + } + + rc =cxl_event_req_irq (cxlds, policy.fatal_settings); +if (rc) { +dev_err (cxlds->dev,"Failed to get interrupt for event Fatal log\n" ); +return rc; + } + +return 0 ; +} + +static bool cxl_event_int_is_fw (u8 setting) +{ +u8 mode =FIELD_GET (CXLDEV_EVENT_INT_MODE_MASK , setting); + +return mode ==CXL_INT_FW ; +} + +static int cxl_event_config (struct pci_host_bridge *host_bridge, +struct cxl_dev_state *cxlds) +{ +struct cxl_event_interrupt_policy policy; +int rc; + +/* +* When BIOS maintains CXL error reporting control, it will process +* event records. Only one agent can do so. +*/ +if (!host_bridge->native_cxl_error) +return 0 ; + + rc =cxl_event_get_int_policy (cxlds, &policy); +if (rc) +return rc; + +if (cxl_event_int_is_fw (policy.info_settings) || +cxl_event_int_is_fw (policy.warn_settings) || +cxl_event_int_is_fw (policy.failure_settings) || +cxl_event_int_is_fw (policy.fatal_settings)) { +dev_err (cxlds->dev,"FW still in control of Event Logs despite _OSC settings\n" ); +return -EBUSY ; + } + + rc =cxl_event_irqsetup (cxlds); +if (rc) +return rc; + +cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); + +return 0 ; +} +static int cxl_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct pci_host_bridge *host_bridge =pci_find_host_bridge (pdev->bus);@@ -519,6 +714,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; + rc =cxl_alloc_irq_vectors (pdev); +if (rc) +return rc; + cxlmd =devm_cxl_add_memdev (cxlds);if (IS_ERR (cxlmd))return PTR_ERR (cxlmd);@@ -527,12 +726,9 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; -/* -* When BIOS maintains CXL error reporting control, it will process -* event records. Only one agent can do so. -*/ -if (host_bridge->native_cxl_error) -cxl_mem_get_event_records (cxlds,CXLDEV_EVENT_STATUS_ALL ); + rc =cxl_event_config (host_bridge, cxlds); +if (rc) +return rc;if (cxlds->regs.ras) {pci_enable_pcie_error_reporting (pdev);
PATCH v4 4/9 cxl/mem: Trace General Media Event Record
In reply to [email protected]From: Ira Weiny <[email protected]>
CXL rev 3.0 section 8.2.9.2.1.1 defines the General Media Event Record.
Determine if the event read is a general media record and if so trace the record as a General Media Event Record.
---
Changes from V3:
Adjust based on changes in patch 1 s/cxl_trace_event_record/cxl_event_trace_record
Dan
Use decimal for reserved field length
Use 'else' instead of return in cxl_event_trace_record()
--- drivers/cxl/core/mbox.c | 29 ++++++++- drivers/cxl/core/trace.h | 124 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 19 ++++++ 3 files changed, 170 insertions(+), 2 deletions(-)
drivers/cxl/core/mbox.c +27 -2
@@ -718,6 +718,31 @@ int cxl_enumerate_cmds(struct cxl_dev_state *cxlds) }EXPORT_SYMBOL_NS_GPL (cxl_enumerate_cmds,CXL ); +/* +* General Media Event Record +* CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 +*/ +static const uuid_t gen_media_event_uuid = +UUID_INIT (0xfbcd0a77 ,0xc260 ,0x417f , +0x85 ,0xa9 ,0x08 ,0x8b ,0x16 ,0x21 ,0xeb ,0xa6 ); + +static void cxl_event_trace_record (const struct device *dev, +enum cxl_event_log_type type, +struct cxl_event_record_raw *record) +{ +uuid_t *id = &record->hdr.id; + +if (uuid_equal (id, &gen_media_event_uuid)) { +struct cxl_event_gen_media *rec = + (struct cxl_event_gen_media *)record; + +trace_cxl_general_media (dev, type, rec); + }else { +/* For unknown record types print just the header */ +trace_cxl_generic_event (dev, type, record); + } +} +static int cxl_clear_event_record (struct cxl_dev_state *cxlds,enum cxl_event_log_type log,struct cxl_get_event_payload *get_pl)
@@ -810,8 +835,8 @@ static void cxl_mem_get_records_log(struct cxl_dev_state *cxlds,break ;for (i =0 ; i < nr_rec; i++) -trace_cxl_generic_event (cxlds->dev, type, - &payload->records[i]); +cxl_event_trace_record (cxlds->dev, type, + &payload->records[i]);if (payload->flags &CXL_GET_EVENT_FLAG_OVERFLOW )trace_cxl_overflow (cxlds->dev, type, payload);
drivers/cxl/core/trace.h +124 -0
130 lines not on this page · raw message
drivers/cxl/cxlmem.h +19 -0
@@ -449,6 +449,25 @@ struct cxl_mbox_clear_event_payload { (sizeof(__le16) * CXL_CLEAR_EVENT_MAX_HANDLES))) / \ sizeof(__le16)) +/* +* General Media Event Record +* CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 +*/ +#define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10 +struct cxl_event_gen_media { +struct cxl_event_record_hdr hdr; +__le64 phys_addr; +u8 descriptor; +u8 type; +u8 transaction_type; +u8 validity_flags[2 ]; +u8 channel; +u8 rank; +u8 device[3 ]; +u8 component_id[CXL_EVENT_GEN_MED_COMP_ID_SIZE ]; +u8 reserved[46 ]; +} __packed; +struct cxl_mbox_get_partition_info {__le64 active_volatile_cap;__le64 active_persistent_cap;
Signature · 1 line
2.37.2
PATCH v4 5/9 cxl/mem: Trace DRAM Event Record
In reply to [email protected]From: Ira Weiny <[email protected]>
CXL rev 3.0 section 8.2.9.2.1.2 defines the DRAM Event Record.
Determine if the event read is a DRAM event record and if so trace the record.
---
Changes from v3:
Dan
Use if/else if/else instead of returns
--- drivers/cxl/core/mbox.c | 12 ++++++ drivers/cxl/core/trace.h | 92 ++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 23 ++++++++++ 3 files changed, 127 insertions(+)
drivers/cxl/core/mbox.c +12 -0
@@ -726,6 +726,14 @@ static const uuid_t gen_media_event_uuid =UUID_INIT (0xfbcd0a77 ,0xc260 ,0x417f ,0x85 ,0xa9 ,0x08 ,0x8b ,0x16 ,0x21 ,0xeb ,0xa6 ); +/* +* DRAM Event Record +* CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 +*/ +static const uuid_t dram_event_uuid = +UUID_INIT (0x601dcbb3 ,0x9c06 ,0x4eab , +0xb8 ,0xaf ,0x4e ,0x9b ,0xfb ,0x5c ,0x96 ,0x24 ); +static void cxl_event_trace_record (const struct device *dev,enum cxl_event_log_type type,struct cxl_event_record_raw *record)
@@ -737,6 +745,10 @@ static void cxl_event_trace_record(const struct device *dev, (struct cxl_event_gen_media *)record;trace_cxl_general_media (dev, type, rec); + }else if (uuid_equal (id, &dram_event_uuid)) { +struct cxl_event_dram *rec = (struct cxl_event_dram *)record; + +trace_cxl_dram (dev, type, rec); }else {/* For unknown record types print just the header */ trace_cxl_generic_event (dev, type, record);
drivers/cxl/core/trace.h +92 -0
98 lines not on this page · raw message
drivers/cxl/cxlmem.h +23 -0
@@ -468,6 +468,29 @@ struct cxl_event_gen_media {u8 reserved[46 ]; } __packed; +/* +* DRAM Event Record - DER +* CXL rev 3.0 section 8.2.9.2.1.2; Table 3-44 +*/ +#define CXL_EVENT_DER_CORRECTION_MASK_SIZE 0x20 +struct cxl_event_dram { +struct cxl_event_record_hdr hdr; +__le64 phys_addr; +u8 descriptor; +u8 type; +u8 transaction_type; +u8 validity_flags[2 ]; +u8 channel; +u8 rank; +u8 nibble_mask[3 ]; +u8 bank_group; +u8 bank; +u8 row[3 ]; +u8 column[2 ]; +u8 correction_mask[CXL_EVENT_DER_CORRECTION_MASK_SIZE ]; +u8 reserved[0x17 ]; +} __packed; +struct cxl_mbox_get_partition_info {__le64 active_volatile_cap;__le64 active_persistent_cap;
Signature · 1 line
2.37.2
PATCH v4 6/9 cxl/mem: Trace Memory Module Event Record
In reply to [email protected]From: Ira Weiny <[email protected]>
CXL rev 3.0 section 8.2.9.2.1.3 defines the Memory Module Event Record.
Determine if the event read is memory module record and if so trace the record.
---
Changes from V3:
Dan
Use if/else if/else instead of return
--- drivers/cxl/core/mbox.c | 13 ++++ drivers/cxl/core/trace.h | 143 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 26 +++++++ 3 files changed, 182 insertions(+)
drivers/cxl/core/mbox.c +13 -0
@@ -734,6 +734,14 @@ static const uuid_t dram_event_uuid =UUID_INIT (0x601dcbb3 ,0x9c06 ,0x4eab ,0xb8 ,0xaf ,0x4e ,0x9b ,0xfb ,0x5c ,0x96 ,0x24 ); +/* +* Memory Module Event Record +* CXL rev 3.0 section 8.2.9.2.1.3; Table 8-45 +*/ +static const uuid_t mem_mod_event_uuid = +UUID_INIT (0xfe927475 ,0xdd59 ,0x4339 , +0xa5 ,0x86 ,0x79 ,0xba ,0xb1 ,0x13 ,0xb7 ,0x74 ); +static void cxl_event_trace_record (const struct device *dev,enum cxl_event_log_type type,struct cxl_event_record_raw *record)
@@ -749,6 +757,11 @@ static void cxl_event_trace_record(const struct device *dev,struct cxl_event_dram *rec = (struct cxl_event_dram *)record;trace_cxl_dram (dev, type, rec); + }else if (uuid_equal (id, &mem_mod_event_uuid)) { +struct cxl_event_mem_module *rec = + (struct cxl_event_mem_module *)record; + +trace_cxl_memory_module (dev, type, rec); }else {/* For unknown record types print just the header */ trace_cxl_generic_event (dev, type, record);
drivers/cxl/core/trace.h +143 -0
149 lines not on this page · raw message
drivers/cxl/cxlmem.h +26 -0
@@ -491,6 +491,32 @@ struct cxl_event_dram {u8 reserved[0x17 ]; } __packed; +/* +* Get Health Info Record +* CXL rev 3.0 section 8.2.9.8.3.1; Table 8-100 +*/ +struct cxl_get_health_info { +u8 health_status; +u8 media_status; +u8 add_status; +u8 life_used; +u8 device_temp[2 ]; +u8 dirty_shutdown_cnt[4 ]; +u8 cor_vol_err_cnt[4 ]; +u8 cor_per_err_cnt[4 ]; +} __packed; + +/* +* Memory Module Event Record +* CXL rev 3.0 section 8.2.9.2.1.3; Table 8-45 +*/ +struct cxl_event_mem_module { +struct cxl_event_record_hdr hdr; +u8 event_type; +struct cxl_get_health_info info; +u8 reserved[0x3d ]; +} __packed; +struct cxl_mbox_get_partition_info {__le64 active_volatile_cap;__le64 active_persistent_cap;
Signature · 1 line
2.37.2
PATCH v4 7/9 cxl/test: Add generic mock events
In reply to [email protected]From: Ira Weiny <[email protected]>
Facilitate testing basic Get/Clear Event functionality by creating multiple logs and generic events with made up UUID's.
Data is completely made up with data patterns which should be easy to spot in trace output.
A single sysfs entry resets the event data and triggers collecting the events for testing.
Test traces are easy to obtain with a small script such as this:
#!/bin/bash -x
devices=find /sys/devices/platform -name cxl_mem*
# Turn on tracing
echo "" > /sys/kernel/tracing/trace echo 1 > /sys/kernel/tracing/events/cxl/enable echo 1 > /sys/kernel/tracing/tracing_on
# Generate fake interrupt
for device in $devices; do
echo 1 > $device/event_trigger
done
# Turn off tracing and report events
echo 0 > /sys/kernel/tracing/tracing_on
cat /sys/kernel/tracing/trace
---
Changes from v3:
Dan
Move code to mem.c and remove event.c and overhead
Clean up function names
--- tools/testing/cxl/test/Kbuild | 2 +- tools/testing/cxl/test/mem.c | 231 ++++++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+), 1 deletion(-)
tools/testing/cxl/test/Kbuild +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y := -I$(srctree)/drivers/cxl/ +ccflags-y := -I$(srctree)/drivers/cxl/ -I$(srctree)/drivers/cxl/core obj-m += cxl_test.o obj-m += cxl_mock.o
tools/testing/cxl/test/mem.c +231 -0
286 lines not on this page · raw message
Signature · 1 line
2.37.2
PATCH v4 8/9 cxl/test: Add specific events
In reply to [email protected]From: Ira Weiny <[email protected]>
Each type of event has different trace point outputs.
Add mock General Media Event, DRAM event, and Memory Module Event records to the mock list of events returned.
---
Changes from V3:
Dan
Move code to mem.c
--- tools/testing/cxl/test/mem.c | 73 ++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
tools/testing/cxl/test/mem.c +73 -0
@@ -277,12 +277,85 @@ struct cxl_event_record_raw hardware_replace = { .data = { 0xDE, 0xAD, 0xBE, 0xEF }, }; +struct cxl_event_gen_media gen_media = { + .hdr = { + .id =UUID_INIT (0xfbcd0a77 ,0xc260 ,0x417f , +0x85 ,0xa9 ,0x08 ,0x8b ,0x16 ,0x21 ,0xeb ,0xa6 ), + .length =sizeof (struct cxl_event_gen_media ), + .flags[0 ] =CXL_EVENT_RECORD_FLAG_PERMANENT , +/* .handle = Set dynamically */ + .related_handle =cpu_to_le16 (0 ), + }, + .phys_addr =cpu_to_le64 (0x2000 ), + .descriptor =CXL_GMER_EVT_DESC_UNCORECTABLE_EVENT , + .type =CXL_GMER_MEM_EVT_TYPE_DATA_PATH_ERROR , + .transaction_type =CXL_GMER_TRANS_HOST_WRITE , +/* .validity_flags = <set below> */ + .channel =1 , + .rank =30 +}; + +struct cxl_event_dram dram = { + .hdr = { + .id =UUID_INIT (0x601dcbb3 ,0x9c06 ,0x4eab , +0xb8 ,0xaf ,0x4e ,0x9b ,0xfb ,0x5c ,0x96 ,0x24 ), + .length =sizeof (struct cxl_event_dram ), + .flags[0 ] =CXL_EVENT_RECORD_FLAG_PERF_DEGRADED , +/* .handle = Set dynamically */ + .related_handle =cpu_to_le16 (0 ), + }, + .phys_addr =cpu_to_le64 (0x8000 ), + .descriptor =CXL_GMER_EVT_DESC_THRESHOLD_EVENT , + .type =CXL_GMER_MEM_EVT_TYPE_INV_ADDR , + .transaction_type =CXL_GMER_TRANS_INTERNAL_MEDIA_SCRUB , +/* .validity_flags = <set below> */ + .channel =1 , + .bank_group =5 , + .bank =2 , + .column = {0xDE ,0xAD }, +}; + +struct cxl_event_mem_module mem_module = { + .hdr = { + .id =UUID_INIT (0xfe927475 ,0xdd59 ,0x4339 , +0xa5 ,0x86 ,0x79 ,0xba ,0xb1 ,0x13 ,0xb7 ,0x74 ), + .length =sizeof (struct cxl_event_mem_module ), +/* .handle = Set dynamically */ + .related_handle =cpu_to_le16 (0 ), + }, + .event_type =CXL_MMER_TEMP_CHANGE , + .info = { + .health_status =CXL_DHI_HS_PERFORMANCE_DEGRADED , + .media_status =CXL_DHI_MS_ALL_DATA_LOST , + .add_status = (CXL_DHI_AS_CRITICAL <<2 ) | + (CXL_DHI_AS_WARNING <<4 ) | + (CXL_DHI_AS_WARNING <<5 ), + .device_temp = {0xDE ,0xAD }, + .dirty_shutdown_cnt = {0xde ,0xad ,0xbe ,0xef }, + .cor_vol_err_cnt = {0xde ,0xad ,0xbe ,0xef }, + .cor_per_err_cnt = {0xde ,0xad ,0xbe ,0xef }, + } +}; +static void cxl_mock_add_event_logs (struct mock_event_store *mes) { +put_unaligned_le16 (CXL_GMER_VALID_CHANNEL |CXL_GMER_VALID_RANK , + &gen_media.validity_flags); + +put_unaligned_le16 (CXL_DER_VALID_CHANNEL |CXL_DER_VALID_BANK_GROUP | +CXL_DER_VALID_BANK |CXL_DER_VALID_COLUMN , + &dram.validity_flags); +mes_add_event (mes,CXL_EVENT_TYPE_INFO , &maint_needed); +mes_add_event (mes,CXL_EVENT_TYPE_INFO , + (struct cxl_event_record_raw *)&gen_media); +mes_add_event (mes,CXL_EVENT_TYPE_INFO , + (struct cxl_event_record_raw *)&mem_module); mes->ev_status |=CXLDEV_EVENT_STATUS_INFO ;mes_add_event (mes,CXL_EVENT_TYPE_FATAL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FATAL , + (struct cxl_event_record_raw *)&dram); mes->ev_status |=CXLDEV_EVENT_STATUS_FATAL ; }
Signature · 1 line
2.37.2
PATCH v4 9/9 cxl/test: Simulate event log overflow
In reply to [email protected]From: Ira Weiny <[email protected]>
Log overflow is marked by a separate trace message.
Simulate a log with lots of messages and flag overflow until space is cleared.
---
Changes from V3:
Dan
Move code to mem.c
--- tools/testing/cxl/test/mem.c | 50 +++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-)
tools/testing/cxl/test/mem.c +49 -1
@@ -78,6 +78,8 @@ struct mock_event_log {u16 clear_idx;u16 cur_idx;u16 nr_events; +u16 nr_overflow; +u16 overflow_reset;struct cxl_event_record_raw *events[CXL_TEST_EVENT_CNT_MAX ]; };
@@ -116,6 +118,7 @@ static void event_reset_log(struct mock_event_log *log) { log->cur_idx =0 ; log->clear_idx =0 ; + log->nr_overflow = log->overflow_reset; }/* Handle can never be 0 use 1 based indexing for handle */
@@ -147,8 +150,12 @@ static void mes_add_event(struct mock_event_store *mes,return ; log = &mes->mock_logs[log_type]; -if (WARN_ON (log->nr_events >=CXL_TEST_EVENT_CNT_MAX )) + +if ((log->nr_events +1 ) >CXL_TEST_EVENT_CNT_MAX ) { + log->nr_overflow++; + log->overflow_reset = log->nr_overflow;return ; + } log->events[log->nr_events] = event; log->nr_events++;
@@ -159,6 +166,7 @@ static int mock_get_event(struct cxl_dev_state *cxlds, {struct cxl_get_event_payload *pl;struct mock_event_log *log; +u16 nr_overflow;u8 log_type;int i;
@@ -191,6 +199,19 @@ static int mock_get_event(struct cxl_dev_state *cxlds,if (!event_log_empty (log)) pl->flags |=CXL_GET_EVENT_FLAG_MORE_RECORDS ; +if (log->nr_overflow) { +u64 ns; + + pl->flags |=CXL_GET_EVENT_FLAG_OVERFLOW ; + pl->overflow_err_count =cpu_to_le16 (nr_overflow); + ns =ktime_get_real_ns (); + ns -=5000000000 ;/* 5s ago */ + pl->first_overflow_timestamp =cpu_to_le64 (ns); + ns =ktime_get_real_ns (); + ns -=1000000000 ;/* 1s ago */ + pl->last_overflow_timestamp =cpu_to_le64 (ns); + } +return 0 ; }
@@ -231,6 +252,9 @@ static int mock_clear_event(struct cxl_dev_state *cxlds, } } +if (log->nr_overflow) + log->nr_overflow =0 ; +/* Clear events */ log->clear_idx += pl->nr_recs;return 0 ;
@@ -353,6 +377,30 @@ static void cxl_mock_add_event_logs(struct mock_event_store *mes) (struct cxl_event_record_raw *)&mem_module); mes->ev_status |=CXLDEV_EVENT_STATUS_INFO ; +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &maint_needed); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , + (struct cxl_event_record_raw *)&dram); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , + (struct cxl_event_record_raw *)&gen_media); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , + (struct cxl_event_record_raw *)&mem_module); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , + (struct cxl_event_record_raw *)&dram); +/* Overflow this log */ +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); +mes_add_event (mes,CXL_EVENT_TYPE_FAIL , &hardware_replace); + mes->ev_status |=CXLDEV_EVENT_STATUS_FAIL ; +mes_add_event (mes,CXL_EVENT_TYPE_FATAL , &hardware_replace);mes_add_event (mes,CXL_EVENT_TYPE_FATAL , (struct cxl_event_record_raw *)&dram);
Signature · 1 line
2.37.2
Quoted 12 lines · On Sun, 11 Dec 2022 23:06:18 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
This code has been tested with a newer qemu which allows for more events to be returned at a time as well an additional QMP event and interrupt injection. Those patches will follow once they have been cleaned up.
The series is now in 3 parts:
1) Base functionality including interrupts
2) Tracing specific events (Dynamic Capacity Event Record is defered)
3) cxl-test infrastructure for basic tests
Quoted 5 lines
Changes from V3
Feedback from Dan
Spit out ACPI changes for Bjorn- Link to v3: https://lore.kernel.org/all/[email protected]/
Because I'm in a grumpy mood (as my colleagues will attest!)... This is dependent on the patch that moves the trace definitions and that's not upstream yet except in cxl/preview which is optimistic place to use for a base commit. The id isn't the one below either which isn't in either mailine or the current CXL trees.
Not that I actually checked the cover letter until it failed to apply (and hence already knew what was missing) but still, please call out dependencies unless they are in the branches Dan has queued up to push.
I just want to play with Dave's fix for the RAS errors so having to jump through these other sets.
Thanks,
Jonathan
Quoted 30 lines
Davidlohr Bueso (1):
cxl/mem: Wire up event interruptsIra Weiny (8):
PCI/CXL: Export native CXL error reporting control cxl/mem: Read, trace, and clear events on driver load cxl/mem: Trace General Media Event Record cxl/mem: Trace DRAM Event Record
cxl/mem: Trace Memory Module Event Record cxl/test: Add generic mock events
cxl/test: Add specific events
cxl/test: Simulate event log overflowdrivers/acpi/pci_root.c | 3 + drivers/cxl/core/mbox.c | 186 +++++++++++++ drivers/cxl/core/trace.h | 479 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 16 ++ drivers/cxl/cxlmem.h | 171 ++++++++++++ drivers/cxl/cxlpci.h | 6 + drivers/cxl/pci.c | 236 +++++++++++++++++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + tools/testing/cxl/test/Kbuild | 2 +- tools/testing/cxl/test/mem.c | 352 +++++++++++++++++++++++++ 11 files changed, 1452 insertions(+), 1 deletion(-)base-commit:
acb704099642bc822ef2aed223a0b8db1f7ea76e
Quoted 19 lines · Jonathan Cameron
Quoted 16 lines · On Sun, 11 Dec 2022 23:06:18 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
This code has been tested with a newer qemu which allows for more events to be returned at a time as well an additional QMP event and interrupt injection. Those patches will follow once they have been cleaned up.
The series is now in 3 parts:
1) Base functionality including interrupts
2) Tracing specific events (Dynamic Capacity Event Record is defered)
3) cxl-test infrastructure for basic testsChanges from V3
Feedback from Dan
Spit out ACPI changes for Bjorn
Quoted 7 lines
Quoted 1 line
- Link to v3: https://lore.kernel.org/all/[email protected]/
Because I'm in a grumpy mood (as my colleagues will attest!)... This is dependent on the patch that moves the trace definitions and that's not upstream yet except in cxl/preview which is optimistic place to use for a base commit. The id isn't the one below either which isn't in either mailine or the current CXL trees.
I do not want to commit to a new baseline until after -rc1, so yes this is in a messy period.
Quoted 6 lines
Not that I actually checked the cover letter until it failed to apply (and hence already knew what was missing) but still, please call out dependencies unless they are in the branches Dan has queued up to push.
I just want to play with Dave's fix for the RAS errors so having to jump through these other sets.
Yes, that is annoying, apologies.
Quoted 36 lines
Thanks,
Jonathan
Quoted 30 lines
Davidlohr Bueso (1):
cxl/mem: Wire up event interruptsIra Weiny (8):
PCI/CXL: Export native CXL error reporting control cxl/mem: Read, trace, and clear events on driver load cxl/mem: Trace General Media Event Record cxl/mem: Trace DRAM Event Record
cxl/mem: Trace Memory Module Event Record cxl/test: Add generic mock events
cxl/test: Add specific events
cxl/test: Simulate event log overflowdrivers/acpi/pci_root.c | 3 + drivers/cxl/core/mbox.c | 186 +++++++++++++ drivers/cxl/core/trace.h | 479 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 16 ++ drivers/cxl/cxlmem.h | 171 ++++++++++++ drivers/cxl/cxlpci.h | 6 + drivers/cxl/pci.c | 236 +++++++++++++++++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + tools/testing/cxl/test/Kbuild | 2 +- tools/testing/cxl/test/mem.c | 352 +++++++++++++++++++++++++ 11 files changed, 1452 insertions(+), 1 deletion(-)base-commit:
acb704099642bc822ef2aed223a0b8db1f7ea76e
I think going forward these base-commits need to be something that are reachable on cxl.git. For now I have pushed out a baseline for both Dave and Ira's patches to cxl/preview which will rebase after -rc1 comes out.
Just the small matter of needing some acks/reviews on those lead in patches so I can move them to through cxl/pending to cxl/next:
http://lore.kernel.org/r/167051869176.436579.9728373544811641087.stgit@dwillia2-xfh.jf.intel.com
http://lore.kernel.org/r/[email protected]
Quoted 74 lines · Dan Williams
Quoted 19 lines · Jonathan Cameron
Quoted 16 lines · On Sun, 11 Dec 2022 23:06:18 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
This code has been tested with a newer qemu which allows for more events to be returned at a time as well an additional QMP event and interrupt injection. Those patches will follow once they have been cleaned up.
The series is now in 3 parts:
1) Base functionality including interrupts
2) Tracing specific events (Dynamic Capacity Event Record is defered)
3) cxl-test infrastructure for basic testsChanges from V3
Feedback from Dan
Spit out ACPI changes for BjornQuoted 7 lines
Quoted 1 line
- Link to v3: https://lore.kernel.org/all/[email protected]/
Because I'm in a grumpy mood (as my colleagues will attest!)... This is dependent on the patch that moves the trace definitions and that's not upstream yet except in cxl/preview which is optimistic place to use for a base commit. The id isn't the one below either which isn't in either mailine or the current CXL trees.
I do not want to commit to a new baseline until after -rc1, so yes this is in a messy period.
Quoted 6 lines
Not that I actually checked the cover letter until it failed to apply (and hence already knew what was missing) but still, please call out dependencies unless they are in the branches Dan has queued up to push.
I just want to play with Dave's fix for the RAS errors so having to jump through these other sets.
Yes, that is annoying, apologies.
Quoted 34 lines
Thanks,
Jonathan
Quoted 29 lines
Davidlohr Bueso (1):
cxl/mem: Wire up event interruptsIra Weiny (8):
PCI/CXL: Export native CXL error reporting control cxl/mem: Read, trace, and clear events on driver load cxl/mem: Trace General Media Event Record cxl/mem: Trace DRAM Event Record
cxl/mem: Trace Memory Module Event Record cxl/test: Add generic mock events
cxl/test: Add specific events
cxl/test: Simulate event log overflowdrivers/acpi/pci_root.c | 3 + drivers/cxl/core/mbox.c | 186 +++++++++++++ drivers/cxl/core/trace.h | 479 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 16 ++ drivers/cxl/cxlmem.h | 171 ++++++++++++ drivers/cxl/cxlpci.h | 6 + drivers/cxl/pci.c | 236 +++++++++++++++++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + tools/testing/cxl/test/Kbuild | 2 +- tools/testing/cxl/test/mem.c | 352 +++++++++++++++++++++++++ 11 files changed, 1452 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
base-commit:
acb704099642bc822ef2aed223a0b8db1f7ea76eI think going forward these base-commits need to be something that are reachable on cxl.git.
Agreed. I thought this was in preview. But even preview is not stable and I should have waited and asked to see this land in next first.
Ira
Quoted 8 lines
For now I have pushed out a baseline for both Dave
and Ira's patches to cxl/preview which will rebase after -rc1 comes out.Just the small matter of needing some acks/reviews on those lead in patches so I can move them to through cxl/pending to cxl/next:
http://lore.kernel.org/r/167051869176.436579.9728373544811641087.stgit@dwillia2-xfh.jf.intel.com
http://lore.kernel.org/r/[email protected]
Quoted 22 lines · On Fri, 16 Dec 2022 09:01:13 -0800 Dan Williams <[email protected]>…
Quoted 21 lines · Jonathan Cameron
Quoted 17 lines · On Sun, 11 Dec 2022 23:06:18 -0800 [email protected] wrote:
From: Ira Weiny <[email protected]>
This code has been tested with a newer qemu which allows for more events to be returned at a time as well an additional QMP event and interrupt injection. Those patches will follow once they have been cleaned up.
The series is now in 3 parts:
1) Base functionality including interrupts
2) Tracing specific events (Dynamic Capacity Event Record is defered)
3) cxl-test infrastructure for basic testsChanges from V3
Feedback from Dan
Spit out ACPI changes for Bjorn- Link to v3: https://lore.kernel.org/all/[email protected]/
Quoted 8 lines
Quoted 5 lines
Because I'm in a grumpy mood (as my colleagues will attest!)... This is dependent on the patch that moves the trace definitions and that's not upstream yet except in cxl/preview which is optimistic place to use for a base commit. The id isn't the one below either which isn't in either mailine or the current CXL trees.
I do not want to commit to a new baseline until after -rc1, so yes this is in a messy period.
Fully understood. I only push trees out as 'testing' for 0-day to hit until I can rebase on rc1.
Quoted 9 lines
Quoted 7 lines
Not that I actually checked the cover letter until it failed to apply (and hence already knew what was missing) but still, please call out dependencies unless they are in the branches Dan has queued up to push.
I just want to play with Dave's fix for the RAS errors so having to jump through these other sets.
Yes, that is annoying, apologies.
Not really a problem I just felt like grumbling :)
Have a good weekend.
Jonathan
Quoted 38 lines
Quoted 37 lines
Thanks,
Jonathan
Quoted 30 lines
Davidlohr Bueso (1):
cxl/mem: Wire up event interruptsIra Weiny (8):
PCI/CXL: Export native CXL error reporting control cxl/mem: Read, trace, and clear events on driver load cxl/mem: Trace General Media Event Record cxl/mem: Trace DRAM Event Record
cxl/mem: Trace Memory Module Event Record cxl/test: Add generic mock events
cxl/test: Add specific events
cxl/test: Simulate event log overflowdrivers/acpi/pci_root.c | 3 + drivers/cxl/core/mbox.c | 186 +++++++++++++ drivers/cxl/core/trace.h | 479 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 16 ++ drivers/cxl/cxlmem.h | 171 ++++++++++++ drivers/cxl/cxlpci.h | 6 + drivers/cxl/pci.c | 236 +++++++++++++++++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + tools/testing/cxl/test/Kbuild | 2 +- tools/testing/cxl/test/mem.c | 352 +++++++++++++++++++++++++ 11 files changed, 1452 insertions(+), 1 deletion(-)base-commit:
acb704099642bc822ef2aed223a0b8db1f7ea76e
Quoted 6 lines
I think going forward these base-commits need to be something that are reachable on cxl.git. For now I have pushed out a baseline for both Dave and Ira's patches to cxl/preview which will rebase after -rc1 comes out.
Just the small matter of needing some acks/reviews on those lead in patches so I can move them to through cxl/pending to cxl/next:
Don't move too fast with Ira's. Some issues coming up in testing.. (admittedly half of them were things where QEMU hadn't kept up with what the kernel code now uses).