From patchwork Fri Nov 10 09:43:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 13452277 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 332B0C4332F for ; Fri, 10 Nov 2023 09:44:37 +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=NUP3Dn1nOBpVw88LHvO4K8DnzlRQm6xD8co8HQ0SVSo=; b=Gse+N6cpn6pxOo fRJh79syXpg69orC7AV4Y7s8ReP9QP9FnrVEVA8BUxc3cOgTgMX3Gdu7eGct7NsyYz2QJXJuBg34q bD5PMss6u4CQPetL3dZR3MwTnioy82DIG6QjnwYjnJfxXrO59VWwam/jBmpmN1HoZK3mmiUrZcWNf LuGdBuEqL49xh57j8hRJnLUOrJQjhPdizbnr4Hcc9fsvkldRdmnz91hrh5m9x8rr6ODDiYF3gRzfB 0tixWNK014UDWO50f9WDhzwvPnxQkzS8+yfB+g6BBIVMBdwHWnDZOdSGLtHE/BkOrdDCSqz9O1P1h M2A6OA07iYhiRqVFtqdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r1O3a-008DbH-1W; Fri, 10 Nov 2023 09:44:06 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r1O3X-008DYx-20 for linux-arm-kernel@lists.infradead.org; Fri, 10 Nov 2023 09:44:05 +0000 Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (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 5FF3266073E6; Fri, 10 Nov 2023 09:43:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699609437; bh=is0ZWawZ7jqZSJcJX0Mc3C68nH2lkPBAPkiqbprBLOY=; h=From:To:Cc:Subject:Date:From; b=X0OeosqrFuMIeI0Y+dc1G1lRieQ0S7uEnh0zjF9NMIq29TGs1sbEqfEWEB4gLlWE8 dD0nBL5MflCxWpv6pVstiQ5X37Au5UvUYVJeH9jQ3wGI3CKqpaAduH033N0lMvHMY2 08WaQ9d26p6QBTUnJjYQO9NAbd/2vEex7/Rg2NeLK6GT9dhdTbfMQwzcTp5QZxCiys NS7CHqhXJo7acThWHHgLWegR58F6e6zvOA6+IvSs3kCdecZAboq1eLMRSCiewfaMQ6 fZcVJ25T9gPD2oXMSMS7ZvF3G6FqMe30gA/G4UVyfvnrpr56HMwxPT9O6Euo6UkFMZ zvuCjlDhTO2hg== From: Boris Brezillon To: Joerg Roedel , iommu@lists.linux.dev, Will Deacon , Robin Murphy , linux-arm-kernel@lists.infradead.org Cc: Rob Clark , Gaurav Kohli , Steven Price , Boris Brezillon Subject: [PATCH v2 0/2] iommu: Allow passing custom allocators to pgtable drivers Date: Fri, 10 Nov 2023 10:43:50 +0100 Message-ID: <20231110094352.565347-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-20231110_014403_788369_5BFB5F97 X-CRM114-Status: GOOD ( 13.64 ) 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. There might also be other good reasons to want custom allocators, like fine-grained memory accounting and resource limiting. 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. 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 | 55 ++++++++++++++++++++++++---------- drivers/iommu/io-pgtable.c | 23 ++++++++++++++ include/linux/io-pgtable.h | 31 +++++++++++++++++++ 3 files changed, 93 insertions(+), 16 deletions(-) Reviewed-by: Gaurav Kohli Tested-by: Gaurav Kohli