Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp662020pxb; Tue, 5 Apr 2022 17:46:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB7C91xx3ZntUIgxYTfM6s82HY2/bI/09Rqb5TZFjez2bc+HX/hi8QEfu8x1Hkc9QTFM10 X-Received: by 2002:a17:907:7204:b0:6db:ebf4:9988 with SMTP id dr4-20020a170907720400b006dbebf49988mr5726889ejc.709.1649205883477; Tue, 05 Apr 2022 17:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649205883; cv=none; d=google.com; s=arc-20160816; b=koxmbBSmM/xICAnsseuwA24vFmxOzP8in7PH7PhvBYIekyjzJ5O2/GDab9tyTc6lM8 ATsAS72Fh/dToBfqlDvJ+kUTnmWRMo8vTkszth6apuqWLAusyMTxsrthRlIyWWNjrVpa 2PUDLww158sg1uc9ZmpAMbYnEU3fYf91oQIAgFDgmgLYxVQ1saojVdHdnn97x/j3yZC7 aozDSUeGM3Qhmb4HCe2NZfO7ZPrdB2nAv9CCnCd/udUFSluS8Fq3wuPi+1ZxCxRFF5Jz 6AbyRSUH9bYfbPOmYwkEwA0W7n0H3OrQb/K97s4KmNgtCojQLFVs77HmbCU7IgMLensz HOCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v+V4C3doOEzLTKDCUzb5Ui3cWDwLQbEdM3o9DxgGNpo=; b=GdufPO0kWOGpmluUsSip7+xNAtfRxoblDQMu5EtIHYqD5Agvtd5YcGhO6y04MZ02ag UEdrCuNwboJyyWWbUEwuzw54AZ7h0SzoNoq+yLS7JyW1pbtzixKktJK9ZgnmPf6/dff9 x3g1VO9WKFlxNtMT7zcMVp9vO7fVwt8eQeGWZc/aE74qwwa4q/2bdM6d2bO5j0v1R+5q jM4QxeJXSIAv//2gxUgONUzDUT11wJlJjU1pOZuivNDS8byNX9AxQ8mgxl49fwWnh1U1 G0tF55S54mLAElaDwEJsUCpDAMoPL2IUjBNKzDtzN9uiaEMWrCmPLD5Kr4JsXBfkSvuX qAdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0K+hzTqx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u23-20020a1709067d1700b006e7ef6c9ed8si5820338ejo.690.2022.04.05.17.44.17; Tue, 05 Apr 2022 17:44:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0K+hzTqx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355349AbiDENHi (ORCPT + 99 others); Tue, 5 Apr 2022 09:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343992AbiDEJQo (ORCPT ); Tue, 5 Apr 2022 05:16:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF58F60FC; Tue, 5 Apr 2022 02:02:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 64109B81C19; Tue, 5 Apr 2022 09:02:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAD43C385A0; Tue, 5 Apr 2022 09:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149344; bh=2valnc8op0vBurNY+QIL/EnW2wscb8NHYd9VGwj8E/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0K+hzTqxAjU3bgGLvlPeOmwTC70tNefza6+7ljj6swHSaaj4C7e9DkaVFAHBU0YY+ Lm/fjLI0iMb0gy1nbkv8lwysRi7a6L60eMDOEPTNfg646sqeLV1HKDOqPQwbjiF9wZ 21PoWi9tt/qhmy696f/a6HvMP0zXkxnuxIKzD/+o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Dan Williams , Sasha Levin Subject: [PATCH 5.16 0683/1017] nvdimm/region: Fix default alignment for small regions Date: Tue, 5 Apr 2022 09:26:36 +0200 Message-Id: <20220405070414.551222067@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Williams [ Upstream commit d9d290d7e659e9db3e4518040cc18b97f5535f4a ] 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") Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/164688416128.2879318.17890707310125575258.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- 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) -- 2.34.1