From patchwork Wed Jul 29 05:16:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 247236 Delivered-To: patches@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1150402ilg; Tue, 28 Jul 2020 22:16:36 -0700 (PDT) X-Received: by 2002:a17:902:8b86:: with SMTP id ay6mr5201038plb.82.1595999795952; Tue, 28 Jul 2020 22:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595999795; cv=none; d=google.com; s=arc-20160816; b=wZNJzxCN9b+ub8xS4UgIGBjF2YuW7ZvCOTGPRQDJ+w9FPIywik5P7Lsudb9MrU1un/ 0tmHd3Nz/LqKQF83hfx3KSzrIpBDclyBVJm8RnKyM5lz/IbZF9U87el7ah2yw1DtoKBQ QvxjGzdCPs6c8jPQpRbQsQaf6qifczbRrcKQeYcRkaUJnHG4OYPi+awx/Xdbs1bL1KtH f20NijX3Hvqp08qdw4nhzwxff2mez0STrwV/jciQQe/FmZP2uzGRs2DuKlQiyoKvvjm/ SUY/OPQU7XMkzBFmil29+vH69UIQs7mgJ1jHWYBmg7shyQLeF27/Bgb9nxlcLGZo5d/y kijA== 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=My6wF6wOxqWj2vALiGYVdW12dpuklXn0QP6e45LDC3s=; b=f4FgxFRyhFBR4LaLQKdcFkP/k7Z+RbtfmOmETaYdzk4yS+E7HxFJrCCBvV3fleDH99 h4xPg33HerNWbmcg9PNwlKr/k5bMzZrcqW5sR8j9OSlTLlo946jAWGwCYJ3jpzMpRUc1 VwQfpIWjgZN2fCU5YwW1KWFRvLXVbgwEtiw3lZTniRi3QMJVcXqxnWXNN9P/B+cIYi5R NLIeJdNo2QdVkNlGkWz+3AUX0GZklnVZU58tENgVbvoTm5Zq9oMr1Bb1mi4ofnLG7aCj UbrNncpflIv9VT3PX8/Nmn/eZQZ654PD9t+n3kpQiojkn+KHDc/wV5gLlwAMwgGyQuDV Lc+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GOVvyPJr; 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 z5sor1029284pfk.79.2020.07.28.22.16.35 for (Google Transport Security); Tue, 28 Jul 2020 22:16:35 -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=GOVvyPJr; 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=My6wF6wOxqWj2vALiGYVdW12dpuklXn0QP6e45LDC3s=; b=GOVvyPJrrzTENjpKfVrZdIbthAOLEx6ZdUkeA8AsNXmYcZSCezeV/a7NZph8KJg9lV KLp/96aECmBQWbGb8QkDg5Dgs8G3J5GU1aMyKkD6lsebcCL60fVBIt5k1jsv0jKfwY6x pGJc1byXU2528vl1cc8a6Xdwh1vfkSlqrrrH7Nv4IOFITe1mqLQZJsatxv+rDG5ql2gH lWRZiydsRYcB8xIFbxcGKrYL3Wjckwzhy3G5myt0C5oPNJ78lOHLUR3t0o4yK9s02NLG huThtxkDGcCHQVDat0vPT5xmLzEqFaZwU/qbCfgdlFg9JgXL4h3bDHHJnza+jypHRzCm IySA== 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=My6wF6wOxqWj2vALiGYVdW12dpuklXn0QP6e45LDC3s=; b=rtf9I9yOMvQFGCCDK/hQHa0F4w7KBic9BMmnzK5+f+qp0/i9yrN5PCIWeCdvxyvqsD 5Otj80kdQgWVzMKOnOiLZyx7oAzS6Dr+Rt1dTQJ/hFp/iugROV9TuupHvhI0VXyDQDra nj6birWWhZI0lb7J1VmTFK/JL4V15fk2tInzX/mbeHMn1eTO6872rKkFOF6Bo34S73Tv AIjYYc+yhHpdwcJcSG9WEp5n2GxetV3gBOKVk4K6C9ADskFfAWL3VE3nUTs3iHlYuumh Tb4TGQFitcs8+hyJImk7wTfxtYuJzMa9oCdPEfY+nymQr3n6rwl3AEh+YO6I6YHCkWLN Eb7Q== X-Gm-Message-State: AOAM531TJZ3WPHXTRDRiUsj5P8ukC82E0n/FmTmAvcW4tiACz+POe69X B4cno6ulzXmeINxdZJGJVPltUf9G X-Google-Smtp-Source: ABdhPJzjtXLQSVD/yUHzhnR26tU6d+mXoVKd/tt4jhYhnke8xXlPicXlGuSoe1HGuATXGGRwJwcK4A== X-Received: by 2002:a62:7c87:: with SMTP id x129mr9289795pfc.165.1595999795532; Tue, 28 Jul 2020 22:16:35 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q5sm762750pgv.1.2020.07.28.22.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 22:16:35 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Sumit Semwal , "Andrew F . Davis" , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [RFC][PATCH 1/2] dma-heap: Keep track of the heap device struct Date: Wed, 29 Jul 2020 05:16:31 +0000 Message-Id: <20200729051632.66040-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 Keep track of the heap device struct. This will be useful for special DMA allocations and actions. Cc: Sumit Semwal Cc: Andrew F. Davis Cc: Benjamin Gaignard Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- drivers/dma-buf/dma-heap.c | 33 +++++++++++++++++++++++++-------- include/linux/dma-heap.h | 9 +++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index afd22c9dbdcf..72c746755d89 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -30,6 +30,7 @@ * @heap_devt heap device node * @list list head connecting to list of heaps * @heap_cdev heap char device + * @heap_dev heap device struct * * Represents a heap of memory from which buffers can be made. */ @@ -40,6 +41,7 @@ struct dma_heap { dev_t heap_devt; struct list_head list; struct cdev heap_cdev; + struct device *heap_dev; }; static LIST_HEAD(heap_list); @@ -190,10 +192,21 @@ void *dma_heap_get_drvdata(struct dma_heap *heap) return heap->priv; } +/** + * dma_heap_get_dev() - get device struct for the heap + * @heap: DMA-Heap to retrieve device struct from + * + * Returns: + * The device struct for the heap. + */ +struct device *dma_heap_get_dev(struct dma_heap *heap) +{ + return heap->heap_dev; +} + struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) { struct dma_heap *heap, *h, *err_ret; - struct device *dev_ret; unsigned int minor; int ret; @@ -247,16 +260,20 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) goto err1; } - dev_ret = device_create(dma_heap_class, - NULL, - heap->heap_devt, - NULL, - heap->name); - if (IS_ERR(dev_ret)) { + heap->heap_dev = device_create(dma_heap_class, + NULL, + heap->heap_devt, + NULL, + heap->name); + if (IS_ERR(heap->heap_dev)) { pr_err("dma_heap: Unable to create device\n"); - err_ret = ERR_CAST(dev_ret); + err_ret = ERR_CAST(heap->heap_dev); goto err2; } + + /* Make sure it doesn't disappear on us */ + heap->heap_dev = get_device(heap->heap_dev); + /* Add heap to the list */ mutex_lock(&heap_list_lock); list_add(&heap->list, &heap_list); diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h index 454e354d1ffb..82857e096910 100644 --- a/include/linux/dma-heap.h +++ b/include/linux/dma-heap.h @@ -50,6 +50,15 @@ struct dma_heap_export_info { */ void *dma_heap_get_drvdata(struct dma_heap *heap); +/** + * dma_heap_get_dev() - get device struct for the heap + * @heap: DMA-Heap to retrieve device struct from + * + * Returns: + * The device struct for the heap. + */ +struct device *dma_heap_get_dev(struct dma_heap *heap); + /** * dma_heap_add - adds a heap to dmabuf heaps * @exp_info: information needed to register this heap