From: Alison Schofield <alison.schofi...@intel.com>

Events cxl_general_media and cxl_dram both report DPAs that may
be mapped in a region. If the DPA is mapped, the trace event will
include the HPA translation, region name and region uuid in the
trace event.

Add a test case that triggers these events with DPAs that map
into a region. Verify the region is included in the trace event.

Signed-off-by: Alison Schofield <alison.schofi...@intel.com>
---
 test/cxl-events.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/test/cxl-events.sh b/test/cxl-events.sh
index fe702bf98ad4..ff4f3fdff1d8 100644
--- a/test/cxl-events.sh
+++ b/test/cxl-events.sh
@@ -23,6 +23,26 @@ modprobe cxl_test
 rc=1
 
 dev_path="/sys/bus/platform/devices"
+trace_path="/sys/kernel/tracing"
+
+test_region_info()
+{
+       # Trigger a memdev in the cxl_test autodiscovered region
+       region=$($CXL list  -R | jq -r ".[] | .region")
+       memdev=$($CXL list -r "$region" --targets |
+               jq -r '.[].mappings' |
+               jq -r '.[0].memdev')
+       host=$($CXL list -m "$memdev" | jq -r '.[].host')
+
+       echo 1 > "$dev_path"/"$host"/event_trigger
+
+       if ! grep "cxl_general_media.*$region" "$trace_path"/trace; then
+               err "$LINENO"
+       fi
+       if ! grep "cxl_dram.*$region" "$trace_path"/trace; then
+               err "$LINENO"
+       fi
+}
 
 test_cxl_events()
 {
@@ -74,6 +94,10 @@ if [ "$num_info" -ne $num_info_expected ]; then
        err "$LINENO"
 fi
 
+echo 1 > /sys/kernel/tracing/tracing_on
+test_region_info
+echo 0 > /sys/kernel/tracing/tracing_on
+
 check_dmesg "$LINENO"
 
 modprobe -r cxl_test
-- 
2.37.3


Reply via email to