All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	"Ira Weiny" <ira.weiny@intel.com>, <linuxarm@huawei.com>
Subject: Re: [PATCH] cxl/pci: Set the device timestamp
Date: Fri, 27 Jan 2023 10:04:06 +0000	[thread overview]
Message-ID: <20230127100406.00006c65@Huawei.com> (raw)
In-Reply-To: <63d2e0f67eee9_ea222294b6@dwillia2-xfh.jf.intel.com.notmuch>

On Thu, 26 Jan 2023 12:22:14 -0800
Dan Williams <dan.j.williams@intel.com> wrote:

> Jonathan Cameron wrote:
> > CXL r3.0 section 8.2.9.4.2 "Set Timestamp" recommends that the host sets
> > the timestamp after every Conventional or CXL Reset to ensure accurate
> > timestamps. This should include on initial boot up. The time base that
> > is being set is used by a device for the poison list overflow timestamp
> > and all event timestamps.  Note that the command is optional and if
> > not supported and the device cannot return accurate timestamps it will
> > fill the fields in with an appropriate marker (see the specification
> > description of each timestamp).
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > ---
> > 
> > Open question: Should we only do this if Linux has control of the
> > error handling?  In theory it should be safe anyway given the
> > specification is clear that the timestamp base should always be the
> > same - so subject to small errors we shouldn't cause any firmware first
> > handling to get confused.
> > 
> >  drivers/cxl/core/mbox.c      | 25 +++++++++++++++++++++++++
> >  drivers/cxl/cxlmem.h         |  7 +++++++
> >  drivers/cxl/pci.c            |  5 +++++
> >  include/uapi/linux/cxl_mem.h |  1 +
> >  4 files changed, 38 insertions(+)
> > 
> > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> > index b03fba212799..a7317bb142ed 100644
> > --- a/drivers/cxl/core/mbox.c
> > +++ b/drivers/cxl/core/mbox.c
> > @@ -65,6 +65,7 @@ static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = {
> >  	CXL_CMD(GET_SCAN_MEDIA_CAPS, 0x10, 0x4, 0),
> >  	CXL_CMD(SCAN_MEDIA, 0x11, 0, 0),
> >  	CXL_CMD(GET_SCAN_MEDIA, 0, CXL_VARIABLE_PAYLOAD, 0),
> > +	CXL_CMD(SET_TIMESTAMP, 8, 0, 0),  
> 
> Is there a use case for userspace to need to send its own view
> of 'timestamp' to the device? I think it's ok if this only a
> kernel-internal thing.

Fair enough. Easier to add the interface later if we need to than to rip
it out.

> 
> >  };
> >  
> >  /*
> > @@ -93,6 +94,7 @@ static u16 cxl_disabled_raw_commands[] = {
> >  	CXL_MBOX_OP_SET_SHUTDOWN_STATE,
> >  	CXL_MBOX_OP_SCAN_MEDIA,
> >  	CXL_MBOX_OP_GET_SCAN_MEDIA,
> > +	CXL_MBOX_OP_SET_TIMESTAMP,  
> 
> The criteria I have in mind for commands that should be added to this
> list are things that need to have a kernel control point (like long
> running background commands), or commands with data integrity
> implications that only the kernel can reasonably manage (like shutdown
> state). While it is odd for userspace to send its own timestamps via
> debug kernel builds that enable raw commands, the side effects of
> allowing this seem benign.

Makes sense I'll drop it from this list.
> 
> >  };
> >  
> >  /*
> > @@ -857,6 +859,29 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds)
> >  }
> >  EXPORT_SYMBOL_NS_GPL(cxl_mem_create_range_info, CXL);
> >  
> > +int cxl_set_timestamp(struct cxl_dev_state *cxlds, u64 ts)
> > +{
> > +	struct cxl_mbox_cmd mbox_cmd;
> > +	struct cxl_mbox_set_timestamp_in pi;
> > +
> > +	/*
> > +	 * Command is optional and functionality should not be affected if
> > +	 * the command is not available.
> > +	 */
> > +	if (!test_bit(CXL_MEM_COMMAND_ID_SET_TIMESTAMP, cxlds->enabled_cmds))
> > +		return 0;
> > +
> > +	pi.timestamp = ts;  
> 
> cpu_to_le64()?

Good point.

Thanks,

Jonathan



  reply	other threads:[~2023-01-27 10:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 18:04 [PATCH] cxl/pci: Set the device timestamp Jonathan Cameron
2023-01-26 18:56 ` Davidlohr Bueso
2023-01-27  9:57   ` Jonathan Cameron
2023-01-27 12:08     ` Jonathan Cameron
2023-01-26 19:59 ` Alison Schofield
2023-01-27  9:59   ` Jonathan Cameron
2023-01-27  9:59     ` Jonathan Cameron
2023-01-26 20:22 ` Dan Williams
2023-01-27 10:04   ` Jonathan Cameron [this message]
2023-01-27 12:10     ` Jonathan Cameron
2023-01-27 19:07       ` Dan Williams
2023-01-27 23:50         ` Ira Weiny
2023-01-28  0:17           ` Dan Williams
2023-01-28 11:21 ` kernel test robot
2023-01-28 11:32 ` kernel test robot
2023-01-30 15:10   ` Jonathan Cameron
2023-01-28 16:01 ` kernel test robot

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=20230127100406.00006c65@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.