aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2016-09-19 19:38:50 -0400
committerDan Williams <dan.j.williams@intel.com>2016-09-30 22:13:42 -0400
commit44c462eb9e19dfa089b454271dd2dff5eaf1ad6d (patch)
tree4973b6ac54b002b340e1c5a863a982048b2f7c1f
parente046114af5fcafe8d6d3f0b6ccb99804bad34bfb (diff)
libnvdimm, region: move region-mapping input-paramters to nd_mapping_desc
Before we add more libnvdimm-private fields to nd_mapping make it clear which parameters are input vs libnvdimm internals. Use struct nd_mapping_desc instead of struct nd_mapping in nd_region_desc and make struct nd_mapping private to libnvdimm. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/acpi/nfit/core.c30
-rw-r--r--drivers/nvdimm/nd.h14
-rw-r--r--drivers/nvdimm/region_devs.c16
-rw-r--r--include/linux/libnvdimm.h25
4 files changed, 45 insertions, 40 deletions
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 02838f928d7e..6490a15abdd3 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1627,9 +1627,9 @@ static int acpi_nfit_init_interleave_set(struct acpi_nfit_desc *acpi_desc,
1627 if (!info) 1627 if (!info)
1628 return -ENOMEM; 1628 return -ENOMEM;
1629 for (i = 0; i < nr; i++) { 1629 for (i = 0; i < nr; i++) {
1630 struct nd_mapping *nd_mapping = &ndr_desc->nd_mapping[i]; 1630 struct nd_mapping_desc *mapping = &ndr_desc->mapping[i];
1631 struct nfit_set_info_map *map = &info->mapping[i]; 1631 struct nfit_set_info_map *map = &info->mapping[i];
1632 struct nvdimm *nvdimm = nd_mapping->nvdimm; 1632 struct nvdimm *nvdimm = mapping->nvdimm;
1633 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 1633 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
1634 struct acpi_nfit_memory_map *memdev = memdev_from_spa(acpi_desc, 1634 struct acpi_nfit_memory_map *memdev = memdev_from_spa(acpi_desc,
1635 spa->range_index, i); 1635 spa->range_index, i);
@@ -2053,7 +2053,7 @@ static int acpi_nfit_insert_resource(struct acpi_nfit_desc *acpi_desc,
2053} 2053}
2054 2054
2055static int acpi_nfit_init_mapping(struct acpi_nfit_desc *acpi_desc, 2055static int acpi_nfit_init_mapping(struct acpi_nfit_desc *acpi_desc,
2056 struct nd_mapping *nd_mapping, struct nd_region_desc *ndr_desc, 2056 struct nd_mapping_desc *mapping, struct nd_region_desc *ndr_desc,
2057 struct acpi_nfit_memory_map *memdev, 2057 struct acpi_nfit_memory_map *memdev,
2058 struct nfit_spa *nfit_spa) 2058 struct nfit_spa *nfit_spa)
2059{ 2059{
@@ -2070,12 +2070,12 @@ static int acpi_nfit_init_mapping(struct acpi_nfit_desc *acpi_desc,
2070 return -ENODEV; 2070 return -ENODEV;
2071 } 2071 }
2072 2072
2073 nd_mapping->nvdimm = nvdimm; 2073 mapping->nvdimm = nvdimm;
2074 switch (nfit_spa_type(spa)) { 2074 switch (nfit_spa_type(spa)) {
2075 case NFIT_SPA_PM: 2075 case NFIT_SPA_PM:
2076 case NFIT_SPA_VOLATILE: 2076 case NFIT_SPA_VOLATILE:
2077 nd_mapping->start = memdev->address; 2077 mapping->start = memdev->address;
2078 nd_mapping->size = memdev->region_size; 2078 mapping->size = memdev->region_size;
2079 break; 2079 break;
2080 case NFIT_SPA_DCR: 2080 case NFIT_SPA_DCR:
2081 nfit_mem = nvdimm_provider_data(nvdimm); 2081 nfit_mem = nvdimm_provider_data(nvdimm);
@@ -2083,13 +2083,13 @@ static int acpi_nfit_init_mapping(struct acpi_nfit_desc *acpi_desc,
2083 dev_dbg(acpi_desc->dev, "spa%d %s missing bdw\n", 2083 dev_dbg(acpi_desc->dev, "spa%d %s missing bdw\n",
2084 spa->range_index, nvdimm_name(nvdimm)); 2084 spa->range_index, nvdimm_name(nvdimm));
2085 } else { 2085 } else {
2086 nd_mapping->size = nfit_mem->bdw->capacity; 2086 mapping->size = nfit_mem->bdw->capacity;
2087 nd_mapping->start = nfit_mem->bdw->start_address; 2087 mapping->start = nfit_mem->bdw->start_address;
2088 ndr_desc->num_lanes = nfit_mem->bdw->windows; 2088 ndr_desc->num_lanes = nfit_mem->bdw->windows;
2089 blk_valid = 1; 2089 blk_valid = 1;
2090 } 2090 }
2091 2091
2092 ndr_desc->nd_mapping = nd_mapping; 2092 ndr_desc->mapping = mapping;
2093 ndr_desc->num_mappings = blk_valid; 2093 ndr_desc->num_mappings = blk_valid;
2094 ndbr_desc = to_blk_region_desc(ndr_desc); 2094 ndbr_desc = to_blk_region_desc(ndr_desc);
2095 ndbr_desc->enable = acpi_nfit_blk_region_enable; 2095 ndbr_desc->enable = acpi_nfit_blk_region_enable;
@@ -2115,7 +2115,7 @@ static bool nfit_spa_is_virtual(struct acpi_nfit_system_address *spa)
2115static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, 2115static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
2116 struct nfit_spa *nfit_spa) 2116 struct nfit_spa *nfit_spa)
2117{ 2117{
2118 static struct nd_mapping nd_mappings[ND_MAX_MAPPINGS]; 2118 static struct nd_mapping_desc mappings[ND_MAX_MAPPINGS];
2119 struct acpi_nfit_system_address *spa = nfit_spa->spa; 2119 struct acpi_nfit_system_address *spa = nfit_spa->spa;
2120 struct nd_blk_region_desc ndbr_desc; 2120 struct nd_blk_region_desc ndbr_desc;
2121 struct nd_region_desc *ndr_desc; 2121 struct nd_region_desc *ndr_desc;
@@ -2134,7 +2134,7 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
2134 } 2134 }
2135 2135
2136 memset(&res, 0, sizeof(res)); 2136 memset(&res, 0, sizeof(res));
2137 memset(&nd_mappings, 0, sizeof(nd_mappings)); 2137 memset(&mappings, 0, sizeof(mappings));
2138 memset(&ndbr_desc, 0, sizeof(ndbr_desc)); 2138 memset(&ndbr_desc, 0, sizeof(ndbr_desc));
2139 res.start = spa->address; 2139 res.start = spa->address;
2140 res.end = res.start + spa->length - 1; 2140 res.end = res.start + spa->length - 1;
@@ -2150,7 +2150,7 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
2150 2150
2151 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) { 2151 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
2152 struct acpi_nfit_memory_map *memdev = nfit_memdev->memdev; 2152 struct acpi_nfit_memory_map *memdev = nfit_memdev->memdev;
2153 struct nd_mapping *nd_mapping; 2153 struct nd_mapping_desc *mapping;
2154 2154
2155 if (memdev->range_index != spa->range_index) 2155 if (memdev->range_index != spa->range_index)
2156 continue; 2156 continue;
@@ -2159,14 +2159,14 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
2159 spa->range_index, ND_MAX_MAPPINGS); 2159 spa->range_index, ND_MAX_MAPPINGS);
2160 return -ENXIO; 2160 return -ENXIO;
2161 } 2161 }
2162 nd_mapping = &nd_mappings[count++]; 2162 mapping = &mappings[count++];
2163 rc = acpi_nfit_init_mapping(acpi_desc, nd_mapping, ndr_desc, 2163 rc = acpi_nfit_init_mapping(acpi_desc, mapping, ndr_desc,
2164 memdev, nfit_spa); 2164 memdev, nfit_spa);
2165 if (rc) 2165 if (rc)
2166 goto out; 2166 goto out;
2167 } 2167 }
2168 2168
2169 ndr_desc->nd_mapping = nd_mappings; 2169 ndr_desc->mapping = mappings;
2170 ndr_desc->num_mappings = count; 2170 ndr_desc->num_mappings = count;
2171 rc = acpi_nfit_init_interleave_set(acpi_desc, ndr_desc, spa); 2171 rc = acpi_nfit_init_interleave_set(acpi_desc, ndr_desc, spa);
2172 if (rc) 2172 if (rc)
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 38d6f039234e..e58c40824e1f 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -98,6 +98,20 @@ struct nd_percpu_lane {
98 spinlock_t lock; 98 spinlock_t lock;
99}; 99};
100 100
101struct nd_mapping {
102 struct nvdimm *nvdimm;
103 struct nd_namespace_label **labels;
104 u64 start;
105 u64 size;
106 /*
107 * @ndd is for private use at region enable / disable time for
108 * get_ndd() + put_ndd(), all other nd_mapping to ndd
109 * conversions use to_ndd() which respects enabled state of the
110 * nvdimm.
111 */
112 struct nvdimm_drvdata *ndd;
113};
114
101struct nd_region { 115struct nd_region {
102 struct device dev; 116 struct device dev;
103 struct ida ns_ida; 117 struct ida ns_ida;
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index e8d5ba7b29af..0ff43cbb15e3 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -755,10 +755,10 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
755 int ro = 0; 755 int ro = 0;
756 756
757 for (i = 0; i < ndr_desc->num_mappings; i++) { 757 for (i = 0; i < ndr_desc->num_mappings; i++) {
758 struct nd_mapping *nd_mapping = &ndr_desc->nd_mapping[i]; 758 struct nd_mapping_desc *mapping = &ndr_desc->mapping[i];
759 struct nvdimm *nvdimm = nd_mapping->nvdimm; 759 struct nvdimm *nvdimm = mapping->nvdimm;
760 760
761 if ((nd_mapping->start | nd_mapping->size) % SZ_4K) { 761 if ((mapping->start | mapping->size) % SZ_4K) {
762 dev_err(&nvdimm_bus->dev, "%s: %s mapping%d is not 4K aligned\n", 762 dev_err(&nvdimm_bus->dev, "%s: %s mapping%d is not 4K aligned\n",
763 caller, dev_name(&nvdimm->dev), i); 763 caller, dev_name(&nvdimm->dev), i);
764 764
@@ -809,11 +809,13 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
809 ndl->count = 0; 809 ndl->count = 0;
810 } 810 }
811 811
812 memcpy(nd_region->mapping, ndr_desc->nd_mapping,
813 sizeof(struct nd_mapping) * ndr_desc->num_mappings);
814 for (i = 0; i < ndr_desc->num_mappings; i++) { 812 for (i = 0; i < ndr_desc->num_mappings; i++) {
815 struct nd_mapping *nd_mapping = &ndr_desc->nd_mapping[i]; 813 struct nd_mapping_desc *mapping = &ndr_desc->mapping[i];
816 struct nvdimm *nvdimm = nd_mapping->nvdimm; 814 struct nvdimm *nvdimm = mapping->nvdimm;
815
816 nd_region->mapping[i].nvdimm = nvdimm;
817 nd_region->mapping[i].start = mapping->start;
818 nd_region->mapping[i].size = mapping->size;
817 819
818 get_device(&nvdimm->dev); 820 get_device(&nvdimm->dev);
819 } 821 }
diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
index 4a5f8c51f2a5..f4947fda11e7 100644
--- a/include/linux/libnvdimm.h
+++ b/include/linux/libnvdimm.h
@@ -50,23 +50,6 @@ typedef int (*ndctl_fn)(struct nvdimm_bus_descriptor *nd_desc,
50 struct nvdimm *nvdimm, unsigned int cmd, void *buf, 50 struct nvdimm *nvdimm, unsigned int cmd, void *buf,
51 unsigned int buf_len, int *cmd_rc); 51 unsigned int buf_len, int *cmd_rc);
52 52
53struct nd_namespace_label;
54struct nvdimm_drvdata;
55
56struct nd_mapping {
57 struct nvdimm *nvdimm;
58 struct nd_namespace_label **labels;
59 u64 start;
60 u64 size;
61 /*
62 * @ndd is for private use at region enable / disable time for
63 * get_ndd() + put_ndd(), all other nd_mapping to ndd
64 * conversions use to_ndd() which respects enabled state of the
65 * nvdimm.
66 */
67 struct nvdimm_drvdata *ndd;
68};
69
70struct nvdimm_bus_descriptor { 53struct nvdimm_bus_descriptor {
71 const struct attribute_group **attr_groups; 54 const struct attribute_group **attr_groups;
72 unsigned long cmd_mask; 55 unsigned long cmd_mask;
@@ -89,9 +72,15 @@ struct nd_interleave_set {
89 u64 cookie; 72 u64 cookie;
90}; 73};
91 74
75struct nd_mapping_desc {
76 struct nvdimm *nvdimm;
77 u64 start;
78 u64 size;
79};
80
92struct nd_region_desc { 81struct nd_region_desc {
93 struct resource *res; 82 struct resource *res;
94 struct nd_mapping *nd_mapping; 83 struct nd_mapping_desc *mapping;
95 u16 num_mappings; 84 u16 num_mappings;
96 const struct attribute_group **attr_groups; 85 const struct attribute_group **attr_groups;
97 struct nd_interleave_set *nd_set; 86 struct nd_interleave_set *nd_set;