From patchwork Mon May 13 18:37:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 164043 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1683493ili; Mon, 13 May 2019 11:37:32 -0700 (PDT) X-Received: by 2002:a17:902:20cb:: with SMTP id v11mr32765686plg.324.1557772652425; Mon, 13 May 2019 11:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557772652; cv=none; d=google.com; s=arc-20160816; b=o3qhH/moSkO0/qd6SDj/SuqTt6oJ/lb/jXm72UVwAmWzlp24lVxekVNKZbRH57Oqsx xDj+uAxfpYbd6l29HDGvQQ7/0YdVOT5LkkdPFcy4rKlcoXMj6RT+dowrvs+Q44w4Zqkf wQET5nSLYZaH03R+KQjb1rnWLjgvx/3q9LKxng9YLu2G6ejgjIndbc3kZq49fVIi5Z8K 3PQABvuXNRQkpoWKXRRKk6H4ozAHwBAke9JXesEJSqF94/lNkimqpfHKP9jtbwTS1dNp teM8Mp6HQoMmN8Nlhpvzj/ml26rf2jdh3tN605VBzMTnpMR9qD0JfOakmBHpDIFtelut 827Q== 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=7ta6Dt81bGZU9BIZmXBk7KPXs3pWx/uQSwyX/aFs/cU=; b=hJfBnKQ2EHdoYqbvK99x9guqsEaZdp7BUsFP+Dt2KY11idDyRJAWas5OHpg/n2WyqW eAQw1KawE1W0FDjSG1ZT/82qeWVQ1zBa96V4dvgh3SwczsQomZOatNuK3Iti/uN3TwaT c6wkeHxxoXoPaabbRW43BG2A3JpgDw0Af1Irp40vkJvnAqTpGzmBm0pddjCxMX45OvlL s75VAxdw4s059QNq1d5PR+cCay1kQjVCV92uAPyu1uxPXoOvY423T/mDupJcaG8ESItC yPvVL9Hqz2/dHKsYb3vwFuHO8l1PCfJ5xoLjZN5B7RZ1vXstSxCPfKPj6R1GNu8TPrHf 8LMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ql9zTXdT; 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 w25sor17596333pfg.23.2019.05.13.11.37.32 for (Google Transport Security); Mon, 13 May 2019 11:37:32 -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=Ql9zTXdT; 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=7ta6Dt81bGZU9BIZmXBk7KPXs3pWx/uQSwyX/aFs/cU=; b=Ql9zTXdTr2UHbU87mcJ0v0HAMUX6aGcYoVfeHA+cb9ZsIVTDmX1dlZ4jqVVw2ceRT7 qgDIIaF9f3wgUMrkaIt6fNHaoO/iZ4BVxJECbgfR3cmJY2ell5O9XgB8fdDMP83Q+0er iN56XU3SVLoTsQvVzX8YpjTFImRP83CcLfAl632vtSlJci12w+OoZrYAEOR9vYBoAE6m u8UmfwhPqVmaOKa/17EOPA8GyBgP0gruqkgIDnf2bbuZSBySdjPatmcDlOqfGZyaievL XYyymbe5MsR3WIPSCwgnskQ2Y9FT0YhqDnQ1KkXHcbCEsdUkL71wrMUR37AesUlLExyP 4y2Q== 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=7ta6Dt81bGZU9BIZmXBk7KPXs3pWx/uQSwyX/aFs/cU=; b=AypqszCECQIm/aoLkSPeoPLTWl3tIMh3KL+BzrFXhtkTxnr7DMTahEE3jFr6XyRAqY PmD1hG5WPf/7t1bVAQtpuo5kcX40Zv5eLElVC0oikIt3pVhDp3UL5urQ2qyMoSmvhA3C 9mKqSmfTOO53WuBzX/Tu3qYhSqZkKXD7ycnaym9y19E08SuhX8oPBS1+B1NTj49p4Sew kswgMQx1G+vtf3Hr3N1JD+5ZKrpyps1uug4nmwTTglOlIB69Y0IyCAQKACdjun1IKbIX s6EP7IwrhhLHBJXp/YQNi0MXEKUN/VF09Qqmx0fd0bKhcf194xwgHuhhBkPB23gNFS6Z RjCw== X-Gm-Message-State: APjAAAXHJNK7nOQ0/4BkPMk9A6VTE5IQrqWI7HygH2Z7+4pYlyUktAVr CFiKYnQK47CrAlWAsBwxPxg7oqlr X-Google-Smtp-Source: APXvYqwfsOAP1xNjvu+u8ncG2XEwfMC9o240s60cZjr4QjdborLBIAOCCwf3Y8Dj8ev2ytQD3izV5w== X-Received: by 2002:aa7:95bb:: with SMTP id a27mr23976186pfk.30.1557772651657; Mon, 13 May 2019 11:37:31 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id u11sm17334881pfh.130.2019.05.13.11.37.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 11:37:30 -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/5 v4] DMA-BUF Heaps (destaging ION) Date: Mon, 13 May 2019 11:37:22 -0700 Message-Id: <20190513183727.15755-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 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 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 for now, since any such accounting should be implemented by dma-buf core or the heaps themselves. New in v4: * Add fd_flags per Benjamin's request to specify the creation flags for the dmabuf fd. * Added some optimization in the system heap to allocate contiguous pages where possible. * Reworked the kselftest code to use vgem rather then introducing a dummy importer * Other cleanups suggested by Benjamin and Andrew. Outstanding concerns: * Need to better understand various secure heap implementations. Some concern that heap private flags will be needed, but its also possible that dma-buf heaps can't solve everyone's needs, in which case, a vendor's secure buffer driver can implement their own dma-buf exporter. * Making sure the performance issues from potentially unnecessary cache-management operations can be resolved properly for system and cma heaps(outstanding issue from ION). 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 (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 | 10 + drivers/dma-buf/Makefile | 2 + drivers/dma-buf/dma-heap.c | 241 ++++++++++++++++ drivers/dma-buf/heaps/Kconfig | 14 + drivers/dma-buf/heaps/Makefile | 4 + drivers/dma-buf/heaps/cma_heap.c | 169 ++++++++++++ drivers/dma-buf/heaps/heap-helpers.c | 261 ++++++++++++++++++ drivers/dma-buf/heaps/heap-helpers.h | 55 ++++ drivers/dma-buf/heaps/system_heap.c | 162 +++++++++++ include/linux/dma-heap.h | 59 ++++ include/uapi/linux/dma-heap.h | 56 ++++ tools/testing/selftests/dmabuf-heaps/Makefile | 11 + .../selftests/dmabuf-heaps/dmabuf-heap.c | 232 ++++++++++++++++ 14 files changed, 1294 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 Reviewed-by: Benjamin Gaignard