From patchwork Thu Oct 29 00:16:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 319298 Delivered-To: patches@linaro.org Received: by 2002:a17:906:3bd4:0:0:0:0 with SMTP id v20csp26017ejf; Wed, 28 Oct 2020 17:16:39 -0700 (PDT) X-Received: by 2002:aa7:8c44:0:b029:160:19fd:a509 with SMTP id e4-20020aa78c440000b029016019fda509mr1720328pfd.6.1603930599238; Wed, 28 Oct 2020 17:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603930599; cv=none; d=google.com; s=arc-20160816; b=iDradnYoOelky2vGSrCe5OjAxn8Svp9a18bcH0Rgchv+yvQC3GKZODXec7Fgi3r7/y AOKtsvIVldgaUbtHggl/38xQrWbBFxOwWPLAogUdee7YEDS3qu5cAj0kyIvgCALxphWN 3AuCxTWGIJLO0K5qW6jgnyjElYDxOWeYwndPNXuLzFIvtOi3u/xqgCMvX/gD5IVStj2m 652rzbpX+aBv9z4UnhtP7RP2sotsS7pEs3hNFu8cJbTNbah5gHTNrdt6mLt9vkhZ9omD TJKmb0QrWUiIlxsOEF9beCQCtSKhLGq5nEQST3JgrSPD2VS68hVQuUv0INGIuN8DfuMu PGbA== 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=cjQyTjilZfU7y4pidwanlMVdWaL7S/g3otqAcD7cf5azow3N+Ho+atxs8E821oR/Xn uKHznOC3U4MkBk48oJLZl8LbTjvnHGq69jPZHF7yzwVJxFa9tIzpWcvE8EyqCHjodbWD ftnfrREA3YbHPtz2zJzzmoiUcM8MGsMDktV2ufrwaDm0cH5yGBu4OWljHRug2qiIvR2b zDZiAfbp1XLVf4cNr5+P7Ta+Tx9MHcL5P4NhTHoK65UtgG41e9nZsRVQIzjekH2SwvXE uFUSdrXyboPZG+nwllTdeJEYFqE8eMCzI6cs7wuAgxHXrVNcVXKOL/nw6KPY5T462vVH 4ngA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sWTJuXyN; 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 q14sor380180pjp.6.2020.10.28.17.16.38 for (Google Transport Security); Wed, 28 Oct 2020 17:16:39 -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=sWTJuXyN; 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=sWTJuXyNDCLZI28ci/F/8bQ4mgW8WKaoqb/ok2c5RN4T6cqgQei9ZDNeJkrrNvr9HU r6ZQ4cQzuoL3YoFO1OMku66UN9TyjTlmvQVxFiULu0AWasjNVfsrbXLR+ZEir6/jJ+kf jtMZYOIUUM6RavrfmjHtdvemSmAkeJDSOAt6cdlxwK0bf8IHOa7Fsfmc4D0mlBaZ6+KA o6yb27kAo+ae6nHlILoG4r3qs4ZN/L/tFmzrhSNbc8CSvtlFofBu4sEnGr1KLqjrTg65 ax/B+xQNdu48Gf1zNjePOdiNoeuR2yAROor/qokG/2jDOt4D9QF3K6Pn80Us5RqZVeWp Nnbw== 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=sz8RPDlf5xvOL9xxXJrUOeRZkZsF4pMI8BB5PYSfO3X6QutznZpzzP8rY8ov3CQI1N ms5RKkdftGSU8gJxeNJoFyteMunFpwtX3IfFq9olPvraHwMuBQ7S6HV8BUzD6YRW3wy2 McWp1GF+pb6q8dV4hH1xMdq04lfiTOkViRkS6z5pg5/ZsVwO4DN/rTC/bQ0Mw8fHC3DD LG7OPZg7DZnuqfeEgFTdbzI4Fl4vGON4jLmB+eAeZoiIgPUo84z4SdC/BZqHLsqbtOAF QW+4OPxYVkJsV7LpFGWs98gJ/CCyg+GHzQNuWBAJvk+hTX6NiHesd6sMH950aRIyz8IZ cTNA== X-Gm-Message-State: AOAM53090pOmhvfA67Y1Xj2sIn2pBhlSnWVyKHWN1D+DY5nUkoUpMEZK kPyoANRaRmhk7PBhBB6iujYNkEZ4 X-Google-Smtp-Source: ABdhPJzI740UrFZhPArstzKSQF+TYxwsPkseC3B5SFZZTFDVUlnVWmvZW4aDRDOTzm36sCMDWZUxIA== X-Received: by 2002:a17:90a:9414:: with SMTP id r20mr1438198pjo.29.1603930598200; Wed, 28 Oct 2020 17:16:38 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id u13sm727407pfl.162.2020.10.28.17.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 17:16:37 -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: Thu, 29 Oct 2020 00:16:23 +0000 Message-Id: <20201029001624.17513-7-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201029001624.17513-1-john.stultz@linaro.org> References: <20201029001624.17513-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