diff mbox series

[1/6] nvdimm/region: Fix default alignment for small regions

Message ID 164688416128.2879318.17890707310125575258.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series libnvdimm: Jettison block-aperture-window support | expand

Commit Message

Dan Williams March 10, 2022, 3:49 a.m. UTC
In preparation for removing BLK aperture support the NVDIMM unit tests
discovered that the default alignment can be set higher than the
capacity of the region. Fall back to PAGE_SIZE in that case.

Given this has not been seen in the wild, elide notifying -stable.

Fixes: 2522afb86a8c ("libnvdimm/region: Introduce an 'align' attribute")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/nvdimm/region_devs.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Christoph Hellwig March 10, 2022, 7:09 a.m. UTC | #1
On Wed, Mar 09, 2022 at 07:49:21PM -0800, Dan Williams wrote:
> In preparation for removing BLK aperture support the NVDIMM unit tests
> discovered that the default alignment can be set higher than the
> capacity of the region. Fall back to PAGE_SIZE in that case.
> 
> Given this has not been seen in the wild, elide notifying -stable.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 9ccf3d608799..70ad891a76ba 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -1025,6 +1025,9 @@  static unsigned long default_align(struct nd_region *nd_region)
 		}
 	}
 
+	if (nd_region->ndr_size < MEMREMAP_COMPAT_ALIGN_MAX)
+		align = PAGE_SIZE;
+
 	mappings = max_t(u16, 1, nd_region->ndr_mappings);
 	div_u64_rem(align, mappings, &remainder);
 	if (remainder)