From patchwork Wed Aug 9 12:17:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 13347872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 55EEBEB64DD for ; Wed, 9 Aug 2023 12:18:31 +0000 (UTC) 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=zQQ2RRuPQBal1as7BXYAGUxIAeN/kVKP/HnxfBxGpwc=; b=3eCix5NDT5cS5u 2f6NkghFZAGubCKx01IkHiX8QfH1khgjFA5bCVkBlzcg4XQKCDIkh2t/FyKgEa65HEDjxLnA69BBa OF35tzFuEpCeTe7Kd2jravSoqcoSsDlQohdhpXAr4Huiu6ovBV9Mc68aoUuCvH1ilQEYOSiHc0CoF OW6Yl6nBW2UVmxWyD//U8xJm+9uCvDzIFRelt9uSswNG/LXSQxjMjD65A465JZE5DPMfMOj8hYJCI mhamfYGpvcRvUoeJ/32YKlEG1hC2EYvjZ3DHONMAWNij9NJv/HYQrvibi0o9UK1uCdEV18lRclz1G yLvDZYOmzaieX1kfRMFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qTi8V-004sNV-1S; Wed, 09 Aug 2023 12:17:59 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTi8S-004sM3-05 for linux-arm-kernel@lists.infradead.org; Wed, 09 Aug 2023 12:17:57 +0000 Received: from localhost.localdomain (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by madras.collabora.co.uk (Postfix) with ESMTPSA id 1506C66071A7; Wed, 9 Aug 2023 13:17:49 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1691583469; bh=7wciAx6Fe66k/xC939VdtxHN9VH10TtN7BBc+jsI0Jc=; h=From:To:Cc:Subject:Date:From; b=R4KIhq4EZqpm0AJ7cB7vYdZLkyQZm5YeSfL2S0X/7hnq+q8V3lcM+D8l3AFgjAZiy 4mpUAyITmvInWvni0NwpsIl7GT21b3uf3GB+uLcOAb7bop4wTS+Ybr9FXsuRxmZ4V5 oCyLtLv16UVnv40dCd7qgr5Xezq++M7WgZrVuObzTHsVpAECnaVADxzSvbGRhs/y37 d8Po9E9qLXqecgKEcYs2I0eejtcu4ayw8EHI2fb/dCWbPSYIVvYPU/RjOZqgzs/OGW jO7YDq5cd99cmkneJ2gpiOcezXYf/4gwaKB2PQMcpNO9k+nOcBOqYOA/g7xeNNuFxO 3wrbOXCqqW48w== From: Boris Brezillon To: Joerg Roedel , iommu@lists.linux.dev, Will Deacon , Robin Murphy , linux-arm-kernel@lists.infradead.org Cc: Rob Clark , Boris Brezillon Subject: [PATCH 0/2] iommu: Allow passing custom allocators to pgtable drivers Date: Wed, 9 Aug 2023 14:17:42 +0200 Message-ID: <20230809121744.2341454-1-boris.brezillon@collabora.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230809_051756_248462_E186D574 X-CRM114-Status: GOOD ( 13.57 ) 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 Hello, This patchset is an attempt at making page table allocation customizable. This is useful to some GPU drivers for various reasons: - speed-up upcoming page table allocations by managing a pool of free pages - batch page table allocation instead of allocating one page at a time - pre-reserve pages for page tables needed for map/unmap operations and return the unused page tables to some pool The first and last reasons are particularly important for GPU drivers wanting to implement asynchronous VM_BIND. Asynchronous VM_BIND requires that any page table needed for a map/unmap operation to succeed be allocated at VM_BIND job creation time. At the time of the job creation, we don't know what the VM will look like when we get to execute the map/unmap, and can't guess how many page tables we will need. Because of that, we have to over-provision page tables for the worst case scenario (page table tree is empty), which means we will allocate/free a lot. Having pool a pool of free pages is crucial if we want to speed-up VM_BIND requests. A real example of how such custom allocators can be used is available here[1]. v2 of the Panthor driver is approaching submission, and I figured I'd try to upstream the dependencies separately, which is why I submit this series now, even though the user of this new API will come afterwards. If you'd prefer to have those patches submitted along with the Panthor driver, let me know. This approach has been discussed with Robin, and is hopefully not too far from what he had in mind. Regards, Boris [1]https://gitlab.freedesktop.org/panfrost/linux/-/blob/panthor/drivers/gpu/drm/panthor/panthor_mmu.c#L441 Boris Brezillon (2): iommu: Allow passing custom allocators to pgtable drivers iommu: Extend LPAE page table format to support custom allocators drivers/iommu/io-pgtable-arm.c | 50 +++++++++++++++++++++++----------- drivers/iommu/io-pgtable.c | 31 +++++++++++++++++++++ include/linux/io-pgtable.h | 21 ++++++++++++++ 3 files changed, 86 insertions(+), 16 deletions(-) Reviewed-by: Steven Price Tested-by: Gaurav Kohli