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: 159710 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp5410308jad; Tue, 5 Mar 2019 12:54:42 -0800 (PST) X-Received: by 2002:a17:902:968a:: with SMTP id n10mr3223780plp.283.1551819282203; Tue, 05 Mar 2019 12:54:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551819282; cv=none; d=google.com; s=arc-20160816; b=yWC8U1n9bv9A/l+Jtz+RMx2BpW9Y5hX1Sj54Wob+vx0S9pjJzeSFc9S65sTlE1wzDa 5kTCNd5mzthBwSzBJr4TJ2J3ZDHHNffVshuFxA3/P7YerwcroMi0GzP/Ml4nbzZMVv48 IWXmkhcx/BjVxRb3LR8je4zhhAzgrrpOASRmYIoxUoFz/Hx9EVDA4aQaeS2tOyRRiIc7 SZJFB13lW8HF8JVECxjgetRkJxzMDQX9VWT3hC0RvES7t69I8D0eRbc4ZYDnYKnWeNOj 8yNwu6HnVNX8CQ7Q6eZZ8CFgRqgKkSfI3wLCmBMWpbROqNk92TlAVyESDKLjIyQJV2+8 XGRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=3sko/Dla6gJ2MlsTozQ22MExjkm/9TQZQ+rE91DCTvQ=; b=xrcrKdMuuKp4q2rv9FBeTn/oVFbY0e3yr2n6T3GUqbvcQbl0giYGRAsqitBJ3Z7U38 Czrau8sHAFCvMPtXpwOBEkW7RzU8PhpLjew+npjRfwMdlOIrS76H6fVQfF/Iy71El0gn jvUyTBHHbrtUZnBox0jzKKhufa1SGwZfRsSvWRZ89auZ5IPJzdETBlRT907m0GY5RukE hBxveiBVPZBuF+AFgR61c8IqsisJDkC9nHbHxsHgvcS8pDng4hqYxtSBBbHAzScUEFyk F9NGtycNlUVulJU4BdMry1BOySHYssHkBHf10DYWSfuc5JG1kvtkeWgvgdMywDvhN8IM mD1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g9X9v0Yj; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b8sor15203440plb.67.2019.03.05.12.54.41 for (Google Transport Security); Tue, 05 Mar 2019 12:54:41 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g9X9v0Yj; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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=CIekUzsGbf4lxx3URLNeggnLQOHPMsaIvKaECLrzwX4yj5a6Ycn0uHbTwEd33YQRgR KE5mxhjl2Q4lOClmcx4324w5ocEBe2qV4gv+urpjIfJxrdgbA48TZGoiuEUVMPl+70a1 yrroWOBiPncF2QGcGlPX66KCbflSTBbHp6OwaRUAvwaoYv53Eemp3n26qvjMeByO6Hv5 cQmfDRST+zDgVigIfUFY7searcHWU3b7ncGlnR0jWc51dlGgF73qrPpnKGd4RoApG0wM 03HJ4R0tz2WiwxI0ViOfzipzlzA1OTFkErlZ61YLsgDknF4ysB4Q0phXn8jNy8SvO16M RTcQ== X-Gm-Message-State: APjAAAV5fOH8dG8y/YZgsQZWiQGtxJH+vxdDgrwhqlGeJ8a18lUvdSms nmQCeMvs9yS627ndyhISo+msoj4A 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) Return-Path: 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 Cc: John Stultz , Laura Abbott , Benjamin Gaignard , Greg KH , Sumit Semwal , Liam Mark , Brian Starkey , "Andrew F . Davis" , Chenbo Feng , Alistair Strachan , dri-devel@lists.freedesktop.org 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 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 -- 2.7.4