From patchwork Thu Feb 9 23:32:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13135202 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A6F4C05027 for ; Thu, 9 Feb 2023 23:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbjBIXfc (ORCPT ); Thu, 9 Feb 2023 18:35:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbjBIXfW (ORCPT ); Thu, 9 Feb 2023 18:35:22 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59ED36D8DB; Thu, 9 Feb 2023 15:34:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675985695; x=1707521695; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T968P/FAEe6VKnvmjVp5xmKSUqYceyzzdlU0Og/7JsY=; b=n89/G/28vyQnspx5kkDccJVu6kFBstTCwHlxvd8YVezfpae7snxcNKMT bAodr0HJt7zVaikrFy7VE4w8tXGBsPz9XLrpVmfoSBWadgbbWXgehD51d q3RoKzCDFaySIYa1ZuqKGHf0azWg7xM2Kyja/mPYg3zzT7nO6RMl6o2Ie hITY0i9CykjHRnz42aVTLrYhemWlTxvXtnuCS9kP2STFzygZ6DTyDYkgZ DBzQGLoO0FbImwMsfdgS9lLfvdGIAFbwO8gxEwEduaFc9iDm4cUA9qguQ D9UtIgKNNrQ99dQ5n465WUjbKggibbYyKNUdlBiR0v5Nf0CGwsRVSOCuH w==; X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="416508716" X-IronPort-AV: E=Sophos;i="5.97,285,1669104000"; d="scan'208";a="416508716" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2023 15:33:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="756592035" X-IronPort-AV: E=Sophos;i="5.97,285,1669104000"; d="scan'208";a="756592035" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.13.232]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2023 15:33:05 -0800 From: alison.schofield@intel.com To: Dan Williams , Ira Weiny , Vishal Verma , Dave Jiang , Ben Widawsky , Steven Rostedt Cc: Alison Schofield , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron Subject: [PATCH v6 2/6] cxl/trace: Add TRACE support for CXL media-error records Date: Thu, 9 Feb 2023 15:32:55 -0800 Message-Id: <4cf3efce0cfe76930a3b3e427a121acd9f8964e4.1675983077.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Alison Schofield CXL devices may support the retrieval of a device poison list. Add a new trace event that the CXL subsystem may use to log the media-error records returned in the poison list. Log each media-error record as a trace event of type 'cxl_poison'. Reviewed-by: Jonathan Cameron Signed-off-by: Alison Schofield --- drivers/cxl/core/mbox.c | 4 +- drivers/cxl/core/trace.h | 85 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index a57de8896846..131ee336b69e 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1142,7 +1142,9 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len, if (rc) break; - /* TODO TRACE the media error records */ + for (int i = 0; i < le16_to_cpu(po->count); i++) + trace_cxl_poison(cxlmd, cxlr, &po->record[i], + po->flags, po->overflow_t); /* Protect against an uncleared _FLAG_MORE */ nr_records = nr_records + le16_to_cpu(po->count); diff --git a/drivers/cxl/core/trace.h b/drivers/cxl/core/trace.h index c72ef9321cfe..c493955719ce 100644 --- a/drivers/cxl/core/trace.h +++ b/drivers/cxl/core/trace.h @@ -7,6 +7,7 @@ #define _CXL_EVENTS_H #include +#include #include #include @@ -581,6 +582,90 @@ TRACE_EVENT(cxl_memory_module, ) ); +#define __show_poison_source(source) \ + __print_symbolic(source, \ + { CXL_POISON_SOURCE_UNKNOWN, "Unknown" }, \ + { CXL_POISON_SOURCE_EXTERNAL, "External" }, \ + { CXL_POISON_SOURCE_INTERNAL, "Internal" }, \ + { CXL_POISON_SOURCE_INJECTED, "Injected" }, \ + { CXL_POISON_SOURCE_VENDOR, "Vendor" }) + +#define show_poison_source(source) \ + (((source > CXL_POISON_SOURCE_INJECTED) && \ + (source != CXL_POISON_SOURCE_VENDOR)) ? "Reserved" \ + : __show_poison_source(source)) + +#define show_poison_flags(flags) \ + __print_flags(flags, "|", \ + { CXL_POISON_FLAG_MORE, "More" }, \ + { CXL_POISON_FLAG_OVERFLOW, "Overflow" }, \ + { CXL_POISON_FLAG_SCANNING, "Scanning" }) + +#define __cxl_poison_addr(record) \ + (le64_to_cpu(record->address)) +#define cxl_poison_record_dpa(record) \ + (__cxl_poison_addr(record) & CXL_POISON_START_MASK) +#define cxl_poison_record_source(record) \ + (__cxl_poison_addr(record) & CXL_POISON_SOURCE_MASK) +#define cxl_poison_record_length(record) \ + (le32_to_cpu(record->length) * CXL_POISON_LEN_MULT) +#define cxl_poison_overflow(flags, time) \ + (flags & CXL_POISON_FLAG_OVERFLOW ? le64_to_cpu(time) : 0) +#define cxl_poison_host_name(cxlmd) \ + (dev_name(cxlmd->dev.parent)) + +TRACE_EVENT(cxl_poison, + + TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *region, + const struct cxl_poison_record *record, + u8 flags, __le64 overflow_t), + + TP_ARGS(cxlmd, region, record, flags, overflow_t), + + TP_STRUCT__entry( + __string(memdev, dev_name(&cxlmd->dev)) + __string(host, cxl_poison_host_name(cxlmd)) + __field(u64, serial) + __string(region, region) + __field(u64, overflow_t) + __field(u64, dpa) + __field(u32, length) + __array(char, uuid, 16) + __field(u8, source) + __field(u8, flags) + ), + + TP_fast_assign( + __assign_str(memdev, dev_name(&cxlmd->dev)); + __assign_str(host, cxl_poison_host_name(cxlmd)); + __entry->serial = cxlmd->cxlds->serial; + __entry->overflow_t = cxl_poison_overflow(flags, overflow_t); + __entry->dpa = cxl_poison_record_dpa(record); + __entry->length = cxl_poison_record_length(record); + __entry->source = cxl_poison_record_source(record); + __entry->flags = flags; + if (region) { + __assign_str(region, dev_name(®ion->dev)); + memcpy(__entry->uuid, ®ion->params.uuid, 16); + } else { + __assign_str(region, ""); + memset(__entry->uuid, 0, 16); + } + ), + + TP_printk("memdev=%s serial=%llu host=%s region=%s region_uuid=%pU dpa=0x%llx length=0x%x source=%s flags=%s overflow_time=%llu", + __get_str(memdev), + __entry->serial, + __get_str(host), + __get_str(region), + __entry->uuid, + __entry->dpa, + __entry->length, + show_poison_source(__entry->source), + show_poison_flags(__entry->flags), + __entry->overflow_t) +); + #endif /* _CXL_EVENTS_H */ #define TRACE_INCLUDE_FILE trace