From patchwork Wed Jan 20 21:09:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 367096 Delivered-To: patches@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp813155jam; Wed, 20 Jan 2021 13:09:42 -0800 (PST) X-Received: by 2002:a17:90b:11d8:: with SMTP id gv24mr7687963pjb.232.1611176982651; Wed, 20 Jan 2021 13:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611176982; cv=none; d=google.com; s=arc-20160816; b=hGV2E+amQ/nnJSvJ7EG15edo/GyksXos8xrgDZKvbYIs2aMD/pw8duOk04gx9fkDiX TFTXjUe8cvFO+J4nS5eWrDiZe8+iTo4nqxS97wax9YY5Ta/iR6tGtDEh5aVw885PvYcr xQGRwPe11rOadNaE3ZWilW8xd11E96a3P/dGZ7qf2aW1VaQVZ4k7s1x52Qgpe7oAaCTW sa4KFhgcyzHqitv7gkCw9xdLgixgrp0BsqXYoOrsMTK2N460K7gpQNbhehPFooFMddEq Ymvxn/zPYHlH+qNCe/S4S8nwYHb5RXpCK/FmFPR/DhMcOUtsc4MzUbmjw/5HDjhnsiUG q9Nw== 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=5p3XfY6TOWEdcAK7xdoxc0ak2IFt6vsK1MpKBtv9a0E=; b=qC7y6T8IzWw7IzTKJm7blXaccRByu1Zz5nGddzZQaT/9KEQhZ5xe/QHWV+rGo46HoH BBDBZvwmCrRxi9IAuzAE9x5otxxURNUrJxMGYZfR7j9wUpdt7Nm037kDdBl4c8azhmBz 9bcf/GvViSVS+7+YrDD/w4yHsVIVFo+C3Tn5mrrnb5pZ8lA5UZj4JZPMDkY5DRz8ruXB yZC1qis0gerBoG681JgCKHrL/EIV0oYh3FU8d+6A92qCZdgjC2hG8w8bGQEoew6bkbyT 9yzYQ8vsJxJYBqKqhhtP5N/yWG9U4OLfKYYCWtVxAWCmiimxiqnXVzLjlK3DtiVLGXXa mXkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dIylZNXU; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 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-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id m4sor1896177pld.35.2021.01.20.13.09.42 for (Google Transport Security); Wed, 20 Jan 2021 13:09:42 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dIylZNXU; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 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=5p3XfY6TOWEdcAK7xdoxc0ak2IFt6vsK1MpKBtv9a0E=; b=dIylZNXUT8UQ3UamF1ogl2nvky0NOqNfe4p5pAKibTyvbKpekUSnf9ybDFs54ibA61 C/ZTwYE6NnSTMniIt78BwgL8jFAh3+rjQvmEWrMrKSJKxbkS0hz96dBKkbEbw9gtFk18 KYuxSgNMJkmdWQ8aLW21q7KBpR80cNf8dfF8N2tIS4SgJpoyaXfqI8wcVAXoTU0krNs6 gdYQeDCNH6YNcse2uf33htcQmPbFox6z6dKVg1FTtNAccuiwdwNizrjmiGcGMnc+kPU+ uA6gayZCbJYLyJQXyg1ltt7mbeoFgUj879fNhy/VNvLDe6KbpVOg4yo1OSBtH16wV3xG JLMg== 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=5p3XfY6TOWEdcAK7xdoxc0ak2IFt6vsK1MpKBtv9a0E=; b=owEgk7yAwqEoTXDiUDoClCG5BkGGD3uITn1xLJeINvyIm3zQCJhev9LsxhQgfwHHHX seO3LtQabsY0g+0Ef3nE6OU8cSDvgGSKYBxf3w+fP3tk1/69ha73b/lCmEGBTPbQ3dts MbewCAMZaLrwhoAAS6lpM01wEr2o7c/TbtSmtNtaMBOFC7pY44aaIcmd90g9B/draNSv kSfXWQisbOIKy2elE1ZKlQ9yeMr35SSTKv6t2YVQL15rQYssKcZ76XT75DcGZ677ErbW 7eHlWJf55oqQgFO4Pus/b3VyNNAOlKtBF2AMo4EpKVb/AjkE1LvCh0giL/6i87ynxFOI EHig== X-Gm-Message-State: AOAM533QDI9so+nb2xFtVJATxkNA2TtPDguud66ruP4nGalV1r+e6GUe PSrg3ylAGUiOslOjDTMafefXbcFe X-Google-Smtp-Source: ABdhPJws6ddONO6NY88RoQ3BGsVYEJuaBeog/gKtwE5U4aqwU6w4J5JtoB3QT6Z/CXX0IqrItU/FPA== X-Received: by 2002:a17:902:b203:b029:dc:973:3ad0 with SMTP id t3-20020a170902b203b02900dc09733ad0mr11671800plr.44.1611176982332; Wed, 20 Jan 2021 13:09:42 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id f15sm3265629pja.24.2021.01.20.13.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 13:09:41 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Daniel Vetter , 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 , Bing Song , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] dma-buf: dma-heap: Keep track of the heap device struct Date: Wed, 20 Jan 2021 21:09:35 +0000 Message-Id: <20210120210937.15069-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210120210937.15069-1-john.stultz@linaro.org> References: <20210120210937.15069-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: Daniel Vetter 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: Bing Song 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