From patchwork Sat Sep 19 07:49:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 313302 Delivered-To: patches@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp1958585ilg; Sat, 19 Sep 2020 00:49:24 -0700 (PDT) X-Received: by 2002:a17:90a:d195:: with SMTP id fu21mr15912719pjb.14.1600501763965; Sat, 19 Sep 2020 00:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600501763; cv=none; d=google.com; s=arc-20160816; b=PTlThNrZenpzegS476J3aMp5yDS1aj0kU0AvwrwJZ/0rrFbnSuUeTssMwdDjqecP2q lmtMwATxBnxxc/VkWx0IqvFTPoaw1c4dW0be95XT01Xccbk72fPyH5ETAtF14vZEiyIv v/LB9oiCOor8og3au8xgbSvxk6TWBSD24cHM+GjfdmJTd7AzhidwrMptcwA5X9+0noeU LyweDengE6xL3T5nvj7wnh/wg1vZf+jjKr7JVOWT9rQ6GgqwNd1vkxPzQEBXKPsWZIMB SIxXP8ovu75hG1r7amJoEHdbN1OFetw8pF3Bz7fAxRLy97ykFEhxTmYQPO82xlMTPvwR vTNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=euqT8lAbNK8yda4fe5ZlU/VWsoGMJIaK1lu2B8reCtQ=; b=qSinHHzXz+KS3rFy0qPH8KOKaUvYi97k9FCQFMjLdVworSY75ngs3uh72kY6Y4vvov tl7SIIgFBNW2uXMPgYSAwfsk2C9/DP6nJdQ4nVxA6PEuW9jnfImRUsG3oPGhW+kri04M DQOjKY870MlOKKb3pK8lxr3D4zmZ8ldFmRkPeyFQP5oeAyaVz3lqrAV5GmtfhfQhjTNW zTqHHVXIS3mFhHISq9bnpo594OL8qdO7e8P1SywXR1gDB5PVtc5eu2SBK5UKxKZOlAKM QGMeRxAkyyKsDcxFJvgL1Jp7MXGeQITC3eEQcoR5pGZSryUukE6PbPCySm1gq70BJGIt YdiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BC0RhrRG; 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 s192sor2591777pfs.100.2020.09.19.00.49.23 for (Google Transport Security); Sat, 19 Sep 2020 00:49:23 -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=BC0RhrRG; 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; bh=euqT8lAbNK8yda4fe5ZlU/VWsoGMJIaK1lu2B8reCtQ=; b=BC0RhrRGJPXpvemnBxslClbKPymkQ96oYf+Ai2v1b9MBEc/maqL371OqqQNo2CodWJ mm0oLv6j/1w3gIGZhSaiCsDSmRG3HLyEYkWnAjoKBVCaOsVuKUccSOhB2ZSCJcoH0mpH 5OsqBadth/QUJ+Dbun88ZdJdIqF71ZRO3hXeUItJponIoDnbJggTBJWHlH2Klu8/gRKY zwspEdA+z589VELkXJrvK39rwLhaJ9dJ6uHrHGwmcZZn8auZeDR5My5bTHUzcCCQpEUf G0Mo514LawqFo8uCYoOWMDWbYwphOV3MHTsTkhw2wCFgq8mYa4RudKbxURJQbUPkqzRl BmtA== 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; bh=euqT8lAbNK8yda4fe5ZlU/VWsoGMJIaK1lu2B8reCtQ=; b=hy7HrmJP73j9unU4Dwf18Ys3BMzVnR3GAkcDtFUFljAaKQHGvNBIOja8e8aWjSsdgC qk8EsKdP8Svb1lLM0dGzbosA1chh63rziZ1+5bRr6UJGsTWZYeUuloRcO3luH9NOn4iJ hoecTe3mucarzheEhSCEo+DLGu2oDiPz+7/BBq9JPOex4Gca/Hk+2E/5DXSpBp7VCTw0 btgwL8bouyvVp/cvVsaHcPSggfoBPoEZQmymVlH9ecHbTl0FhvEJ6WMuXTnKnJV5M341 MKgrd+0c9MJyf4h3RlEpIXY0IvCuJl9H6qqgwLGicfvNVoE8I/L67cWAAeznEDvMziZg hwiA== X-Gm-Message-State: AOAM533ujErz/ypyL5zWdZtXIFj478kNGZP6Jf3KjUbJEFvOlfS8gk5v n/kaibSN2TiGkFOOFHuYWKv6O+i0 X-Google-Smtp-Source: ABdhPJxpKPIvszjM3OQE3v39tCZq8Ro9FvcwzLrJYNhAyKJA0YoP0JQIOlLxT75zeuGDZwscO0GLHw== X-Received: by 2002:a62:1c96:0:b029:142:4bf7:15f3 with SMTP id c144-20020a621c960000b02901424bf715f3mr14299830pfc.75.1600501763512; Sat, 19 Sep 2020 00:49:23 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id m13sm5688151pfk.103.2020.09.19.00.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 00:49:22 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Sumit Semwal , "Andrew F . Davis" , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v3 1/2] dma-heap: Keep track of the heap device struct Date: Sat, 19 Sep 2020 07:49:04 +0000 Message-Id: <20200919074905.82036-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 Keep track of the heap device struct. This will be useful for special DMA allocations and actions. Cc: Sumit Semwal Cc: Andrew F. Davis Cc: Benjamin Gaignard Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju 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