Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1091833pxf; Thu, 18 Mar 2021 21:05:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcWMknt+z0Lty4N+eymTIvGPT3lhjTi2QvgF1zfur3/h1UMT69lYMJJtX+G2c0kLHESOxR X-Received: by 2002:a05:6402:b70:: with SMTP id cb16mr7377371edb.11.1616126735970; Thu, 18 Mar 2021 21:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616126735; cv=none; d=google.com; s=arc-20160816; b=JmS9V1XGevu6DV/ktO8+85N6/QrHbiHZzb8xHu4fx4n0e+CuDJZvgpq5HiuCBz4GjU YnALJGKO8ya1xmFCKBmYS+p+qND19HoQvG1ZgSKdUyRkWeVHoxqURW3pO1CeL1OUDjHT 66EzdGOVWYjz7xDTnU8auHrloROGbU7D9hG1mYulqjXhdzt2Q2oxIUbMaFZOe1vCdP69 6C80EAHQjbQswapDRqOzsAJENB+6l5IOcR021OoBxO9TsinPnM+cav1t1nlnKqTUdXvz nXh7M1KrfSpJMGdtj1uXytAJ3V6nvaO/tcy+ptZ8+YkxVv5Pq1YfCLidcJc7lubvsZag O2/A== 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:dkim-signature; bh=ryeZqjeyYgMVyJ2yaoJp0ylfGz6ueh5H5F2dT0FCD+4=; b=cfxgxE6NaDtUNULLpVG3RmiW1V6lczm/o/lvaSl6YRnxej0Ck7+/hO3ooLw3wpXlpW FSpsSdTzJQmqjWiLk+HyHRQRCuCUvPVbwJZBHSM2OrPU6AHUi/cxtgqPhryqdfcVa5BR T3QwMimwQuTx39+VWlcngVROWeCO9zFII53Zc92LY5l0ywu+gJBWwgx8AVdcrrZJQ4k2 hRTTQrsads8vN28t84EfNI8IYNBKKQ2tBs5VNgBFW+eLxH3g5FC69EFUdM+RV/3cgoNb TTLfklD1xrp9eQkH5iZYZyQwBA72/bC87bKuyFMPjfSwl2djO+CVDidBJQrBihBv2qtk WpWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NEapts2x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mc14si3190959ejb.639.2021.03.18.21.05.12; Thu, 18 Mar 2021 21:05:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NEapts2x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231838AbhCSEEO (ORCPT + 99 others); Fri, 19 Mar 2021 00:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbhCSEDk (ORCPT ); Fri, 19 Mar 2021 00:03:40 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3570CC06174A for ; Thu, 18 Mar 2021 21:03:38 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id s21so4009180pjq.1 for ; Thu, 18 Mar 2021 21:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ryeZqjeyYgMVyJ2yaoJp0ylfGz6ueh5H5F2dT0FCD+4=; b=NEapts2xA7NIOuh03lb2AfHJiMCEq2c9+HhCbqNF1ZLNnT3sOAOrgUHGF8LylRFR64 54Oo13jXEFjx27m3Blc1t1sOFcxy2ajFjm48s2K2HdKcoj/R9LPGBV7r7/+vWshTgyuw lTv23UVUs7HckciSLX98yORfNgmVndcjlhnuzx+r/LB51spj65OJBzqVt8rI2OdTa7AF 1IXKDoP7EQLYyB5prCP6meBtuGt0JThbFkswykK80FWRYblqrP6pC3e77L+nWCWZXuBN IIBuMO1vYsVuROQiMUKF2zjoBnw1HyGirYSYI/zFlnLGo6TFGUyEQx/x7UA+Du17zsZd S5Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ryeZqjeyYgMVyJ2yaoJp0ylfGz6ueh5H5F2dT0FCD+4=; b=FEXQxQssoxVvPSuJkZioPXP3Pxn4e4ECzY5OiTSjrRLl+4r4JFEr1zFb8YDBA2QNws e+A4eP8wqG8YOxE2qj/afOJHpKqK3rVlkidv1RCr1tXX+/dDXDqMaGm/QnGkpROPYVPg Aa5AWRGUzCdnBXkk2j2Ofei4imb9SIBsOZJjhLwweiX0NAHsXBrBq9keAwKIJEvTjW0I Zj6QcV/fzBIdWPlRWph2RyG9hXueo/z5Y5t9DqJAnqvMSFHYWgs5YRI5F0Ime4c+XdAW sEUA84TABLFjALUq278sV3zvBqJYM4jVmzNQmpbVzN41mTBRLnyWX+QWXch+MUWmGY5w ZfPw== X-Gm-Message-State: AOAM531LC7FF8Bk/8rb0Ia8qFLXP5x5yee3rYehlcK0EPrgKFulEOGhc OQpIlfILiSDqjZAEuKiAelY= X-Received: by 2002:a17:90b:fd2:: with SMTP id gd18mr7792951pjb.115.1616126617718; Thu, 18 Mar 2021 21:03:37 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id c24sm3752517pfi.193.2021.03.18.21.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 21:03:37 -0700 (PDT) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org Cc: Florian Fainelli , Konrad Rzeszutek Wilk , Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux-foundation.org (open list:SWIOTLB SUBSYSTEM), linux-kernel@vger.kernel.org (open list), Russell King , Mike Rapoport , Andrew Morton , Ard Biesheuvel , Max Filippov , Catalin Marinas , opendmb@gmail.com Subject: [PATCH] ARM: Qualify enabling of swiotlb_init() Date: Thu, 18 Mar 2021 21:03:33 -0700 Message-Id: <20210319040333.183827-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 828a2561b229..8356bf1daa28 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -301,7 +301,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); -- 2.25.1