From patchwork Tue Nov 10 03:49:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 321005 Delivered-To: patches@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp2273803ilc; Mon, 9 Nov 2020 19:49:47 -0800 (PST) X-Received: by 2002:a17:90a:dd42:: with SMTP id u2mr2804377pjv.159.1604980186961; Mon, 09 Nov 2020 19:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604980186; cv=none; d=google.com; s=arc-20160816; b=ReqQS6fkGrW4HPiJDrrJ0+Wy734P2BPS5fCubd2is/etlssi0/4/OK74hPy/sS/+Qe vi7zRQtG9S6RbsTBSRceZLxKZNofAyHNxMkJSn/Bo4FlvZLL7tToRmDnVbjiZP4MLE3x 2qBV+iyGTJ4FUiEGewds2VUt9xaEl3byKmHRmbyh/f+hNzy5GhS+RoW9pWgv2j/68A85 X2+yslQbVvs+vPziTaaxtHdnE5/eILAeSy2pw+fCvx1TakFgIu4EB8R1tDrkO6bwFDhv NpcRxEtBGCl2WpBkgYmNFo03fSZbrNTKJyEixEAbrv1DPIvLNGKHari/Fs0A4vh8028H cdYw== 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=j5h+p47GQc+S4dNfVSB4J4USE4BcRFQAoB8iGafysDrRf5v4em9S+0oOgqavwLpzFD Yl3GY1ujp9ZPaPpppgJzXStFOyeQDOkjUiMl7Zt/FHi0Sa/uHn+nWytZ8WlIx58qyPP7 YwuNtN30CeYnsGY8QGRQxCdCehomkCMjpe5VMjiRYjK460yxn4VTzpd5PDdnuEv60GsS 8PvTunFcma3xCow0pSL/iz7VrnU+kqH+DBNm/ud3t9NlOqrKR92q3VfyNIEMHb/WIxCf u789obhpnkVQibw/hnpLqbzsTHLup8eNTizP+Sj2kF6NRUOYHUO9uAURvdRtMtHAB+oC qzHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ufp302/I"; 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 n10sor1031609pjt.33.2020.11.09.19.49.46 for (Google Transport Security); Mon, 09 Nov 2020 19:49:46 -0800 (PST) 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="ufp302/I"; 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=ufp302/IxJQeNPSAn/oG0B7slHsqXLhIaqrxmacDetxK4DKaSaXiaobRRXokmFt6qm qVBiUCq58nepS2WX6lx6AMUPPLdPRlE2cNrSjCWFYvv2bj+5PPwPdcJh4X2ARgdmdmtS uB+tiGJJjTHY0lghPGMJNNEQx61kN+m4u8NAcC56BhD8qV3KJGIHmuMhMwY+mXT/A5eD zZy41bECU/98xAKE8mzxpQGAqcK3y6nn7i55dYt12X38Jd4KsuckJ5VDvGHYGiwqp+vb TbPk9/DtMWP8D/E5FIwOvq9LyZX+SG/oVSVIwNtOV9bOTQrK7X4jY7Htq/DpEjxjCKPh TYJQ== 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=Cnk6oSc7vvcm39XIw/HK0lnYeDv5bPAQFmguaxx7AD8wk7HPOskt6N1kn8NmrjisVt +LrkJRT3hpms69OPo7rr419pG83wNmBgz1dMGnFbpHBgTHNr/ZgYuP/GG6kZQXTtUOxf ccLzEyt7MHWpb0w4r4N3daOBq4SYR7zx8wD3I/kjLvx4RzXvlrYvFwAOk2+6mURMt4RL TXyP3+9JYInNHi8otXrn8qKlqpXG9Qilts4ebOrJDKxIH0Yj/NyfojOlXIrfaCswHmri ff/QNmNyyS3A61lZMTfws6EX35YEgfia1vgKabAqecHysQt0VuQ7vMTOXPqtGgOZQe7a TgyQ== X-Gm-Message-State: AOAM533Ake2/1e6D6rth7n+twdRjVxibc+cupECj7tq0p5XCNCLl80Z2 NiqbVDsKs+iFv8OVO7Y15cbwPNM3 X-Google-Smtp-Source: ABdhPJy3C6z8WgvKfa3+iIExPXU/G5Au0PlnF8H64NrwiW6423OfMKUtvdYTjtKk3kZruKsUbgxHxw== X-Received: by 2002:a17:90a:fe07:: with SMTP id ck7mr2868620pjb.212.1604980186664; Mon, 09 Nov 2020 19:49:46 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b4sm12380693pfi.208.2020.11.09.19.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 19:49:45 -0800 (PST) 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 v5 6/7] dma-buf: dma-heap: Keep track of the heap device struct Date: Tue, 10 Nov 2020 03:49:33 +0000 Message-Id: <20201110034934.70898-7-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201110034934.70898-1-john.stultz@linaro.org> References: <20201110034934.70898-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