From patchwork Sat Oct 17 01:32:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 317842 Delivered-To: patches@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp1946971ilm; Fri, 16 Oct 2020 18:33:15 -0700 (PDT) X-Received: by 2002:a62:53c1:0:b029:156:438e:2d6c with SMTP id h184-20020a6253c10000b0290156438e2d6cmr6355719pfb.37.1602898394981; Fri, 16 Oct 2020 18:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602898394; cv=none; d=google.com; s=arc-20160816; b=TUXbzEuuUjfsleqgqZTm60yU5ZYVwaUfqWSuLYi7wtitCo5GF64Cxy4am4+n9j8Uir puDWL1WR6CXWBLA+1NvA6R5rtOC8z3ts7wMq4t6esCHfbmZRtjs4akbx+nqamTYYQdNC MV6DkxYB3Hmb/MiNGOHAMQg59KLwK2i7xtlC/ctPnRxMyGbCyVFH4Koy8I1wb57kmOsr +giM8xzAz7e4BY+94CQkuCP8gX1SkPQmrEHHCbfdClfxmaebyN66EsEgWkG7CmMXo+2E bC4ZuhLM/S/++A+TKc3j/Zddexf9RbOEHZVhj+ZIHNDWxAGbFAha7ok1IFXc/uZrxcOq Rfhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=P68wKVWfyCPNBm8l+XiI7Y585elPVzN5iuk0IO/H+/E=; b=xxTbjdTjqKQFU1rHsaISmolJsEGqTLvNZGNhC8vSzIekMMsRxlpD4IdFfGkQE+niDJ 5aMVZeFvOoRa3Ehp/AoIKoyE6v++Zs6fr7ih1FsNpXVXWYyxhFZboyIgEEIVN5qoUd1R nuwsFy8Dqcle/DPqhuIKjxRSo4ZFPLizAjpm8YxggP1IK1H1uHnKeLCjdhMj4vc7tQVd +FWKJ7MNn+59PYsIcFpBHxzw18MdMJxrcgF6/fyqnCx3+jlpb2HXbXXhl9NbVLUZqFkX ZYvlGa3UvIMJHz2/LAiPf/8A7DFnoMFdoLDDLSwaXUZPi68bHYLvSI75nLC7A6zxusGt yWSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bdWzJhf+; 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 mq8sor2053233pjb.6.2020.10.16.18.33.14 for (Google Transport Security); Fri, 16 Oct 2020 18:33:14 -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=bdWzJhf+; 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 :mime-version:content-transfer-encoding; bh=P68wKVWfyCPNBm8l+XiI7Y585elPVzN5iuk0IO/H+/E=; b=bdWzJhf+Kt74SwdjGClZiLTK6Liqdc61K8jTehvBvcFdqmcILzkkCu6ynV2hBRrVEu 1pRQZehRxNgqVrBa+pMecr5Dr5+lqyMsuF9ucnzNvuTHw6CYBI5fUrMj2ZPC1UISlEk3 vLSJokv2OQC/BD4QC9wF367LFkQRvq06c0vFklyVkA+BJQHi0RBeH04qnblM6/0wWzzG 6ZR1WV9D+zUofDWUzH14k1P3gCaQQA2uWDojbYTMR6x+otkXIYbKyvhQxxUm0gOS/xbS cRYRiVFLPRMQtjWVoUAm9wKpGrsUL/6T1fVEeBTIzDsoNW/by0HXALYNmTPMIN3ewHq/ Q38g== 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:mime-version:content-transfer-encoding; bh=P68wKVWfyCPNBm8l+XiI7Y585elPVzN5iuk0IO/H+/E=; b=JjJ42IkEGGG6ZTCBMYi/vd1qj0B+/qWWtgYxawaLoFkCWqSghwf7XA0ssaiP/rF/xx vWYO4YGqdNC6/kjoQy1YWJo63t58feWxo1bIAl5deyZUo4/7TogeOsL11S03SZwqXfO/ h2jIEcqANjLYT5fogNALPV7XgvTuYwFtVHWbN09iwF5g92aO8cqTrX+g11M3M6DwBhMG 1ACLA1ujeK6C3NHS5YloqbFI1W+MDNy/qIigzRBx2jkso8Dj1Dx73u19n1jh1omgliu1 1lGISLl4LxyZDCVMFL8DBzf6ME1v1SVlRiwNXsm9mmoVT8dTA99ZbzrdcZlkOUoqFGaJ TVUw== X-Gm-Message-State: AOAM530Ok1tZVUb/Bj0cgr9ZgVyUEEVZFPFHt2XekTug3fIqkP4/NEdL giW+GOsY9T5XLRmr6qIp5bnaruEz X-Google-Smtp-Source: ABdhPJxXdKj7nSAtkG+Eczc0+aZcCvZHERtkfZGx5ovLSOefr82WKn91iVR+sj6Dnq0bOj3NmoOHFw== X-Received: by 2002:a17:90a:8c87:: with SMTP id b7mr6918045pjo.66.1602898394682; Fri, 16 Oct 2020 18:33:14 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id e186sm4222122pfh.60.2020.10.16.18.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 18:33:14 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Sumit Semwal , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , Chris Goldsworthy , =?utf-8?q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v4 6/7] dma-buf: dma-heap: Keep track of the heap device struct Date: Sat, 17 Oct 2020 01:32:54 +0000 Message-Id: <20201017013255.43568-7-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201017013255.43568-1-john.stultz@linaro.org> References: <20201017013255.43568-1-john.stultz@linaro.org> MIME-Version: 1.0 Keep track of the heap device struct. This will be useful for special DMA allocations and actions. Cc: Sumit Semwal Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: Chris Goldsworthy Cc: Ørjan Eide Cc: Robin Murphy Cc: Ezequiel Garcia Cc: Simon Ser Cc: James Jones 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