From patchwork Wed Jul 24 00:36:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 169584 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9527380ilk; Tue, 23 Jul 2019 17:37:03 -0700 (PDT) X-Received: by 2002:a17:902:b789:: with SMTP id e9mr80871453pls.294.1563928623184; Tue, 23 Jul 2019 17:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563928623; cv=none; d=google.com; s=arc-20160816; b=Kds1JaQuMrXbzhWvTZ4Chhv/Km4hGezfCvNftsWmyXSjjjc2ZPf7yxATOkhrDlBU7X j3cZ8fh3sZERvivdT+FTeav0gquwX4mL2GCYYDBPLyiGfJM0Mg1p7e3jTQMnvIUzDjvN jrXy3X6521PWyitsw8iOycvFK9BlJhwxGMWy1Ai9TO6l11xcLCnysbBwhNC9ukYUx77x zrDTjR9Ds5a7LOyCnIEavosr88aH3m/kk1XSfucBug5nLo9eQY5bzJmuay3utHhXSWOv vGkMZSTjleAt3Lwh++z+CClCogQHXl6aqcnt71klcq3xqLS6S2zdCixBRjjESC8kgM4o Grhg== 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=Rr/xnJYIYPtES/KYVdfSYwWQuwOMrM9NXRwqhvYtOeI=; b=QNle9/aByzscxbSgvLXd39vnJLgtjbUvFAWI6QVebE0MhJyIt8TCUF8h6tIFnhFQd1 KemcGLUr2syFewQdj+7wcnntqAb3AsTTSNCOFUaIEzgmc/dnZuhEcQah0xkN4pXhxRwA emQ80Wa2ssEs6yfCY6iL0yKN134z+zmkWK5WLP/e6HHAIg26kv6FyLcPefie/qikMkz6 xQ3/SGFfDGX/JYkFTJrsOV5EUcenTjuFBdj1yUsxYbtiOhziz7LfSr/cKYgkqIHgLMKd 0cjCXwVqqjERNkavsXRJChD53DLJzA7rLG1TyK1FqVcYG5PO8WWYRUwDmspWpU1MXOBs 8f6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uIn0Lomb; 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 17sor54114026pjh.2.2019.07.23.17.37.03 for (Google Transport Security); Tue, 23 Jul 2019 17:37:03 -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=uIn0Lomb; 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=Rr/xnJYIYPtES/KYVdfSYwWQuwOMrM9NXRwqhvYtOeI=; b=uIn0LombegkiJxXFKlEpOg9SFE+17v76HmQs6L6g4R5LtONn5LFHTTwmK8HE3jjb+h FNg90C9QhuT59GJxsWEDjfj/i6qZhYFPmdBzd7rkGdf0H0iQO6zUYKM/3m3gjrHZLC/g YAB3YPfExc3uuPllROXVrpqNc2aqt12IcVfpwQA4939X+paEv7phQ3j2hhZzdVrcFXyW D6RDYxceot2IaoBv84G3rhXck+04pUFRba/JML30v6vbaDAbrzgfECoTwO5cCZI6dbyM Xb7Qg/ab5WS6gvPGygsoxN7Ak3rsSIT+ZzpYKW37Q4XL+rhNzySTkBler5icKqG2xBEo oqWg== 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=Rr/xnJYIYPtES/KYVdfSYwWQuwOMrM9NXRwqhvYtOeI=; b=k/ic//VKsL74r+t/zgsksUGkX9MiAmNc9UiMEJjE4HP04gMNphE2uP3pNlzPVpncqq YUNs9cFwFECGa43ddl+Unh/R9SZXyM8p724AD55U0nrEn2panyaPnI8dlvYDLE0oyyT3 jH3oI94zT/m4ZIZv7SxLvWvnqfi7TTgtcwQWL/42Q5kdqkVFnEcDGy1rE2qOUQXp938y /+9eww6kIFnFqHnY0VMV8aUG9FnASXY5CMqZFjssbhTHGRONHrd3gXCtKyR4B2q4/htQ PXXvqHF91ZKs7ob2q4dv862FSbbbtqw54nZ8uesBK8qdcPBmlfXGOitm8S6LelhWgtkH 754A== X-Gm-Message-State: APjAAAUpFdOA2zP/wvd4jTzubhSBTy1dRNIQvQvXdj6KZR+5EVCNVTiE BecGa0Lkm/HfBknGYw5hQdJRbVcr X-Google-Smtp-Source: APXvYqxY36haiuKUyV2u4Er3a+w5Yr+x7sqm5YRUUZ1UHHesU9T0RdjuJL4f73r/mpzhQwg3/64BgQ== X-Received: by 2002:a17:90a:17a6:: with SMTP id q35mr85071276pja.118.1563928622570; Tue, 23 Jul 2019 17:37:02 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id x26sm58890022pfq.69.2019.07.23.17.36.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 23 Jul 2019 17:37:01 -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" , Christoph Hellwig , Chenbo Feng , Alistair Strachan , Hridya Valsaraju , dri-devel@lists.freedesktop.org Subject: [PATCH v7 0/5] DMA-BUF Heaps (destaging ION) Date: Wed, 24 Jul 2019 00:36:51 +0000 Message-Id: <20190724003656.59780-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 Here is yet another pass at 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 relatively simple system and cma heaps. 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, since any such accounting should be implemented by dma-buf core or the heaps themselves. New in v7: * Longer Kconfig description to quiet checkpatch warnings * Re-add compat_ioctl bits (Hridya noticed 32bit userland wasn't working) * Make init_heap_helper_buffer lowercase, as suggested by Christoph * Add dmabuf export helper to reduce boilerplate code * Add system heap DOS avoidance suggested by Laura from ION code Thoughts and feedback would be greatly appreciated! 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: Christoph Hellwig Cc: Chenbo Feng Cc: Alistair Strachan Cc: Hridya Valsaraju 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 heaps kselftests: Add dma-heap test MAINTAINERS | 18 ++ drivers/dma-buf/Kconfig | 11 + drivers/dma-buf/Makefile | 2 + drivers/dma-buf/dma-heap.c | 252 ++++++++++++++++ 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 | 276 ++++++++++++++++++ drivers/dma-buf/heaps/heap-helpers.h | 58 ++++ drivers/dma-buf/heaps/system_heap.c | 123 ++++++++ include/linux/dma-heap.h | 59 ++++ include/uapi/linux/dma-heap.h | 55 ++++ tools/testing/selftests/dmabuf-heaps/Makefile | 9 + .../selftests/dmabuf-heaps/dmabuf-heap.c | 235 +++++++++++++++ 14 files changed, 1280 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.17.1