^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /**************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2007-2008, Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) **************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef _PSB_GTT_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _PSB_GTT_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <drm/drm_gem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /* This wants cleaning up with respect to the psb_dev and un-needed stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct psb_gtt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) uint32_t gatt_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) uint32_t mmu_gatt_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) uint32_t gtt_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) uint32_t gtt_phys_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) unsigned gtt_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) unsigned gatt_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) unsigned long stolen_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned long vram_stolen_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct rw_semaphore sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* Exported functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extern int psb_gtt_init(struct drm_device *dev, int resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) extern void psb_gtt_takedown(struct drm_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* Each gtt_range describes an allocation in the GTT area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct gtt_range {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct resource resource; /* Resource for our allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u32 offset; /* GTT offset of our object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct drm_gem_object gem; /* GEM high level stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int in_gart; /* Currently in the GART (ref ct) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) bool stolen; /* Backed from stolen RAM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) bool mmapping; /* Is mmappable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct page **pages; /* Backing pages if present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int npage; /* Number of backing pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int roll; /* Roll applied to the GTT entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define to_gtt_range(x) container_of(x, struct gtt_range, gem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) const char *name, int backed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) u32 align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern void psb_gtt_kref_put(struct gtt_range *gt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) extern int psb_gtt_pin(struct gtt_range *gt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern void psb_gtt_unpin(struct gtt_range *gt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) extern void psb_gtt_roll(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct gtt_range *gt, int roll);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) extern int psb_gtt_restore(struct drm_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #endif