From patchwork Wed Sep 22 21:58:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12511503 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,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 60374C433F5 for ; Wed, 22 Sep 2021 22:01:54 +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 223C5611CA for ; Wed, 22 Sep 2021 22:01:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 223C5611CA 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=cEJejXAp8LEqgdZ6f3oYyPb5MaHngJIkLTDDWGucZKI=; b=wdeXgzGl7etKKQ ZDBp+9U2E9uysDXbTtdxGEiykuPA0cb2yGrOYj7iA5GVIRu1thgsMP8FwfJk/sQaYE6NJECZWCDy5 dVY47Wowi3cxusbr6MTvU6vvCp3LJuqUicl9Q7LbOVnFOiZ22SolaXJ42po1VtQhQkiqftnL24sQ7 V/G9tNf7W5X63aIi2gfgHrYytstx9TKv753cAFIitsfJEcLQZe4G1cj8j+yEAKykYJjw5+JgN2D2j F2Go4EE3WfTIRnPiBYtC4h0tgHAoJVncPDCDuk+vhOKZG7G0LcyAjmuk7Sy/91KajFKBfnjtw4shm 7GP557ZTMecIYSXs+/+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTAGd-009nBi-P5; Wed, 22 Sep 2021 21:59:04 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTAGY-009nAy-VQ for linux-arm-kernel@lists.infradead.org; Wed, 22 Sep 2021 21:59:00 +0000 Received: by mail-pj1-x102a.google.com with SMTP id pf3-20020a17090b1d8300b0019e081aa87bso3463954pjb.0 for ; Wed, 22 Sep 2021 14:58:58 -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=rMBeU/71xEPqn3ZCfK2c1H6EFmFZ1vtxEagd/NgluDo=; b=nJaJX1L1Jc9ae4su39y8VecCuh+/vHKtQhHDFIEl/e/OHm5irOXp0pW/1pjT8n7vZ6 gO7FOn4jlZEDWeHDtm5aUFzfUPviM7bObmILAY1RGRrAgqP1tZDD0ClK8wkhsyM8fBpL rV0xtol3/Cz9KGWMevriO5Joh36NTEFcwYfnp4BMeoi8cnMQYTvPj55Th6HF4gS8J0T+ CG7Lb/wdVlLkLrnf7thPDtIOgtG0eUlAwPzYWkLstFpO+sm5nMpDoRWymzL5vQ6gLWcJ xk0EvEPUJwrIqZgxQye9gIwR3fPw3P3/JRqHgpQ5dh9P7ZN3vOaL2Hnp2WCaIfkXQwzl eF+Q== 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=rMBeU/71xEPqn3ZCfK2c1H6EFmFZ1vtxEagd/NgluDo=; b=yB0kQ6PlSrkQTlHzn6mpM0yuk/7zYHIY2qNqAibCkwG1H12FLEzx2dz4q7M0hNrh/E hoRUQ67HJAoctuvbKh2iK/6br4/MlieGAb5GpFQeeCyP7tyeYfMPK7PsnQ2jGHkoSecF EvW5zUYXk+UjzMkUPuqmtPEzDj0dEw80gN8QuaXQqhf2H3MA4GsaxCaaeJBa8e6QUC5u 6NMZDm4FQsW4wFhU40lxuwVa2ZLaQryPgwJzJl1tLwPtD/IiTiv1PTMSvRsit1mCZdRe Dqh60i195F93x7Qd0keZ7ECB7Aw35Q0sjhbXeAjEMBuiYLd1xAXBaBscdHIZ5dJ30H49 /Hkw== X-Gm-Message-State: AOAM531M68pZ7G9hr7f7s1eWzjvuVauvpamnD1j8uBQtp5LdqCXSjEZW HWo6lx3vd/SHoOp7wFvKVPY= X-Google-Smtp-Source: ABdhPJzpAheJ6Ku5Z/vFaZMTZsvnC1yk9Gkgs3akEYvrhjtlQLoDpKkSnHu+7wcqZgAsjL0fMArFAA== X-Received: by 2002:a17:902:e04d:b0:13a:70c9:11b8 with SMTP id x13-20020a170902e04d00b0013a70c911b8mr1164001plx.82.1632347938124; Wed, 22 Sep 2021 14:58:58 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id x10sm6516891pjv.57.2021.09.22.14.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 14:58:57 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, Greg Kroah-Hartman , Sasha Levin , Florian Fainelli , Konrad Rzeszutek Wilk , Russell King , Linus Walleij , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT) Subject: [PATCH stable 5.4] ARM: Qualify enabling of swiotlb_init() Date: Wed, 22 Sep 2021 14:58:51 -0700 Message-Id: <20210922215851.312769-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_145859_061125_3619BB21 X-CRM114-Status: GOOD ( 13.19 ) 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 0804a6af4a3b..5a3641b5ec2c 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -469,7 +469,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);