Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1022376lqo; Fri, 17 May 2024 08:28:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8Wnbd4e313uHFJZpUfEmYXaOaTqPd+JD2FmKQo2Nh4kGkFGVktjF64H9ddre0M0f3mydg3M673VPa03QbF6w1zkrDbsdeNP7Z0DJ5bA== X-Google-Smtp-Source: AGHT+IGnuNbAHpPKnaPmU8v1gKYyMc2b554i7QdrvqGhX+kfalAgmzECr29ZChzEy2gvExwWpeb3 X-Received: by 2002:a17:90b:3715:b0:2b3:9ce8:1239 with SMTP id 98e67ed59e1d1-2b6cc1438dbmr19833289a91.6.1715959734790; Fri, 17 May 2024 08:28:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715959734; cv=pass; d=google.com; s=arc-20160816; b=TAIyxK1Bf+drnmjLxKvMb+i8a+hafeT/2T740CbyQas1sIxDFyu3aKp9qsA30KxNg7 34ahf3hOSsPX+QeWeCaCgoXCHwF5AA9P/Lmbmzip9EtT1Eippjks9MR4IM/EwEiHJ3KT AlbGiDe5ON5DgDOECCkRdYdho+XT6PuiiOryucs+MrojAQO0PQyjEa2wrpBg4veLUwP2 KATy3965FLZyPaIlQA3b2xTTs+UbI9knWfyr0kwigXm6KfNsCCcBbLIlniYNggAIvqBQ 519n8mrj+Hon/tznWHSpY0FYysfGNqzyYpzD5negPD5Z42Lwt478KxaUSIA7RDRWxTap OufQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bmKu0kqqmznkjcc3/CALDEAeF8ln+y7W7adYxVl6kzA=; fh=LYYCpA3IWkujkzyA12eFNF7q/Xr4FiW1umPZh3PiG5c=; b=AQe1vsNGK7tdEq5yfimHhms551nxx50vUR7/DZjSXtYQ2atGNU6/h87ZX7eD1GZwv7 XRzWxJS7BFLTH4eAGE/M5ZuXhpcCXYfwadACYnbnPE5pWF7EPwsgrZ+fu4+GhxPmvkFA l+Xk27qPFXcSwWsQy3Ll3T10PujytyIwhr8ERC4n9szqadHh3nPgcEMEnN5BF8QYNUqC UgKeuehDeU+ZStj+Imz1oo2IbVEaKO+uU1lNHLMHCRgvyvy7dJwddGz95/gyDaKbm6v9 Blk90HHNYOcMiChXOMj8GiqCCzBHAxyKEbkrT667UgPF1xGtIDan3M0wT1ZXqIIQjyuS NiHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KlU2OuBo; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-182130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182130-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628a5d820si3010423a91.75.2024.05.17.08.28.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 08:28:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KlU2OuBo; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-182130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182130-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9D49BB2229E for ; Fri, 17 May 2024 13:07:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D06B502A1; Fri, 17 May 2024 13:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KlU2OuBo" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 C05224F1E4; Fri, 17 May 2024 13:07:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715951231; cv=none; b=LgfnG3sRFA6m+l795XzNl16Djq7nGnbl+K0ekzwHHxFeNqmsnVMe2l3wpPSVwZQWqWR5bssZTYxT62IpFjIub/GjCNeLQmf1sxe7mgByswCQlg9qMUanbjOCasCcKzs2xHkRJRhazFRZOe2q2Wo7zMiBouuuhD5LDyWARzlSjxM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715951231; c=relaxed/simple; bh=E8NIBmhuXkQWY9tdw0NTb9s7Ylgh7bn9fuNNOGVJNic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rSQ/xjI/yZETQFG1N8V8r24v/ADgHFDpir9zWIyeaz7jrOxjVeYPod2OqegwuK1z0togVsimBbzEJeZUtF+UUNYgUMrhld8ww8E+BKh0Czd6Lyuq/jCRkv6fyno/MJX9R509UTPPM9oxRszGzsq2juYNVJOn+V49WhEEwoc2f5k= 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=KlU2OuBo; arc=none smtp.client-ip=198.175.65.12 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=1715951230; x=1747487230; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E8NIBmhuXkQWY9tdw0NTb9s7Ylgh7bn9fuNNOGVJNic=; b=KlU2OuBouO9TmBila2MRLVTaNBVPuDvos4Mp5tvCUGkEGB0Qi2+wfoQx Zx0aFmYmUZrhE8a08MzNsdo44p0SeutP8sqNmb3cfKlCZdWKbvjvj33z5 QMfjCwuNtOOZomrIlhgLUH9cvGgqJ5q3toNQbG0pSGkQm4w+Ag/onvKbP X+6aiOaFeBi2ZEXk6ip49FcfLyykrR9+Suwzvr2gsUUrXrvg3RjffC08y s2YZDZBbcI+4hHE8TodaAR8wqqr6FV75l2QU/Pup9T5wJpdVH8a2P39dc Q0JsA8lWUpEpb+adg8389IIrsf+ZEKns89iGjVh2ovg78dm1xIr9tpzU5 Q==; X-CSE-ConnectionGUID: 5S/0eS+VRjOBj7mNU0lCLQ== X-CSE-MsgGUID: Yp+zmC1uRUqbpl0Fl4hsig== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="23527149" X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="23527149" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 06:07:09 -0700 X-CSE-ConnectionGUID: xtTZ3099SYu2icluC7wbcg== X-CSE-MsgGUID: X+CWfPMdS3S1PjrlrEneAA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="32333302" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.localnet) ([10.245.246.21]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 06:07:06 -0700 From: "Fabio M. De Francesco" To: Ira Weiny , Ira Weiny Cc: Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Dan Williams , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cxl/events: Use a common struct for DRAM and General Media events Date: Fri, 17 May 2024 15:07:02 +0200 Message-ID: <5789047.t9SDvczpPo@fdefranc-mobl3> In-Reply-To: <66467b8b47170_8c79294b3@iweiny-mobl.notmuch> References: <20240515190512.3480817-1-fabio.m.de.francesco@linux.intel.com> <66467b8b47170_8c79294b3@iweiny-mobl.notmuch> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Thursday, May 16, 2024 11:32:59=E2=80=AFPM GMT+2 Ira Weiny wrote: > Fabio M. De Francesco wrote: > > Use cxl_event_media as a common structure to record information about D= RAM > > and General Media events because it simplifies handling the two events. > >=20 > > Suggested-by: Dan Williams > > Signed-off-by: Fabio M. De Francesco > > > > --- > >=20 > > drivers/cxl/core/mbox.c | 6 ++-- > > drivers/cxl/core/trace.h | 4 +-- > > include/linux/cxl-event.h | 70 +++++++++++++++--------------------- > > tools/testing/cxl/test/mem.c | 4 +-- > > 4 files changed, 36 insertions(+), 48 deletions(-) >=20 > Other than saving 12 lines of code what are we saving with this change? > > The addition of media_common implies an additional event type which is not > in the specification. (perhaps confusing future contributors?) And the > code is more complex to follow. The decode of the phys_addr field is not > simplified (which IIRC was the point of this idea.) > > I'm probably being dense but I just don't see the need for the > struct_group complexity here. >=20 > Ira Ira, I think you are right, there is no need for struct_group here and this code= is=20 unnecessarily complex. Anyway, for the next version, I'll use the simpler solution showed by Dan i= n=20 his comment on v2. Thanks, =46abio =20 >=20 > > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c > > index 2626f3fff201..ad4d7b0f7f4d 100644 > > --- a/drivers/cxl/core/mbox.c > > +++ b/drivers/cxl/core/mbox.c > > @@ -875,16 +875,16 @@ void cxl_event_trace_record(const struct cxl_memd= ev > > *cxlmd,>=20 > > guard(rwsem_read)(&cxl_region_rwsem); > > guard(rwsem_read)(&cxl_dpa_rwsem); > >=20 > > - dpa =3D le64_to_cpu(evt->common.phys_addr) &=20 CXL_DPA_MASK; > > + dpa =3D le64_to_cpu(evt->media_common.phys_addr) &=20 CXL_DPA_MASK; > >=20 > > cxlr =3D cxl_dpa_to_region(cxlmd, dpa); > > if (cxlr) > > =09 > > hpa =3D cxl_trace_hpa(cxlr, cxlmd, dpa); > > =09 > > if (event_type =3D=3D CXL_CPER_EVENT_GEN_MEDIA) > > =09 > > trace_cxl_general_media(cxlmd, type, cxlr,=20 hpa, > >=20 > > - &evt- >gen_media); > > + &evt- >media_general); > >=20 > > else if (event_type =3D=3D CXL_CPER_EVENT_DRAM) > >=20 > > - trace_cxl_dram(cxlmd, type, cxlr, hpa, &evt- >dram); > > + trace_cxl_dram(cxlmd, type, cxlr, hpa, &evt- >media_dram); > >=20 > > } > > =20 > > } > > EXPORT_SYMBOL_NS_GPL(cxl_event_trace_record, CXL); > >=20 > > diff --git a/drivers/cxl/core/trace.h b/drivers/cxl/core/trace.h > > index 07a0394b1d99..2c7293761bb2 100644 > > --- a/drivers/cxl/core/trace.h > > +++ b/drivers/cxl/core/trace.h > > @@ -316,7 +316,7 @@ TRACE_EVENT(cxl_generic_event, > >=20 > > TRACE_EVENT(cxl_general_media, > > =20 > > TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type=20 log, > >=20 > > - struct cxl_region *cxlr, u64 hpa, struct=20 cxl_event_gen_media *rec), > > + struct cxl_region *cxlr, u64 hpa, struct=20 cxl_event_media *rec), > >=20 > > TP_ARGS(cxlmd, log, cxlr, hpa, rec), > >=20 > > @@ -413,7 +413,7 @@ TRACE_EVENT(cxl_general_media, > >=20 > > TRACE_EVENT(cxl_dram, > > =20 > > TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type=20 log, > >=20 > > - struct cxl_region *cxlr, u64 hpa, struct=20 cxl_event_dram *rec), > > + struct cxl_region *cxlr, u64 hpa, struct=20 cxl_event_media *rec), > >=20 > > TP_ARGS(cxlmd, log, cxlr, hpa, rec), > >=20 > > diff --git a/include/linux/cxl-event.h b/include/linux/cxl-event.h > > index 60b25020281f..e417556cc120 100644 > > --- a/include/linux/cxl-event.h > > +++ b/include/linux/cxl-event.h > > @@ -32,41 +32,38 @@ struct cxl_event_generic { > >=20 > > * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 > > */ > > =20 > > #define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10 > >=20 > > -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; > > - > >=20 > > /* > > =20 > > * DRAM Event Record - DER > > * CXL rev 3.0 section 8.2.9.2.1.2; Table 3-44 > > */ > > =20 > > #define CXL_EVENT_DER_CORRECTION_MASK_SIZE 0x20 > >=20 > > -struct cxl_event_dram { > > +struct cxl_event_media { > >=20 > > struct cxl_event_record_hdr hdr; > >=20 > > - __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]; > > + struct_group_tagged(cxl_event_media_hdr, media_hdr, > > + __le64 phys_addr; > > + u8 descriptor; > > + u8 type; > > + u8 transaction_type; > > + u8 validity_flags[2]; > > + u8 channel; > > + u8 rank; > > + ); > > + union { > > + struct_group(general, > > + u8 device[3]; > > + u8=20 component_id[CXL_EVENT_GEN_MED_COMP_ID_SIZE]; > > + u8 gen_reserved[46]; > > + ); > > + struct_group(dram, > > + u8 nibble_mask[3]; > > + u8 bank_group; > > + u8 bank; > > + u8 row[3]; > > + u8 column[2]; > > + u8=20 correction_mask[CXL_EVENT_DER_CORRECTION_MASK_SIZE]; > > + u8 dram_reserved[0x17]; > > + ); > > + }; > >=20 > > } __packed; > > =20 > > /* > >=20 > > @@ -95,21 +92,12 @@ struct cxl_event_mem_module { > >=20 > > u8 reserved[0x3d]; > > =20 > > } __packed; > >=20 > > -/* > > - * 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; > > - > >=20 > > union cxl_event { > > =20 > > struct cxl_event_generic generic; > >=20 > > - struct cxl_event_gen_media gen_media; > > - struct cxl_event_dram dram; > > + struct cxl_event_media media_general; > > + struct cxl_event_media media_dram; > >=20 > > struct cxl_event_mem_module mem_module; > >=20 > > - struct cxl_event_common common; > > + struct cxl_event_media media_common; > >=20 > > } __packed; > > =20 > > /* > >=20 > > diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c > > index 6584443144de..0a8fd145c391 100644 > > --- a/tools/testing/cxl/test/mem.c > > +++ b/tools/testing/cxl/test/mem.c > > @@ -378,7 +378,7 @@ struct cxl_event_record_raw hardware_replace =3D { > >=20 > > struct cxl_test_gen_media { > > =20 > > uuid_t id; > >=20 > > - struct cxl_event_gen_media rec; > > + struct cxl_event_media rec; > >=20 > > } __packed; > > =20 > > struct cxl_test_gen_media gen_media =3D { > >=20 > > @@ -402,7 +402,7 @@ struct cxl_test_gen_media gen_media =3D { > >=20 > > struct cxl_test_dram { > > =20 > > uuid_t id; > >=20 > > - struct cxl_event_dram rec; > > + struct cxl_event_media rec; > >=20 > > } __packed; > > =20 > > struct cxl_test_dram dram =3D {