1818
1919static DEFINE_IDA (dimm_ida );
2020
21- static bool noblk ;
22- module_param (noblk , bool , 0444 );
23- MODULE_PARM_DESC (noblk , "force disable BLK / local alias support" );
24-
2521/*
2622 * Retrieve bus and dimm handle and return if this bus supports
2723 * get_config_data commands
@@ -211,22 +207,6 @@ struct nvdimm *to_nvdimm(struct device *dev)
211207}
212208EXPORT_SYMBOL_GPL (to_nvdimm );
213209
214- struct nvdimm * nd_blk_region_to_dimm (struct nd_blk_region * ndbr )
215- {
216- struct nd_region * nd_region = & ndbr -> nd_region ;
217- struct nd_mapping * nd_mapping = & nd_region -> mapping [0 ];
218-
219- return nd_mapping -> nvdimm ;
220- }
221- EXPORT_SYMBOL_GPL (nd_blk_region_to_dimm );
222-
223- unsigned long nd_blk_memremap_flags (struct nd_blk_region * ndbr )
224- {
225- /* pmem mapping properties are private to libnvdimm */
226- return ARCH_MEMREMAP_PMEM ;
227- }
228- EXPORT_SYMBOL_GPL (nd_blk_memremap_flags );
229-
230210struct nvdimm_drvdata * to_ndd (struct nd_mapping * nd_mapping )
231211{
232212 struct nvdimm * nvdimm = nd_mapping -> nvdimm ;
@@ -312,8 +292,7 @@ static ssize_t flags_show(struct device *dev,
312292{
313293 struct nvdimm * nvdimm = to_nvdimm (dev );
314294
315- return sprintf (buf , "%s%s%s\n" ,
316- test_bit (NDD_ALIASING , & nvdimm -> flags ) ? "alias " : "" ,
295+ return sprintf (buf , "%s%s\n" ,
317296 test_bit (NDD_LABELING , & nvdimm -> flags ) ? "label " : "" ,
318297 test_bit (NDD_LOCKED , & nvdimm -> flags ) ? "lock " : "" );
319298}
@@ -612,8 +591,6 @@ struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
612591
613592 nvdimm -> dimm_id = dimm_id ;
614593 nvdimm -> provider_data = provider_data ;
615- if (noblk )
616- flags |= 1 << NDD_NOBLK ;
617594 nvdimm -> flags = flags ;
618595 nvdimm -> cmd_mask = cmd_mask ;
619596 nvdimm -> num_flush = num_flush ;
@@ -726,133 +703,6 @@ static unsigned long dpa_align(struct nd_region *nd_region)
726703 return nd_region -> align / nd_region -> ndr_mappings ;
727704}
728705
729- int alias_dpa_busy (struct device * dev , void * data )
730- {
731- resource_size_t map_end , blk_start , new ;
732- struct blk_alloc_info * info = data ;
733- struct nd_mapping * nd_mapping ;
734- struct nd_region * nd_region ;
735- struct nvdimm_drvdata * ndd ;
736- struct resource * res ;
737- unsigned long align ;
738- int i ;
739-
740- if (!is_memory (dev ))
741- return 0 ;
742-
743- nd_region = to_nd_region (dev );
744- for (i = 0 ; i < nd_region -> ndr_mappings ; i ++ ) {
745- nd_mapping = & nd_region -> mapping [i ];
746- if (nd_mapping -> nvdimm == info -> nd_mapping -> nvdimm )
747- break ;
748- }
749-
750- if (i >= nd_region -> ndr_mappings )
751- return 0 ;
752-
753- ndd = to_ndd (nd_mapping );
754- map_end = nd_mapping -> start + nd_mapping -> size - 1 ;
755- blk_start = nd_mapping -> start ;
756-
757- /*
758- * In the allocation case ->res is set to free space that we are
759- * looking to validate against PMEM aliasing collision rules
760- * (i.e. BLK is allocated after all aliased PMEM).
761- */
762- if (info -> res ) {
763- if (info -> res -> start >= nd_mapping -> start
764- && info -> res -> start < map_end )
765- /* pass */ ;
766- else
767- return 0 ;
768- }
769-
770- retry :
771- /*
772- * Find the free dpa from the end of the last pmem allocation to
773- * the end of the interleave-set mapping.
774- */
775- align = dpa_align (nd_region );
776- if (!align )
777- return 0 ;
778-
779- for_each_dpa_resource (ndd , res ) {
780- resource_size_t start , end ;
781-
782- if (strncmp (res -> name , "pmem" , 4 ) != 0 )
783- continue ;
784-
785- start = ALIGN_DOWN (res -> start , align );
786- end = ALIGN (res -> end + 1 , align ) - 1 ;
787- if ((start >= blk_start && start < map_end )
788- || (end >= blk_start && end <= map_end )) {
789- new = max (blk_start , min (map_end , end ) + 1 );
790- if (new != blk_start ) {
791- blk_start = new ;
792- goto retry ;
793- }
794- }
795- }
796-
797- /* update the free space range with the probed blk_start */
798- if (info -> res && blk_start > info -> res -> start ) {
799- info -> res -> start = max (info -> res -> start , blk_start );
800- if (info -> res -> start > info -> res -> end )
801- info -> res -> end = info -> res -> start - 1 ;
802- return 1 ;
803- }
804-
805- info -> available -= blk_start - nd_mapping -> start ;
806-
807- return 0 ;
808- }
809-
810- /**
811- * nd_blk_available_dpa - account the unused dpa of BLK region
812- * @nd_mapping: container of dpa-resource-root + labels
813- *
814- * Unlike PMEM, BLK namespaces can occupy discontiguous DPA ranges, but
815- * we arrange for them to never start at an lower dpa than the last
816- * PMEM allocation in an aliased region.
817- */
818- resource_size_t nd_blk_available_dpa (struct nd_region * nd_region )
819- {
820- struct nvdimm_bus * nvdimm_bus = walk_to_nvdimm_bus (& nd_region -> dev );
821- struct nd_mapping * nd_mapping = & nd_region -> mapping [0 ];
822- struct nvdimm_drvdata * ndd = to_ndd (nd_mapping );
823- struct blk_alloc_info info = {
824- .nd_mapping = nd_mapping ,
825- .available = nd_mapping -> size ,
826- .res = NULL ,
827- };
828- struct resource * res ;
829- unsigned long align ;
830-
831- if (!ndd )
832- return 0 ;
833-
834- device_for_each_child (& nvdimm_bus -> dev , & info , alias_dpa_busy );
835-
836- /* now account for busy blk allocations in unaliased dpa */
837- align = dpa_align (nd_region );
838- if (!align )
839- return 0 ;
840- for_each_dpa_resource (ndd , res ) {
841- resource_size_t start , end , size ;
842-
843- if (strncmp (res -> name , "blk" , 3 ) != 0 )
844- continue ;
845- start = ALIGN_DOWN (res -> start , align );
846- end = ALIGN (res -> end + 1 , align ) - 1 ;
847- size = end - start + 1 ;
848- if (size >= info .available )
849- return 0 ;
850- info .available -= size ;
851- }
852-
853- return info .available ;
854- }
855-
856706/**
857707 * nd_pmem_max_contiguous_dpa - For the given dimm+region, return the max
858708 * contiguous unallocated dpa range.
@@ -900,24 +750,16 @@ resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
900750 * nd_pmem_available_dpa - for the given dimm+region account unallocated dpa
901751 * @nd_mapping: container of dpa-resource-root + labels
902752 * @nd_region: constrain available space check to this reference region
903- * @overlap: calculate available space assuming this level of overlap
904753 *
905754 * Validate that a PMEM label, if present, aligns with the start of an
906- * interleave set and truncate the available size at the lowest BLK
907- * overlap point.
908- *
909- * The expectation is that this routine is called multiple times as it
910- * probes for the largest BLK encroachment for any single member DIMM of
911- * the interleave set. Once that value is determined the PMEM-limit for
912- * the set can be established.
755+ * interleave set.
913756 */
914757resource_size_t nd_pmem_available_dpa (struct nd_region * nd_region ,
915- struct nd_mapping * nd_mapping , resource_size_t * overlap )
758+ struct nd_mapping * nd_mapping )
916759{
917- resource_size_t map_start , map_end , busy = 0 , available , blk_start ;
918760 struct nvdimm_drvdata * ndd = to_ndd (nd_mapping );
761+ resource_size_t map_start , map_end , busy = 0 ;
919762 struct resource * res ;
920- const char * reason ;
921763 unsigned long align ;
922764
923765 if (!ndd )
@@ -929,46 +771,28 @@ resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
929771
930772 map_start = nd_mapping -> start ;
931773 map_end = map_start + nd_mapping -> size - 1 ;
932- blk_start = max (map_start , map_end + 1 - * overlap );
933774 for_each_dpa_resource (ndd , res ) {
934775 resource_size_t start , end ;
935776
936777 start = ALIGN_DOWN (res -> start , align );
937778 end = ALIGN (res -> end + 1 , align ) - 1 ;
938779 if (start >= map_start && start < map_end ) {
939- if (strncmp (res -> name , "blk" , 3 ) == 0 )
940- blk_start = min (blk_start ,
941- max (map_start , start ));
942- else if (end > map_end ) {
943- reason = "misaligned to iset" ;
944- goto err ;
945- } else
946- busy += end - start + 1 ;
780+ if (end > map_end ) {
781+ nd_dbg_dpa (nd_region , ndd , res ,
782+ "misaligned to iset\n" );
783+ return 0 ;
784+ }
785+ busy += end - start + 1 ;
947786 } else if (end >= map_start && end <= map_end ) {
948- if (strncmp (res -> name , "blk" , 3 ) == 0 ) {
949- /*
950- * If a BLK allocation overlaps the start of
951- * PMEM the entire interleave set may now only
952- * be used for BLK.
953- */
954- blk_start = map_start ;
955- } else
956- busy += end - start + 1 ;
787+ busy += end - start + 1 ;
957788 } else if (map_start > start && map_start < end ) {
958789 /* total eclipse of the mapping */
959790 busy += nd_mapping -> size ;
960- blk_start = map_start ;
961791 }
962792 }
963793
964- * overlap = map_end + 1 - blk_start ;
965- available = blk_start - map_start ;
966- if (busy < available )
967- return ALIGN_DOWN (available - busy , align );
968- return 0 ;
969-
970- err :
971- nd_dbg_dpa (nd_region , ndd , res , "%s\n" , reason );
794+ if (busy < nd_mapping -> size )
795+ return ALIGN_DOWN (nd_mapping -> size - busy , align );
972796 return 0 ;
973797}
974798
@@ -999,7 +823,7 @@ struct resource *nvdimm_allocate_dpa(struct nvdimm_drvdata *ndd,
999823/**
1000824 * nvdimm_allocated_dpa - sum up the dpa currently allocated to this label_id
1001825 * @nvdimm: container of dpa-resource-root + labels
1002- * @label_id: dpa resource name of the form { pmem|blk} -<human readable uuid>
826+ * @label_id: dpa resource name of the form pmem-<human readable uuid>
1003827 */
1004828resource_size_t nvdimm_allocated_dpa (struct nvdimm_drvdata * ndd ,
1005829 struct nd_label_id * label_id )
0 commit comments