diff options
Diffstat (limited to 'drivers/nvdimm/pfn_devs.c')
-rw-r--r-- | drivers/nvdimm/pfn_devs.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 3e7b11cf1aae..cb98b8fe786e 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c | |||
@@ -655,6 +655,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) | |||
655 | resource_size_t start, size; | 655 | resource_size_t start, size; |
656 | struct nd_region *nd_region; | 656 | struct nd_region *nd_region; |
657 | unsigned long npfns, align; | 657 | unsigned long npfns, align; |
658 | u32 end_trunc; | ||
658 | struct nd_pfn_sb *pfn_sb; | 659 | struct nd_pfn_sb *pfn_sb; |
659 | phys_addr_t offset; | 660 | phys_addr_t offset; |
660 | const char *sig; | 661 | const char *sig; |
@@ -696,6 +697,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) | |||
696 | size = resource_size(&nsio->res); | 697 | size = resource_size(&nsio->res); |
697 | npfns = PHYS_PFN(size - SZ_8K); | 698 | npfns = PHYS_PFN(size - SZ_8K); |
698 | align = max(nd_pfn->align, (1UL << SUBSECTION_SHIFT)); | 699 | align = max(nd_pfn->align, (1UL << SUBSECTION_SHIFT)); |
700 | end_trunc = start + size - ALIGN_DOWN(start + size, align); | ||
699 | if (nd_pfn->mode == PFN_MODE_PMEM) { | 701 | if (nd_pfn->mode == PFN_MODE_PMEM) { |
700 | /* | 702 | /* |
701 | * The altmap should be padded out to the block size used | 703 | * The altmap should be padded out to the block size used |
@@ -714,7 +716,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) | |||
714 | return -ENXIO; | 716 | return -ENXIO; |
715 | } | 717 | } |
716 | 718 | ||
717 | npfns = PHYS_PFN(size - offset); | 719 | npfns = PHYS_PFN(size - offset - end_trunc); |
718 | pfn_sb->mode = cpu_to_le32(nd_pfn->mode); | 720 | pfn_sb->mode = cpu_to_le32(nd_pfn->mode); |
719 | pfn_sb->dataoff = cpu_to_le64(offset); | 721 | pfn_sb->dataoff = cpu_to_le64(offset); |
720 | pfn_sb->npfns = cpu_to_le64(npfns); | 722 | pfn_sb->npfns = cpu_to_le64(npfns); |
@@ -723,6 +725,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) | |||
723 | memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); | 725 | memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); |
724 | pfn_sb->version_major = cpu_to_le16(1); | 726 | pfn_sb->version_major = cpu_to_le16(1); |
725 | pfn_sb->version_minor = cpu_to_le16(3); | 727 | pfn_sb->version_minor = cpu_to_le16(3); |
728 | pfn_sb->end_trunc = cpu_to_le32(end_trunc); | ||
726 | pfn_sb->align = cpu_to_le32(nd_pfn->align); | 729 | pfn_sb->align = cpu_to_le32(nd_pfn->align); |
727 | checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); | 730 | checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); |
728 | pfn_sb->checksum = cpu_to_le64(checksum); | 731 | pfn_sb->checksum = cpu_to_le64(checksum); |