Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1793642pxk; Fri, 2 Oct 2020 21:04:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAsGfWHxla9nDvCuZv0oN2kXLD0XQvg5E+I7MsxzVO3gAsmAAye3G+IYwtCRv4LnI1tIqw X-Received: by 2002:a50:a693:: with SMTP id e19mr5989183edc.205.1601697892483; Fri, 02 Oct 2020 21:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601697892; cv=none; d=google.com; s=arc-20160816; b=LVM9agegGCIrsTwMNI6O73jBNoxyjwpgHlJaaoDItNVCYs4jdvpkIut00bApE4pwGI 64psUFxeT7II8HN1s3lXBBOOflXllzp09CFKQnSV0LKOxIa9rdWhX8I5NVUAeewoHFdG K4Dv0m4/EGWknvC7FwMplk3Y7slGMfMnQFtOJ/VIMYRaF1eTNNPyQsEmW6f6Ihy4jMZj Rs/+Tkipv6HLJi7bjkbeucLDXD/nqDjRmn8njjfcKzmCu0lVNQ4qp8HC8camEL2YxKEI 6chD9csIuUfaxrZCIuPjdtPuix35aX2p856N/2SacEyVxe7K4ISjra5aoaX6gz+Cv44A 1ABQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P68wKVWfyCPNBm8l+XiI7Y585elPVzN5iuk0IO/H+/E=; b=hqu0m9aeYkqzVplyemcbyjGKlVJl88tKBXt/ZBJ2Cp+wfocJCZzRXn7cPNiHQKmDbi NFmOD56KcupqVDb8anzdH3d62F0sLfKxh8qYa1VXBVHRRxQuak7ZDHFrmrJfShiYTKYl s+U6ltHYWhA+ecSoLZVCcp2Q4cYlZHg0VojNtwDQKx+5lXXkxKT32eLYpKnBhNq1jlAH v+RgKTKvUqHLiunwpyHfmUpt6amDpG7OizrNCasVglFZDfq8Spqc+rHioVPFIVZoPVJP 3/ga2Gg61zVOMxmKkEIXiiF4NA48HJHl5eKxrsBHle6yaTC7khFsZoCvA9EOjlgVMteM lXOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DoA/WXci"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si2524540eds.162.2020.10.02.21.04.30; Fri, 02 Oct 2020 21:04:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DoA/WXci"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725838AbgJCEDV (ORCPT + 99 others); Sat, 3 Oct 2020 00:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgJCEDQ (ORCPT ); Sat, 3 Oct 2020 00:03:16 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B06BC0613E7 for ; Fri, 2 Oct 2020 21:03:16 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id x2so2146094pjk.0 for ; Fri, 02 Oct 2020 21:03:16 -0700 (PDT) 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=DoA/WXci/N6o2iCahmaE/6s0q36QnObD7Kz0rTkp+Wir/LUz0b97SkvNv7xR8a7ae1 RhoBSY2JhZVsel487aadjO1WZBme5eKV9taGbs7OEZj7tP1hdrTrDyftqkQwVGwgrW61 FiW7nbBi6IUykERJktulqpG5s1Mx4/OOXLINs2shI5aG3o/yj9b+6340TrewWhofNsKh at1Plc5eH1zH3vg7LejixlzlKVVC8vJNdvOHnzLXvQCLdVq15VJl7/7z3xH0J/VNtxJQ K4cNL4vwhilksSyNVrIEvRW/vsqhEu3pCbvcRCAwzTKKo81cnhKZPRUOQaVp2V4vrQaP hzRw== 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=ivVHh+CvvbSslC5/uwSbZIohbK8OwgzpPi4dtffN4ylwWq0UN6CMpvhxrpyHBK1V1z 5wPQR3AaYsO6h1ffFh6aYf1GSHLnybxWjgFov2jpimwdGGdfL2liq99AubhfoE3+51a1 HoXw4OVA6/T3YN7gl3sg+qDugO1ZeImxK0Gg/RHeO6lkWQTiuOtRTO8SV/Hut1QSJK/7 vkNDNwLV7p4DSbbJmq8h5WS12t096aNzu7Rc3/BgxeP+B0G2XUQm8JJUNST3N5dkNCdS Il4XfhwYoKUMLEZXCYfXQAsLJQQR3xS720JykeG1rH/72Seo/AEuVKxG97J4mIWxu8Z4 0MCQ== X-Gm-Message-State: AOAM533yn3txrCvOcccZJwQNGEwamHvUsmp2GWSy2XnbI6Kt82fHSMGQ MzKyXqGiT3Lgn0bnyZmpDZcHxk/dKMrXvw== X-Received: by 2002:a17:90a:ead5:: with SMTP id ev21mr5465614pjb.188.1601697795315; Fri, 02 Oct 2020 21:03:15 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id 190sm3909290pfy.22.2020.10.02.21.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 21:03: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=20Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v3 6/7] dma-buf: dma-heap: Keep track of the heap device struct Date: Sat, 3 Oct 2020 04:02:56 +0000 Message-Id: <20201003040257.62768-7-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201003040257.62768-1-john.stultz@linaro.org> References: <20201003040257.62768-1-john.stultz@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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 -- 2.17.1