From patchwork Mon Oct 21 19:03:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 177129 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3815234ill; Mon, 21 Oct 2019 12:03:13 -0700 (PDT) X-Received: by 2002:a17:902:7b87:: with SMTP id w7mr26169322pll.110.1571684593466; Mon, 21 Oct 2019 12:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571684593; cv=none; d=google.com; s=arc-20160816; b=m594Zx2lTj96zGJ5s3RzyDaYU1fgcu9xhdlCZ1TZCRhxZb/djuERkAdhoydSI6K7yz ymz7gL22yrO06cCmHgkfODOX+jzrDde//rJolFnULvnlF6P3DWJHeMerKA51VxkiW63j RpwrgoaTySNR0nyelVKJFsaJmYOw9LeQj+G76+77irYeGzb9dPbeKxoywfegufcoVerl YimzhGEB2CNT3NA4xZUyN+smMsuRmwoDEtqKajqobXFFlNCmoK8PCwwPJ94gOWdp4OXx BNXuRcIORKlnNAjTsIeBDApPcZDH7Neaf/WfnqkFutA5yRS7vygjykaU00aybuZ/5HxL 0sBQ== 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=jJ5jwtEtZvz3RKTAhKxTqC3TqPRBane8BbT7Fv1RJW8=; b=pR1dtD0d817/c+azYK4GDkiJe6yH54WaRW/gJ0dVg+jt5iTOr0tAYb935DEJGv8lir Bx1thyB/04Z02lUROxyrhxehxYTghxYAcZK1BKSyqPvMunS6zt4/An5GAeyUq5drLoYb aAz2DgX1CcdopQfpEwiNZbo9qCVZvQDUgRVI2y5zH8kUDLpR8P3/jLzwDfJ40BSB0gAf QNAoGGcWP0epDk/FEz+rX1LRy1lZ+a/W8aWJlpvTr6Z6U5xrLVcyAPXJDuE2oSo1Y6Ww pFhzQWwfADhx4jEkkZNxWLv9e5g5/w4+XTKNNHxLyhtjM8ulsZy5UW9ZIgbgMPOoHpjP QiJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hOZYCqXH; 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 20sor16769491pfp.4.2019.10.21.12.03.13 for (Google Transport Security); Mon, 21 Oct 2019 12:03:13 -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=hOZYCqXH; 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=jJ5jwtEtZvz3RKTAhKxTqC3TqPRBane8BbT7Fv1RJW8=; b=hOZYCqXHqLC3n/MXyVtTmVRpZnPhQox7vXpqyfiWUOSxFNESfl7BJbI5z7n718hGfv +SqpxbTaH8IK/C8WlH1ldbzr0hXhYFj8W/DyfAj9XpFWFGTEjuvCVQH57EJuLW8Wae97 CuSrqpRnahvLph3SP0hlhbQ0ui3dyhNCUKYZGd9m4XHvoX+luJo39SBp7goWzNtEDBNR aft7fRiF/YRgIBEEeEK5/7AVK9UHtMY2IotFkc1BJXono6yiwCRV84AgjaK/oAQzB1ax pKfUOm0u/ZZe7Rwddo+wNwfJtY+hWxgEwFV88yFj1xHlTy7fau8HHxXpl+pRHAi8ga4n 9zQQ== 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=jJ5jwtEtZvz3RKTAhKxTqC3TqPRBane8BbT7Fv1RJW8=; b=AVZb0NcezuqJIyqYo+KjmaDRCjb9PcFYlOUczWEAeC41EpfmttPXd/xYkfQ0RaCJwg nXW1YqJhNpWoSEPfmW8b7Rl+Bv73tdCYArfW52Az2mkJ9mbZ1T37MrpKdgTQVTR/UMUf 2VdOU0qNiW1wIEDvJJlGvt2X90T+Sqb2xv6f886T+LDnfMrODa0hhBUT2zNwc8UsiTtq 9AQ9MB5kQg6bnaTBEyje/zL0jyFQfg8o7DW78NxywYvgMpOny7fVzVfa8lhnoQNY2pPc stdgfmQR5jqelX1cZ3dGC/yfs6m2plsCmz9ElocLpRLTCogS5FOFpMqX1tpDACG+xi3a QYcA== X-Gm-Message-State: APjAAAU7XgRxGVAfJKmw9z5nXXoQ16O2PRjVYOaBLZWt6EXwO8yUEDw3 yDzuQOtI/o/0pE1+KOhD1oWPrUGW X-Google-Smtp-Source: APXvYqyTxiGSUWeYPGBn1NS7PIVC/jrrrhYoJpYqEd42zW4SoPqkKsN9p0nK2EnaXEJfoULDWS5CuQ== X-Received: by 2002:a62:6842:: with SMTP id d63mr24242194pfc.16.1571684592819; Mon, 21 Oct 2019 12:03:12 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id 127sm16223673pfy.56.2019.10.21.12.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 12:03:12 -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 , Hillf Danton , dri-devel@lists.freedesktop.org Subject: [PATCH v13 0/5] DMA-BUF Heaps (destaging ION) Date: Mon, 21 Oct 2019 19:03:05 +0000 Message-Id: <20191021190310.85221-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 Lucky number 13! :) Last week in v12 I had re-added some symbol exports to support later patches I have pending to enable loading heaps from modules. He reminded me that back around v3 (its been awhile!) I had removed those exports due to concerns about the fact that we don't support module removal. So I'm respinning the patches, removing the exports again. I'll submit a patch to re-add them in a later series enabling moduels which can be reviewed indepently. With that done, lets get on to the boilerplate! 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 v13: * Re-remove symbol exports, per discussion with Brian. I'll resubmit these separately in a later patch so they can be independently reviewed 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: Hillf Danton 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 | 269 ++++++++++++++++++ drivers/dma-buf/heaps/Kconfig | 14 + drivers/dma-buf/heaps/Makefile | 4 + drivers/dma-buf/heaps/cma_heap.c | 178 ++++++++++++ drivers/dma-buf/heaps/heap-helpers.c | 268 +++++++++++++++++ drivers/dma-buf/heaps/heap-helpers.h | 55 ++++ drivers/dma-buf/heaps/system_heap.c | 124 ++++++++ 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 | 238 ++++++++++++++++ 14 files changed, 1304 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