Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1007213ybb; Thu, 28 Mar 2019 17:18:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDRD0wxFb9FNzUFrwbX1DisecwSNuzLnbwVyjzAn6FIQuPYEBljpAZVoH9ppN8WevaHQzj X-Received: by 2002:a63:544f:: with SMTP id e15mr43570206pgm.344.1553818693031; Thu, 28 Mar 2019 17:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553818693; cv=none; d=google.com; s=arc-20160816; b=U+F7hWLff4QYnW2VfXO6l0qYRpwer/6FbLBn5eCwkzUOq+hjEyKk1x8MrPNQeg15F+ +YJjZQKE9jLrWj2a59pZ5L+0dszcf69ynjX0RatyRjfSO39A+3ymPV4s1LymgO2hzOTZ VHU7oG1weU1wI6J+77XqLjbbyweaNDsG9CdgySj0fNDY9D+u143WrFUYa7C1Cyo2S9YJ DnA4CmQaQ7agL40a8uJynGtevnrC/Es8g4MW7vCl65yt/0nbszCAMq7lUGu2Ycdg1UjN uKGZUguFviFwuQkL0NobAbt5fOFYG2FfOx5/78mFRa5DbBwKJI5jwDjtocVRrz5/zGVO f10w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=zUD6J6xvycIjyNyLvpEuugsPd2gKGFqcuvSvKt5Ezpk=; b=rn3O46jyQlifyNmt+Q0tYlitVpg46y2PwEf2Wz5iqX8y+m7QSZIad2ArCHqWi6DG2M l4C8LbB3C6qz2aQpD4FWeNrdJTdeV5x4nPK9rls1oJ8nislLv7Yf6Tnf/iCtk3f2+Mzv WT4HnL+5/wlruP6QQXVR6AKLwJN8km+2pEYtU5L9FdvrtuWFDL1D+Kj+I8YSkumWuBwT +R3eCA0EaFHza1jNUri4r5sdMEaPu+mRzNVF4N6w/P0BfmNUcfYXN399szSbNXGPelLz Lpj7Jx6BxIJn5tkIULDqDbB1tXUqEPW398S1Ai/aTFnJIWjxLWKhZsADAYjf6TXNbzZf f6sg== 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: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z127si415263pfz.214.2019.03.28.17.17.57; Thu, 28 Mar 2019 17:18:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fB+O0res; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728651AbfC2AQI (ORCPT + 99 others); Thu, 28 Mar 2019 20:16:08 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35926 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728552AbfC2AQI (ORCPT ); Thu, 28 Mar 2019 20:16:08 -0400 Received: by mail-pl1-f195.google.com with SMTP id k2so137246plt.3 for ; Thu, 28 Mar 2019 17:16:08 -0700 (PDT) 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=sGVcRyV9Nvxx8wiuuUb54oPLWqdAS9YzSY1o0u9M9LAOxPZw2U8eVCKqEQXe6TzXLA r82TmKNX7IGbKvQpxnjrI17VgVjO1/tPAsjLsXJbRP3zhJc6ALLjUhD8EUeUCbM9Unig iI8S5BSuOB4UgGGF8wAS7i6jgDULK9maV3qeV7LqiG5MrStg7E0o5REU7/a0ZEzGVbtO Mbl1CfbnGGBViC8+nmMPjeXdBGRwxSK3DyrMrV/YlPXTGbzh6m/GErkr2x3HOY6Zvrmw srLgxlqH6Dg4KHKn43mg4XQrgHSIR4WAJDywsi5YqKTtIHRrRtG/dmyhzw6PVJNcX9Mk FHJw== X-Gm-Message-State: APjAAAUI1CYDRBkr8Jt/g29DPOTgfpH6HkZ1QlKtOvRAPYasON2vAaYo NAdl0wiRfRfummnkkY8vzC0ckUiSmBE= X-Received: by 2002:a17:902:6b8c:: with SMTP id p12mr46647990plk.282.1553818566731; Thu, 28 Mar 2019 17:16:06 -0700 (PDT) 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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