Update KGSL code to msm-5.10 commit f3801b189e25 (Merge "msm: kgsl: Correct a6xx CP init sequence"). This includes the following changes from msm-5.10: 4aabff3db0cf (msm: kgsl: Add support to query process memory usage) dcf93c3a2f0b (msm: kgsl: Vote ddr perf mode for better performance) dc70d7f2961e (msm: kgsl: Enable preemption for gen7 GPU) 211d943edc87 (msm: kgsl: Provide a mechanism to unbind a range in VBO) 45d7e571a332 (msm: kgsl: Correctly validate devfreq_add_device return value) a07afc4e1477 (msm: kgsl: Reclaim gpu pages asynchronously) 8b5de66d4f1d (msm: kgsl: Fix uninitialized variable use in kgsl_iommu_print_fault()) 0bd2f8ba6a8f (msm: kgsl: Use kmalloc() for HFI message storage) 79f18623e7f1 (msm: kgsl: Make sure BR doesn't race ahead of BV) 48fc67d2bcfb (msm: kgsl: Get rid of per ringbuffer scratch memory) 96f7537ccfcd (msm: kgsl: Remove redundant SET_PSEUDO_REGISTER packets) ca1cbeedfcd6 (msm: kgsl: Fix return value due to devfreq_add_device() failure) 2092f3df2fae (msm: kgsl: Add enable_signaling for timeline fence) 6f24e5a5112e (msm: kgsl: Remove unneeded NULL check when submitting commands) 9d13d7a5ca6d (msm: kgsl: Pre-allocate page pool tracking structures) 7e5a0845ad64 (msm: kgsl: Add Gen7 support for RDPM frequency register writes) 682d0ea32d62 (msm: kgsl: Add RDPM update for GMU frequency changes) 2eddfeae4850 (msm: kgsl: Add support for the new bit in RESET_CONTEXT_STATE packet) 1141005a4787 (msm: kgsl: Add support for A662 GPU) fc04d956e44a (msm: kgsl: Fix gmu power counter reg address) 286d5d09faf1 (msm: kgsl: Remove invalid kgsl_process_private_put) 4b5e16dbec0d (msm: kgsl: Update the list of protected registers for A730) 3a107bfc062a (msm: kgsl: Bail out of allocation loops if a SIG_KILL is pending) ca22fde3705d (msm: kgsl: Fix out of bound write in adreno_profile_submit_time) 73d27010f02f (msm: kgsl: Avoid parsing IBs during atomic snapshot) 684032d39451 (msm: kgsl: Correct VMID flag for secure buffer validation) 8548ed02e179 (msm: kgsl: Expose memtype stats through sysfs) 52757e33639a (msm: kgsl: Enable Preemption on A662 GPU) a8edbf590967 (msm: kgsl: Add support for new GMU uncached VA range) ff25ecb13ad5 (msm: kgsl: Remove process debugfs and kobject without mutex) 397f7d63607e (msm: kgsl: Fix clockgating values for various blocks) 06f837b9da4f (msm: kgsl: Allow concurrent requests for oob_perfcntr) 73a66962fe20 (msm: kgsl: Make the Adreno trace instance enabled through Kconfig) 6d65fed34558 (msm: kgsl: Update range checking when building voltage tables) 698d612ba43d (msm: kgsl: Verify secure access before importing buffers) 1a278333d0c7 (msm: kgsl: Fix syncsource spinlock recursion) 82c89093b63b (msm: kgsl: Fix HWSCHED_MAX_DISPATCH_NUMIBS) e6d7e1d4bdc3 (msm: kgsl: Set max ACD levels to match max power levels) eb56597e5392 (msm: kgsl: Ensure global entry free stays in bounds) 8a8fbdf97a7a (msm: kgsl: Ensure local variables are set before use) 402bb87906b3 (msm: kgsl: Take snapshot if GPU isn't idle before slumber) 6341d395821b (msm: kgsl: Fix syncpoint timeout log for timeline fences) 0058b5eb2760 (msm: kgsl: Add inflight commands to tracepoint) 127ac415117e (msm: kgsl: Fix NULL pointer dereference) 4433948157f8 (msm: kgsl: Do not process HFI queues in F2H daemon during init sequence) 6a298b62c2d7 (msm: kgsl: Increase wait during kgsl_open) e5fd445b298e (msm: kgsl: Update register protection config) eff8f6e07da7 (msm: kgsl: Set min_pwrlevel based on configuration) e13459b66d4a (msm: kgsl: Log unprotected write address) c19ed67ffbcf (msm: kgsl: Free up iommu page tables on process close) d221f9dd6c44 (msm: kgsl: Update the IFPC power up reglist) 697143a7d17a (msm: kgsl: Update GPUCC Offsets for A662) 180c1d5e124a (msm: kgsl: Add support for C501 GPU) f583f456d0a2 (msm: kgsl: Correct a6xx CP init sequence) dde4355ea92d (msm: kgsl: Add GBIF L2 CGC control with A6x CGC) Change-Id: Ib679fb0b2cb47b79e7caed531de0c0aa7ef0558d Signed-off-by: Lynus Vaz <quic_lvaz@quicinc.com>
226 lines
7.7 KiB
C
226 lines
7.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2002,2007-2021, The Linux Foundation. All rights reserved.
|
|
*/
|
|
#ifndef __ADRENO_RINGBUFFER_H
|
|
#define __ADRENO_RINGBUFFER_H
|
|
|
|
/* Given a ringbuffer, return the adreno device that owns it */
|
|
|
|
#define _RB_OFFSET(_id) (offsetof(struct adreno_device, ringbuffers) + \
|
|
((_id) * sizeof(struct adreno_ringbuffer)))
|
|
|
|
#define ADRENO_RB_DEVICE(_rb) \
|
|
((struct adreno_device *) (((void *) (_rb)) - _RB_OFFSET((_rb)->id)))
|
|
|
|
/* Adreno ringbuffer size in bytes */
|
|
#define KGSL_RB_SIZE (32 * 1024)
|
|
|
|
/*
|
|
* A handy macro to convert the RB size to dwords since most ringbuffer
|
|
* operations happen in dword increments
|
|
*/
|
|
#define KGSL_RB_DWORDS (KGSL_RB_SIZE >> 2)
|
|
|
|
/* Specifies that the command should be run in protected mode */
|
|
#define F_NOTPROTECTED BIT(0)
|
|
/* Indicates that the CP should wait for idle after executing the command */
|
|
#define F_WFI BIT(1)
|
|
/* Indicates that the poweron fixup should be executed before the command */
|
|
#define F_PWRON_FIXUP BIT(2)
|
|
/* Indicates that the submission should be secure */
|
|
#define F_SECURE BIT(3)
|
|
/* Indicates that the IBs in the submission should be skipped */
|
|
#define F_SKIP BIT(4)
|
|
/* Indicates that user always on timer profiling is enabled */
|
|
#define F_USER_PROFILE BIT(5)
|
|
/* Indicates that kernel always on timer profiling is enabled */
|
|
#define F_KERNEL_PROFILE BIT(6)
|
|
/* Indicates that the submission has a preamble */
|
|
#define F_PREAMBLE BIT(7)
|
|
|
|
#define IS_NOTPROTECTED(flags) ((flags) & F_NOTPROTECTED)
|
|
#define IS_WFI(flags) ((flags) & F_WFI)
|
|
#define IS_PWRON_FIXUP(flags) ((flags) & F_PWRON_FIXUP)
|
|
#define IS_SECURE(flags) ((flags) & F_SECURE)
|
|
#define IS_SKIP(flags) ((flags) & F_SKIP)
|
|
#define IS_USER_PROFILE(flags) ((flags) & F_USER_PROFILE)
|
|
#define IS_KERNEL_PROFILE(flags) ((flags) & F_KERNEL_PROFILE)
|
|
#define IS_PREAMBLE(flags) ((flags) & F_PREAMBLE)
|
|
|
|
struct kgsl_device;
|
|
struct kgsl_device_private;
|
|
|
|
/**
|
|
* struct adreno_submit_time - utility structure to store the wall clock / GPU
|
|
* ticks at command submit time
|
|
* @ticks: GPU ticks at submit time (from the 19.2Mhz timer)
|
|
* @ktime: local clock time (in nanoseconds)
|
|
* @utime: Wall clock time
|
|
* @drawobj: the object that we want to profile
|
|
*/
|
|
struct adreno_submit_time {
|
|
uint64_t ticks;
|
|
u64 ktime;
|
|
struct timespec64 utime;
|
|
struct kgsl_drawobj *drawobj;
|
|
};
|
|
|
|
/**
|
|
* This is to keep track whether the SET_PSEUDO_REGISTER packet needs to be submitted
|
|
* or not
|
|
*/
|
|
#define ADRENO_RB_SET_PSEUDO_DONE 0
|
|
|
|
/**
|
|
* struct adreno_ringbuffer - Definition for an adreno ringbuffer object
|
|
* @flags: Internal control flags for the ringbuffer
|
|
* @buffer_desc: Pointer to the ringbuffer memory descriptor
|
|
* @_wptr: The next value of wptr to be written to the hardware on submit
|
|
* @wptr: Local copy of the wptr offset last written to hardware
|
|
* @last_wptr: offset of the last wptr that was written to CFF
|
|
* @rb_ctx: The context that represents a ringbuffer
|
|
* @id: Priority level of the ringbuffer, also used as an ID
|
|
* @fault_detect_ts: The last retired global timestamp read during fault detect
|
|
* @timestamp: The RB's global timestamp
|
|
* @events: A kgsl_event_group for this context - contains the list of GPU
|
|
* events
|
|
* @drawctxt_active: The last pagetable that this ringbuffer is set to
|
|
* @preemption_desc: The memory descriptor containing
|
|
* preemption info written/read by CP
|
|
* @secure_preemption_desc: The memory descriptor containing
|
|
* preemption info written/read by CP for secure contexts
|
|
* @perfcounter_save_restore_desc: Used by CP to save/restore the perfcounter
|
|
* values across preemption
|
|
* and the commands to switch pagetable on the RB
|
|
* @dispatch_q: The dispatcher side queue for this ringbuffer
|
|
* @ts_expire_waitq: Wait queue to wait for rb timestamp to expire
|
|
* @ts_expire_waitq: Wait q to wait for rb timestamp to expire
|
|
* @wptr_preempt_end: Used during preemption to check that preemption occurred
|
|
* at the right rptr
|
|
* @gpr11: The gpr11 value of this RB
|
|
* @preempted_midway: Indicates that the RB was preempted before rptr = wptr
|
|
* @preempt_lock: Lock to protect the wptr pointer while it is being updated
|
|
* @skip_inline_wptr: Used during preemption to make sure wptr is updated in
|
|
* hardware
|
|
*/
|
|
struct adreno_ringbuffer {
|
|
unsigned long flags;
|
|
struct kgsl_memdesc *buffer_desc;
|
|
unsigned int _wptr;
|
|
unsigned int wptr;
|
|
unsigned int last_wptr;
|
|
int id;
|
|
unsigned int fault_detect_ts;
|
|
unsigned int timestamp;
|
|
struct kgsl_event_group events;
|
|
struct adreno_context *drawctxt_active;
|
|
struct kgsl_memdesc *preemption_desc;
|
|
struct kgsl_memdesc *secure_preemption_desc;
|
|
struct kgsl_memdesc *perfcounter_save_restore_desc;
|
|
struct adreno_dispatcher_drawqueue dispatch_q;
|
|
wait_queue_head_t ts_expire_waitq;
|
|
unsigned int wptr_preempt_end;
|
|
unsigned int gpr11;
|
|
int preempted_midway;
|
|
spinlock_t preempt_lock;
|
|
bool skip_inline_wptr;
|
|
/**
|
|
* @profile_desc: global memory to construct IB1s to do user side
|
|
* profiling
|
|
*/
|
|
struct kgsl_memdesc *profile_desc;
|
|
/**
|
|
* @profile_index: Pointer to the next "slot" in profile_desc for a user
|
|
* profiling IB1. This allows for PAGE_SIZE / 16 = 256 simultaneous
|
|
* commands per ringbuffer with user profiling enabled
|
|
* enough.
|
|
*/
|
|
u32 profile_index;
|
|
};
|
|
|
|
/* Returns the current ringbuffer */
|
|
#define ADRENO_CURRENT_RINGBUFFER(a) ((a)->cur_rb)
|
|
|
|
int adreno_ringbuffer_issueibcmds(struct kgsl_device_private *dev_priv,
|
|
struct kgsl_context *context,
|
|
struct kgsl_drawobj *drawobj,
|
|
uint32_t *timestamp);
|
|
|
|
/**
|
|
* adreno_ringbuffer_setup - Do generic set up on a ringbuffer
|
|
* @adreno_dev: Pointer to an Adreno GPU handle
|
|
* @rb: Pointer to the ringbuffer struct to set up
|
|
* @id: Index of the ringbuffer
|
|
*
|
|
* Set up generic memory and other bits of a ringbuffer.
|
|
* Return: 0 on success or negative on error.
|
|
*/
|
|
int adreno_ringbuffer_setup(struct adreno_device *adreno_dev,
|
|
struct adreno_ringbuffer *rb, int id);
|
|
|
|
int adreno_ringbuffer_submitcmd(struct adreno_device *adreno_dev,
|
|
struct kgsl_drawobj_cmd *cmdobj,
|
|
struct adreno_submit_time *time);
|
|
|
|
|
|
void adreno_ringbuffer_stop(struct adreno_device *adreno_dev);
|
|
|
|
void adreno_ringbuffer_submit(struct adreno_ringbuffer *rb,
|
|
struct adreno_submit_time *time);
|
|
|
|
void kgsl_cp_intrcallback(struct kgsl_device *device);
|
|
|
|
unsigned int *adreno_ringbuffer_allocspace(struct adreno_ringbuffer *rb,
|
|
unsigned int numcmds);
|
|
|
|
void adreno_ringbuffer_read_pfp_ucode(struct kgsl_device *device);
|
|
|
|
void adreno_ringbuffer_read_pm4_ucode(struct kgsl_device *device);
|
|
|
|
int adreno_ringbuffer_waittimestamp(struct adreno_ringbuffer *rb,
|
|
unsigned int timestamp,
|
|
unsigned int msecs);
|
|
|
|
int adreno_rb_readtimestamp(struct adreno_device *adreno_dev,
|
|
void *priv, enum kgsl_timestamp_type type,
|
|
unsigned int *timestamp);
|
|
|
|
static inline int adreno_ringbuffer_count(struct adreno_ringbuffer *rb,
|
|
unsigned int rptr)
|
|
{
|
|
if (rb->wptr >= rptr)
|
|
return rb->wptr - rptr;
|
|
return rb->wptr + KGSL_RB_DWORDS - rptr;
|
|
}
|
|
|
|
/* Increment a value by 4 bytes with wrap-around based on size */
|
|
static inline unsigned int adreno_ringbuffer_inc_wrapped(unsigned int val,
|
|
unsigned int size)
|
|
{
|
|
return (val + sizeof(unsigned int)) % size;
|
|
}
|
|
|
|
/* Decrement a value by 4 bytes with wrap-around based on size */
|
|
static inline unsigned int adreno_ringbuffer_dec_wrapped(unsigned int val,
|
|
unsigned int size)
|
|
{
|
|
return (val + size - sizeof(unsigned int)) % size;
|
|
}
|
|
|
|
/**
|
|
* adreno_ringbuffer_set_constraint - Set a system constraint before submission
|
|
* @device: A KGSL GPU device handle
|
|
* @drawobj: Pointer to the drawobj being sbumitted
|
|
*
|
|
* Check the drawobj to see if a constraint is applied and apply it.
|
|
*/
|
|
void adreno_ringbuffer_set_constraint(struct kgsl_device *device,
|
|
struct kgsl_drawobj *drawobj);
|
|
|
|
void adreno_get_submit_time(struct adreno_device *adreno_dev,
|
|
struct adreno_ringbuffer *rb,
|
|
struct adreno_submit_time *time);
|
|
|
|
#endif /* __ADRENO_RINGBUFFER_H */
|