Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp874895rwb; Thu, 22 Sep 2022 07:27:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yq83ln2LGgkK8//mwESB/j6/JuFSqo+h8dfD5zZuWaf5rnO/JLOyk3c3tLHT2w4mdIm7b X-Received: by 2002:a63:6e8e:0:b0:430:3886:3a20 with SMTP id j136-20020a636e8e000000b0043038863a20mr3308943pgc.604.1663856833745; Thu, 22 Sep 2022 07:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663856833; cv=none; d=google.com; s=arc-20160816; b=p+wt4X5cf2mVKyCfVR45OsHfUo5LbVXmD+Jh0ie98GBllYEuH2W6C/a8AOsINNMVhv yNuSKeRYVfsjvMznj8e7rEvhN9Gy6bwvPQnmim000QaX9YKOTd3GrRDt/6G9IOxz8A51 /LSH1B6W4Us2Vext/JWPbXu6oN3jVx7FHqsqLZX1tegw/Dva+0w40onH9LePG51S/QdZ r637v0dYy2jI2bQaEnhomaGtYMNBwss5Pu9Lq2UQKRWqCCjQchkZ0WYS/plKDG1Kdnwu iuCWcA5WSOSiMLgV68PnI9Vf5tMMw/F6aoIf20RpF1pdfE5Pv960I/vxr0E1AyPhXk/6 e6cA== 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:dkim-signature; bh=AnEZgNT3rWX40x0L3glC9XDv6W25c/hZHbhMl98veYw=; b=f8bHTf5FL79sqMYeCNA/Nfzk7dxC8sxor9KWnyscUT1pSCRlRVxy3ASLOrRl4bX2Ec n5rBgpQQcp5MPLRnrJCg5ii0EWxLVEpkhU0/3clWjxEH73Zb3OpGTP9GHm3eyOU/RKgI 8JVWuug09jxia2cPHtYS6ptL7IlHRgr/vsfhLVMcMPCAF4TLMRxW3m32HIrxQNMb26xk QDCLuHZVCpvikUVmWGKXHIyaWP2uv3jCzlo40r9TA4bG0WK28qRlQ77J1Sps2v6zYPPV Pm14W4zZZ/O9pr8Ry7jVB/CSV4rVWo1RbtBVxhGcKiqb8p75M20SIWWGceKjVODCPv/h vc9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marcan.st header.s=default header.b=hwq1CgHE; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q30-20020a635c1e000000b00439c6a4b4c9si6670605pgb.329.2022.09.22.07.27.00; Thu, 22 Sep 2022 07:27:13 -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; dkim=pass header.i=@marcan.st header.s=default header.b=hwq1CgHE; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=marcan.st Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229866AbiIVOFU (ORCPT + 99 others); Thu, 22 Sep 2022 10:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbiIVOFS (ORCPT ); Thu, 22 Sep 2022 10:05:18 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FD42A833A for ; Thu, 22 Sep 2022 07:05:17 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id 7381A43EB1; Thu, 22 Sep 2022 14:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1663855515; bh=zazRxHKtoneGKsskBRsohC7oce8ruEz8HWEHQMMKR3Y=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=hwq1CgHEtDkOP+DEoK9qIjM8a8yuGdKuFMm834GspvP7dE/YoaUydpDNQU/KEH8cz NzZAST22rCXOchWb/vSuMBrxMQDTZzxSMUcgyzQRD9LvSvGo2bs4GqM2iYnoh/tTAk rx66yfpmWHBOIG+5QkX5PT6wI9MJ0+0oIHuVQRnkgnL+AHHv+6MENO8vZ1BO6LWbq/ X8tIracsg/nPgSmFd8oNssgAFB+P4GDq4gDRJWl2Em3Albi2yr0Qrizx9NORial9Na DkKyWMVxTgAMwWyxG9RqnTzTl03ifqrlQNVm9Rt9KsrlpJedCp/W4ugkh7tXA/6dqv mXmih0BkwfRpw== Message-ID: Date: Thu, 22 Sep 2022 23:05:10 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v5 2/5] iommu/io-pgtable: Move Apple DART support to its own file Content-Language: es-ES To: Janne Grunau , iommu@lists.linux.dev Cc: Konrad Dybcio , asahi@lists.linux.dev, Robin Murphy , Sven Peter , Alyssa Rosenzweig , Joerg Roedel , Will Deacon , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220916094152.87137-1-j@jannau.net> <20220916094152.87137-3-j@jannau.net> From: Hector Martin In-Reply-To: <20220916094152.87137-3-j@jannau.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS 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 16/09/2022 18.41, Janne Grunau wrote: > The pte format used by the DARTs found in the Apple M1 (t8103) is not > fully compatible with io-pgtable-arm. The 24 MSB are used for subpage > protection (mapping only parts of page) and conflict with the address > mask. In addition bit 1 is not available for tagging entries but disables > subpage protection. Subpage protection could be useful to support a CPU > granule of 4k with the fixed IOMMU page size of 16k. > > The DARTs found on Apple M1 Pro/Max/Ultra use another different pte > format which is even less compatible. To support an output address size > of 42 bit the address is shifted down by 4. Subpage protection is > mandatory and bit 1 signifies uncached mappings used by the display > controller. > > It would be advantageous to share code for all known Apple DART > variants to support common features. The page table allocator for DARTs > is less complex since it uses a two levels of translation table without > support for huge pages. > > Signed-off-by: Janne Grunau > Acked-by: Robin Murphy > Acked-by: Sven Peter > > --- [...] > +static void *__dart_alloc_pages(size_t size, gfp_t gfp, > + struct io_pgtable_cfg *cfg) > +{ > + struct device *dev = cfg->iommu_dev; > + int order = get_order(size); > + struct page *p; > + > + VM_BUG_ON((gfp & __GFP_HIGHMEM)); > + p = alloc_pages(gfp | __GFP_ZERO, order); > + if (!p) > + return NULL; > + > + return page_address(p); > +} This throws a warning: drivers/iommu/io-pgtable-dart.c: In function ‘__dart_alloc_pages’: drivers/iommu/io-pgtable-dart.c:112:24: warning: unused variable ‘dev’ [-Wunused-variable] 112 | struct device *dev = cfg->iommu_dev; | ^~~ The fix is trivial, of course. - Hector