From patchwork Tue Mar 5 20:54:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 10840111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC42F17E0 for ; Tue, 5 Mar 2019 20:54:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B99992AA6B for ; Tue, 5 Mar 2019 20:54:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD26D2CE19; Tue, 5 Mar 2019 20:54:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E4C62CEBF for ; Tue, 5 Mar 2019 20:54:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DEB2789B55; Tue, 5 Mar 2019 20:54:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F5E189B55 for ; Tue, 5 Mar 2019 20:54:42 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id q17so6605121pfh.10 for ; Tue, 05 Mar 2019 12:54:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3sko/Dla6gJ2MlsTozQ22MExjkm/9TQZQ+rE91DCTvQ=; b=fuj60onunXj8gEfkO8cByrZSTlo4Yb8WbpfNE295f9i2jV7Bdlb7/kXwNncCBu7A6z 7kbaubvK4i4T4sBVcQLmOPkAf6qdbwAarhBImTeXQ8RujtbBoWaImQ+nVrOjlBpJOvfo ZC/qXIxIjXTsKkZsF+hqnB+ti18onIwaUI7OTo+wRGMjC0gfFr6XYyR1S9hPq7OlByjO oFY82bKXz0cZFJOxM4xI4eRMwTDezgQlUSAWdXqrI1VCeEBR3sEHw8hUN9mkGvihI8V0 fsnFtXYgihQKiJq4dHCgENv+c09i1iHsws9d/05H4oNGeDuxaCIZnPfzQyCqI/xfDvui xCbA== X-Gm-Message-State: APjAAAWrjukHmd5Z3YKdv/6vFQ/nWUPLQCF6eW3LOv8PXDHdn01zxOqK ASou3jH2LuSBPrECrFSrkv+Vjw== X-Google-Smtp-Source: APXvYqyT2BI00CWfP3ElcpycqhAMpRkoU43GQklbQWoWjw4Ew+Pn0MYprAK7GpqwdVlnW3G+MzagUQ== X-Received: by 2002:a17:902:728f:: with SMTP id d15mr3253789pll.156.1551819281363; Tue, 05 Mar 2019 12:54:41 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id i4sm13411788pfo.158.2019.03.05.12.54.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Mar 2019 12:54:39 -0800 (PST) From: John Stultz To: lkml Subject: [RFC][PATCH 0/5 v2] DMA-BUF Heaps (destaging ION) Date: Tue, 5 Mar 2019 12:54:28 -0800 Message-Id: <1551819273-640-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3sko/Dla6gJ2MlsTozQ22MExjkm/9TQZQ+rE91DCTvQ=; b=g9X9v0YjrXxg8xtTraPDMyNGWK4K5YqwNl4nc+GWpoh4J+EOOukCpaDJPXfDa4P+9B z3kEZSrN/jue+zq/5COC89lPVUTX87WPqkW8aBBAIYjhfvGB5u+3XS57gtl7PLZTTYCR PCHSKrngqe8Nq6uoVbmP1Ua17gnR3gP8N+G07pbVKJW1Xbq4ozn9wAG/WJTj3E0gg4HB MsKbQk7mw1X1X4wvpHfjQxE6klc5dDMlGDuZGklxzSBsAjhklLMWRFuuAy171GQfVA7+ c5+qiUgfU7THq2pXBve8blYmFVy5s3MMfPg2U2AUgmphSzq1xhPW5UbsYEHg9/eIuVye nItQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg KH , Chenbo Feng , Alistair Strachan , Liam Mark , dri-devel@lists.freedesktop.org, "Andrew F . Davis" MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Here is a initial RFC of the dma-buf heaps patchset Andrew and I have been working on which tries to destage a fair chunk of ION functionality. The patchset implements per-heap devices which can be opened directly and then an ioctl is used to allocate a dmabuf from the heap. The interface is similar, but much simpler then IONs, only providing an ALLOC ioctl. Also, I've provided simple system and cma heaps. The system heap in particular is missing the page-pool optimizations ION had, but works well enough to validate the interface. I've booted and tested these patches with AOSP on the HiKey960 using the kernel tree here: https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/dma-buf-heap And the userspace changes here: https://android-review.googlesource.com/c/device/linaro/hikey/+/909436 Compared to ION, this patchset is missing the system-contig, carveout and chunk heaps, as I don't have a device that uses those, so I'm unable to do much useful validation there. Additionally we have no upstream users of chunk or carveout, and the system-contig has been deprecated in the common/andoid-* kernels, so this should be ok. I've also removed the stats accounting for now, since it should be implemented by the heaps themselves. Eventual TODOS: * Reimplement page-pool for system heap (working on this) * Add stats accounting to system/cma heaps * Make the kselftest actually useful * Add other heaps folks see as useful (would love to get some help from actual carveout/chunk users)! That said, the main user-interface is shaping up and I wanted to get some input on the device model (particularly from GreKH) and any other API/ABI specific input. thanks -john Cc: Laura Abbott Cc: Benjamin Gaignard Cc: Greg KH Cc: Sumit Semwal Cc: Liam Mark Cc: Brian Starkey Cc: Andrew F. Davis Cc: Chenbo Feng Cc: Alistair Strachan Cc: dri-devel@lists.freedesktop.org Andrew F. Davis (1): dma-buf: Add dma-buf heaps framework John Stultz (4): dma-buf: heaps: Add heap helpers dma-buf: heaps: Add system heap to dmabuf heaps dma-buf: heaps: Add CMA heap to dmabuf heapss kselftests: Add dma-heap test MAINTAINERS | 16 + drivers/dma-buf/Kconfig | 10 + drivers/dma-buf/Makefile | 2 + drivers/dma-buf/dma-heap.c | 191 ++++++++++++ drivers/dma-buf/heaps/Kconfig | 14 + drivers/dma-buf/heaps/Makefile | 4 + drivers/dma-buf/heaps/cma_heap.c | 164 ++++++++++ drivers/dma-buf/heaps/heap-helpers.c | 335 +++++++++++++++++++++ drivers/dma-buf/heaps/heap-helpers.h | 48 +++ drivers/dma-buf/heaps/system_heap.c | 132 ++++++++ include/linux/dma-heap.h | 65 ++++ include/uapi/linux/dma-heap.h | 52 ++++ tools/testing/selftests/dmabuf-heaps/Makefile | 11 + tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 96 ++++++ 14 files changed, 1140 insertions(+) create mode 100644 drivers/dma-buf/dma-heap.c create mode 100644 drivers/dma-buf/heaps/Kconfig create mode 100644 drivers/dma-buf/heaps/Makefile create mode 100644 drivers/dma-buf/heaps/cma_heap.c create mode 100644 drivers/dma-buf/heaps/heap-helpers.c create mode 100644 drivers/dma-buf/heaps/heap-helpers.h create mode 100644 drivers/dma-buf/heaps/system_heap.c create mode 100644 include/linux/dma-heap.h create mode 100644 include/uapi/linux/dma-heap.h create mode 100644 tools/testing/selftests/dmabuf-heaps/Makefile create mode 100644 tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c