From patchwork Thu Mar 10 03:49:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 550181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6714FC433EF for ; Thu, 10 Mar 2022 03:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239311AbiCJDuX (ORCPT ); Wed, 9 Mar 2022 22:50:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231249AbiCJDuX (ORCPT ); Wed, 9 Mar 2022 22:50:23 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8FFF6D946 for ; Wed, 9 Mar 2022 19:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646884161; x=1678420161; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=01uk1STa+uanKsxMHNVT1kNKcSTu9PKVe8HwVPVDqRs=; b=nGnNZFG8Mi7theFu20BJ6DoZ+fkscs6hkhwB2VpH1eru2zfDCN4/HMdq m5bl6nGtzkJSqm/vBDjl8FajBL5HFZrSNU3NRADjFYVYsFGaV7kLfBTFf w4lLfJJAefeGZ5XFAX5OU99O3OQR8RxZJ+lNjAqQHuWqdGgU++CzkSG+b 3hOU6FglZcPbGEqhaYa2PQsnULKdGifJWxBz4QjH74AIzZpDlDwNS8uxg 2uZQL5vLWhKs9jlHePUHHvLa46VdNwQ0ZbdcbjtFfwDWwrZhCNAknwPgK 23IbmMUtyd+44nF9reD6fIsEIuhznrV6RUXHvUYaQsv71v2nZK0UqCKHx Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10281"; a="279887037" X-IronPort-AV: E=Sophos;i="5.90,169,1643702400"; d="scan'208";a="279887037" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2022 19:49:21 -0800 X-IronPort-AV: E=Sophos;i="5.90,169,1643702400"; d="scan'208";a="781317744" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2022 19:49:21 -0800 Subject: [PATCH 1/6] nvdimm/region: Fix default alignment for small regions From: Dan Williams To: nvdimm@lists.linux.dev Cc: robert.hu@linux.intel.com, vishal.l.verma@intel.com, hch@lst.de, linux-acpi@vger.kernel.org Date: Wed, 09 Mar 2022 19:49:21 -0800 Message-ID: <164688416128.2879318.17890707310125575258.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <164688415599.2879318.17035042246954533659.stgit@dwillia2-desk3.amr.corp.intel.com> References: <164688415599.2879318.17035042246954533659.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 Reviewed-by: Christoph Hellwig --- drivers/nvdimm/region_devs.c | 3 +++ 1 file changed, 3 insertions(+) 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)