Files
linux-legacy-genesi/drivers/mxc/amd-gpu/kgsl_ringbuffer.h
Matt Sealey 76e264f5ed amd-gpu: huge commit with many, many changes
Just to save work and get it up online. Current status;

GL not working as per usual

VG works - but closing Z160 device locks the driver (seems to be that
device_idle is called after the device is closed and there may be a
driver lock contention going on here).

imxng graphics driver works first run (same as above) but there are
some strange graphical glitches on smaller blits and rectangle fills,
which may be down to some kind of cache coherency problem.

Real (platform device) MMU enable causes the whole thing to explode,
since none of this got updated properly.

Tasks done:
* remove per-process support
* clean up use of device_id -> device since passing the id is a mess
  for some reason 3D device isn't inited properly and some parts of
  the driver call 3D device functions (notably on closing everything)
  possibly because of some off-by-ones
* more global driver locking per qualcomm and to allow below fix
* clean up sharedmem and other APIs which used such semantics e.g.
    kgsl_sharedmem_read -> lock, call kgsl_sharedmem_read0, unlock
  to just use kgsl_sharedmem_read with manual locks before the call
  where required, cleaning up the API a lot
* ditched the requirement for a device argument to sharedmem_alloc
  since it never allocated from a per-device pool anyway. This is
  a weird hack since the MMU setup needs a real device to set up
  on.. Qualcomm's has a much better system and that will be in place
  soon
* fixed the cmdstream_issueibcmds wrapper crap
* added kgsl_ringbuffer_issueibcmds to CMDSTREAM_ISSUEIBCMDS ioctl
  again (no real effect)
* put kgsl_device_active in kgsl_g12_issueibcmds rather than calling
  it manually before executing the function (ensures the autogating
  is turned off before telling the Z160 to run a stream) from ioctl
* lots of ioctl debugging code (mostly commented out)
* function renames everywhere
* locks around suspend/resume
* removed a lot of the finegrained locking stuff as qualcomm doesn't
  use it. That said, cmdwindow needs some locking (qcom uses a
  spinlock) - will be added later
* LOTS of code cleanups/lint/checkpatch fixing
* removed interrupt handler abstraction
* Z160 idle timer update
* move more HAL stuff into the right places to remove the HAL more
* MMU handling cleanups (not complete, lots of it is disabled)
* NOTE: must re-add runpending to sharedmem_alloc? May not be required
  when moving to new sharedmem API
* NOTE: check 3D interrupt enables
2012-12-07 09:44:13 -06:00

173 lines
6.4 KiB
C

/* Copyright (c) 2002,2007-2010, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Code Aurora nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __GSL_RINGBUFFER_H
#define __GSL_RINGBUFFER_H
#include "kgsl_types.h"
// CONFIGURATION ITEMS
//#define GSL_STATS_RINGBUFFER
#define GSL_RB_USE_MEM_RPTR
#define GSL_RB_USE_MEM_TIMESTAMP
#define GSL_RB_TIMESTAMP_INTERUPT // not qualcomm!
/* #define GSL_RB_USE_WPTR_POLLING */
/* #define GSL_DEVICE_SHADOW_MEMSTORE_TO_USER */
/* ringbuffer sizes log2quadword */
#define GSL_RB_SIZE_8 0
#define GSL_RB_SIZE_16 1
#define GSL_RB_SIZE_32 2
#define GSL_RB_SIZE_64 3
#define GSL_RB_SIZE_128 4
#define GSL_RB_SIZE_256 5
#define GSL_RB_SIZE_512 6
#define GSL_RB_SIZE_1K 7
#define GSL_RB_SIZE_2K 8
#define GSL_RB_SIZE_4K 9
#define GSL_RB_SIZE_8K 10
#define GSL_RB_SIZE_16K 11
#define GSL_RB_SIZE_32K 12
#define GSL_RB_SIZE_64K 13
#define GSL_RB_SIZE_128K 14
#define GSL_RB_SIZE_256K 15
#define GSL_RB_SIZE_512K 16
#define GSL_RB_SIZE_1M 17
#define GSL_RB_SIZE_2M 18
#define GSL_RB_SIZE_4M 19
static const unsigned int kgsl_cfg_rb_sizelog2quadwords = GSL_RB_SIZE_32K;
static const unsigned int kgsl_cfg_rb_blksizequadwords = GSL_RB_SIZE_16;
/* qcom: forward decls for device, device_private, drawctxt, ringbuffer */
/* CP timestamp register */
#define REG_CP_TIMESTAMP REG_SCRATCH_REG0
#define GSL_RB_MEMPTRS_SCRATCH_COUNT 8
struct kgsl_rbmemptrs {
volatile int rptr;
volatile int wptr_poll;
};
#define GSL_RB_MEMPTRS_RPTR_OFFSET \
(offsetof(struct kgsl_rbmemptrs, rptr))
#define GSL_RB_MEMPTRS_WPTRPOLL_OFFSET \
(offsetof(struct kgsl_rbmemptrs, wptr_poll))
struct kgsl_ringbuffer {
struct kgsl_device *device;
unsigned int flags;
struct kgsl_memdesc buffer_desc; // allocated memory descriptor
struct kgsl_memdesc memptrs_desc;
struct kgsl_rbmemptrs *memptrs;
/* ring buffer size */
unsigned int sizedwords;
unsigned int blksizequadwords;
unsigned int wptr; /* write pointer offset in dwords from baseaddr */
unsigned int rptr; /* read pointer offset in dwords from baseaddr */
unsigned int timestamp;
/* qcom: queue of memfrees pending timestamp elapse (struct list_head_memqueue) */
/* old qcom: watchdog, stats */
};
/* dword base address of the GFX decode space */
#define GSL_HAL_SUBBLOCK_OFFSET(reg) ((unsigned int)((reg) - (0x2000)))
#define GSL_RB_WRITE(ring, data) \
do { \
mb(); \
writel(data, ring); \
ring++; \
} while (0)
#ifdef GSL_DEVICE_SHADOW_MEMSTORE_TO_USER
#warning GSL_DEVICE_SHADOW_MEMSTORE_TO_USER
#define GSL_RB_USE_MEM_TIMESTAMP
#endif /* GSL_DEVICE_SHADOW_MEMSTORE_TO_USER */
#ifdef GSL_RB_USE_MEM_TIMESTAMP
/* enable timestamp (...scratch0) memory shadowing */
#warning GSL_RB_USE_MEM_TIMESTAMP
#define GSL_RB_MEMPTRS_SCRATCH_MASK 0x1
#define GSL_RB_INIT_TIMESTAMP(rb)
#else
#define GSL_RB_MEMPTRS_SCRATCH_MASK 0x0
#define GSL_RB_INIT_TIMESTAMP(rb) \
kgsl_yamato_regwrite((rb)->device, REG_CP_TIMESTAMP, 0);
#endif /* GSL_RB_USE_MEMTIMESTAMP */
#ifdef GSL_RB_USE_MEM_RPTR
#warning GSL_RB_USE_MEM_RPTR
#define GSL_RB_CNTL_NO_UPDATE 0x0 /* enable */
#define GSL_RB_GET_READPTR(rb, data) \
do { \
*(data) = (rb)->memptrs->rptr; \
} while (0)
#else
#define GSL_RB_CNTL_NO_UPDATE 0x1 /* disable */
#define GSL_RB_GET_READPTR(rb, data) \
do { \
kgsl_yamato_regread((rb)->device, REG_CP_RB_RPTR,(data)); \
} while (0)
#endif /* GSL_RB_USE_MEMRPTR */
#ifdef GSL_RB_USE_WPTR_POLLING
#warning GSL_RB_USE_WPTR_POLLING
#define GSL_RB_CNTL_POLL_EN 0x1 /* enable */
#define GSL_RB_UPDATE_WPTR_POLLING(rb) \
do { (rb)->memptrs->wptr_poll = (rb)->wptr; } while (0)
#else
#define GSL_RB_CNTL_POLL_EN 0x0 /* disable */
#define GSL_RB_UPDATE_WPTR_POLLING(rb)
#endif /* GSL_RB_USE_WPTR_POLLING */
/* qcom: fwd decl kgsl_mem_entry */
int kgsl_ringbuffer_init(struct kgsl_device *device);
int kgsl_ringbuffer_close(struct kgsl_ringbuffer *rb);
int kgsl_ringbuffer_start(struct kgsl_ringbuffer *rb);
int kgsl_ringbuffer_stop(struct kgsl_ringbuffer *rb);
unsigned int kgsl_ringbuffer_issuecmds(struct kgsl_device *device, unsigned int flags, unsigned int *cmdaddr, int sizedwords);
int kgsl_ringbuffer_issueibcmds(struct kgsl_device *device, int drawctxt_index, uint32_t ibaddr, int sizedwords, unsigned int *timestamp, unsigned int flags);
int kgsl_ringbuffer_bist(struct kgsl_ringbuffer *rb);
// qcom: missing int kgsl_ringbuffer_gettimestampshadow(struct kgsl_device *device, unsigned int *sopaddr, unsigned int *eopaddr);
// qcom: missing void kgsl_cp_intrcallback(struct kgsl_device *device);
#endif // __GSL_RINGBUFFER_H