From patchwork Mon Nov 18 20:23:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 179602 Delivered-To: patches@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3371526ilf; Mon, 18 Nov 2019 12:23:36 -0800 (PST) X-Received: by 2002:a63:c805:: with SMTP id z5mr1328392pgg.14.1574108616113; Mon, 18 Nov 2019 12:23:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574108616; cv=none; d=google.com; s=arc-20160816; b=YLofarcYNefi4zOrcEzmJWGvwNDK4EAoUkBgsJplrA7BDisJZ1RQwoTWP9k04bM2qN eunUqE8FcniZ3yes5+CSP/jEEDf6b0zT8gho5ffVnd1bJv0+a3L7RonK6gqZBeopV5gx LqZxH3Eu3LPHELu0G1XMxHMYKgLc8afe55oAVa6H3xq4fYP2QyvQYC6PQdWUQ4SZuiLi Hu5UMKwwkLzK5rqtG9j/d3DBU2zzfseAdzKxyARjp6Cdb8FoVOkP1dBToHbcd1F1qWeC Mxy/D2+kkJeML58DSl+1gqNraFrBEzpLGPNtvglMmq49ex1i4AH58iecWQOr++0IkFfb s89A== 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=XAQisB4dl7aAbIG9o/3Fhs9EnGFzGUZ+Rh3JFJPeyUo=; b=Rgfg4fZzZfB8jKYLIVaQTkOg3cV376NXfLdbZ81CZm73FLUVLyo1hKpyXLneTw62Va PpRT9hMKQqGlVgPdofOsodRbizmg7iAgHMgmaPC1FLdLrMZ2BtKTqSXTI6HLmmKUpvmj UeXGwRR6OkGQi2dPbLFLjk1y77uL6cH/wiFy9YIghCnn+PtZ3x1nJoE+SkbQbWlmWq03 mbnvGwhtzfPWDw7Nh50gj8cSQQ2mcrczpcix9Dv7I+HQ1l+5+guBjR6I9Ku8ZhvuD/qg Yeka65jDBIVi57SCcadbjM2kjmfttjgLbAN/sweHi/n+3MXRf4du41TvYsvSD4wQRspE p5aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fnKkNnpK; 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 r17sor18682362pgm.62.2019.11.18.12.23.35 for (Google Transport Security); Mon, 18 Nov 2019 12:23:36 -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=fnKkNnpK; 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=XAQisB4dl7aAbIG9o/3Fhs9EnGFzGUZ+Rh3JFJPeyUo=; b=fnKkNnpKHlNbmv516hbcaEVWV22ATAFpClGc5Mdu+VVOigCtBLxcu6J5CNtzvEghSM POZZtYYNU5wABbzevm8CUIdywLovEthS4H95eRLUYEFNQ4gJwmyX/G8C+t4QtRwkh4Ko EE5RcRpBRcAFa9w+g/xgOr8zRRPVCaus9YPRdsbxtTBFPhlzUHyqImODxk7ySg3BqoIx Wz1uMJ7Vc1ySCOJZKskur+Uyp+wEz2sUjacf/Tq7j7JGZpHlEwcZ7OLvWa1F78LEgnms LiVhHaw11wI9VHIZSqGjTiKlRIExquPZVj0X2xCSAIQNk4l22x+k8LJM310TV2eg56oc b7Pg== 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=XAQisB4dl7aAbIG9o/3Fhs9EnGFzGUZ+Rh3JFJPeyUo=; b=pAFmIyjFuMcW8am26fzIWpCiTnlTv2mQfkKHxfmlFFWoxrj6n9oypNZqk9HBsmvQL6 lYHtnftVco0KQoiBpirR163hO8Rsv6LBduydW74e7siSPsGIX+BIKuRI4O4WcP/8kXke j2RhFBLdfbnf4+XGKvZqwOIrOr+diA6TltO2hGgpAwxMOJT0lQFkuQU5D3PdDOlDVMYl SRo6/SeCu0IdgDrKIFw1sDyyKYxWJqn1SswoU4td6T8+rkha60WfCe/kx5onBoCDUjbu c92jWQqQph7t8+zDS26ge/ZucBSlQryp6d13bq+gGjN9gttDrX0OvTGjk77pcnIWlPkh iSCA== X-Gm-Message-State: APjAAAVZWsku2+H0APS8FI1xQKjfvYH+a2eDIelV2kDcfOAInvhMw1Ae 0gh5Z3XI6VIayY4F3hNt8z2+azRx X-Google-Smtp-Source: APXvYqzszKweGiIVWPVEYmvVa4MfrnoT/NXciccAdxnbe9x2+dCK8nky7DqCpR/Q+xoBIN4KAiMfzQ== X-Received: by 2002:a63:5246:: with SMTP id s6mr1260904pgl.349.1574108615429; Mon, 18 Nov 2019 12:23:35 -0800 (PST) Return-Path: Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id 7sm11021871pgk.25.2019.11.18.12.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 12:23:34 -0800 (PST) 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 , Sandeep Patil , Hillf Danton , Dave Airlie , dri-devel@lists.freedesktop.org Subject: [PATCH v16 0/5] DMA-BUF Heaps (destaging ION) Date: Mon, 18 Nov 2019 20:23:27 +0000 Message-Id: <20191118202332.109172-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 Just wanted to resend v16 with a few minor changes. This 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 reviewed (+2'ed) 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 v16: * Typo fix suggested by Hridya Valsaraju * Add extra error and ioctl compatibility testing suggested by Daniel Vetter to the kselftest test Thanks again for all the reviews and feedback! -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: Sandeep Patil Cc: Hillf Danton Cc: Dave Airlie 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 | 297 +++++++++++++ drivers/dma-buf/heaps/Kconfig | 14 + drivers/dma-buf/heaps/Makefile | 4 + drivers/dma-buf/heaps/cma_heap.c | 177 ++++++++ drivers/dma-buf/heaps/heap-helpers.c | 271 ++++++++++++ drivers/dma-buf/heaps/heap-helpers.h | 53 +++ drivers/dma-buf/heaps/system_heap.c | 123 ++++++ include/linux/dma-heap.h | 59 +++ include/uapi/linux/dma-heap.h | 53 +++ tools/testing/selftests/dmabuf-heaps/Makefile | 6 + .../selftests/dmabuf-heaps/dmabuf-heap.c | 396 ++++++++++++++++++ 14 files changed, 1484 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