Linux CXL
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fabio.m.de.francesco@linux.intel.com>
To: Ira Weiny <ira.weiny@intel.com>, Ira Weiny <ira.weiny@intel.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	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	[thread overview]
Message-ID: <5789047.t9SDvczpPo@fdefranc-mobl3> (raw)
In-Reply-To: <66467b8b47170_8c79294b3@iweiny-mobl.notmuch>

On Thursday, May 16, 2024 11:32:59 PM GMT+2 Ira Weiny wrote:
> Fabio M. De Francesco wrote:
> > Use cxl_event_media as a common structure to record information about DRAM
> > and General Media events because it simplifies handling the two events.
> > 
> > Suggested-by: Dan Williams <dan.j.williams@intel.com>
> > Signed-off-by: Fabio M. De Francesco
> > <fabio.m.de.francesco@linux.intel.com>
> > ---
> > 
> >  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(-)
> 
> 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.
> 
> Ira

Ira,

I think you are right, there is no need for struct_group here and this code is 
unnecessarily complex.

Anyway, for the next version, I'll use the simpler solution showed by Dan in 
his comment on v2.

Thanks,

Fabio
 
> 
> > 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_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_common.phys_addr) & 
CXL_DPA_MASK;
> > 
> >  		cxlr = cxl_dpa_to_region(cxlmd, dpa);
> >  		if (cxlr)
> >  		
> >  			hpa = cxl_trace_hpa(cxlr, cxlmd, dpa);
> >  		
> >  		if (event_type == CXL_CPER_EVENT_GEN_MEDIA)
> >  		
> >  			trace_cxl_general_media(cxlmd, type, cxlr, 
hpa,
> > 
> > -						&evt-
>gen_media);
> > +						&evt-
>media_general);
> > 
> >  		else if (event_type == CXL_CPER_EVENT_DRAM)
> > 
> > -			trace_cxl_dram(cxlmd, type, cxlr, hpa, &evt-
>dram);
> > +			trace_cxl_dram(cxlmd, type, cxlr, hpa, &evt-
>media_dram);
> > 
> >  	}
> >  
> >  }
> >  EXPORT_SYMBOL_NS_GPL(cxl_event_trace_record, CXL);
> > 
> > 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,
> > 
> >  TRACE_EVENT(cxl_general_media,
> >  
> >  	TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type 
log,
> > 
> > -		 struct cxl_region *cxlr, u64 hpa, struct 
cxl_event_gen_media *rec),
> > +		 struct cxl_region *cxlr, u64 hpa, struct 
cxl_event_media *rec),
> > 
> >  	TP_ARGS(cxlmd, log, cxlr, hpa, rec),
> > 
> > @@ -413,7 +413,7 @@ TRACE_EVENT(cxl_general_media,
> > 
> >  TRACE_EVENT(cxl_dram,
> >  
> >  	TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type 
log,
> > 
> > -		 struct cxl_region *cxlr, u64 hpa, struct 
cxl_event_dram *rec),
> > +		 struct cxl_region *cxlr, u64 hpa, struct 
cxl_event_media *rec),
> > 
> >  	TP_ARGS(cxlmd, log, cxlr, hpa, rec),
> > 
> > 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 {
> > 
> >   * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43
> >   */
> >  
> >  #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;
> > -	u8 device[3];
> > -	u8 component_id[CXL_EVENT_GEN_MED_COMP_ID_SIZE];
> > -	u8 reserved[46];
> > -} __packed;
> > -
> > 
> >  /*
> >  
> >   * DRAM Event Record - DER
> >   * CXL rev 3.0 section 8.2.9.2.1.2; Table 3-44
> >   */
> >  
> >  #define CXL_EVENT_DER_CORRECTION_MASK_SIZE	0x20
> > 
> > -struct cxl_event_dram {
> > +struct cxl_event_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 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 
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 
correction_mask[CXL_EVENT_DER_CORRECTION_MASK_SIZE];
> > +			u8 dram_reserved[0x17];
> > +		);
> > +	};
> > 
> >  } __packed;
> >  
> >  /*
> > 
> > @@ -95,21 +92,12 @@ 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_media media_general;
> > +	struct cxl_event_media media_dram;
> > 
> >  	struct cxl_event_mem_module mem_module;
> > 
> > -	struct cxl_event_common common;
> > +	struct cxl_event_media media_common;
> > 
> >  } __packed;
> >  
> >  /*
> > 
> > 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 = {
> > 
> >  struct cxl_test_gen_media {
> >  
> >  	uuid_t id;
> > 
> > -	struct cxl_event_gen_media rec;
> > +	struct cxl_event_media rec;
> > 
> >  } __packed;
> >  
> >  struct cxl_test_gen_media gen_media = {
> > 
> > @@ -402,7 +402,7 @@ struct cxl_test_gen_media gen_media = {
> > 
> >  struct cxl_test_dram {
> >  
> >  	uuid_t id;
> > 
> > -	struct cxl_event_dram rec;
> > +	struct cxl_event_media rec;
> > 
> >  } __packed;
> >  
> >  struct cxl_test_dram dram = {





      reply	other threads:[~2024-05-17 13:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15 19:04 [PATCH] cxl/events: Use a common struct for DRAM and General Media events Fabio M. De Francesco
2024-05-16  2:01 ` Alison Schofield
2024-05-16 21:32 ` Ira Weiny
2024-05-17 13:07   ` Fabio M. De Francesco [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5789047.t9SDvczpPo@fdefranc-mobl3 \
    --to=fabio.m.de.francesco@linux.intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox