drivers/gpu/drm/exynos/exynos_drm_gem.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/exynos/exynos_drm_gem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/exynos/exynos_drm_gem.c- Extension
.c- Size
- 11317 bytes
- Lines
- 455
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-buf.hlinux/shmem_fs.hlinux/module.hdrm/drm_device.hdrm/drm_dumb_buffers.hdrm/drm_prime.hdrm/drm_print.hdrm/drm_vma_manager.hdrm/exynos_drm.hexynos_drm_drv.hexynos_drm_gem.h
Detected Declarations
function exynos_drm_alloc_buffunction exynos_drm_free_buffunction exynos_drm_gem_handle_createfunction exynos_drm_gem_destroyfunction exynos_drm_gem_free_objectfunction exynos_drm_gem_create_ioctlfunction exynos_drm_gem_map_ioctlfunction exynos_drm_gem_mmap_bufferfunction exynos_drm_gem_get_ioctlfunction exynos_drm_gem_dumb_createfunction exynos_drm_gem_mmapfunction exynos_drm_gem_prime_import_sg_table
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/* exynos_drm_gem.c
*
* Copyright (c) 2011 Samsung Electronics Co., Ltd.
* Author: Inki Dae <inki.dae@samsung.com>
*/
#include <linux/dma-buf.h>
#include <linux/shmem_fs.h>
#include <linux/module.h>
#include <drm/drm_device.h>
#include <drm/drm_dumb_buffers.h>
#include <drm/drm_prime.h>
#include <drm/drm_print.h>
#include <drm/drm_vma_manager.h>
#include <drm/exynos_drm.h>
#include "exynos_drm_drv.h"
#include "exynos_drm_gem.h"
MODULE_IMPORT_NS("DMA_BUF");
static int exynos_drm_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem, bool kvmap)
{
struct drm_device *dev = exynos_gem->base.dev;
unsigned long attr = 0;
if (exynos_gem->dma_addr) {
DRM_DEV_DEBUG_KMS(drm_dev_dma_dev(dev), "already allocated.\n");
return 0;
}
/*
* if EXYNOS_BO_CONTIG, fully physically contiguous memory
* region will be allocated else physically contiguous
* as possible.
*/
if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG))
attr |= DMA_ATTR_FORCE_CONTIGUOUS;
/*
* if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping
* else cachable mapping.
*/
if (exynos_gem->flags & EXYNOS_BO_WC ||
!(exynos_gem->flags & EXYNOS_BO_CACHABLE))
attr |= DMA_ATTR_WRITE_COMBINE;
/* FBDev emulation requires kernel mapping */
if (!kvmap)
attr |= DMA_ATTR_NO_KERNEL_MAPPING;
exynos_gem->dma_attrs = attr;
exynos_gem->cookie = dma_alloc_attrs(drm_dev_dma_dev(dev), exynos_gem->base.size,
&exynos_gem->dma_addr, GFP_KERNEL,
exynos_gem->dma_attrs);
if (!exynos_gem->cookie) {
DRM_DEV_ERROR(drm_dev_dma_dev(dev), "failed to allocate buffer.\n");
return -ENOMEM;
}
if (kvmap)
exynos_gem->kvaddr = exynos_gem->cookie;
DRM_DEV_DEBUG_KMS(drm_dev_dma_dev(dev), "dma_addr(%pad), size(0x%zx)\n",
&exynos_gem->dma_addr, exynos_gem->base.size);
return 0;
}
static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem)
{
struct drm_device *dev = exynos_gem->base.dev;
if (!exynos_gem->dma_addr) {
DRM_DEV_DEBUG_KMS(dev->dev, "dma_addr is invalid.\n");
return;
}
DRM_DEV_DEBUG_KMS(dev->dev, "dma_addr(0x%pad), size(0x%zx)\n",
&exynos_gem->dma_addr, exynos_gem->base.size);
dma_free_attrs(drm_dev_dma_dev(dev), exynos_gem->base.size, exynos_gem->cookie,
(dma_addr_t)exynos_gem->dma_addr,
exynos_gem->dma_attrs);
}
Annotation
- Immediate include surface: `linux/dma-buf.h`, `linux/shmem_fs.h`, `linux/module.h`, `drm/drm_device.h`, `drm/drm_dumb_buffers.h`, `drm/drm_prime.h`, `drm/drm_print.h`, `drm/drm_vma_manager.h`.
- Detected declarations: `function exynos_drm_alloc_buf`, `function exynos_drm_free_buf`, `function exynos_drm_gem_handle_create`, `function exynos_drm_gem_destroy`, `function exynos_drm_gem_free_object`, `function exynos_drm_gem_create_ioctl`, `function exynos_drm_gem_map_ioctl`, `function exynos_drm_gem_mmap_buffer`, `function exynos_drm_gem_get_ioctl`, `function exynos_drm_gem_dumb_create`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.