Re: [PATCH v2 16/27] nvdimm/ocxl: Implement the Read Error Log command
Hi Alastair, Thank you for the patch! Yet something to improve: [auto build test ERROR on v5.4-rc8] [also build test ERROR on char-misc/char-misc-testing] [cannot apply to linux-nvdimm/libnvdimm-for-next linus/master next-20191205] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982] url: https://github.com/0day-ci/linux/commits/Alastair-D-Silva/Add-support-for-OpenCAPI-SCM-devices/20191203-120511 base:af42d3466bdc8f39806b26f593604fdc54140bcb config: x86_64-randconfig-b001-20191203 (attached as .config) compiler: gcc-7 (Debian 7.5.0-1) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 If you fix the issue, kindly add following tag Reported-by: kbuild test robot All errors (new ones prefixed by >>): In file included from :32:0: >> ./usr/include/nvdimm/ocxl-scm.h:21:24: error: C++ style comments are not >> allowed in ISO C90 __u32 log_identifier; // out ^ >> ./usr/include/nvdimm/ocxl-scm.h:21:24: error: (this will be reported only >> once per input file) --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org Intel Corporation .config.gz Description: application/gzip
Re: [PATCH v2 16/27] nvdimm/ocxl: Implement the Read Error Log command
On Tue, 2019-12-03 at 14:46 +1100, Alastair D'Silva wrote: > From: Alastair D'Silva > > The read error log command extracts information from the controller's > internal error log. > > This patch exposes this information in 2 ways: > - During probe, if an error occurs & a log is available, print it to > the > console > - After probe, make the error log available to userspace via an > IOCTL. > Userspace is notified of pending error logs in a later patch > ("nvdimm/ocxl: Forward events to userspace") > > Signed-off-by: Alastair D'Silva > --- > drivers/nvdimm/ocxl/scm.c | 270 > + > drivers/nvdimm/ocxl/scm_internal.h | 1 + > include/uapi/nvdimm/ocxl-scm.h | 46 + > 3 files changed, 317 insertions(+) > create mode 100644 include/uapi/nvdimm/ocxl-scm.h > > diff --git a/drivers/nvdimm/ocxl/scm.c b/drivers/nvdimm/ocxl/scm.c > index c313a473a28e..0bbe1a14291e 100644 > --- a/drivers/nvdimm/ocxl/scm.c > +++ b/drivers/nvdimm/ocxl/scm.c > @@ -495,10 +495,220 @@ static int scm_file_release(struct inode > *inode, struct file *file) > return 0; > } > > +/** > + * scm_error_log_header_parse() - Parse the first 64 bits of the > error log command response > + * @scm_data: the SCM metadata > + * @length: out, returns the number of bytes in the response > (excluding the 64 bit header) > + */ > +static int scm_error_log_header_parse(struct scm_data *scm_data, u16 > *length) > +{ > + int rc; > + u64 val; > + > + u16 data_identifier; > + u32 data_length; > + > + rc = ocxl_global_mmio_read64(scm_data->ocxl_afu, > + scm_data- > >admin_command.data_offset, > + OCXL_LITTLE_ENDIAN, ); > + if (rc) > + return rc; > + > + data_identifier = val >> 48; > + data_length = val & 0x; > + > + if (data_identifier != 0x454C) { > + dev_err(_data->dev, > + "Bad data identifier for error log data, > expected 'EL', got '%2s' (%#x), data_length=%u\n", > + (char *)_identifier, > + (unsigned int)data_identifier, data_length); > + return -EINVAL; > + } > + > + *length = data_length; > + return 0; > +} > + > +static int scm_error_log_offset_0x08(struct scm_data *scm_data, > + u32 *log_identifier, u32 > *program_ref_code) > +{ > + int rc; > + u64 val; > + > + rc = ocxl_global_mmio_read64(scm_data->ocxl_afu, > + scm_data- > >admin_command.data_offset + 0x08, > + OCXL_LITTLE_ENDIAN, ); > + if (rc) > + return rc; > + > + *log_identifier = val >> 32; > + *program_ref_code = val & 0x; > + > + return 0; > +} > + > +static int scm_read_error_log(struct scm_data *scm_data, > + struct scm_ioctl_error_log *log, bool > buf_is_user) > +{ > + u64 val; > + u16 user_buf_length; > + u16 buf_length; > + u16 i; > + int rc; > + > + if (log->buf_size % 8) > + return -EINVAL; > + > + rc = scm_chi(scm_data, ); > + if (rc) > + goto out; > + > + if (!(val & GLOBAL_MMIO_CHI_ELA)) > + return -EAGAIN; > + > + user_buf_length = log->buf_size; > + > + mutex_lock(_data->admin_command.lock); > + > + rc = scm_admin_command_request(scm_data, ADMIN_COMMAND_ERRLOG); > + if (rc) > + goto out; > + > + rc = scm_admin_command_execute(scm_data); > + if (rc) > + goto out; > + > + rc = scm_admin_command_complete_timeout(scm_data, > ADMIN_COMMAND_ERRLOG); > + if (rc < 0) { > + dev_warn(_data->dev, "Read error log timed out\n"); > + goto out; > + } > + > + rc = scm_admin_response(scm_data); > + if (rc < 0) > + goto out; > + if (rc != STATUS_SUCCESS) { > + scm_warn_status(scm_data, "Unexpected status from > retrieve error log", rc); > + goto out; > + } > + > + > + rc = scm_error_log_header_parse(scm_data, >buf_size); > + if (rc) > + goto out; > + // log->buf_size now contains the scm buffer size, not the user > size > + > + rc = scm_error_log_offset_0x08(scm_data, >log_identifier, > +>program_reference_code); > + if (rc) > + goto out; > + > + rc = ocxl_global_mmio_read64(scm_data->ocxl_afu, > + scm_data- > >admin_command.data_offset + 0x10, > + OCXL_LITTLE_ENDIAN, ); > + if (rc) > + goto out; > + > + log->error_log_type = val >> 56; > + log->action_flags = (log->error_log_type == > SCM_ERROR_LOG_TYPE_GENERAL) ? > + (val >> 32) & 0xFF : 0; > + log->power_on_seconds = val & 0x; > + > + rc = ocxl_global_mmio_read64(scm_data->ocxl_afu,
[PATCH v2 16/27] nvdimm/ocxl: Implement the Read Error Log command
From: Alastair D'Silva The read error log command extracts information from the controller's internal error log. This patch exposes this information in 2 ways: - During probe, if an error occurs & a log is available, print it to the console - After probe, make the error log available to userspace via an IOCTL. Userspace is notified of pending error logs in a later patch ("nvdimm/ocxl: Forward events to userspace") Signed-off-by: Alastair D'Silva --- drivers/nvdimm/ocxl/scm.c | 270 + drivers/nvdimm/ocxl/scm_internal.h | 1 + include/uapi/nvdimm/ocxl-scm.h | 46 + 3 files changed, 317 insertions(+) create mode 100644 include/uapi/nvdimm/ocxl-scm.h diff --git a/drivers/nvdimm/ocxl/scm.c b/drivers/nvdimm/ocxl/scm.c index c313a473a28e..0bbe1a14291e 100644 --- a/drivers/nvdimm/ocxl/scm.c +++ b/drivers/nvdimm/ocxl/scm.c @@ -495,10 +495,220 @@ static int scm_file_release(struct inode *inode, struct file *file) return 0; } +/** + * scm_error_log_header_parse() - Parse the first 64 bits of the error log command response + * @scm_data: the SCM metadata + * @length: out, returns the number of bytes in the response (excluding the 64 bit header) + */ +static int scm_error_log_header_parse(struct scm_data *scm_data, u16 *length) +{ + int rc; + u64 val; + + u16 data_identifier; + u32 data_length; + + rc = ocxl_global_mmio_read64(scm_data->ocxl_afu, +scm_data->admin_command.data_offset, +OCXL_LITTLE_ENDIAN, ); + if (rc) + return rc; + + data_identifier = val >> 48; + data_length = val & 0x; + + if (data_identifier != 0x454C) { + dev_err(_data->dev, + "Bad data identifier for error log data, expected 'EL', got '%2s' (%#x), data_length=%u\n", + (char *)_identifier, + (unsigned int)data_identifier, data_length); + return -EINVAL; + } + + *length = data_length; + return 0; +} + +static int scm_error_log_offset_0x08(struct scm_data *scm_data, +u32 *log_identifier, u32 *program_ref_code) +{ + int rc; + u64 val; + + rc = ocxl_global_mmio_read64(scm_data->ocxl_afu, +scm_data->admin_command.data_offset + 0x08, +OCXL_LITTLE_ENDIAN, ); + if (rc) + return rc; + + *log_identifier = val >> 32; + *program_ref_code = val & 0x; + + return 0; +} + +static int scm_read_error_log(struct scm_data *scm_data, + struct scm_ioctl_error_log *log, bool buf_is_user) +{ + u64 val; + u16 user_buf_length; + u16 buf_length; + u16 i; + int rc; + + if (log->buf_size % 8) + return -EINVAL; + + rc = scm_chi(scm_data, ); + if (rc) + goto out; + + if (!(val & GLOBAL_MMIO_CHI_ELA)) + return -EAGAIN; + + user_buf_length = log->buf_size; + + mutex_lock(_data->admin_command.lock); + + rc = scm_admin_command_request(scm_data, ADMIN_COMMAND_ERRLOG); + if (rc) + goto out; + + rc = scm_admin_command_execute(scm_data); + if (rc) + goto out; + + rc = scm_admin_command_complete_timeout(scm_data, ADMIN_COMMAND_ERRLOG); + if (rc < 0) { + dev_warn(_data->dev, "Read error log timed out\n"); + goto out; + } + + rc = scm_admin_response(scm_data); + if (rc < 0) + goto out; + if (rc != STATUS_SUCCESS) { + scm_warn_status(scm_data, "Unexpected status from retrieve error log", rc); + goto out; + } + + + rc = scm_error_log_header_parse(scm_data, >buf_size); + if (rc) + goto out; + // log->buf_size now contains the scm buffer size, not the user size + + rc = scm_error_log_offset_0x08(scm_data, >log_identifier, + >program_reference_code); + if (rc) + goto out; + + rc = ocxl_global_mmio_read64(scm_data->ocxl_afu, +scm_data->admin_command.data_offset + 0x10, +OCXL_LITTLE_ENDIAN, ); + if (rc) + goto out; + + log->error_log_type = val >> 56; + log->action_flags = (log->error_log_type == SCM_ERROR_LOG_TYPE_GENERAL) ? + (val >> 32) & 0xFF : 0; + log->power_on_seconds = val & 0x; + + rc = ocxl_global_mmio_read64(scm_data->ocxl_afu, +scm_data->admin_command.data_offset + 0x18, +OCXL_LITTLE_ENDIAN, >timestamp); + if (rc) + goto out; + + rc =