mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-24 02:01:36 +03:00
Add the upstream tegra-drm driver with the 'Host1x/Tegra UAPI' series [0] applied. This driver will be built as an external module for testing and development with upstream Linux kernels. The following modifications have been made to the series posted upstream 1. Update the Makefile to always build the driver as a module 2. Always enable the tegra_drm_ioctl_xxx in the tegra_drm_ioctls and remove the dependency on CONFIG_DRM_TEGRA_STAGING. 3. Rename the include/uapi/drm/tegra_drm.h to include/uapi/drm/tegra_drm_next.h to avoid conflicts with upstream headers when building as an external module. 5. Rename the module that is built to be tegra-drm-next.ko instead of tegra-drm.ko to avoid any depmod conflicts with the upstream driver. [0] https://patchwork.ozlabs.org/project/linux-tegra/list/?series=215770 Bug 3156385 Change-Id: I19206f989325c9c6ff3c2b9301d964140d52234f Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2435802 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
87 lines
1.7 KiB
C
87 lines
1.7 KiB
C
// 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,
|
|
};
|