forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drm/tegra: Implement job submission part of new UAPI
Implement the job submission IOCTL with a minimum feature set. Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
- Loading branch information
1 parent
2b3b622
commit d5a3a65
Showing
6 changed files
with
552 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* Copyright (c) 2020 NVIDIA Corporation */ | ||
|
||
#include <linux/scatterlist.h> | ||
#include <linux/slab.h> | ||
|
||
#include "gather_bo.h" | ||
|
||
static struct host1x_bo *gather_bo_get(struct host1x_bo *host_bo) | ||
{ | ||
struct gather_bo *bo = container_of(host_bo, struct gather_bo, base); | ||
|
||
kref_get(&bo->ref); | ||
|
||
return host_bo; | ||
} | ||
|
||
static void gather_bo_release(struct kref *ref) | ||
{ | ||
struct gather_bo *bo = container_of(ref, struct gather_bo, ref); | ||
|
||
kfree(bo->gather_data); | ||
kfree(bo); | ||
} | ||
|
||
void gather_bo_put(struct host1x_bo *host_bo) | ||
{ | ||
struct gather_bo *bo = container_of(host_bo, struct gather_bo, base); | ||
|
||
kref_put(&bo->ref, gather_bo_release); | ||
} | ||
|
||
static struct sg_table * | ||
gather_bo_pin(struct device *dev, struct host1x_bo *host_bo, dma_addr_t *phys) | ||
{ | ||
struct gather_bo *bo = container_of(host_bo, struct gather_bo, base); | ||
struct sg_table *sgt; | ||
int err; | ||
|
||
if (phys) { | ||
*phys = virt_to_phys(bo->gather_data); | ||
return NULL; | ||
} | ||
|
||
sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); | ||
if (!sgt) | ||
return ERR_PTR(-ENOMEM); | ||
|
||
err = sg_alloc_table(sgt, 1, GFP_KERNEL); | ||
if (err) { | ||
kfree(sgt); | ||
return ERR_PTR(err); | ||
} | ||
|
||
sg_init_one(sgt->sgl, bo->gather_data, bo->gather_data_words*4); | ||
|
||
return sgt; | ||
} | ||
|
||
static void gather_bo_unpin(struct device *dev, struct sg_table *sgt) | ||
{ | ||
if (sgt) { | ||
sg_free_table(sgt); | ||
kfree(sgt); | ||
} | ||
} | ||
|
||
static void *gather_bo_mmap(struct host1x_bo *host_bo) | ||
{ | ||
struct gather_bo *bo = container_of(host_bo, struct gather_bo, base); | ||
|
||
return bo->gather_data; | ||
} | ||
|
||
static void gather_bo_munmap(struct host1x_bo *host_bo, void *addr) | ||
{ | ||
} | ||
|
||
const struct host1x_bo_ops gather_bo_ops = { | ||
.get = gather_bo_get, | ||
.put = gather_bo_put, | ||
.pin = gather_bo_pin, | ||
.unpin = gather_bo_unpin, | ||
.mmap = gather_bo_mmap, | ||
.munmap = gather_bo_munmap, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* Copyright (c) 2020 NVIDIA Corporation */ | ||
|
||
#ifndef _TEGRA_DRM_SUBMIT_GATHER_BO_H | ||
#define _TEGRA_DRM_SUBMIT_GATHER_BO_H | ||
|
||
#include <linux/host1x.h> | ||
#include <linux/kref.h> | ||
|
||
struct gather_bo { | ||
struct host1x_bo base; | ||
|
||
struct kref ref; | ||
|
||
u32 *gather_data; | ||
size_t gather_data_words; | ||
}; | ||
|
||
extern const struct host1x_bo_ops gather_bo_ops; | ||
void gather_bo_put(struct host1x_bo *host_bo); | ||
|
||
#endif |
Oops, something went wrong.