@@ -580,6 +580,11 @@ int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns)
580
580
}
581
581
EXPORT_SYMBOL (nd_pfn_probe );
582
582
583
+ static u32 info_block_reserve (void )
584
+ {
585
+ return ALIGN (SZ_8K , PAGE_SIZE );
586
+ }
587
+
583
588
/*
584
589
* We hotplug memory at section granularity, pad the reserved area from
585
590
* the previous section base to the namespace base address.
@@ -593,7 +598,7 @@ static unsigned long init_altmap_base(resource_size_t base)
593
598
594
599
static unsigned long init_altmap_reserve (resource_size_t base )
595
600
{
596
- unsigned long reserve = PHYS_PFN ( SZ_8K ) ;
601
+ unsigned long reserve = info_block_reserve () >> PAGE_SHIFT ;
597
602
unsigned long base_pfn = PHYS_PFN (base );
598
603
599
604
reserve += base_pfn - PFN_SECTION_ALIGN_DOWN (base_pfn );
@@ -608,6 +613,7 @@ static int __nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap)
608
613
u64 offset = le64_to_cpu (pfn_sb -> dataoff );
609
614
u32 start_pad = __le32_to_cpu (pfn_sb -> start_pad );
610
615
u32 end_trunc = __le32_to_cpu (pfn_sb -> end_trunc );
616
+ u32 reserve = info_block_reserve ();
611
617
struct nd_namespace_common * ndns = nd_pfn -> ndns ;
612
618
struct nd_namespace_io * nsio = to_nd_namespace_io (& ndns -> dev );
613
619
resource_size_t base = nsio -> res .start + start_pad ;
@@ -621,7 +627,7 @@ static int __nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap)
621
627
res -> end -= end_trunc ;
622
628
623
629
if (nd_pfn -> mode == PFN_MODE_RAM ) {
624
- if (offset < SZ_8K )
630
+ if (offset < reserve )
625
631
return - EINVAL ;
626
632
nd_pfn -> npfns = le64_to_cpu (pfn_sb -> npfns );
627
633
pgmap -> altmap_valid = false;
@@ -634,7 +640,7 @@ static int __nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap)
634
640
le64_to_cpu (nd_pfn -> pfn_sb -> npfns ),
635
641
nd_pfn -> npfns );
636
642
memcpy (altmap , & __altmap , sizeof (* altmap ));
637
- altmap -> free = PHYS_PFN (offset - SZ_8K );
643
+ altmap -> free = PHYS_PFN (offset - reserve );
638
644
altmap -> alloc = 0 ;
639
645
pgmap -> altmap_valid = true;
640
646
} else
@@ -678,18 +684,17 @@ static void trim_pfn_device(struct nd_pfn *nd_pfn, u32 *start_pad, u32 *end_trun
678
684
if (region_intersects (start , size , IORESOURCE_SYSTEM_RAM ,
679
685
IORES_DESC_NONE ) == REGION_MIXED
680
686
|| !IS_ALIGNED (end , nd_pfn -> align )
681
- || nd_region_conflict (nd_region , start , size + adjust ))
687
+ || nd_region_conflict (nd_region , start , size ))
682
688
* end_trunc = end - phys_pmem_align_down (nd_pfn , end );
683
689
}
684
690
685
691
static int nd_pfn_init (struct nd_pfn * nd_pfn )
686
692
{
687
- u32 dax_label_reserve = is_nd_dax (& nd_pfn -> dev ) ? SZ_128K : 0 ;
688
693
struct nd_namespace_common * ndns = nd_pfn -> ndns ;
689
694
struct nd_namespace_io * nsio = to_nd_namespace_io (& ndns -> dev );
695
+ u32 start_pad , end_trunc , reserve = info_block_reserve ();
690
696
resource_size_t start , size ;
691
697
struct nd_region * nd_region ;
692
- u32 start_pad , end_trunc ;
693
698
struct nd_pfn_sb * pfn_sb ;
694
699
unsigned long npfns ;
695
700
phys_addr_t offset ;
@@ -734,19 +739,18 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
734
739
*/
735
740
start = nsio -> res .start + start_pad ;
736
741
size = resource_size (& nsio -> res );
737
- npfns = PFN_SECTION_ALIGN_UP ((size - start_pad - end_trunc - SZ_8K )
742
+ npfns = PFN_SECTION_ALIGN_UP ((size - start_pad - end_trunc - reserve )
738
743
/ PAGE_SIZE );
739
744
if (nd_pfn -> mode == PFN_MODE_PMEM ) {
740
745
/*
741
746
* The altmap should be padded out to the block size used
742
747
* when populating the vmemmap. This *should* be equal to
743
748
* PMD_SIZE for most architectures.
744
749
*/
745
- offset = ALIGN (start + SZ_8K + 64 * npfns + dax_label_reserve ,
750
+ offset = ALIGN (start + reserve + 64 * npfns ,
746
751
max (nd_pfn -> align , PMD_SIZE )) - start ;
747
752
} else if (nd_pfn -> mode == PFN_MODE_RAM )
748
- offset = ALIGN (start + SZ_8K + dax_label_reserve ,
749
- nd_pfn -> align ) - start ;
753
+ offset = ALIGN (start + reserve , nd_pfn -> align ) - start ;
750
754
else
751
755
return - ENXIO ;
752
756
0 commit comments