Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5431969rwl; Tue, 21 Mar 2023 19:15:42 -0700 (PDT) X-Google-Smtp-Source: AK7set+X3FidQnyxNaFFIjQZJuR1i+2gpfsUI8KvZhZwqU4sc3iQgmLXgh7bdB7j3hAnQ9/rJx8b X-Received: by 2002:a17:906:1ce:b0:939:5398:768e with SMTP id 14-20020a17090601ce00b009395398768emr4952220ejj.7.1679451342022; Tue, 21 Mar 2023 19:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679451342; cv=none; d=google.com; s=arc-20160816; b=tpY5nuSL1vmYS2qoHnKXjsng/Wo3PcGLKyLgMEkFPbxep590g5FolqcXQouP06TE+R uBCNWVXNBNiID46KnmSrv8dNGutH7lEwHkHy/IAj57u+n6wqZW00IYHjSSu2eBDxKd+7 0dHvrScinAXZ6Lb9xLBaezHzO8rXKyJ4IG5jcnX0IQzlRJytVqBNeH+IIImCDiDRshwX jA0lrbi73Ztk37DTeQfU00eCaHHhk4EbeQ3//SJgv299ROH14H5M0/LwB+6ed40nJWLO PgeMRn1oP/Hyy8WfbO2mj0HF/SBa1p2Heg0pV6slRN2hjCeknsHy1OaPh69vQLRXtQq4 YzYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dPrR8CQG1zdtMTUhHnXtREiHobr4MaicCwKOrzh2YOo=; b=pcmaZxFkpz8e8AL3Qcn7Ao7+3Uor0rYfrNl9APZ/eSYu1lGGRoifaJI6rB/e19ZDom TkKAew/xXwkXBDVTnrPGwXTlqD2fkH6yEKMP/lGz2pq6CsoHPseRLgUBg9awdJ3mhy6g VDrayzBf/qR8n4MaBelxvMQq59rbpTrXC2zDY3NABYyFVDouEuUSBO2RJKu2FRnsm/Mz vhIUCIAtU6av8pF15FKFWWmIT9lhDJ9e+Dtis92Zdt7EoKEGUqvLe09PEhwfX1dSrs0A 2F7VyV6pGv2mKppniTQmJXgwkTaRL1Y/0FfwufsnZ2mwjURpr80FKwMjZVh1Mk2oYS+u B15A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="g/Pk/Ofq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ty20-20020a170907c71400b009334c541c5bsi8993189ejc.102.2023.03.21.19.15.17; Tue, 21 Mar 2023 19:15:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="g/Pk/Ofq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbjCVCMi (ORCPT + 99 others); Tue, 21 Mar 2023 22:12:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbjCVCM1 (ORCPT ); Tue, 21 Mar 2023 22:12:27 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A07865A18C; Tue, 21 Mar 2023 19:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679451146; x=1710987146; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TZvFUemshfvvi/Wz6kY2Ao2MmH+K/4+eHAd1NP7Pmf4=; b=g/Pk/Ofqm09FJ+E95EQtxYw/l5b5m55ZjYW72LnzA93Eeww+oEU9aVCq ueJHNh/76wL6Bs52TW/c9QXTsc4HL+vcymaVFsRbadlnUqHD/TWU5EAWE u6Q0TIQIde1mHRQ5d4NAtS/edEijy+47pMjs7jOfvJXqSEi//nWF3isQG 4TD1/OR4qjXtArKTU+Qg/O7vDuDoxpjhCDOQigs7yKLGWO/HqG6e75Hwu wt2gLszZiOLOOg9xwmEQGyyzcMQc+0UbNvniLBn+SFHW6q+lzkAnn2uBW QYdhfuGmH9Mx1vdyITa/e3uczd55uZbIURgxPMsJnoVnUCz5oAKfBkX5U Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="401677438" X-IronPort-AV: E=Sophos;i="5.98,280,1673942400"; d="scan'208";a="401677438" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2023 19:12:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="746126854" X-IronPort-AV: E=Sophos;i="5.98,280,1673942400"; d="scan'208";a="746126854" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.251.21.85]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2023 19:12:25 -0700 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 v10 2/6] cxl/trace: Add TRACE support for CXL media-error records Date: Tue, 21 Mar 2023 19:12:15 -0700 Message-Id: X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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'. Signed-off-by: Alison Schofield Reviewed-by: Jonathan Cameron --- drivers/cxl/core/core.h | 4 ++ drivers/cxl/core/mbox.c | 5 ++- drivers/cxl/core/trace.h | 94 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index cde475e13216..e888e293943e 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -64,4 +64,8 @@ int cxl_memdev_init(void); void cxl_memdev_exit(void); void cxl_mbox_init(void); +enum cxl_poison_trace_type { + CXL_POISON_TRACE_LIST, +}; + #endif /* __CXL_CORE_H__ */ diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 0da0a30511f2..a8369ef56f61 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1147,7 +1147,10 @@ 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, + CXL_POISON_TRACE_LIST); /* 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 9b8d3d997834..2ebfa55c31a8 100644 --- a/drivers/cxl/core/trace.h +++ b/drivers/cxl/core/trace.h @@ -7,10 +7,12 @@ #define _CXL_EVENTS_H #include +#include #include #include #include +#include "core.h" #define CXL_RAS_UC_CACHE_DATA_PARITY BIT(0) #define CXL_RAS_UC_CACHE_ADDR_PARITY BIT(1) @@ -600,6 +602,98 @@ TRACE_EVENT(cxl_memory_module, ) ); +#define show_poison_trace_type(type) \ + __print_symbolic(type, \ + { CXL_POISON_TRACE_LIST, "LIST" }) + +#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_dpa_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) + +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, enum cxl_poison_trace_type type), + + TP_ARGS(cxlmd, region, record, flags, overflow_t, type), + + TP_STRUCT__entry( + __string(memdev, dev_name(&cxlmd->dev)) + __string(host, dev_name(cxlmd->dev.parent)) + __field(u64, serial) + __field(u8, type) + __string(region, region) + __field(u64, overflow_t) + __field(u64, dpa) + __field(u32, dpa_length) + __array(char, uuid, 16) + __field(u8, source) + __field(u8, flags) + ), + + TP_fast_assign( + __assign_str(memdev, dev_name(&cxlmd->dev)); + __assign_str(host, dev_name(cxlmd->dev.parent)); + __entry->serial = cxlmd->cxlds->serial; + __entry->overflow_t = cxl_poison_overflow(flags, overflow_t); + __entry->dpa = cxl_poison_record_dpa(record); + __entry->dpa_length = cxl_poison_record_dpa_length(record); + __entry->source = cxl_poison_record_source(record); + __entry->type = type; + __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 host=%s serial=%lld type=%s region=%s " \ + "region_uuid=%pU hpa=0x%llx dpa=0x%llx dpa_length=0x%x "\ + "source=%s flags=%s overflow_time=%llu", + __get_str(memdev), + __get_str(host), + __entry->serial, + show_poison_trace_type(__entry->type), + __get_str(region), + __entry->uuid, + __entry->dpa, + __entry->dpa_length, + show_poison_source(__entry->source), + show_poison_flags(__entry->flags), + __entry->overflow_t + ) +); + #endif /* _CXL_EVENTS_H */ #define TRACE_INCLUDE_FILE trace -- 2.37.3