Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6486013rwd; Mon, 19 Jun 2023 08:00:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6uT4vj8DaDWN2655oC4zNAJ25yPhlRGe/7LlT26vwQmGlDemW9Day8nJD1e2NQxOqebF/+ X-Received: by 2002:a05:6a20:7f93:b0:118:eeef:2a25 with SMTP id d19-20020a056a207f9300b00118eeef2a25mr15033671pzj.34.1687186801147; Mon, 19 Jun 2023 08:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687186801; cv=none; d=google.com; s=arc-20160816; b=IkAkY6/wErdSqFH1ShosAJCFV6GIBsneV8BcdQc7Ema1ohEHK/aCNm46EKe7bMW79q hylOKhBXc4pCGosLV4bV7ZQ6029yMNq7UcB1AixnCMV3fTogImfCgpi9kCDZaaWdL36G zT3gTafvX8szoNko6WL3F56LDPmn4D5CPW41KeaJ6L/oSvdPhusTJGz3nTqBp7defBs2 Zyma8x7VXVquRb6uAzGWFebbxrkIBpORDCeiorPOrZt7hAzWeaFWIbjQCo370C+SfFdv m3aHAsCGKvM76gwAEdeHza0yrzaHAy5bZXxyOeFaL6hzUr/H1lkYDXIFD2Lv5R/6GPbR S9Sw== 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=XuRYDEW8oUUVZqi0ELA6zfcAcMEgGOJisx24mYD03ic=; b=jrOZFYVpej7W0nblV7ua+xyLF0LVrQiza2PEgy9EYoXSFZOoqKHEWFlJYVeMw/5Oab 6JZe4X7qYlQnBiTCQZN+hf5tCCqT2LNf7U0QWNXgRto+g4CxqSWnS0g8+UIOE/5VXfTZ viWHjmSwDQpRnA3y1iKKnxzmwGsUg7hngMSY6hnhSIftwe4+9/3aBmZ3Iur6bRxuLO8i ZEDMY5UpXExPdhrF0054mLBFgbU4HUqNjXjB2PSyAvJVm7cA7JyBc0CZopidLvc9pEUl OW3rAf1+No1HJFBuIQX/r98VTt39wtXnvVtiMA3bikVoBBHs8yyTFZGLrCs0JtcDJgP5 742Q== 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 j14-20020a637a4e000000b005538961c4ebsi6204501pgn.715.2023.06.19.07.59.47; Mon, 19 Jun 2023 08:00:01 -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 S232135AbjFSOvd (ORCPT + 99 others); Mon, 19 Jun 2023 10:51:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbjFSOvc (ORCPT ); Mon, 19 Jun 2023 10:51:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C1BA8C1 for ; Mon, 19 Jun 2023 07:51:30 -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 577F512FC; Mon, 19 Jun 2023 07:52:14 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6ACBB3F59C; Mon, 19 Jun 2023 07:51:29 -0700 (PDT) Message-ID: <092dda67-8751-9e80-304d-05465162cd97@arm.com> Date: Mon, 19 Jun 2023 15:51:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v3 2/2] iommu: rockchip: Allocate tables from all available memory for IOMMU v2 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: <20230617182540.3091374-1-jonas@kwiboo.se> <20230617182540.3091374-3-jonas@kwiboo.se> From: Robin Murphy In-Reply-To: <20230617182540.3091374-3-jonas@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 17/06/2023 7:25 pm, Jonas Karlman wrote: > IOMMU v2 found in newer Rockchip SoCs, e.g. RK356x and RK3588, support > placing directory and page tables in up to 40-bit addressable physical > memory. > > Remove the use of GFP_DMA32 flag for IOMMU v2 now that the physical > address to the directory table is correctly written to DTE_ADDR. FWIW I'd be tempted to refactor a bit harder since this is closely coupled to the DMA mask and both could be calculated from a single data value, but there's absolutely nothing wrong with this approach either. Reviewed-by: Robin Murphy [ In fact if you start down that rabbit-hole, then I think logically it leads to an even bigger refactor to convert the whole lot to use dma_alloc_pages() instead ] > Signed-off-by: Jonas Karlman > --- > v3: > - rework to only affect IOMMU v2 > > v2: > - no change > > drivers/iommu/rockchip-iommu.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c > index ae42959bc490..8ff69fbf9f65 100644 > --- a/drivers/iommu/rockchip-iommu.c > +++ b/drivers/iommu/rockchip-iommu.c > @@ -99,6 +99,7 @@ struct rk_iommu_ops { > u32 (*mk_dtentries)(dma_addr_t pt_dma); > u32 (*mk_ptentries)(phys_addr_t page, int prot); > u64 dma_bit_mask; > + gfp_t gfp_flags; > }; > > struct rk_iommu { > @@ -727,7 +728,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 | rk_ops->gfp_flags); > if (!page_table) > return ERR_PTR(-ENOMEM); > > @@ -1076,7 +1077,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 | rk_ops->gfp_flags); > if (!rk_domain->dt) > goto err_free_domain; > > @@ -1377,6 +1378,7 @@ static struct rk_iommu_ops iommu_data_ops_v1 = { > .mk_dtentries = &rk_mk_dte, > .mk_ptentries = &rk_mk_pte, > .dma_bit_mask = DMA_BIT_MASK(32), > + .gfp_flags = GFP_DMA32, > }; > > static struct rk_iommu_ops iommu_data_ops_v2 = { > @@ -1384,6 +1386,7 @@ static struct rk_iommu_ops iommu_data_ops_v2 = { > .mk_dtentries = &rk_mk_dte_v2, > .mk_ptentries = &rk_mk_pte_v2, > .dma_bit_mask = DMA_BIT_MASK(40), > + .gfp_flags = 0, > }; > > static const struct of_device_id rk_iommu_dt_ids[] = {