Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3106036lqo; Tue, 21 May 2024 07:08:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbeyNtYonqdV5ycs7fyR0Knu9X2wMnhRto3DGCDEj/LhgZ+dumnqMgv8nVbAUtESLROrZ2GpRdkclqYyyOIjsIMCKIYKLn7tJdbu1mxw== X-Google-Smtp-Source: AGHT+IE73KPbrd1/vqsrtfFiZ0kQESleNc+hyKZr6Q+R1ECKoLs0+mLyvDd0Rbf9uOsFfwTx2cMf X-Received: by 2002:a17:906:7011:b0:a59:a895:3ee with SMTP id a640c23a62f3a-a5a2d5cca0fmr2096003866b.45.1716300493889; Tue, 21 May 2024 07:08:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716300493; cv=pass; d=google.com; s=arc-20160816; b=0uFcaM2hh/jEvClQgd/O5Wv7bzQOi3Bhs5zjuXQeLQrU8UVcOXQn87Z2cgldGhPHL6 TO1r/frn3Em0Zgi/FdAJn7zeJ3gCv2UZX15SYnRnZ6TXFaygKpCqVHHqTtcpzDG7wNxD hpPCciPap09y488O/Og+gB/5cPai++Zpa/hnY8mqjsayQoUoJ3G1RhtRCXGpitpyA0uE L8P5ojbpbb/6fmb5WcAWddcTtjacCSQIZrQhu8adUrmxaMabpcwi+DpaLiNACuTu+Dyd iAUVbFXXlchuMKnwX8cw3TLmpnZoysLAT9WZIQCxtfYwoeOXb5Ogx8OH/VT8346BT3OZ izfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=PXfBxiMZmV1Ksu8TuT4GK5f503JAaczNg/ZJSNpUf4I=; fh=d4WNuHy9pcJ+piD+CaT8A6phUGOCN8b9Km6TiVlQE0U=; b=n2J5JfcqYOmpYHY4xLXA2MaYPXMcVwXoB1ZbiyTqJuhRC1/wMPl0RsFZbR6RoVFHGi 0p5vaTMHo0EOWmXz0yqRn587EeCYDU+dsPFHNBrtFd1E4EMYKj7c5qZfCVV14qzQG72+ CvAnscYglZqAcgcMkxYAXVx392ZBCAe9FO/b9d3iBb4MhpRPAla9LOKrrubyX1gUjpSV aqRFiMSvhVkfJ43F/7KlzHyithd2THWNMFYHkn2fh8fKKrvEny3DGDLtzoSdHwU28jQd 4xaw14n9cqNv9rhnH+3guqU93in5cvjgFhZJTVtxBMLUGCBcmoO6He9yHcm2KPo5fUmv 0ryg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="lRf7c/mA"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-185063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a5d844e6dsi1103075866b.452.2024.05.21.07.08.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 07:08:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="lRf7c/mA"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-185063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 75E0F1F23368 for ; Tue, 21 May 2024 14:08:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 872087F7C5; Tue, 21 May 2024 14:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lRf7c/mA" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 919EB7F48C; Tue, 21 May 2024 14:08:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716300484; cv=none; b=qpNsJ+RQHjIMJ9fY9ZVT1R1iFgMDWta5AFWcr/RqUvZ103pxDlvXDe+WYpvwGRJfOB48Hmp/+XrDjFlZqhlh8rvrRvPt9vpwQkTJVeTmQE8mJa6RZO7G2xWt6CEwvzFDJnTtuUG4vPDWp6fkdYceaO8lGv47a9Gl4gb2RLFq/34= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716300484; c=relaxed/simple; bh=tRs3Xc3i+74zhh0Ksrv2C+PgqwtmV5gpBRlD2RbhUis=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eJ28bhGaVHlvLFQ7r5LoXyIykuKMPdczas6ZOFAfam8d52XPBV481YkfewjWMXmAKuutCO1rdDrC/67IPrJ9L65unLxSG8ptN30AB84MwQWM3YK9MLg24JWBUCDKxXnU8D6YF2lpQHkJ6hlJ2MMh6MsuWyOnadcozBW84+hiKNM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lRf7c/mA; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716300482; x=1747836482; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tRs3Xc3i+74zhh0Ksrv2C+PgqwtmV5gpBRlD2RbhUis=; b=lRf7c/mA5e20C/QIfS7AFVKZCIKMZQdeAEZ0BGuTeUTzvsxCqxi+GtEF FZ18AOEAk47ZGw/NRCvu0oOFzqoqHyLPrvexnsDf/Oiw6REL5hkNrl5br iIQqgem/n7mO4AYwogv/vMKxprQB7lJ9r3eHNmr2o/85TjfAEFTu/HE3N s3Jdxlb1HJGekhOS9XVY6TuGosVugm/yXtO6TuJhFpPLPD+9iUWxOoFIX jZUzpeE0dmZStPws8ARe33QZFYj51JB7H+5GcPIbKK37x1h66axsF5eGk sdbzQKMx4F5Ro8raBAnzSYGe6zlWfDMsGxXA6Gogmep3CUxzWyH1cmgus g==; X-CSE-ConnectionGUID: OpnEGWRyRjC9oIeUW7qrQQ== X-CSE-MsgGUID: CQ1hmVJSR/KgsC4Fk1wOdQ== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12288021" X-IronPort-AV: E=Sophos;i="6.08,178,1712646000"; d="scan'208";a="12288021" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 07:08:01 -0700 X-CSE-ConnectionGUID: Egn6sZOnRNaHLxP1HXoXZA== X-CSE-MsgGUID: fk/Q2vykRby0dZWSBRpCDA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,178,1712646000"; d="scan'208";a="33487386" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.intel.com) ([10.245.246.183]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 07:07:58 -0700 From: "Fabio M. De Francesco" To: Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" Subject: [PATCH v4] cxl/events: Use a common struct for DRAM and General Media events Date: Tue, 21 May 2024 16:05:08 +0200 Message-ID: <20240521140750.26035-1-fabio.m.de.francesco@linux.intel.com> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit cxl_event_common was an unfortunate naming choice and caused confusion with the existing Common Event Record. Furthermore, its fields didn't map all the common information between DRAM and General Media Events. Remove cxl_event_common and introduce cxl_event_media_hdr to record common information between DRAM and General Media events. cxl_event_media_hdr, which is embedded in both cxl_event_gen_media and cxl_event_dram, leverages the commonalities between the two events to simplify their respective handling. Suggested-by: Dan Williams Signed-off-by: Fabio M. De Francesco --- - Changes for v4 - - Initialise cxl_test_dram and cxl_test_gen_media without unnecessary extra de-references (Dan) - Add a comment for media_hdr in union cxl_event (Alison) - Changes for v3 - - Rework the layout of cxl_event_dram and cxl_event_gen_media to make a simpler change (Dan) - Remove a "Fixes" tag (Dan) - Don't use unnecessary struct_group[_tagged] (Jonathan, Ira) - Rewrite end extend the commit message - Link to v3 - https://lore.kernel.org/linux-cxl/20240518113317.3683718-1-fabio.m.de.francesco@linux.intel.com/ drivers/cxl/core/mbox.c | 2 +- drivers/cxl/core/trace.h | 32 ++++++++++----------- include/linux/cxl-event.h | 41 ++++++++++----------------- tools/testing/cxl/test/mem.c | 54 +++++++++++++++++++----------------- 4 files changed, 61 insertions(+), 68 deletions(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 2626f3fff201..a08f050cc1ca 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -875,7 +875,7 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd, guard(rwsem_read)(&cxl_region_rwsem); guard(rwsem_read)(&cxl_dpa_rwsem); - dpa = le64_to_cpu(evt->common.phys_addr) & CXL_DPA_MASK; + dpa = le64_to_cpu(evt->media_hdr.phys_addr) & CXL_DPA_MASK; cxlr = cxl_dpa_to_region(cxlmd, dpa); if (cxlr) hpa = cxl_trace_hpa(cxlr, cxlmd, dpa); diff --git a/drivers/cxl/core/trace.h b/drivers/cxl/core/trace.h index 07a0394b1d99..5a76f94accf4 100644 --- a/drivers/cxl/core/trace.h +++ b/drivers/cxl/core/trace.h @@ -340,23 +340,23 @@ TRACE_EVENT(cxl_general_media, ), TP_fast_assign( - CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); + CXL_EVT_TP_fast_assign(cxlmd, log, rec->media_hdr.hdr); __entry->hdr_uuid = CXL_EVENT_GEN_MEDIA_UUID; /* General Media */ - __entry->dpa = le64_to_cpu(rec->phys_addr); + __entry->dpa = le64_to_cpu(rec->media_hdr.phys_addr); __entry->dpa_flags = __entry->dpa & CXL_DPA_FLAGS_MASK; /* Mask after flags have been parsed */ __entry->dpa &= CXL_DPA_MASK; - __entry->descriptor = rec->descriptor; - __entry->type = rec->type; - __entry->transaction_type = rec->transaction_type; - __entry->channel = rec->channel; - __entry->rank = rec->rank; + __entry->descriptor = rec->media_hdr.descriptor; + __entry->type = rec->media_hdr.type; + __entry->transaction_type = rec->media_hdr.transaction_type; + __entry->channel = rec->media_hdr.channel; + __entry->rank = rec->media_hdr.rank; __entry->device = get_unaligned_le24(rec->device); memcpy(__entry->comp_id, &rec->component_id, CXL_EVENT_GEN_MED_COMP_ID_SIZE); - __entry->validity_flags = get_unaligned_le16(&rec->validity_flags); + __entry->validity_flags = get_unaligned_le16(&rec->media_hdr.validity_flags); __entry->hpa = hpa; if (cxlr) { __assign_str(region_name, dev_name(&cxlr->dev)); @@ -440,19 +440,19 @@ TRACE_EVENT(cxl_dram, ), TP_fast_assign( - CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); + CXL_EVT_TP_fast_assign(cxlmd, log, rec->media_hdr.hdr); __entry->hdr_uuid = CXL_EVENT_DRAM_UUID; /* DRAM */ - __entry->dpa = le64_to_cpu(rec->phys_addr); + __entry->dpa = le64_to_cpu(rec->media_hdr.phys_addr); __entry->dpa_flags = __entry->dpa & CXL_DPA_FLAGS_MASK; __entry->dpa &= CXL_DPA_MASK; - __entry->descriptor = rec->descriptor; - __entry->type = rec->type; - __entry->transaction_type = rec->transaction_type; - __entry->validity_flags = get_unaligned_le16(rec->validity_flags); - __entry->channel = rec->channel; - __entry->rank = rec->rank; + __entry->descriptor = rec->media_hdr.descriptor; + __entry->type = rec->media_hdr.type; + __entry->transaction_type = rec->media_hdr.transaction_type; + __entry->validity_flags = get_unaligned_le16(rec->media_hdr.validity_flags); + __entry->channel = rec->media_hdr.channel; + __entry->rank = rec->media_hdr.rank; __entry->nibble_mask = get_unaligned_le24(rec->nibble_mask); __entry->bank_group = rec->bank_group; __entry->bank = rec->bank; diff --git a/include/linux/cxl-event.h b/include/linux/cxl-event.h index 60b25020281f..1119d0bbb091 100644 --- a/include/linux/cxl-event.h +++ b/include/linux/cxl-event.h @@ -21,6 +21,17 @@ struct cxl_event_record_hdr { u8 reserved[15]; } __packed; +struct cxl_event_media_hdr { + struct cxl_event_record_hdr hdr; + __le64 phys_addr; + u8 descriptor; + u8 type; + u8 transaction_type; + u8 validity_flags[2]; + u8 channel; + u8 rank; +} __packed; + #define CXL_EVENT_RECORD_DATA_LENGTH 0x50 struct cxl_event_generic { struct cxl_event_record_hdr hdr; @@ -33,14 +44,7 @@ struct cxl_event_generic { */ #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; + struct cxl_event_media_hdr media_hdr; u8 device[3]; u8 component_id[CXL_EVENT_GEN_MED_COMP_ID_SIZE]; u8 reserved[46]; @@ -52,14 +56,7 @@ struct cxl_event_gen_media { */ #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; + struct cxl_event_media_hdr media_hdr; u8 nibble_mask[3]; u8 bank_group; u8 bank; @@ -95,21 +92,13 @@ struct cxl_event_mem_module { u8 reserved[0x3d]; } __packed; -/* - * General Media or DRAM Event Common Fields - * - provides common access to phys_addr - */ -struct cxl_event_common { - struct cxl_event_record_hdr hdr; - __le64 phys_addr; -} __packed; - union cxl_event { struct cxl_event_generic generic; struct cxl_event_gen_media gen_media; struct cxl_event_dram dram; struct cxl_event_mem_module mem_module; - struct cxl_event_common common; + /* dram & gen_media event header */ + struct cxl_event_media_hdr media_hdr; } __packed; /* diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c index 6584443144de..142333e63cdf 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -384,19 +384,21 @@ struct cxl_test_gen_media { struct cxl_test_gen_media gen_media = { .id = CXL_EVENT_GEN_MEDIA_UUID, .rec = { - .hdr = { - .length = sizeof(struct cxl_test_gen_media), - .flags[0] = CXL_EVENT_RECORD_FLAG_PERMANENT, - /* .handle = Set dynamically */ - .related_handle = cpu_to_le16(0), + .media_hdr = { + .hdr = { + .length = sizeof(struct cxl_test_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 = */ + .channel = 1, + .rank = 30, }, - .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 = */ - .channel = 1, - .rank = 30 }, }; @@ -408,18 +410,20 @@ struct cxl_test_dram { struct cxl_test_dram dram = { .id = CXL_EVENT_DRAM_UUID, .rec = { - .hdr = { - .length = sizeof(struct cxl_test_dram), - .flags[0] = CXL_EVENT_RECORD_FLAG_PERF_DEGRADED, - /* .handle = Set dynamically */ - .related_handle = cpu_to_le16(0), + .media_hdr = { + .hdr = { + .length = sizeof(struct cxl_test_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 = */ + .channel = 1, }, - .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 = */ - .channel = 1, .bank_group = 5, .bank = 2, .column = {0xDE, 0xAD}, @@ -473,11 +477,11 @@ static int mock_set_timestamp(struct cxl_dev_state *cxlds, 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.rec.validity_flags); + &gen_media.rec.media_hdr.validity_flags); put_unaligned_le16(CXL_DER_VALID_CHANNEL | CXL_DER_VALID_BANK_GROUP | CXL_DER_VALID_BANK | CXL_DER_VALID_COLUMN, - &dram.rec.validity_flags); + &dram.rec.media_hdr.validity_flags); mes_add_event(mes, CXL_EVENT_TYPE_INFO, &maint_needed); mes_add_event(mes, CXL_EVENT_TYPE_INFO, -- 2.45.1