From: jonathan.derrick@intel.com (Jon Derrick)
Subject: [PATCH] nvme: Add support for NVMe 1.3 Timestamp Feature
Date: Tue, 18 Jul 2017 15:13:10 -0600 [thread overview]
Message-ID: <8fcc46b3-558b-df7e-b875-fec445246029@intel.com> (raw)
In-Reply-To: <20170713073500.GD12984@lst.de>
On 07/13/2017 01:35 AM, Christoph Hellwig wrote:
> On Wed, Jul 12, 2017@04:11:01PM -0600, Jon Derrick wrote:
>> NVME's Timestamp feature allows controllers to be aware of the epoch
>> time in milliseconds. This patch adds the set features hook for various
>> transports. It also wires it up to the pci reset path, so that resets
>> and resumes can update the controller as necessary.
>
> Please find a way to do this entirely from common code, currently you
> miss out on all the non-PCIe transports.
>
>> + u64 cur_ms;
>> + u8 ts[8] = { 0, };
>> + int status;
>> + u32 result;
>> +
>> + cur_ms = ktime_to_ms(ktime_get_real());
>> + put_unaligned_le64(cur_ms, &ts[0]);
>> +
>> + status = nvme_set_features(ctrl, NVME_FEAT_TIMESTAMP, 0, ts, 8,
>
> I think this could simply be something like:
>
> __le64 ts;
>
> ts = cpu_to_le64(ktime_to_ms(ktime_get_real()));
> status = nvme_set_features(ctrl, NVME_FEAT_TIMESTAMP, 0, &ts,
> sizeof(ts),
>
>> + &result);
>> + if (status < 0)
>> + dev_warn_once(ctrl->device,
>> + "could not set timestamp (%08x)\n", result);
>> +}
>
> The Timestamp feature does not define a result, so you should just
> pass NULL for the result parameter. And if you want to print something
> on error the status value is probably more useful.
>
>> + if (dev->ctrl.vs >= NVME_VS(1, 3, 0) &&
>> + dev->ctrl.oncs & NVME_CTRL_ONCS_TIMESTAMP)
>> + nvme_set_timestamp(&dev->ctrl);
>
> No need to check for the version - NVMe TPs also apply to all previous
> versions if they are backwards compatible, which this one is.
>
Thanks for the tips
prev parent reply other threads:[~2017-07-18 21:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-12 22:11 [PATCH] nvme: Add support for NVMe 1.3 Timestamp Feature Jon Derrick
2017-07-12 23:24 ` Keith Busch
2017-07-13 7:01 ` Sagi Grimberg
2017-07-18 21:12 ` Jon Derrick
2017-07-13 7:35 ` Christoph Hellwig
2017-07-18 21:13 ` Jon Derrick [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=8fcc46b3-558b-df7e-b875-fec445246029@intel.com \
--to=jonathan.derrick@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