From patchwork Tue May 5 19:58:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 186214 Delivered-To: patches@linaro.org Received: by 2002:a92:8d81:0:0:0:0:0 with SMTP id w1csp1458628ill; Tue, 5 May 2020 12:59:09 -0700 (PDT) X-Received: by 2002:a17:902:6b0a:: with SMTP id o10mr4626106plk.32.1588708749323; Tue, 05 May 2020 12:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588708749; cv=none; d=google.com; s=arc-20160816; b=p38ilKphZ4UUGi4OZKBmnZuSjRfLFoJkQ33KIv+b7uIRXX9hO/uncMc52Z0gg4bKpR a8OGqWl4gx44Dw/Ivvm2hjALwlFnfwDJHbkrA6EzCz9Q0Yrc/l90dqcQRUFVmqc7QR/3 NMj6SdTROZDa04+uTJh3arl2u5Nao+Hamd5cq3qyHNG420FZq7QpUbHaadEAebA2nRxV pm4P0tpMwB5co9JWr2qnRg+qCoGvqetnMoIFvykVBuetidrDReOW5azCerlNtW8zzQnh JRmyozJDd45/ZsZ9+xBiyXqTN3eowB/F3vpu1SqHjPcbeFa9w8beuORzaXBhVejKZXEJ I7cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m+GmLE4pz0xLhaDU1Bou6l9fXNg2SfUgElMcEuCIBRo=; b=Ok/nCiNz1UW0CDkmIffMZlR9/u0deIpIXy4RbKhjUZ+Ol+WNYqo5yvmy5uuxiJlCFp oiuMm5XiB3Kmi20ZsHLnH9ixfcW7d22b8T79+J2DZOYblY+FFh87s4Pk16BqvWnM2ALF tt3KaorQtUCnD5q8kqnUq8TV/V5jWJjajB3QM1FuY6jPKMoKdysoJUGrNfQgOsTWnz8c aArQ2MhPIgfYhsesxYLZxs5qyBC9WN8qUucFfGpgDbISGjAMkKlc6xFre07SCjqWYBRh kDTar8142LRZIMoWypbh402Zk61XiH+OvDjO/pgWoAVMERVNtgCkLhNVDY4K9PCP6Mnh PKVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C8OMBNqI; 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 t74sor2800589pfc.42.2020.05.05.12.59.09 for (Google Transport Security); Tue, 05 May 2020 12:59:09 -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=C8OMBNqI; 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:in-reply-to:references; bh=m+GmLE4pz0xLhaDU1Bou6l9fXNg2SfUgElMcEuCIBRo=; b=C8OMBNqIyGzIYCKP2wQwb726+RHMNXFCdNizC3qDuj6hRiFUDCozV+SCONFUly5CDu 7V0OnUyCZiXPti6Pf19/1Cd1dht2bx3PGeGZuocB5qBfk4xfJYKl3rb/KfwSNlXePuYq +cMo4C65+KxHKfHC+3RiDZTnx8FSBkYF3wT3ZFCzRb5Vmf8b90FmOdydWYT0hHKoHBzl 7nqQjLFRlYykNkt43sVcv4IpCutSr2JTXpu/Mn1rza6PkGjEH7GSX31N2ZnXOeTd4+zV bULYcjlTHCIi9kDywosAK1yF5hWNHwqtQd+oT0GmpJrIrCILDxPfYNcLXkQgkiZ6vnhg r4HQ== 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:in-reply-to :references; bh=m+GmLE4pz0xLhaDU1Bou6l9fXNg2SfUgElMcEuCIBRo=; b=UUOBIK7TgHQKvCSNHIwwUcBN6LK1RoPWJu18k89WE1e0o3vWMfzndmneLB5zzzof/2 sKiXnAsNuk2S+Bxt6qpMn8N0fz28M0uOSaS2tVzoDFG93FOSScdNpaWtzcm6OQLKmJ9l SV9DbBg/T10foT+EkMOVJ2k9qsukb4H3k3PitSpbDiAOAhT79vNYhF0lmgsicAxUCAno CHgHm/Nc4zp5dssLHFMspUYCYlLNgXQ4l4zw7CCjkWHBnI94rlWTZ7SErmVG5uReFyjW K1cqxouUmYFAMM1vsh8i7KFaHCM1fVj2CwLoreTv0P1YKFDo8v7yoBgxhG4lH8t8RsNX YBcg== X-Gm-Message-State: AGi0PuaZ8ywXObf5N+tDOrfwyvSUftr6nZE7VHmQpL0ndnYlSstaRLqI gcn/iZ6u0TkdjOsvbNm+HuG7J12CQMKMhQ== X-Google-Smtp-Source: APiQypKadkqAbDyl+6AauLKxHH+zYTBuqlg/3T8m8CbMCh4BEU1KUam4JOLiybhWmSTw62KL9hEw6w== X-Received: by 2002:aa7:8ec1:: with SMTP id b1mr4733879pfr.103.1588708748963; Tue, 05 May 2020 12:59:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id c1sm2559317pfo.152.2020.05.05.12.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 12:59:08 -0700 (PDT) From: John Stultz To: "Andrew F. Davis" , Sumit Semwal Cc: John Stultz Subject: [PATCH 2/2] dma-heap: Provide accessors so that in-kernel drivers can allocate dmabufs from specific heaps Date: Tue, 5 May 2020 19:58:55 +0000 Message-Id: <20200505195855.94934-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200505195855.94934-1-john.stultz@linaro.org> References: <20200505195855.94934-1-john.stultz@linaro.org> Really early RFC. Basically trying to provide in-kernel accessors to the DMA-BUF heaps, similar to what the ion interface provided Before we can push this patch, we need an actual in-kernel user Signed-off-by: John Stultz --- drivers/dma-buf/dma-heap.c | 8 ++++---- include/linux/dma-heap.h | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index de09a0626a61..f4f699f9c8c4 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -48,7 +48,7 @@ static dev_t dma_heap_devt; static struct class *dma_heap_class; static DEFINE_XARRAY_ALLOC(dma_heap_minors); -static struct dma_heap *dma_heap_find(const char* name) +struct dma_heap *dma_heap_find(const char* name) { struct dma_heap *h; @@ -64,9 +64,9 @@ static struct dma_heap *dma_heap_find(const char* name) return NULL; } -static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, - unsigned int fd_flags, - unsigned int heap_flags) +int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, + unsigned int fd_flags, + unsigned int heap_flags) { if (fd_flags & ~DMA_HEAP_VALID_FD_FLAGS) return -EINVAL; diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h index 454e354d1ffb..2971b0b5f223 100644 --- a/include/linux/dma-heap.h +++ b/include/linux/dma-heap.h @@ -56,4 +56,22 @@ void *dma_heap_get_drvdata(struct dma_heap *heap); */ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info); + + +/** + * dma_heap_find - Returns the registered dma_heap with the specified name + * @name: Name of the heap to find + */ +struct dma_heap *dma_heap_find(char* name); + +/** + * dma_heap_buffer_alloc - Allocate dma-buf from a dma_heap + * @heap: dma_heap to allocate from + * @len: size to allocate + * @fd_flags: flags to set on returned dma-buf fd + * @heap_flags: flags to pass to the dma heap + */ +int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, + unsigned int fd_flags, + unsigned int heap_flags); #endif /* _DMA_HEAPS_H */