|
@@ -536,6 +536,37 @@ resource_size_t nd_blk_available_dpa(struct nd_region *nd_region)
|
|
|
return info.available;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * nd_pmem_max_contiguous_dpa - For the given dimm+region, return the max
|
|
|
+ * contiguous unallocated dpa range.
|
|
|
+ * @nd_region: constrain available space check to this reference region
|
|
|
+ * @nd_mapping: container of dpa-resource-root + labels
|
|
|
+ */
|
|
|
+resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
|
|
|
+ struct nd_mapping *nd_mapping)
|
|
|
+{
|
|
|
+ struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
|
|
|
+ struct nvdimm_bus *nvdimm_bus;
|
|
|
+ resource_size_t max = 0;
|
|
|
+ struct resource *res;
|
|
|
+
|
|
|
+ /* if a dimm is disabled the available capacity is zero */
|
|
|
+ if (!ndd)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ nvdimm_bus = walk_to_nvdimm_bus(ndd->dev);
|
|
|
+ if (__reserve_free_pmem(&nd_region->dev, nd_mapping->nvdimm))
|
|
|
+ return 0;
|
|
|
+ for_each_dpa_resource(ndd, res) {
|
|
|
+ if (strcmp(res->name, "pmem-reserve") != 0)
|
|
|
+ continue;
|
|
|
+ if (resource_size(res) > max)
|
|
|
+ max = resource_size(res);
|
|
|
+ }
|
|
|
+ release_free_pmem(nvdimm_bus, nd_mapping);
|
|
|
+ return max;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* nd_pmem_available_dpa - for the given dimm+region account unallocated dpa
|
|
|
* @nd_mapping: container of dpa-resource-root + labels
|