On Tue, 2020-03-31 at 07:41 +0200, Klaus Birkelund Jensen wrote: > On Mar 25 12:40, Maxim Levitsky wrote: > > On Mon, 2020-03-16 at 07:28 -0700, Klaus Jensen wrote: > > > From: Klaus Jensen <k.jen...@samsung.com> > > > > > > Add support for the Get Log Page command and basic implementations of > > > the mandatory Error Information, SMART / Health Information and Firmware > > > Slot Information log pages. > > > > > > In violation of the specification, the SMART / Health Information log > > > page does not persist information over the lifetime of the controller > > > because the device has no place to store such persistent state. > > > > > > Note that the LPA field in the Identify Controller data structure > > > intentionally has bit 0 cleared because there is no namespace specific > > > information in the SMART / Health information log page. > > > > > > Required for compliance with NVMe revision 1.2.1. See NVM Express 1.2.1, > > > Section 5.10 ("Get Log Page command"). > > > > > > Signed-off-by: Klaus Jensen <klaus.jen...@cnexlabs.com> > > > Acked-by: Keith Busch <kbu...@kernel.org> > > > --- > > > hw/block/nvme.c | 138 +++++++++++++++++++++++++++++++++++++++++- > > > hw/block/nvme.h | 10 +++ > > > hw/block/trace-events | 2 + > > > 3 files changed, 149 insertions(+), 1 deletion(-) > > > > > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > > > index 64c42101df5c..83ff3fbfb463 100644 > > > > > > +static uint16_t nvme_error_info(NvmeCtrl *n, NvmeCmd *cmd, uint32_t > > > buf_len, > > > + uint64_t off, NvmeRequest *req) > > > +{ > > > + uint32_t trans_len; > > > + uint64_t prp1 = le64_to_cpu(cmd->dptr.prp1); > > > + uint64_t prp2 = le64_to_cpu(cmd->dptr.prp2); > > > + uint8_t errlog[64]; > > > > I'll would replace this with sizeof(NvmeErrorLogEntry) > > (and add NvmeErrorLogEntry to the nvme.h), just for the sake of consistency, > > and in case we end up reporting some errors to the log in the future. > > > > NvmeErrorLog is already in nvme.h; Fixed to actually use it. True that! I'll would rename it to NvmeErrorLogEntry to be honest (in that patch that added many nvme spec changes) but I don't mind keeping it as is as well.
> > > > > > + > > > + if (off > sizeof(errlog)) { > > > + return NVME_INVALID_FIELD | NVME_DNR; > > > + } > > > + > > > + memset(errlog, 0x0, sizeof(errlog)); > > > + > > > + trans_len = MIN(sizeof(errlog) - off, buf_len); > > > + > > > + return nvme_dma_read_prp(n, errlog, trans_len, prp1, prp2); > > > +} > > > > Besides this, looks good now. > > > > > > Best regards, > > Maxim Levitsky > > > > Best regards, Maxim Levitsky