From patchwork Mon Oct 16 12:52:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 15423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3436406vqb; Mon, 16 Oct 2023 05:53:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfPB07Cx0EgHl+Kf6C1wUGwXDCAzdI96A63JbydIxy4dHqOM4pJcwmfO6QxbKtOoHFcwZX X-Received: by 2002:a05:6359:b9a:b0:14d:2dd5:a777 with SMTP id gf26-20020a0563590b9a00b0014d2dd5a777mr28027720rwb.2.1697460801738; Mon, 16 Oct 2023 05:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697460801; cv=none; d=google.com; s=arc-20160816; b=eU319T3SIG3NuXsjJsgIn2NW+RQsvls27XoVTN8N3O2hwvLXDousFmY0G/6mW3w3Bf jhjxAoGpg8C3IDl6BfpbD+JuWG3PkoCnzJFDeC+tOLiK4JVNGlwFJKmCf1qpd0IJfAhc DBATq5Pc13sMjjC6EFpCTcGzZKH/K6FbhQt86vXATUo+zO1ptjDtidSbjE+ymFdsz0zZ 5ACgO7e8J0WwO9nGxVYA9Ja5AOI+VTFY9VefDp9/OKUHv/lnXGcSmPFg74XVMWwmeC0p x+dCWGvKMOPhrvJCaTGpaIYQdpDAaoKhA+0Lg0sCTesEgazGSVcR3TrTe1+ElrHhGnyt 9rgg== 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 :message-id:date:subject:cc:to:from; bh=Xq5kXvsTJhBu9TRs/OZWAZj95Lq5XxGGaCzC9r5mb0I=; fh=68tg6b1bPtmZVBq+B2APHMHzj3ZViBb0z45z2Kpdrwo=; b=b6Ryfko7SuC91mFZPe7KD9Tarm0z1U8nLrgnjl/cT7yI3uT5jiGY9rfZZ03lewcSN5 xa9dGDP9cQgsnUH7I24E7WCPq92f6PKfTS1lJbxeZB4Ax0hHQgYDg3zD1UA1fAoUwJle kght551OhPBh+Prz4tikkiBi/sveXqQSO/Z27UYGySXHP/T8lVjsssO/Ic++pCihPJTi 7Wr6b3ohbSQGA/hJmX9DdpLbRxE1ZqoxKosWkxH5c9Key0zoWluURuYo37lElo6JkIwP KpQO/1TnE3/ACQtwCY0mchtxxnUgWRMiP7nd5w2zYK6vgoIn8zS4/XgXST1SVjFqaowm jAOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k10-20020aa79d0a000000b006bd78b99aa5si3456558pfp.334.2023.10.16.05.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 05:53:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9C747806AFD0; Mon, 16 Oct 2023 05:53:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233476AbjJPMxJ (ORCPT + 18 others); Mon, 16 Oct 2023 08:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233411AbjJPMxI (ORCPT ); Mon, 16 Oct 2023 08:53:08 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 06FFAE6 for ; Mon, 16 Oct 2023 05:53:06 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 506331FB; Mon, 16 Oct 2023 05:53:46 -0700 (PDT) Received: from entos-ampere02.shanghai.arm.com (unknown [10.169.212.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4EB523F5A1; Mon, 16 Oct 2023 05:53:03 -0700 (PDT) From: Jia He To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux.dev Cc: linux-kernel@vger.kernel.org, nd@arm.com, Jia He Subject: [PATCH v3 0/2] fix dma_addressing_limited() if dma_range_map Date: Mon, 16 Oct 2023 12:52:52 +0000 Message-Id: <20231016125254.1875-1-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 05:53:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779916657955488571 X-GMAIL-MSGID: 1779916657955488571 This is to fix the hangs at boot. The root cause is the nvme device dma mapping is failed in the checking path of phys_to_dma() since dma_max_mapping_size() gave the wrong answer to start with. --- Changelog: v1: https://lore.kernel.org/all/20230912084002.2168-1-justin.he@arm.com/ v2: https://lore.kernel.org/lkml/20231010020835.3678-1-justin.he@arm.com/ - refine the subject and commit msg (By Robin Murphy) - refactor the checking loop in check_ram_in_range_map() in the pages unit to avoid wrap to 0 on 32bits platforms (Robin) v3: - move and export dma_addressing_limited() to avoid adding a new exported helper (by Christoph Hellwig) Jia He (2): dma-mapping: export dma_addressing_limited() dma-mapping: fix dma_addressing_limited() if dma_range_map can't cover all system RAM include/linux/dma-mapping.h | 19 ++++-------- kernel/dma/mapping.c | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 14 deletions(-)