Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2469025rwd; Fri, 16 Jun 2023 04:15:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nIXMCgFKvpBkJd7pmrDZA/HZYVuyN2v+jMHjlplxwrEFm7m3PcGPG0OWGOqW8UJytDUno X-Received: by 2002:a05:6808:1403:b0:39a:b35b:a06c with SMTP id w3-20020a056808140300b0039ab35ba06cmr2055386oiv.30.1686914100717; Fri, 16 Jun 2023 04:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686914100; cv=none; d=google.com; s=arc-20160816; b=ppnrCVky9yvKpSdriJwrJHzHCWcA1eDs3cP8t7etP1savRA25axR8nchP5k7m8wqfZ QSpzo5dqARS5qW/CaOYdJjxpea/6hS0bdFA+eUU9/aHyH/HrvUtpbspEsR76+ts+7kOd 9BTqq4piMpTUqwt+IVRmeSRxcsErz4UleJ4G3lq1R8wgrWnyuOax8HApvv+dnKO/AAfN 1K2w1N0lc13+FMOpgKrwrbvMHGK4U2xeqdVIz2QcE1i4E/5H09o/dM9JrgSKmA6enQ4Y BV3LUuL4/6gN6eWfVjFOqxa6EY5kFzTE4DK2Rchi1X7KyfH6Ub2pQeSxyt6Gz8M7iBFu C3rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=tTmHBKzyGK5Rv5YIbeXxSFp9x2ttVkCdW1wDM8n3S30=; b=nGaBJY9n3StE84YmLJPYWCTgejtqqaoRxI3u+04ltoLAIMLGQc/C6HER8Nae8mT682 cnLl3Z9neAI1cEx9gxzYUSkAE0oujCQhLxZmffFV5123xI1tMBf51996HzLfjCuStFxZ 85PsA+yoKJlWf7JgZyt9fA4MDxd4VlfGR9zLTgTyxxTMG3yCqddifc7aWuxdOq/YMaCc zKgdbHFlE5bRqnHAq15qSblMu8eKaC0yZz6d73gzkrJnirGzKsRWOm4EF6A/stN0lhOD O5kwwBRnSKN4wqXpXCxFbQqlFTo6CnWb/O0K2T4ryJaTqOlskxEDUq7aKGbXVDJ5U9it B8hg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me3-20020a17090b17c300b0025546028cbesi1558309pjb.31.2023.06.16.04.14.48; Fri, 16 Jun 2023 04:15:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345562AbjFPLEP (ORCPT + 99 others); Fri, 16 Jun 2023 07:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345163AbjFPLDv (ORCPT ); Fri, 16 Jun 2023 07:03:51 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D40D55BE for ; Fri, 16 Jun 2023 03:58:16 -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 D836E1FB; Fri, 16 Jun 2023 03:58:59 -0700 (PDT) Received: from [10.57.85.251] (unknown [10.57.85.251]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F2653F5A1; Fri, 16 Jun 2023 03:58:14 -0700 (PDT) Message-ID: <7c6558bc-36a2-a9fa-dc66-466b3948f61f@arm.com> Date: Fri, 16 Jun 2023 11:58:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2 3/3] iommu: rockchip: Allocate tables from all available memory Content-Language: en-GB To: Jonas Karlman , Joerg Roedel , Will Deacon , Heiko Stuebner Cc: Benjamin Gaignard , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org References: <20230615201042.2291867-1-jonas@kwiboo.se> <20230615201042.2291867-4-jonas@kwiboo.se> <67aab611-29cd-1a80-d0e2-e5b6523b2785@arm.com> <0feaf393-21ca-f6ff-bc5d-d179d6169a70@kwiboo.se> From: Robin Murphy In-Reply-To: <0feaf393-21ca-f6ff-bc5d-d179d6169a70@kwiboo.se> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-06-15 23:26, Jonas Karlman wrote: > On 2023-06-15 23:25, Robin Murphy wrote: >> On 2023-06-15 21:10, Jonas Karlman wrote: >>> Newer Rockchip SoCs, RK356x and RK3588, support more then 4GB of memory. >> >> Older ones supposedly did too, e.g. commit 79db45be2b8b ("ARM: dts: >> rockchip: convert rk3288 device tree files to 64 bits"). Are we certain >> that nobody actually has a system with IOMMUv1 and more than 4GB of RAM? > > In IOMMU v1 bit 11:0 read back as 0 from MMU_DTE_ADDR reg, so I expect > that the old limit for v1 is 4GB. Right, that was my point, sorry if it was unclear - on at least RK3288, the *SoC* apparently supports RAM above 4GB, even if it's only the CPUs that can access it. GFP_DMA32 technically *is* correct and appropriate for IOMMUv1, so it's only safe to unconditionally remove it if we're sure that, on all relevant IOMMUv1 SoCs in practice, no RAM above 4GB exists such that ZONE_NORMAL is empty and all allocations come from ZONE_DMA32 by default anyway. (in truth this only matters for 64-bit SoCs, since on 32-bit there is no ZONE_DMA32, but any >4GB RAM would already have to be in ZONE_HIGHMEM, so safely out of scope) Thanks, Robin. > I will reword this to focus on IOMMU > v1 vs v2 instead of SoCs in v3. > >> >>> However, the RK IOMMU driver is using the GFP_DMA32 flag to limit >>> allocation of the discovery and page tables into memory below 4GB. >>> >>> Let's remove this limitation now that the discovery table address is >> >> Nit: s/discovery/directory/g again > > Will fix in v3 :-) > > Regards, > Jonas > >> >> Thanks, >> Robin. >> >>> correctly configured for addresses above 4GB. >>> >>> Signed-off-by: Jonas Karlman >>> --- >>> v2: >>> - no change >>> >>> drivers/iommu/rockchip-iommu.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c >>> index 62be9bf42390..46498fc382ee 100644 >>> --- a/drivers/iommu/rockchip-iommu.c >>> +++ b/drivers/iommu/rockchip-iommu.c >>> @@ -727,7 +727,7 @@ static u32 *rk_dte_get_page_table(struct rk_iommu_domain *rk_domain, >>> if (rk_dte_is_pt_valid(dte)) >>> goto done; >>> >>> - page_table = (u32 *)get_zeroed_page(GFP_ATOMIC | GFP_DMA32); >>> + page_table = (u32 *)get_zeroed_page(GFP_ATOMIC); >>> if (!page_table) >>> return ERR_PTR(-ENOMEM); >>> >>> @@ -1076,7 +1076,7 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type) >>> * Each level1 (dt) and level2 (pt) table has 1024 4-byte entries. >>> * Allocate one 4 KiB page for each table. >>> */ >>> - rk_domain->dt = (u32 *)get_zeroed_page(GFP_KERNEL | GFP_DMA32); >>> + rk_domain->dt = (u32 *)get_zeroed_page(GFP_KERNEL); >>> if (!rk_domain->dt) >>> goto err_free_domain; >>> >