Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Davidlohr Bueso <dave@stgolabs.net>
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>,
	Dan Williams <dan.j.williams@intel.com>, <linuxarm@huawei.com>
Subject: Re: [PATCH] cxl/pci: Set the device timestamp
Date: Fri, 27 Jan 2023 09:57:06 +0000	[thread overview]
Message-ID: <20230127095706.00002d36@Huawei.com> (raw)
In-Reply-To: <20230126185620.52bfkr7cksjyjghk@offworld>

On Thu, 26 Jan 2023 10:56:20 -0800
Davidlohr Bueso <dave@stgolabs.net> wrote:

> On Thu, 26 Jan 2023, Jonathan Cameron wrote:
> 
> >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).  
> 
> A few questions (which I'm missing from the spec):
> 
> - How to verify if a ts was actually set? I would assume that if SET
> is unsupported, GET will also be, and since you set the ts at
> bootup, it should never occur in reality.

I don't think we care.  If a record comes back with the magic code (all
zeros) that is in the spec. Get can still be supported.

> 
> - Does "unsupported" return type mean the command cannot mean that
> flat out the device cannot handle timestamps or is it more that the
> device cannot handle nanosecond resolution?

Neither - it just means that it cannot be set by this means.
There is no provision for anything other than nanoseconds, but there is also
no statement on accuracy.  So if you only do seconds, multiply the number
by 1x10^9

The device might have another means of setting it. MCTP for example
or in theory might have an RTC.  The OS can only tell if that is true
when it sees a timestamp.



> 
> ...
> 
> >@@ -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),
> > };
> >
> > /*
> >@@ -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,  
> 
> Why no GET support?
> 
> > };
> >
> > /*
> >@@ -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;  
> 
> Considering we always want "now", maybe just remove the parameter and just
> compute ktime_get_real_ns() here?

Sure. We could do that, and bring the parameter back if we want to
do anything clever in future.

> 
> >+	mbox_cmd = (struct cxl_mbox_cmd) {
> >+		.opcode = CXL_MBOX_OP_SET_TIMESTAMP,
> >+		.size_in = sizeof(pi),
> >+		.payload_in = &pi,
> >+	};
> >+
> >+	return cxl_internal_send_cmd(cxlds, &mbox_cmd);
> >+}  
> 
> Thanks,
> Davidlohr


  reply	other threads:[~2023-01-27  9:57 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 [this message]
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
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=20230127095706.00002d36@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox