From patchwork Thu Apr 4 16:25:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank van der Linden X-Patchwork-Id: 13618052 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8D10CD1292 for ; Thu, 4 Apr 2024 16:25:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58DF56B009A; Thu, 4 Apr 2024 12:25:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 53E636B009C; Thu, 4 Apr 2024 12:25:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 405FA6B009E; Thu, 4 Apr 2024 12:25:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1DE396B009A for ; Thu, 4 Apr 2024 12:25:25 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D17EC80B06 for ; Thu, 4 Apr 2024 16:25:24 +0000 (UTC) X-FDA: 81972374568.18.DCDFE68 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf10.hostedemail.com (Postfix) with ESMTP id 29926C002C for ; Thu, 4 Apr 2024 16:25:22 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=JmO9WkLX; spf=pass (imf10.hostedemail.com: domain of 3cdQOZgQKCIwvBt1w44w1u.s421y3AD-220Bqs0.47w@flex--fvdl.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3cdQOZgQKCIwvBt1w44w1u.s421y3AD-220Bqs0.47w@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712247923; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=JwgqNuPbWd+ghf0eHeFjaoIaXwCHA/FmnPhXROWNzvU=; b=7Xc9UJ/uFPNz7/BvwBEwYk53nWLHk4o32QZeKbmv7pY5yo+zYl9oZtO1vobdudilCXZjTQ jCQ6dOpW8+Dc0Hqvsfpj7khOD2qwgHz3Il2e3a9r9oI4e87mCFjRj0DG5bExIW6d++oLHJ 2j1gFytt7UVvHsAJx9mjoQQUVIkdAzU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712247923; a=rsa-sha256; cv=none; b=HOmj4/qPFmxngEjOg3aNM5P5JL9lC00JR9SPxNy/jU1DTh9byrQfPfuLJwYYamWBWZ+1+w pM+SHUi9FQZAhKcDdXT+H1lqk7HahCHpqI/t6Mob/9cavuGAdXdKXnqPn7Fuy0od3YU0sT z5TqeG32HGMV6loCRvBMeYE7k/XV8+0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=JmO9WkLX; spf=pass (imf10.hostedemail.com: domain of 3cdQOZgQKCIwvBt1w44w1u.s421y3AD-220Bqs0.47w@flex--fvdl.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3cdQOZgQKCIwvBt1w44w1u.s421y3AD-220Bqs0.47w@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6ecf5c622c2so290214b3a.0 for ; Thu, 04 Apr 2024 09:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712247922; x=1712852722; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=JwgqNuPbWd+ghf0eHeFjaoIaXwCHA/FmnPhXROWNzvU=; b=JmO9WkLXLsiQw2ff+bMJ5a8Wzev3RfceGpM9v6s9FzX7HDNrFMV95MAmDAblm9w19o jeGBcDXiOB2ydCSDVxO1z5oLQTjkOEkipK+KtjBxvyXo6EI3UyR+nuMu39U4OM4XU7yQ O5v7dxDpIIUMyea60bjW+YxXj2nvxngs2O+kz9rJfjXGw6OaY1Jf4cdjzjMVrRdcBbs/ CYqxJGo9mJkZ5fkHuw/TJwoCAC623GHvqsFANnSVEsREhsF+qj0Zizr8pIuS8lBujz0C EBoI3PL4YFtTB7z3HDJIWnpQbNFV5kU/Zrvp1QVJm+djQwCyZirnw5PODyheLixxOVdn ru6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712247922; x=1712852722; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=JwgqNuPbWd+ghf0eHeFjaoIaXwCHA/FmnPhXROWNzvU=; b=GC98ppmViJa1SsyEZXDWLebvlhCb02kyIyI6Zs26Xv8UpZriciNsVQCjKB5eFykd1n ryALxAiczlibFxIa9AiH5jBa7N/J3y2UGBPCJdw7GZoHukPfGutWVDllzzgS6CcC/Szb 2IDzVBMVNTsgz9Pdaz8Z0U+xKaKbwbSuTaGnZFIBRUO17oKXht8v56j27V7PQ7qdBghW LqLi1+a9Xu0h4Kn28KKeeSkG90CInYjAV0j1n16WdbYctSwtpFCvRauS2+QI9RQr7Zy3 sZGIRQ6pYjDZYoOY5xV2FXcb9iZAKRi0PxcfYpf0EOF6Ggvj7EbRSDIonBrHEmomSEiw u7HQ== X-Gm-Message-State: AOJu0Yzgo8BQTXh/Ei4mhusD4q7UDQ7NRNvsfjp8VVo/AacOFKVOnbAx wgOtIAZLJtYIraJSrrryO4L0dLK4M1lXEOqXTmNEGPpdnEXx9cmWLIPOyn94JXTsUA7jVHc9XXC s78Frq9geisLBZgqAwp+TFFv2xnxAxFoIX5Qp6I1wNVyGDrPqeNMT8nkhiV0bIJeE2PUmO7SU1Q D6LkLGShYoC23nYTJB X-Google-Smtp-Source: AGHT+IGmTy0ApIn2dhH0LzN26X146CIvoiU4QSzU9JW23Tz+Bp1C3JdAh55IZ1CT3/6jCiShvd/YXKP2 X-Received: from fvdl-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:46ab]) (user=fvdl job=sendgmr) by 2002:a05:6a00:9a8:b0:6ea:8ece:3b3a with SMTP id u40-20020a056a0009a800b006ea8ece3b3amr198pfg.4.1712247921520; Thu, 04 Apr 2024 09:25:21 -0700 (PDT) Date: Thu, 4 Apr 2024 16:25:14 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240404162515.527802-1-fvdl@google.com> Subject: [PATCH 1/2] mm/cma: drop incorrect alignment check in cma_init_reserved_mem From: Frank van der Linden To: linux-mm@kvack.org, muchun.song@linux.dev, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Frank van der Linden , Marek Szyprowski , David Hildenbrand X-Rspamd-Queue-Id: 29926C002C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: f3n7e17bt1xao3bk4tjro3pab8he1ftn X-HE-Tag: 1712247922-203303 X-HE-Meta: U2FsdGVkX19NbJ4iSVzhEWxT0GUFaETtHMEqQ5tdqKOPYbjGPJgNuYvW2Z7qciIdk9tNxuCXImn+IiI1aKJDqxgL0Xiabxmq1zq6F2frG0v0xwf9wVMCiHsDs9EbMdVzGqPB54MsecWWHcOPyGMd9k5ckwR1OSRhVNRpl14ZYopm6JPoCRINbCpfuTPRqrl5vn0HQ4B0cADgEH3GnGFebXDzy5PVwM6lpg7HbMKyOY9vp91qTJ+EfjunP/V9xcqfXE1n3v9Pn+3qQMvrJa6XNQufCwGyU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93oOpwJ/TgESPYH/UJgxzTSVgcWc7+I8HxdCBZvRrswFW3U87s1eOl01CVarYu9iHLCaAvSJYzql4XpEwLSIWNnx6v1RMBDF3M4CUHkOJ4JlCptmAIWuMX2bVEPcD9LmybGedyxRGmibB1GIh+qLyDqnrXJ3ztLWfq3aXb7nBOLVRhck55G2TEbLeqbqC7J1D1pz4d1PgqWi6zxOqXFfmPR1hNOUlgJQ0H529DM5aakHvKqH9eQEvszQmSpj62r7akxnBFUhiL/ai7VN+zbDmjPtNAIDgiarNibP1lvT67nw175GJvV9/016ZEoSkpag== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001468, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: cma_init_reserved_mem uses IS_ALIGNED to check if the size represented by one bit in the cma allocation bitmask is aligned with CMA_MIN_ALIGNMENT_BYTES (pageblock size). However, this is too strict, as this will fail if order_per_bit > pageblock_order, which is a valid configuration. We could check IS_ALIGNED both ways, but since both numbers are powers of two, no check is needed at all. Signed-off-by: Frank van der Linden Cc: Marek Szyprowski Cc: David Hildenbrand Fixes: de9e14eebf33 ("drivers: dma-contiguous: add initialization from device tree") --- mm/cma.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index 01f5a8f71ddf..3e9724716bad 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -182,10 +182,6 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, if (!size || !memblock_is_region_reserved(base, size)) return -EINVAL; - /* alignment should be aligned with order_per_bit */ - if (!IS_ALIGNED(CMA_MIN_ALIGNMENT_PAGES, 1 << order_per_bit)) - return -EINVAL; - /* ensure minimal alignment required by mm core */ if (!IS_ALIGNED(base | size, CMA_MIN_ALIGNMENT_BYTES)) return -EINVAL;