drivers/gpu/drm/drm_auth.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_auth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_auth.c- Extension
.c- Size
- 12777 bytes
- Lines
- 451
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/export.hlinux/slab.hdrm/drm_auth.hdrm/drm_drv.hdrm/drm_file.hdrm/drm_lease.hdrm/drm_print.hdrm_internal.h
Detected Declarations
function filesfunction drm_is_current_masterfunction drm_getmagicfunction drm_authmagicfunction drm_set_masterfunction drm_new_set_masterfunction drm_master_check_permfunction drm_setmaster_ioctlfunction drm_drop_masterfunction drm_dropmaster_ioctlfunction drm_master_openfunction drm_master_releasefunction drm_master_putfunction drm_master_destroyfunction drm_master_putfunction drm_master_internal_acquirefunction drm_master_internal_releaseexport drm_is_current_masterexport drm_master_getexport drm_file_get_masterexport drm_master_putexport drm_master_internal_acquireexport drm_master_internal_release
Annotated Snippet
#include <linux/export.h>
#include <linux/slab.h>
#include <drm/drm_auth.h>
#include <drm/drm_drv.h>
#include <drm/drm_file.h>
#include <drm/drm_lease.h>
#include <drm/drm_print.h>
#include "drm_internal.h"
/**
* DOC: master and authentication
*
* &struct drm_master is used to track groups of clients with open
* primary device nodes. For every &struct drm_file which has had at
* least once successfully became the device master (either through the
* SET_MASTER IOCTL, or implicitly through opening the primary device node when
* no one else is the current master that time) there exists one &drm_master.
* This is noted in &drm_file.is_master. All other clients have just a pointer
* to the &drm_master they are associated with.
*
* In addition only one &drm_master can be the current master for a &drm_device.
* It can be switched through the DROP_MASTER and SET_MASTER IOCTL, or
* implicitly through closing/opening the primary device node. See also
* drm_is_current_master().
*
* Clients can authenticate against the current master (if it matches their own)
* using the GETMAGIC and AUTHMAGIC IOCTLs. Together with exchanging masters,
* this allows controlled access to the device for an entire group of mutually
* trusted clients.
*/
static bool drm_is_current_master_locked(struct drm_file *fpriv)
{
lockdep_assert_once(lockdep_is_held(&fpriv->master_lookup_lock) ||
lockdep_is_held(&fpriv->minor->dev->master_mutex));
return fpriv->is_master && drm_lease_owner(fpriv->master) == fpriv->minor->dev->master;
}
/**
* drm_is_current_master - checks whether @priv is the current master
* @fpriv: DRM file private
*
* Checks whether @fpriv is current master on its device. This decides whether a
* client is allowed to run DRM_MASTER IOCTLs.
*
* Most of the modern IOCTL which require DRM_MASTER are for kernel modesetting
* - the current master is assumed to own the non-shareable display hardware.
*/
bool drm_is_current_master(struct drm_file *fpriv)
{
bool ret;
spin_lock(&fpriv->master_lookup_lock);
ret = drm_is_current_master_locked(fpriv);
spin_unlock(&fpriv->master_lookup_lock);
return ret;
}
EXPORT_SYMBOL(drm_is_current_master);
int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
struct drm_auth *auth = data;
int ret = 0;
guard(mutex)(&dev->master_mutex);
if (!file_priv->magic) {
ret = idr_alloc(&file_priv->master->magic_map, file_priv,
1, 0, GFP_KERNEL);
if (ret >= 0)
file_priv->magic = ret;
}
auth->magic = file_priv->magic;
drm_dbg_core(dev, "%u\n", auth->magic);
return ret < 0 ? ret : 0;
}
int drm_authmagic(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_auth *auth = data;
struct drm_file *file;
drm_dbg_core(dev, "%u\n", auth->magic);
Annotation
- Immediate include surface: `linux/export.h`, `linux/slab.h`, `drm/drm_auth.h`, `drm/drm_drv.h`, `drm/drm_file.h`, `drm/drm_lease.h`, `drm/drm_print.h`, `drm_internal.h`.
- Detected declarations: `function files`, `function drm_is_current_master`, `function drm_getmagic`, `function drm_authmagic`, `function drm_set_master`, `function drm_new_set_master`, `function drm_master_check_perm`, `function drm_setmaster_ioctl`, `function drm_drop_master`, `function drm_dropmaster_ioctl`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.