From patchwork Fri Mar 29 00:15:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 161374 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1367799jan; Thu, 28 Mar 2019 17:16:07 -0700 (PDT) X-Received: by 2002:a62:5ec2:: with SMTP id s185mr6294089pfb.16.1553818567841; Thu, 28 Mar 2019 17:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553818567; cv=none; d=google.com; s=arc-20160816; b=oRX3sxMn70dFT8hV80KE8kv30oPN7x7SylysEd+4B+jkh4tcvRhfaVwTeAg2mV8A23 OIv3VXKnzOEZp8HyWimT5BoiFf63TqPVWczi5AaQaFf+12+7voy1f4JqirGvlWkDoWbP 0n5+yAC1/5BSDVwaEfUvVUIt3M+SwLYNY3aDqYnMxcmpVbTJ5shfaf5LY3UaSXfGoyiU PyJaJ/weBCJkDKgN+AL4cE5Qxv3M0oqaM5uk4J+wafhk/TDKLwERsBAGBEkOK6NoUERr N6Y/EqAvFR2aPO7lAYE+H1ZyqJDurSNuLPwATe7MPA7ceuMJIQHYdoI6qDBGVaErILAo GT6Q== 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=zUD6J6xvycIjyNyLvpEuugsPd2gKGFqcuvSvKt5Ezpk=; b=oaideespMKmDaqXtN3aNvsf9N4s3mQvv3Cc4Hlb8Ksn4QAcBimvbUCquVfmPI+WDjo zU3uX2NLVuxdsmyEG3ugdu6oZFe5h+uyEpg8HkE99AHRsIoV8r9kdvduEwUG2Kjak4vy rgTmamH+IQxIZl1pNrxpdHf0N9IGpKNx4NSIMLEb04MNiAKy5UjPDMAw6QXvV8noa8Jp zqT67nuIACsA7V2sx3UaXYbWQAPAvQrTkucfpW3GUXJ/rmt+CWuHcU3Ho+iI/uleFzG1 qmyCtIhq85dzqfQUAKvcNLLs9Snsz7LqtXTJ1jfofVGjq2vBoCYvgkPNUmbSHQ0wqB/g 6WqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fB+O0res; 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 d33sor422031pla.12.2019.03.28.17.16.07 for (Google Transport Security); Thu, 28 Mar 2019 17:16:07 -0700 (PDT) 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=fB+O0res; 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=zUD6J6xvycIjyNyLvpEuugsPd2gKGFqcuvSvKt5Ezpk=; b=fB+O0resKM3NMQsIy2cMyDKoPAozo2Dj4jfS7fml6mW72XIV5N9Cv4ireGBBjcwzZW N/AHI56YHyigeAMcRvi0aJ4tJpBak5GaMzVh0rNJ7k6TRlUZ1f+kgk9v9kpK81RdP3sw ykvzH87A2KzPg6EgXO4WJOEVGcrN6apaFPsfS1fBwNwWpWRDhkevJ3E0LmS+Luue0z+Q NWCkLtxp2ssv8rWq7HyUDNU3iRcMI/o9wEVNrTcJthGqJwkHFM654mnTLbO/KREUQMkE A3pOzjyBoiXf3ou/0HNtwGHk89ze0lfh2zzMJVojusRLwu7rHCQ6bdMG36ShNExyQj+O wjow== 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=zUD6J6xvycIjyNyLvpEuugsPd2gKGFqcuvSvKt5Ezpk=; b=ph+EkPdU2iPF0HCilHQRESBmZNFzPyIVPydNfsnn2+b6EJ+VBqtuGhIun1HhNtorWC 0FSGkDWlhKd7ntL3o2ixi5F0/xOsQwc4DIOISCZX2EcNQHJ3jI6XzW5AUML1PI4jpqc+ NGqhMtzg1wRpuofm4rMp2x9N9MAV9MKdiyqF27rldOTdYiSK8m+JurRAy30SYwhxnBI0 YMNvDSRGvUc5AOwycQpvrl9bcyhrv5/WSjhcoyWeuQyU7zYKntCSZVfRX6fFrd7RUkBr 3CFKDs2I0yljWDvaBjbk2uYLLb/wZboy8bYE5W7/9Ns+7+lRCanglmsmEIfhGT++7Zno 2fOQ== X-Gm-Message-State: APjAAAV78NADCjwHopBg6uBtjct0nbdi6YWXZvC8hz8qdJF/djrBVTDy RyW0CUe3vw746hzLYAwb9HtSNOKj X-Google-Smtp-Source: APXvYqxYOvuMaNb07WtFoeQX0BD9F2k2Xa9veT1mthqUdGCwJpUOTtXshw98A7/cF2s7bOejLMTj2A== X-Received: by 2002:a17:902:6b8c:: with SMTP id p12mr46647990plk.282.1553818566731; Thu, 28 Mar 2019 17:16:06 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id g5sm430137pfo.53.2019.03.28.17.16.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Mar 2019 17:16:05 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Laura Abbott , Benjamin Gaignard , Sumit Semwal , Liam Mark , Pratik Patel , Brian Starkey , Vincent Donnefort , Sudipto Paul , "Andrew F . Davis" , Xu YiPing , "Chenfeng (puck)" , butao , "Xiaqing (A)" , Yudongbin , Christoph Hellwig , Chenbo Feng , Alistair Strachan , dri-devel@lists.freedesktop.org Subject: [RFC][PATCH 0/6 v3] DMA-BUF Heaps (destaging ION) Date: Thu, 28 Mar 2019 17:15:56 -0700 Message-Id: <1553818562-2516-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 Here is another 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. New in v3: * Proper /dev/heap/* names on both Android and classic Linux environments * Major rework of the helper code from Andrew * Dummy test device added to test importing * *Lots* of cleanups suggested by many (thank you for all the input)! Outstanding concerns: * Potential need for private flags in interface for secure heaps. Need to better understand secure heap usage. * Making sure the performance issues from potentially unnecessary cache-management operations can be resolved properly for system and cma heaps (outstanding issue from ION). Eventual TODOS: * Sanity filtering for heap names * Reimplement performance optimizations for system heap * Add stats accounting to system/cma heaps * Make the kselftest more 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: Sumit Semwal Cc: Liam Mark Cc: Pratik Patel Cc: Brian Starkey Cc: Vincent Donnefort Cc: Sudipto Paul Cc: Andrew F. Davis Cc: Xu YiPing Cc: "Chenfeng (puck)" Cc: butao Cc: "Xiaqing (A)" Cc: Yudongbin Cc: Christoph Hellwig Cc: Chenbo Feng Cc: Alistair Strachan Cc: dri-devel@lists.freedesktop.org Andrew F. Davis (2): dma-buf: Add dma-buf heaps framework dma-buf: Add Dummy Importer Test Device 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 | 18 ++ drivers/dma-buf/Kconfig | 16 ++ drivers/dma-buf/Makefile | 3 + drivers/dma-buf/dma-buf-testdev.c | 239 +++++++++++++++++++ drivers/dma-buf/dma-heap.c | 234 ++++++++++++++++++ drivers/dma-buf/heaps/Kconfig | 14 ++ drivers/dma-buf/heaps/Makefile | 4 + drivers/dma-buf/heaps/cma_heap.c | 170 ++++++++++++++ drivers/dma-buf/heaps/heap-helpers.c | 261 +++++++++++++++++++++ drivers/dma-buf/heaps/heap-helpers.h | 55 +++++ drivers/dma-buf/heaps/system_heap.c | 120 ++++++++++ include/linux/dma-heap.h | 58 +++++ include/uapi/linux/dma-buf-testdev.h | 37 +++ include/uapi/linux/dma-heap.h | 52 ++++ tools/testing/selftests/dmabuf-heaps/Makefile | 11 + tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 169 +++++++++++++ 16 files changed, 1461 insertions(+) create mode 100644 drivers/dma-buf/dma-buf-testdev.c 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-buf-testdev.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