Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/nvdimm/nvdimm.c
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/uuid.h> | #include <sys/uuid.h> | ||||
#include <contrib/dev/acpica/include/acpi.h> | #include <contrib/dev/acpica/include/acpi.h> | ||||
#include <contrib/dev/acpica/include/accommon.h> | #include <contrib/dev/acpica/include/accommon.h> | ||||
#include <contrib/dev/acpica/include/acuuid.h> | #include <contrib/dev/acpica/include/acuuid.h> | ||||
#include <dev/acpica/acpivar.h> | #include <dev/acpica/acpivar.h> | ||||
#include <dev/nvdimm/nvdimm_dsm.h> | |||||
#include <dev/nvdimm/nvdimm_var.h> | #include <dev/nvdimm/nvdimm_var.h> | ||||
#define _COMPONENT ACPI_OEM | #define _COMPONENT ACPI_OEM | ||||
ACPI_MODULE_NAME("NVDIMM") | ACPI_MODULE_NAME("NVDIMM") | ||||
static struct uuid intel_nvdimm_dsm_uuid = | static struct uuid intel_nvdimm_dsm_uuid = | ||||
{0x4309AC30,0x0D11,0x11E4,0x91,0x91,{0x08,0x00,0x20,0x0C,0x9A,0x66}}; | {0x4309AC30,0x0D11,0x11E4,0x91,0x91,{0x08,0x00,0x20,0x0C,0x9A,0x66}}; | ||||
cem: This looks like the proper way to define these UUIDs. I did not look to see how nvdimm.c… | |||||
#define INTEL_NVDIMM_DSM_REV 1 | #define INTEL_NVDIMM_DSM_REV 1 | ||||
#define INTEL_NVDIMM_DSM_GET_LABEL_SIZE 4 | #define INTEL_NVDIMM_DSM_GET_LABEL_SIZE 4 | ||||
#define INTEL_NVDIMM_DSM_GET_LABEL_DATA 5 | #define INTEL_NVDIMM_DSM_GET_LABEL_DATA 5 | ||||
static devclass_t nvdimm_devclass; | static devclass_t nvdimm_devclass; | ||||
MALLOC_DEFINE(M_NVDIMM, "nvdimm", "NVDIMM driver memory"); | MALLOC_DEFINE(M_NVDIMM, "nvdimm", "NVDIMM driver memory"); | ||||
static int | static int | ||||
▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | nvdimm_attach(device_t dev) | ||||
error = read_label_area_size(nv); | error = read_label_area_size(nv); | ||||
if (error == 0) { | if (error == 0) { | ||||
/* | /* | ||||
* Ignoring errors reading labels. Not all NVDIMMs | * Ignoring errors reading labels. Not all NVDIMMs | ||||
* support labels and namespaces. | * support labels and namespaces. | ||||
*/ | */ | ||||
read_labels(nv); | read_labels(nv); | ||||
} | } | ||||
status = AcpiInstallNotifyHandler(handle, ACPI_DEVICE_NOTIFY, | |||||
nvdimm_acpi_notify, dev); | |||||
if (ACPI_FAILURE(status)) { | |||||
device_printf(dev, "Couldn't install health notify handler: " | |||||
"0x%08x\n", status); | |||||
} else | |||||
nv->have_handler = true; | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
nvdimm_detach(device_t dev) | nvdimm_detach(device_t dev) | ||||
{ | { | ||||
ACPI_STATUS status; | |||||
struct nvdimm_dev *nv; | struct nvdimm_dev *nv; | ||||
struct nvdimm_label_entry *label, *next; | struct nvdimm_label_entry *label, *next; | ||||
nv = device_get_softc(dev); | nv = device_get_softc(dev); | ||||
if (nv->have_handler) { | |||||
status = AcpiRemoveNotifyHandler( | |||||
nvdimm_root_get_acpi_handle(dev), ACPI_DEVICE_NOTIFY, | |||||
nvdimm_acpi_notify); | |||||
if (ACPI_FAILURE(status)) { | |||||
device_printf(dev, "Couldn't remove health notify " | |||||
"handler: 0x%08x\n", status); | |||||
} | |||||
nv->have_handler = false; | |||||
} | |||||
free(nv->nv_flush_addr, M_NVDIMM); | free(nv->nv_flush_addr, M_NVDIMM); | ||||
free(nv->label_index, M_NVDIMM); | free(nv->label_index, M_NVDIMM); | ||||
SLIST_FOREACH_SAFE(label, &nv->labels, link, next) { | SLIST_FOREACH_SAFE(label, &nv->labels, link, next) { | ||||
SLIST_REMOVE_HEAD(&nv->labels, link); | SLIST_REMOVE_HEAD(&nv->labels, link); | ||||
free(label, M_NVDIMM); | free(label, M_NVDIMM); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 33 Lines |
This looks like the proper way to define these UUIDs. I did not look to see how nvdimm.c already uses this DSM. Note the duplicate definition in nvdimm_leaf_dsm_guid in nvdimm_dsm.c; I would suggest converting the raw definitions in nvdimm_dsm.c to uuid, moving intel_nvdimm_dsm_uuid to that file, adding an extern declaration for it in nvdimm_dsm.h, and also figuring out what overlap there is and if maybe some code should move from one of the two files to the other.