mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-31 22:23:05 +00:00

Currently, an interrupt can be triggered during a GPU reset, which can
lead to GPU hangs and NULL pointer dereference in an interrupt context
as shown in the following trace:
[ 314.035040] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000c0
[ 314.043822] Mem abort info:
[ 314.046606] ESR = 0x0000000096000005
[ 314.050347] EC = 0x25: DABT (current EL), IL = 32 bits
[ 314.055651] SET = 0, FnV = 0
[ 314.058695] EA = 0, S1PTW = 0
[ 314.061826] FSC = 0x05: level 1 translation fault
[ 314.066694] Data abort info:
[ 314.069564] ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
[ 314.075039] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 314.080080] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 314.085382] user pgtable: 4k pages, 39-bit VAs, pgdp=0000000102728000
[ 314.091814] [00000000000000c0] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
[ 314.100511] Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP
[ 314.106770] Modules linked in: v3d i2c_brcmstb vc4 snd_soc_hdmi_codec gpu_sched drm_shmem_helper drm_display_helper cec drm_dma_helper drm_kms_helper drm drm_panel_orientation_quirks snd_soc_core snd_compress snd_pcm_dmaengine snd_pcm snd_timer snd backlight
[ 314.129654] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.12.25+rpt-rpi-v8 #1 Debian 1:6.12.25-1+rpt1
[ 314.139388] Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT)
[ 314.145211] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 314.152165] pc : v3d_irq+0xec/0x2e0 [v3d]
[ 314.156187] lr : v3d_irq+0xe0/0x2e0 [v3d]
[ 314.160198] sp : ffffffc080003ea0
[ 314.163502] x29: ffffffc080003ea0 x28: ffffffec1f184980 x27: 021202b000000000
[ 314.170633] x26: ffffffec1f17f630 x25: ffffff8101372000 x24: ffffffec1f17d9f0
[ 314.177764] x23: 000000000000002a x22: 000000000000002a x21: ffffff8103252000
[ 314.184895] x20: 0000000000000001 x19: 00000000deadbeef x18: 0000000000000000
[ 314.192026] x17: ffffff94e51d2000 x16: ffffffec1dac3cb0 x15: c306000000000000
[ 314.199156] x14: 0000000000000000 x13: b2fc982e03cc5168 x12: 0000000000000001
[ 314.206286] x11: ffffff8103f8bcc0 x10: ffffffec1f196868 x9 : ffffffec1dac3874
[ 314.213416] x8 : 0000000000000000 x7 : 0000000000042a3a x6 : ffffff810017a180
[ 314.220547] x5 : ffffffec1ebad400 x4 : ffffffec1ebad320 x3 : 00000000000bebeb
[ 314.227677] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
[ 314.234807] Call trace:
[ 314.237243] v3d_irq+0xec/0x2e0 [v3d]
[ 314.240906] __handle_irq_event_percpu+0x58/0x218
[ 314.245609] handle_irq_event+0x54/0xb8
[ 314.249439] handle_fasteoi_irq+0xac/0x240
[ 314.253527] handle_irq_desc+0x48/0x68
[ 314.257269] generic_handle_domain_irq+0x24/0x38
[ 314.261879] gic_handle_irq+0x48/0xd8
[ 314.265533] call_on_irq_stack+0x24/0x58
[ 314.269448] do_interrupt_handler+0x88/0x98
[ 314.273624] el1_interrupt+0x34/0x68
[ 314.277193] el1h_64_irq_handler+0x18/0x28
[ 314.281281] el1h_64_irq+0x64/0x68
[ 314.284673] default_idle_call+0x3c/0x168
[ 314.288675] do_idle+0x1fc/0x230
[ 314.291895] cpu_startup_entry+0x3c/0x50
[ 314.295810] rest_init+0xe4/0xf0
[ 314.299030] start_kernel+0x5e8/0x790
[ 314.302684] __primary_switched+0x80/0x90
[ 314.306691] Code: 940029eb 360ffc13 f9442ea0 52800001 (f9406017)
[ 314.312775] ---[ end trace 0000000000000000 ]---
[ 314.317384] Kernel panic - not syncing: Oops: Fatal exception in interrupt
[ 314.324249] SMP: stopping secondary CPUs
[ 314.328167] Kernel Offset: 0x2b9da00000 from 0xffffffc080000000
[ 314.334076] PHYS_OFFSET: 0x0
[ 314.336946] CPU features: 0x08,00002013,c0200000,0200421b
[ 314.342337] Memory Limit: none
[ 314.345382] ---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]---
Before resetting the GPU, it's necessary to disable all interrupts and
deal with any interrupt handler still in-flight. Otherwise, the GPU might
reset with jobs still running, or yet, an interrupt could be handled
during the reset.
Cc: stable@vger.kernel.org
Fixes: 57692c94dc
("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://lore.kernel.org/r/20250628224243.47599-1-mcanal@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
634 lines
16 KiB
C
634 lines
16 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/* Copyright (C) 2015-2018 Broadcom */
|
|
|
|
#include <linux/delay.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/spinlock_types.h>
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <drm/drm_encoder.h>
|
|
#include <drm/drm_gem.h>
|
|
#include <drm/drm_gem_shmem_helper.h>
|
|
#include <drm/gpu_scheduler.h>
|
|
|
|
#include "v3d_performance_counters.h"
|
|
|
|
#include "uapi/drm/v3d_drm.h"
|
|
|
|
struct clk;
|
|
struct platform_device;
|
|
struct reset_control;
|
|
|
|
#define V3D_MMU_PAGE_SHIFT 12
|
|
#define V3D_PAGE_FACTOR (PAGE_SIZE >> V3D_MMU_PAGE_SHIFT)
|
|
|
|
#define V3D_MAX_QUEUES (V3D_CPU + 1)
|
|
|
|
static inline char *v3d_queue_to_string(enum v3d_queue queue)
|
|
{
|
|
switch (queue) {
|
|
case V3D_BIN: return "bin";
|
|
case V3D_RENDER: return "render";
|
|
case V3D_TFU: return "tfu";
|
|
case V3D_CSD: return "csd";
|
|
case V3D_CACHE_CLEAN: return "cache_clean";
|
|
case V3D_CPU: return "cpu";
|
|
}
|
|
return "UNKNOWN";
|
|
}
|
|
|
|
struct v3d_stats {
|
|
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.
|
|
*/
|
|
seqcount_t lock;
|
|
};
|
|
|
|
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;
|
|
};
|
|
|
|
/* 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 */
|
|
int rev;
|
|
|
|
bool single_irq_line;
|
|
|
|
int irq[V3D_MAX_IRQS];
|
|
|
|
struct v3d_perfmon_info perfmon_info;
|
|
|
|
void __iomem *hub_regs;
|
|
void __iomem *core_regs[3];
|
|
void __iomem *bridge_regs;
|
|
void __iomem *gca_regs;
|
|
void __iomem *sms_regs;
|
|
struct clk *clk;
|
|
struct reset_control *reset;
|
|
|
|
/* Virtual and DMA addresses of the single shared page table. */
|
|
volatile u32 *pt;
|
|
dma_addr_t pt_paddr;
|
|
|
|
/* Virtual and DMA addresses of the MMU's scratch page. When
|
|
* a read or write is invalid in the MMU, it will be
|
|
* redirected here.
|
|
*/
|
|
void *mmu_scratch;
|
|
dma_addr_t mmu_scratch_paddr;
|
|
/* virtual address bits from V3D to the MMU. */
|
|
int va_width;
|
|
|
|
/* Number of V3D cores. */
|
|
u32 cores;
|
|
|
|
/* Allocator managing the address space. All units are in
|
|
* number of pages.
|
|
*/
|
|
struct drm_mm mm;
|
|
spinlock_t mm_lock;
|
|
|
|
/*
|
|
* tmpfs instance used for shmem backed objects
|
|
*/
|
|
struct vfsmount *gemfs;
|
|
|
|
struct work_struct overflow_mem_work;
|
|
|
|
struct v3d_bin_job *bin_job;
|
|
struct v3d_render_job *render_job;
|
|
struct v3d_tfu_job *tfu_job;
|
|
struct v3d_csd_job *csd_job;
|
|
|
|
struct v3d_queue_state queue[V3D_MAX_QUEUES];
|
|
|
|
/* Spinlock used to synchronize the overflow memory
|
|
* management against bin job submission.
|
|
*/
|
|
spinlock_t job_lock;
|
|
|
|
/* Used to track the active perfmon if any. */
|
|
struct v3d_perfmon *active_perfmon;
|
|
|
|
/* Protects bo_stats */
|
|
struct mutex bo_lock;
|
|
|
|
/* Lock taken when resetting the GPU, to keep multiple
|
|
* processes from trying to park the scheduler threads and
|
|
* reset at once.
|
|
*/
|
|
struct mutex reset_lock;
|
|
|
|
/* Lock taken when creating and pushing the GPU scheduler
|
|
* jobs, to keep the sched-fence seqnos in order.
|
|
*/
|
|
struct mutex sched_lock;
|
|
|
|
/* Lock taken during a cache clean and when initiating an L2
|
|
* flush, to keep L2 flushes from interfering with the
|
|
* synchronous L2 cleans.
|
|
*/
|
|
struct mutex cache_clean_lock;
|
|
|
|
struct {
|
|
u32 num_allocated;
|
|
u32 pages_allocated;
|
|
} bo_stats;
|
|
|
|
/* To support a performance analysis tool in user space, we require
|
|
* a single, globally configured performance monitor (perfmon) for
|
|
* all jobs.
|
|
*/
|
|
struct v3d_perfmon *global_perfmon;
|
|
};
|
|
|
|
static inline struct v3d_dev *
|
|
to_v3d_dev(struct drm_device *dev)
|
|
{
|
|
return container_of(dev, struct v3d_dev, drm);
|
|
}
|
|
|
|
static inline bool
|
|
v3d_has_csd(struct v3d_dev *v3d)
|
|
{
|
|
return v3d->ver >= V3D_GEN_41;
|
|
}
|
|
|
|
#define v3d_to_pdev(v3d) to_platform_device((v3d)->drm.dev)
|
|
|
|
/* The per-fd struct, which tracks the MMU mappings. */
|
|
struct v3d_file_priv {
|
|
struct v3d_dev *v3d;
|
|
|
|
struct {
|
|
struct idr idr;
|
|
struct mutex lock;
|
|
} perfmon;
|
|
|
|
struct drm_sched_entity sched_entity[V3D_MAX_QUEUES];
|
|
|
|
/* Stores the GPU stats for a specific queue for this fd. */
|
|
struct v3d_stats stats[V3D_MAX_QUEUES];
|
|
};
|
|
|
|
struct v3d_bo {
|
|
struct drm_gem_shmem_object base;
|
|
|
|
struct drm_mm_node node;
|
|
|
|
/* List entry for the BO's position in
|
|
* v3d_render_job->unref_list
|
|
*/
|
|
struct list_head unref_head;
|
|
|
|
void *vaddr;
|
|
};
|
|
|
|
static inline struct v3d_bo *
|
|
to_v3d_bo(struct drm_gem_object *bo)
|
|
{
|
|
return (struct v3d_bo *)bo;
|
|
}
|
|
|
|
struct v3d_fence {
|
|
struct dma_fence base;
|
|
struct drm_device *dev;
|
|
/* v3d seqno for signaled() test */
|
|
u64 seqno;
|
|
enum v3d_queue queue;
|
|
};
|
|
|
|
static inline struct v3d_fence *
|
|
to_v3d_fence(struct dma_fence *fence)
|
|
{
|
|
return (struct v3d_fence *)fence;
|
|
}
|
|
|
|
#define V3D_READ(offset) readl(v3d->hub_regs + offset)
|
|
#define V3D_WRITE(offset, val) writel(val, v3d->hub_regs + offset)
|
|
|
|
#define V3D_BRIDGE_READ(offset) readl(v3d->bridge_regs + offset)
|
|
#define V3D_BRIDGE_WRITE(offset, val) writel(val, v3d->bridge_regs + offset)
|
|
|
|
#define V3D_GCA_READ(offset) readl(v3d->gca_regs + offset)
|
|
#define V3D_GCA_WRITE(offset, val) writel(val, v3d->gca_regs + offset)
|
|
|
|
#define V3D_SMS_IDLE 0x0
|
|
#define V3D_SMS_ISOLATING_FOR_RESET 0xa
|
|
#define V3D_SMS_RESETTING 0xb
|
|
#define V3D_SMS_ISOLATING_FOR_POWER_OFF 0xc
|
|
#define V3D_SMS_POWER_OFF_STATE 0xd
|
|
|
|
#define V3D_SMS_READ(offset) readl(v3d->sms_regs + (offset))
|
|
#define V3D_SMS_WRITE(offset, val) writel(val, v3d->sms_regs + (offset))
|
|
|
|
#define V3D_CORE_READ(core, offset) readl(v3d->core_regs[core] + offset)
|
|
#define V3D_CORE_WRITE(core, offset, val) writel(val, v3d->core_regs[core] + offset)
|
|
|
|
struct v3d_job {
|
|
struct drm_sched_job base;
|
|
|
|
struct kref refcount;
|
|
|
|
struct v3d_dev *v3d;
|
|
|
|
/* This is the array of BOs that were looked up at the start
|
|
* of submission.
|
|
*/
|
|
struct drm_gem_object **bo;
|
|
u32 bo_count;
|
|
|
|
/* v3d fence to be signaled by IRQ handler when the job is complete. */
|
|
struct dma_fence *irq_fence;
|
|
|
|
/* scheduler fence for when the job is considered complete and
|
|
* the BO reservations can be released.
|
|
*/
|
|
struct dma_fence *done_fence;
|
|
|
|
/* Pointer to a performance monitor object if the user requested it,
|
|
* NULL otherwise.
|
|
*/
|
|
struct v3d_perfmon *perfmon;
|
|
|
|
/* File descriptor of the process that submitted the job that could be used
|
|
* for collecting stats by process of GPU usage.
|
|
*/
|
|
struct drm_file *file;
|
|
|
|
/* Callback for the freeing of the job on refcount going to 0. */
|
|
void (*free)(struct kref *ref);
|
|
};
|
|
|
|
struct v3d_bin_job {
|
|
struct v3d_job base;
|
|
|
|
/* GPU virtual addresses of the start/end of the CL job. */
|
|
u32 start, end;
|
|
|
|
u32 timedout_ctca, timedout_ctra;
|
|
|
|
/* Corresponding render job, for attaching our overflow memory. */
|
|
struct v3d_render_job *render;
|
|
|
|
/* Submitted tile memory allocation start/size, tile state. */
|
|
u32 qma, qms, qts;
|
|
};
|
|
|
|
struct v3d_render_job {
|
|
struct v3d_job base;
|
|
|
|
/* GPU virtual addresses of the start/end of the CL job. */
|
|
u32 start, end;
|
|
|
|
u32 timedout_ctca, timedout_ctra;
|
|
|
|
/* List of overflow BOs used in the job that need to be
|
|
* released once the job is complete.
|
|
*/
|
|
struct list_head unref_list;
|
|
};
|
|
|
|
struct v3d_tfu_job {
|
|
struct v3d_job base;
|
|
|
|
struct drm_v3d_submit_tfu args;
|
|
};
|
|
|
|
struct v3d_csd_job {
|
|
struct v3d_job base;
|
|
|
|
u32 timedout_batches;
|
|
|
|
struct drm_v3d_submit_csd args;
|
|
};
|
|
|
|
enum v3d_cpu_job_type {
|
|
V3D_CPU_JOB_TYPE_INDIRECT_CSD = 1,
|
|
V3D_CPU_JOB_TYPE_TIMESTAMP_QUERY,
|
|
V3D_CPU_JOB_TYPE_RESET_TIMESTAMP_QUERY,
|
|
V3D_CPU_JOB_TYPE_COPY_TIMESTAMP_QUERY,
|
|
V3D_CPU_JOB_TYPE_RESET_PERFORMANCE_QUERY,
|
|
V3D_CPU_JOB_TYPE_COPY_PERFORMANCE_QUERY,
|
|
};
|
|
|
|
struct v3d_timestamp_query {
|
|
/* Offset of this query in the timestamp BO for its value. */
|
|
u32 offset;
|
|
|
|
/* Syncobj that indicates the timestamp availability */
|
|
struct drm_syncobj *syncobj;
|
|
};
|
|
|
|
struct v3d_performance_query {
|
|
/* Performance monitor IDs for this query */
|
|
u32 *kperfmon_ids;
|
|
|
|
/* Syncobj that indicates the query availability */
|
|
struct drm_syncobj *syncobj;
|
|
};
|
|
|
|
struct v3d_indirect_csd_info {
|
|
/* Indirect CSD */
|
|
struct v3d_csd_job *job;
|
|
|
|
/* Clean cache job associated to the Indirect CSD job */
|
|
struct v3d_job *clean_job;
|
|
|
|
/* Offset within the BO where the workgroup counts are stored */
|
|
u32 offset;
|
|
|
|
/* Workgroups size */
|
|
u32 wg_size;
|
|
|
|
/* Indices of the uniforms with the workgroup dispatch counts
|
|
* in the uniform stream.
|
|
*/
|
|
u32 wg_uniform_offsets[3];
|
|
|
|
/* Indirect BO */
|
|
struct drm_gem_object *indirect;
|
|
|
|
/* Context of the Indirect CSD job */
|
|
struct ww_acquire_ctx acquire_ctx;
|
|
};
|
|
|
|
struct v3d_timestamp_query_info {
|
|
struct v3d_timestamp_query *queries;
|
|
|
|
u32 count;
|
|
};
|
|
|
|
struct v3d_performance_query_info {
|
|
struct v3d_performance_query *queries;
|
|
|
|
/* Number of performance queries */
|
|
u32 count;
|
|
|
|
/* Number of performance monitors related to that query pool */
|
|
u32 nperfmons;
|
|
|
|
/* Number of performance counters related to that query pool */
|
|
u32 ncounters;
|
|
};
|
|
|
|
struct v3d_copy_query_results_info {
|
|
/* Define if should write to buffer using 64 or 32 bits */
|
|
bool do_64bit;
|
|
|
|
/* Define if it can write to buffer even if the query is not available */
|
|
bool do_partial;
|
|
|
|
/* Define if it should write availability bit to buffer */
|
|
bool availability_bit;
|
|
|
|
/* Offset of the copy buffer in the BO */
|
|
u32 offset;
|
|
|
|
/* Stride of the copy buffer in the BO */
|
|
u32 stride;
|
|
};
|
|
|
|
struct v3d_cpu_job {
|
|
struct v3d_job base;
|
|
|
|
enum v3d_cpu_job_type job_type;
|
|
|
|
struct v3d_indirect_csd_info indirect_csd;
|
|
|
|
struct v3d_timestamp_query_info timestamp_query;
|
|
|
|
struct v3d_copy_query_results_info copy;
|
|
|
|
struct v3d_performance_query_info performance_query;
|
|
};
|
|
|
|
typedef void (*v3d_cpu_job_fn)(struct v3d_cpu_job *);
|
|
|
|
struct v3d_submit_outsync {
|
|
struct drm_syncobj *syncobj;
|
|
};
|
|
|
|
struct v3d_submit_ext {
|
|
u32 flags;
|
|
u32 wait_stage;
|
|
|
|
u32 in_sync_count;
|
|
u64 in_syncs;
|
|
|
|
u32 out_sync_count;
|
|
struct v3d_submit_outsync *out_syncs;
|
|
};
|
|
|
|
/**
|
|
* __wait_for - magic wait macro
|
|
*
|
|
* Macro to help avoid open coding check/wait/timeout patterns. Note that it's
|
|
* important that we check the condition again after having timed out, since the
|
|
* timeout could be due to preemption or similar and we've never had a chance to
|
|
* check the condition before the timeout.
|
|
*/
|
|
#define __wait_for(OP, COND, US, Wmin, Wmax) ({ \
|
|
const ktime_t end__ = ktime_add_ns(ktime_get_raw(), 1000ll * (US)); \
|
|
long wait__ = (Wmin); /* recommended min for usleep is 10 us */ \
|
|
int ret__; \
|
|
might_sleep(); \
|
|
for (;;) { \
|
|
const bool expired__ = ktime_after(ktime_get_raw(), end__); \
|
|
OP; \
|
|
/* Guarantee COND check prior to timeout */ \
|
|
barrier(); \
|
|
if (COND) { \
|
|
ret__ = 0; \
|
|
break; \
|
|
} \
|
|
if (expired__) { \
|
|
ret__ = -ETIMEDOUT; \
|
|
break; \
|
|
} \
|
|
usleep_range(wait__, wait__ * 2); \
|
|
if (wait__ < (Wmax)) \
|
|
wait__ <<= 1; \
|
|
} \
|
|
ret__; \
|
|
})
|
|
|
|
#define _wait_for(COND, US, Wmin, Wmax) __wait_for(, (COND), (US), (Wmin), \
|
|
(Wmax))
|
|
#define wait_for(COND, MS) _wait_for((COND), (MS) * 1000, 10, 1000)
|
|
|
|
static inline unsigned long nsecs_to_jiffies_timeout(const u64 n)
|
|
{
|
|
/* nsecs_to_jiffies64() does not guard against overflow */
|
|
if ((NSEC_PER_SEC % HZ) != 0 &&
|
|
div_u64(n, NSEC_PER_SEC) >= MAX_JIFFY_OFFSET / HZ)
|
|
return MAX_JIFFY_OFFSET;
|
|
|
|
return min_t(u64, MAX_JIFFY_OFFSET, nsecs_to_jiffies64(n) + 1);
|
|
}
|
|
|
|
/* v3d_bo.c */
|
|
struct drm_gem_object *v3d_create_object(struct drm_device *dev, size_t size);
|
|
void v3d_free_object(struct drm_gem_object *gem_obj);
|
|
struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv,
|
|
size_t size);
|
|
void v3d_get_bo_vaddr(struct v3d_bo *bo);
|
|
void v3d_put_bo_vaddr(struct v3d_bo *bo);
|
|
int v3d_create_bo_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_get_bo_offset_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
struct drm_gem_object *v3d_prime_import_sg_table(struct drm_device *dev,
|
|
struct dma_buf_attachment *attach,
|
|
struct sg_table *sgt);
|
|
|
|
/* v3d_debugfs.c */
|
|
void v3d_debugfs_init(struct drm_minor *minor);
|
|
|
|
/* v3d_drv.c */
|
|
void v3d_get_stats(const struct v3d_stats *stats, u64 timestamp,
|
|
u64 *active_runtime, u64 *jobs_completed);
|
|
|
|
/* v3d_fence.c */
|
|
extern const struct dma_fence_ops v3d_fence_ops;
|
|
struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum v3d_queue queue);
|
|
|
|
/* v3d_gem.c */
|
|
int v3d_gem_init(struct drm_device *dev);
|
|
void v3d_gem_destroy(struct drm_device *dev);
|
|
void v3d_reset_sms(struct v3d_dev *v3d);
|
|
void v3d_reset(struct v3d_dev *v3d);
|
|
void v3d_invalidate_caches(struct v3d_dev *v3d);
|
|
void v3d_clean_caches(struct v3d_dev *v3d);
|
|
|
|
/* v3d_gemfs.c */
|
|
extern bool super_pages;
|
|
void v3d_gemfs_init(struct v3d_dev *v3d);
|
|
void v3d_gemfs_fini(struct v3d_dev *v3d);
|
|
|
|
/* v3d_submit.c */
|
|
void v3d_job_cleanup(struct v3d_job *job);
|
|
void v3d_job_put(struct v3d_job *job);
|
|
int v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_submit_cpu_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
|
|
/* v3d_irq.c */
|
|
int v3d_irq_init(struct v3d_dev *v3d);
|
|
void v3d_irq_enable(struct v3d_dev *v3d);
|
|
void v3d_irq_disable(struct v3d_dev *v3d);
|
|
void v3d_irq_reset(struct v3d_dev *v3d);
|
|
|
|
/* v3d_mmu.c */
|
|
int v3d_mmu_flush_all(struct v3d_dev *v3d);
|
|
int v3d_mmu_set_page_table(struct v3d_dev *v3d);
|
|
void v3d_mmu_insert_ptes(struct v3d_bo *bo);
|
|
void v3d_mmu_remove_ptes(struct v3d_bo *bo);
|
|
|
|
/* v3d_sched.c */
|
|
void v3d_timestamp_query_info_free(struct v3d_timestamp_query_info *query_info,
|
|
unsigned int count);
|
|
void v3d_performance_query_info_free(struct v3d_performance_query_info *query_info,
|
|
unsigned int count);
|
|
void v3d_job_update_stats(struct v3d_job *job, enum v3d_queue queue);
|
|
int v3d_sched_init(struct v3d_dev *v3d);
|
|
void v3d_sched_fini(struct v3d_dev *v3d);
|
|
|
|
/* v3d_perfmon.c */
|
|
void v3d_perfmon_init(struct v3d_dev *v3d);
|
|
void v3d_perfmon_get(struct v3d_perfmon *perfmon);
|
|
void v3d_perfmon_put(struct v3d_perfmon *perfmon);
|
|
void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon);
|
|
void v3d_perfmon_stop(struct v3d_dev *v3d, struct v3d_perfmon *perfmon,
|
|
bool capture);
|
|
struct v3d_perfmon *v3d_perfmon_find(struct v3d_file_priv *v3d_priv, int id);
|
|
void v3d_perfmon_open_file(struct v3d_file_priv *v3d_priv);
|
|
void v3d_perfmon_close_file(struct v3d_file_priv *v3d_priv);
|
|
int v3d_perfmon_create_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_perfmon_get_values_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_perfmon_get_counter_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int v3d_perfmon_set_global_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
|
|
/* v3d_sysfs.c */
|
|
int v3d_sysfs_init(struct device *dev);
|
|
void v3d_sysfs_destroy(struct device *dev);
|