Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107290368
D18346.id51134.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D18346.id51134.diff
View Options
Index: sys/dev/nvdimm/nvdimm_spa.c
===================================================================
--- sys/dev/nvdimm/nvdimm_spa.c
+++ sys/dev/nvdimm/nvdimm_spa.c
@@ -64,19 +64,6 @@
#include <dev/acpica/acpivar.h>
#include <dev/nvdimm/nvdimm_var.h>
-struct SPA_mapping *spa_mappings;
-int spa_mappings_cnt;
-
-static int
-nvdimm_spa_count(void *nfitsubtbl __unused, void *arg)
-{
- int *cnt;
-
- cnt = arg;
- (*cnt)++;
- return (0);
-}
-
static struct nvdimm_SPA_uuid_list_elm {
const char *u_name;
const char *u_id_str;
@@ -386,7 +373,7 @@
}
static g_init_t nvdimm_spa_g_init;
-static g_fini_t nvdimm_spa_g_fini;
+static g_ctl_destroy_geom_t nvdimm_spa_g_destroy_geom;
struct g_class nvdimm_spa_g_class = {
.name = "SPA",
@@ -394,7 +381,7 @@
.start = nvdimm_spa_g_start,
.access = nvdimm_spa_g_access,
.init = nvdimm_spa_g_init,
- .fini = nvdimm_spa_g_fini,
+ .destroy_geom = nvdimm_spa_g_destroy_geom,
};
DECLARE_GEOM_CLASS(nvdimm_spa_g_class, g_spa);
@@ -507,9 +494,7 @@
msleep(&spa->spa_g_queue, &spa->spa_g_mtx, PRIBIO, "spa_e", 0);
mtx_unlock(&spa->spa_g_mtx);
if (spa->spa_g != NULL) {
- g_topology_lock();
g_wither_geom(spa->spa_g, ENXIO);
- g_topology_unlock();
spa->spa_g = NULL;
spa->spa_p = NULL;
}
@@ -535,20 +520,22 @@
{
ACPI_NFIT_SYSTEM_ADDRESS *nfitaddr;
struct SPA_mapping *spa;
- int error, *i, j;
+ int error, j;
- i = arg;
- spa = &spa_mappings[*i];
nfitaddr = nfitsubtbl;
for (j = 0; j < nitems(nvdimm_SPA_uuid_list); j++) {
- /* XXXKIB: is ACPI UUID representation compatible ? */
if (uuidcmp((struct uuid *)&nfitaddr->RangeGuid,
&nvdimm_SPA_uuid_list[j].u_id) != 0)
continue;
+ spa = malloc(sizeof(struct SPA_mapping), M_NVDIMM, M_WAITOK | M_ZERO);
error = nvdimm_spa_init_one(spa, nfitaddr, j);
- if (error != 0)
+ if (error != 0) {
+ g_topology_lock();
nvdimm_spa_fini_one(spa);
+ g_topology_unlock();
+ free(spa, M_NVDIMM);
+ }
break;
}
if (j == nitems(nvdimm_SPA_uuid_list) && bootverbose) {
@@ -556,7 +543,6 @@
printf_uuid((struct uuid *)&nfitaddr->RangeGuid);
printf("\n");
}
- (*i)++;
return (0);
}
@@ -579,20 +565,8 @@
}
error = nvdimm_iterate_nfit(nfitbl, ACPI_NFIT_TYPE_SYSTEM_ADDRESS,
- nvdimm_spa_count, &spa_mappings_cnt);
- if (error != 0)
- return (error);
- spa_mappings = malloc(sizeof(struct SPA_mapping) * spa_mappings_cnt,
- M_NVDIMM, M_WAITOK | M_ZERO);
- i = 0;
- error = nvdimm_iterate_nfit(nfitbl, ACPI_NFIT_TYPE_SYSTEM_ADDRESS,
- nvdimm_spa_parse, &i);
- if (error != 0) {
- free(spa_mappings, M_NVDIMM);
- spa_mappings = NULL;
- return (error);
- }
- return (0);
+ nvdimm_spa_parse, NULL);
+ return (error);
}
static void
@@ -602,8 +576,6 @@
ACPI_STATUS status;
int error;
- spa_mappings_cnt = 0;
- spa_mappings = NULL;
if (acpi_disabled("nvdimm"))
return;
status = AcpiGetTable(ACPI_SIG_NFIT, 1, (ACPI_TABLE_HEADER **)&nfitbl);
@@ -618,16 +590,14 @@
AcpiPutTable(&nfitbl->Header);
}
-static void
-nvdimm_spa_g_fini(struct g_class *mp __unused)
+static int
+nvdimm_spa_g_destroy_geom(struct gctl_req *req, struct g_class *cp,
+ struct g_geom *gp)
{
- int i;
+ struct SPA_mapping *spa;
- if (spa_mappings == NULL)
- return;
- for (i = 0; i < spa_mappings_cnt; i++)
- nvdimm_spa_fini_one(&spa_mappings[i]);
- free(spa_mappings, M_NVDIMM);
- spa_mappings = NULL;
- spa_mappings_cnt = 0;
+ spa = gp->softc;
+ nvdimm_spa_fini_one(spa);
+ free(spa, M_NVDIMM);
+ return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 13, 1:46 AM (15 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15774749
Default Alt Text
D18346.id51134.diff (3 KB)
Attached To
Mode
D18346: nvdimm: add a driver for the NVDIMM root device
Attached
Detach File
Event Timeline
Log In to Comment