drivers/gpu/drm/v3d/v3d_drv.h

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/v3d/v3d_drv.h

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/v3d/v3d_drv.h
Extension
.h
Size
17795 bytes
Lines
663
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct v3d_stats {
	struct kref refcount;

	u64 start_ns;
	u64 enabled_ns;
	u64 jobs_completed;

	/*
	 * This seqcount is used to protect the access to the GPU stats
	 * variables. It must be used as, while we are reading the stats,
	 * IRQs can happen and the stats can be updated.
	 *
	 * However, we use the raw seqcount helpers to interact with this lock
	 * to avoid false positives from lockdep, which is unable to detect that
	 * our readers are never from irq or softirq context, and that, for CPU
	 * job queues, even the write side never is.
	 */
	seqcount_t lock;

	atomic_t reset_counter;
};

struct v3d_queue_state {
	struct drm_gpu_scheduler sched;

	u64 fence_context;
	u64 emit_seqno;

	/* Stores the GPU stats for this queue in the global context. */
	struct v3d_stats *stats;

	/* Currently active job for this queue */
	struct v3d_job *active_job;
	spinlock_t queue_lock;
};

/* Performance monitor object. The perform lifetime is controlled by userspace
 * using perfmon related ioctls. A perfmon can be attached to a submit_cl
 * request, and when this is the case, HW perf counters will be activated just
 * before the submit_cl is submitted to the GPU and disabled when the job is
 * done. This way, only events related to a specific job will be counted.
 */
struct v3d_perfmon {
	/* Tracks the number of users of the perfmon, when this counter reaches
	 * zero the perfmon is destroyed.
	 */
	refcount_t refcnt;

	/* Protects perfmon stop, as it can be invoked from multiple places. */
	struct mutex lock;

	/* Number of counters activated in this perfmon instance
	 * (should be less than DRM_V3D_MAX_PERF_COUNTERS).
	 */
	u8 ncounters;

	/* Events counted by the HW perf counters. */
	u8 counters[DRM_V3D_MAX_PERF_COUNTERS];

	/* Storage for counter values. Counters are incremented by the
	 * HW perf counter values every time the perfmon is attached
	 * to a GPU job.  This way, perfmon users don't have to
	 * retrieve the results after each job if they want to track
	 * events covering several submissions.  Note that counter
	 * values can't be reset, but you can fake a reset by
	 * destroying the perfmon and creating a new one.
	 */
	u64 values[] __counted_by(ncounters);
};

enum v3d_gen {
	V3D_GEN_33 = 33,
	V3D_GEN_41 = 41,
	V3D_GEN_42 = 42,
	V3D_GEN_71 = 71,
};

enum v3d_irq {
	V3D_CORE_IRQ,
	V3D_HUB_IRQ,
	V3D_MAX_IRQS,
};

struct v3d_dev {
	struct drm_device drm;

	/* Short representation (e.g. 33, 41) of the V3D tech version */
	enum v3d_gen ver;

	/* Short representation (e.g. 5, 6) of the V3D tech revision */

Annotation

Implementation Notes