acpi/nvdimm: Define trace events for NVDIMM and substitute nvdimm_debug()
Signed-off-by: Robert Hoo <robert.hu@linux.intel.com> Reviewed-by: Jingqi Liu <jingqi.liu@intel.com> Message-Id: <20220704085852.330005-1-robert.hu@linux.intel.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
d1c912b816
commit
e4bcec0c3c
@ -35,6 +35,7 @@
|
|||||||
#include "hw/nvram/fw_cfg.h"
|
#include "hw/nvram/fw_cfg.h"
|
||||||
#include "hw/mem/nvdimm.h"
|
#include "hw/mem/nvdimm.h"
|
||||||
#include "qemu/nvdimm-utils.h"
|
#include "qemu/nvdimm-utils.h"
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* define Byte Addressable Persistent Memory (PM) Region according to
|
* define Byte Addressable Persistent Memory (PM) Region according to
|
||||||
@ -550,8 +551,8 @@ static void nvdimm_dsm_func_read_fit(NVDIMMState *state, NvdimmDsmIn *in,
|
|||||||
|
|
||||||
fit = fit_buf->fit;
|
fit = fit_buf->fit;
|
||||||
|
|
||||||
nvdimm_debug("Read FIT: offset 0x%x FIT size 0x%x Dirty %s.\n",
|
trace_acpi_nvdimm_read_fit(read_fit->offset, fit->len,
|
||||||
read_fit->offset, fit->len, fit_buf->dirty ? "Yes" : "No");
|
fit_buf->dirty ? "Yes" : "No");
|
||||||
|
|
||||||
if (read_fit->offset > fit->len) {
|
if (read_fit->offset > fit->len) {
|
||||||
func_ret_status = NVDIMM_DSM_RET_STATUS_INVALID;
|
func_ret_status = NVDIMM_DSM_RET_STATUS_INVALID;
|
||||||
@ -658,7 +659,7 @@ static void nvdimm_dsm_label_size(NVDIMMDevice *nvdimm, hwaddr dsm_mem_addr)
|
|||||||
label_size = nvdimm->label_size;
|
label_size = nvdimm->label_size;
|
||||||
mxfer = nvdimm_get_max_xfer_label_size();
|
mxfer = nvdimm_get_max_xfer_label_size();
|
||||||
|
|
||||||
nvdimm_debug("label_size 0x%x, max_xfer 0x%x.\n", label_size, mxfer);
|
trace_acpi_nvdimm_label_info(label_size, mxfer);
|
||||||
|
|
||||||
label_size_out.func_ret_status = cpu_to_le32(NVDIMM_DSM_RET_STATUS_SUCCESS);
|
label_size_out.func_ret_status = cpu_to_le32(NVDIMM_DSM_RET_STATUS_SUCCESS);
|
||||||
label_size_out.label_size = cpu_to_le32(label_size);
|
label_size_out.label_size = cpu_to_le32(label_size);
|
||||||
@ -674,20 +675,18 @@ static uint32_t nvdimm_rw_label_data_check(NVDIMMDevice *nvdimm,
|
|||||||
uint32_t ret = NVDIMM_DSM_RET_STATUS_INVALID;
|
uint32_t ret = NVDIMM_DSM_RET_STATUS_INVALID;
|
||||||
|
|
||||||
if (offset + length < offset) {
|
if (offset + length < offset) {
|
||||||
nvdimm_debug("offset 0x%x + length 0x%x is overflow.\n", offset,
|
trace_acpi_nvdimm_label_overflow(offset, length);
|
||||||
length);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nvdimm->label_size < offset + length) {
|
if (nvdimm->label_size < offset + length) {
|
||||||
nvdimm_debug("position 0x%x is beyond label data (len = %" PRIx64 ").\n",
|
trace_acpi_nvdimm_label_oversize(offset + length, nvdimm->label_size);
|
||||||
offset + length, nvdimm->label_size);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > nvdimm_get_max_xfer_label_size()) {
|
if (length > nvdimm_get_max_xfer_label_size()) {
|
||||||
nvdimm_debug("length (0x%x) is larger than max_xfer (0x%x).\n",
|
trace_acpi_nvdimm_label_xfer_exceed(length,
|
||||||
length, nvdimm_get_max_xfer_label_size());
|
nvdimm_get_max_xfer_label_size());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,8 +709,8 @@ static void nvdimm_dsm_get_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in,
|
|||||||
get_label_data->offset = le32_to_cpu(get_label_data->offset);
|
get_label_data->offset = le32_to_cpu(get_label_data->offset);
|
||||||
get_label_data->length = le32_to_cpu(get_label_data->length);
|
get_label_data->length = le32_to_cpu(get_label_data->length);
|
||||||
|
|
||||||
nvdimm_debug("Read Label Data: offset 0x%x length 0x%x.\n",
|
trace_acpi_nvdimm_read_label(get_label_data->offset,
|
||||||
get_label_data->offset, get_label_data->length);
|
get_label_data->length);
|
||||||
|
|
||||||
status = nvdimm_rw_label_data_check(nvdimm, get_label_data->offset,
|
status = nvdimm_rw_label_data_check(nvdimm, get_label_data->offset,
|
||||||
get_label_data->length);
|
get_label_data->length);
|
||||||
@ -749,8 +748,8 @@ static void nvdimm_dsm_set_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in,
|
|||||||
set_label_data->offset = le32_to_cpu(set_label_data->offset);
|
set_label_data->offset = le32_to_cpu(set_label_data->offset);
|
||||||
set_label_data->length = le32_to_cpu(set_label_data->length);
|
set_label_data->length = le32_to_cpu(set_label_data->length);
|
||||||
|
|
||||||
nvdimm_debug("Write Label Data: offset 0x%x length 0x%x.\n",
|
trace_acpi_nvdimm_write_label(set_label_data->offset,
|
||||||
set_label_data->offset, set_label_data->length);
|
set_label_data->length);
|
||||||
|
|
||||||
status = nvdimm_rw_label_data_check(nvdimm, set_label_data->offset,
|
status = nvdimm_rw_label_data_check(nvdimm, set_label_data->offset,
|
||||||
set_label_data->length);
|
set_label_data->length);
|
||||||
@ -821,7 +820,7 @@ static void nvdimm_dsm_device(NvdimmDsmIn *in, hwaddr dsm_mem_addr)
|
|||||||
static uint64_t
|
static uint64_t
|
||||||
nvdimm_dsm_read(void *opaque, hwaddr addr, unsigned size)
|
nvdimm_dsm_read(void *opaque, hwaddr addr, unsigned size)
|
||||||
{
|
{
|
||||||
nvdimm_debug("BUG: we never read _DSM IO Port.\n");
|
trace_acpi_nvdimm_read_io_port();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -832,7 +831,7 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
|
|||||||
NvdimmDsmIn *in;
|
NvdimmDsmIn *in;
|
||||||
hwaddr dsm_mem_addr = val;
|
hwaddr dsm_mem_addr = val;
|
||||||
|
|
||||||
nvdimm_debug("dsm memory address 0x%" HWADDR_PRIx ".\n", dsm_mem_addr);
|
trace_acpi_nvdimm_dsm_mem_addr(dsm_mem_addr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The DSM memory is mapped to guest address space so an evil guest
|
* The DSM memory is mapped to guest address space so an evil guest
|
||||||
@ -846,12 +845,10 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
|
|||||||
in->function = le32_to_cpu(in->function);
|
in->function = le32_to_cpu(in->function);
|
||||||
in->handle = le32_to_cpu(in->handle);
|
in->handle = le32_to_cpu(in->handle);
|
||||||
|
|
||||||
nvdimm_debug("Revision 0x%x Handler 0x%x Function 0x%x.\n", in->revision,
|
trace_acpi_nvdimm_dsm_info(in->revision, in->handle, in->function);
|
||||||
in->handle, in->function);
|
|
||||||
|
|
||||||
if (in->revision != 0x1 /* Currently we only support DSM Spec Rev1. */) {
|
if (in->revision != 0x1 /* Currently we only support DSM Spec Rev1. */) {
|
||||||
nvdimm_debug("Revision 0x%x is not supported, expect 0x%x.\n",
|
trace_acpi_nvdimm_invalid_revision(in->revision);
|
||||||
in->revision, 0x1);
|
|
||||||
nvdimm_dsm_no_payload(NVDIMM_DSM_RET_STATUS_UNSUPPORT, dsm_mem_addr);
|
nvdimm_dsm_no_payload(NVDIMM_DSM_RET_STATUS_UNSUPPORT, dsm_mem_addr);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -70,3 +70,16 @@ acpi_erst_reset_out(unsigned record_count) "record_count %u"
|
|||||||
acpi_erst_post_load(void *header, unsigned slot_size) "header: 0x%p slot_size %u"
|
acpi_erst_post_load(void *header, unsigned slot_size) "header: 0x%p slot_size %u"
|
||||||
acpi_erst_class_init_in(void)
|
acpi_erst_class_init_in(void)
|
||||||
acpi_erst_class_init_out(void)
|
acpi_erst_class_init_out(void)
|
||||||
|
|
||||||
|
# nvdimm.c
|
||||||
|
acpi_nvdimm_read_fit(uint32_t offset, uint32_t len, const char *dirty) "Read FIT: offset 0x%" PRIx32 " FIT size 0x%" PRIx32 " Dirty %s"
|
||||||
|
acpi_nvdimm_label_info(uint32_t label_size, uint32_t mxfer) "label_size 0x%" PRIx32 ", max_xfer 0x%" PRIx32
|
||||||
|
acpi_nvdimm_label_overflow(uint32_t offset, uint32_t length) "offset 0x%" PRIx32 " + length 0x%" PRIx32 " is overflow"
|
||||||
|
acpi_nvdimm_label_oversize(uint32_t pos, uint64_t size) "position 0x%" PRIx32 " is beyond label data (len = %" PRIu64 ")"
|
||||||
|
acpi_nvdimm_label_xfer_exceed(uint32_t length, uint32_t max_xfer) "length (0x%" PRIx32 ") is larger than max_xfer (0x%" PRIx32 ")"
|
||||||
|
acpi_nvdimm_read_label(uint32_t offset, uint32_t length) "Read Label Data: offset 0x%" PRIx32 " length 0x%" PRIx32
|
||||||
|
acpi_nvdimm_write_label(uint32_t offset, uint32_t length) "Write Label Data: offset 0x%" PRIx32 " length 0x%" PRIx32
|
||||||
|
acpi_nvdimm_read_io_port(void) "Alert: we never read _DSM IO Port"
|
||||||
|
acpi_nvdimm_dsm_mem_addr(uint64_t dsm_mem_addr) "dsm memory address 0x%" PRIx64
|
||||||
|
acpi_nvdimm_dsm_info(uint32_t revision, uint32_t handle, uint32_t function) "Revision 0x%" PRIx32 " Handle 0x%" PRIx32 " Function 0x%" PRIx32
|
||||||
|
acpi_nvdimm_invalid_revision(uint32_t revision) "Revision 0x%" PRIx32 " is not supported, expect 0x1"
|
||||||
|
@ -29,14 +29,6 @@
|
|||||||
#include "hw/acpi/aml-build.h"
|
#include "hw/acpi/aml-build.h"
|
||||||
#include "qom/object.h"
|
#include "qom/object.h"
|
||||||
|
|
||||||
#define NVDIMM_DEBUG 0
|
|
||||||
#define nvdimm_debug(fmt, ...) \
|
|
||||||
do { \
|
|
||||||
if (NVDIMM_DEBUG) { \
|
|
||||||
fprintf(stderr, "nvdimm: " fmt, ## __VA_ARGS__); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The minimum label data size is required by NVDIMM Namespace
|
* The minimum label data size is required by NVDIMM Namespace
|
||||||
* specification, see the chapter 2 Namespaces:
|
* specification, see the chapter 2 Namespaces:
|
||||||
|
Loading…
Reference in New Issue
Block a user