From patchwork Thu Sep 23 00:14:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12511687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 762FFC433EF for ; Thu, 23 Sep 2021 00:16:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43E77611CA for ; Thu, 23 Sep 2021 00:16:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 43E77611CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CeGkBUkGxOOjDxAFPnzOWhhdWqjEIvWlNqWSYRycfBY=; b=vph/Sf+HT/qGwY BDLchl+JzNIbX4UWWQRnPTAcOP17fJNtzTfwoqTXKB8iMSwJwSFy9N9XkcdmKjAq8Iyd6+a1NrFoU 5Gzy/RImynHAF0dju72smcB0LZROSMkHd56gWTzfB4ygVSpwFNbdB5HQOnXWxug+EB7napWQ+fCQF ax6xReANVVtc2miyYvbR1gHt0/jGvYUsOAHv0nxQRKLXcczBryUJ4FocuEX8+nw4E5MzWBQNsHVi7 kTOJtiuxYLrYXm0sxk8+OjfNlVGulEHeaKDLEJd7XYdYMW0zjwAS5W5JQxz5e6/M+brbnwpAHJzRr ko8jmPYOHhOFSMrKqpAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTCNp-00A03v-3g; Thu, 23 Sep 2021 00:14:37 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTCNl-00A03W-UB for linux-arm-kernel@lists.infradead.org; Thu, 23 Sep 2021 00:14:35 +0000 Received: by mail-pj1-x102f.google.com with SMTP id k23-20020a17090a591700b001976d2db364so3625338pji.2 for ; Wed, 22 Sep 2021 17:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M419tx9qbN6UyXQusgJi5ma7tnyBkMa/xyVjWd0AjKs=; b=FYrhaM3Wle0ET5ZjzF9KA8vMYqQ4uCCqyrlFaGudSc9FXrJPWIzIIoV7w2c4BwHxDN XPHbzfoiECIRsaPLTY7XyQaLgDP5xpXlNDrKMH14LZAxAUVMFSnD+OG9HIeZ+lsK2sOI iPF17L2fUK+oD994nnXHM5qbrTz6bLLM2l3UJxBB/Lb6AId0cJ4LaVGghVISS+XDlTei H3FkKFubuHbia9u/MvvhMKagHJKJkRSJizS0Cij+y9XNEmlR0g3SDg+e0e6f5+L3oMGg PgcH7yqokTRBG+FHOu+C0Cg8Fjwlgii05B4vW8yykRzTYib9jBrUsSCzeX7kwZdY28Ne nJxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M419tx9qbN6UyXQusgJi5ma7tnyBkMa/xyVjWd0AjKs=; b=fr+JJ7+Sc4Zja6mZeS2Uq/PQE1nSjEhzEam9wK1ugYdHctPtX/Bmk3s8aM7M3V5SDz rUC8sLpgmzU1riePlvPJZxQWwnqEdhgsWDpiRC8oCky3xrSWbjIFCFW3pHy24/qj1QGw Z5QBl5PS86+6lUOKl2yQBV7qzkN83usaaTNc7RrkHudgCP3Y+EyoSwj1wp7pAHaAvt8m FgWo5qlfv0sPu21qU5FcxieKxJSkImDBAJ7jqsIcZcNF9Re3HiXVo4tVjHom53VDYTwg PgyNJVrKy1Vpn63N96FbfUKU6vUK1Z081MbuDFcCVcEazjW7Pqgii+F7B0rq4Vtyro5R YNTg== X-Gm-Message-State: AOAM532IsdEFsP2UXhzjYtw4dEsAvKsZYL98DBPLDJLizkh89hkAhf1s NcFNTUe3zsYEM5AkOQCwF1c= X-Google-Smtp-Source: ABdhPJx64rbQwadQ7CvJCPSG7vl0Z/DZcFYRFaKJ7clwipFuO7X+n7QWRpSRgk43U+4o7ZLRBdxuZg== X-Received: by 2002:a17:90b:383:: with SMTP id ga3mr1974925pjb.72.1632356072892; Wed, 22 Sep 2021 17:14:32 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id p26sm2789734pfw.137.2021.09.22.17.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 17:14:32 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Sasha Levin , stable@vger.kernel.org, Florian Fainelli , Konrad Rzeszutek Wilk , Russell King , Mike Rapoport , Andrew Morton , Ard Biesheuvel , Max Filippov , linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT) Subject: [PATCH stable 5.10] ARM: Qualify enabling of swiotlb_init() Date: Wed, 22 Sep 2021 17:14:24 -0700 Message-Id: <20210923001425.414046-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210922_171434_013334_3381D4D4 X-CRM114-Status: GOOD ( 13.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org commit fcf044891c84e38fc90eb736b818781bccf94e38 upstream We do not need a SWIOTLB unless we have DRAM that is addressable beyond the arm_dma_limit. Compare max_pfn with arm_dma_pfn_limit to determine whether we do need a SWIOTLB to be initialized. Fixes: ad3c7b18c5b3 ("arm: use swiotlb for bounce buffering on LPAE configs") Signed-off-by: Florian Fainelli Signed-off-by: Konrad Rzeszutek Wilk --- arch/arm/mm/init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index d54d69cf1732..75f3ab531bdf 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -378,7 +378,11 @@ static void __init free_highpages(void) void __init mem_init(void) { #ifdef CONFIG_ARM_LPAE - swiotlb_init(1); + if (swiotlb_force == SWIOTLB_FORCE || + max_pfn > arm_dma_pfn_limit) + swiotlb_init(1); + else + swiotlb_force = SWIOTLB_NO_FORCE; #endif set_max_mapnr(pfn_to_page(max_pfn) - mem_map);