Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i915 module: update changes from lts-v6.1.12-linux-230424T063740Z #71

Merged
merged 1 commit into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,10 @@ i915-y += \
i915-y += i915_perf.o

# Protected execution platform (PXP) support
ifeq ($(call kver_ge,6,2,0),1)
i915-y += \
pxp/intel_pxp.o \
pxp/intel_pxp_tee.o \
pxp/intel_pxp_huc.o
else
i915-y += \
pxp/intel_pxp.o \
pxp/intel_pxp_tee.o
endif

i915-$(CONFIG_DRM_I915_PXP) += \
pxp/intel_pxp_cmd.o \
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/display/intel_cx0_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ static const struct intel_c20pll_state * const mtl_c20_dp_tables[] = {
* HDMI link rates with 38.4 MHz reference clock.
*/

static const struct intel_c10mpllb_state mtl_c10_hdmi_25_2 = {
static const struct intel_c10mpllb_state __maybe_unused mtl_c10_hdmi_25_2 = {
.clock = 25200,
.pll[0] = 0x4,
.pll[1] = 0,
Expand Down Expand Up @@ -2065,7 +2065,7 @@ int intel_c20pll_calc_port_clock(struct intel_encoder *encoder,
const struct intel_c20pll_state *pll_state)
{
unsigned int frac_quot = 0, frac_rem = 0, frac_den = 1;
unsigned int multiplier, tx_clk_div, refclk = 38400;
unsigned int multiplier = 0, tx_clk_div = 0, refclk = 38400;

if (pll_state->mpllb[6] & C20_MPLLB_FRACEN) {
frac_quot = pll_state->mpllb[8];
Expand Down
14 changes: 7 additions & 7 deletions drivers/gpu/drm/i915/display/intel_dpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ static void gen8_set_pte(void __iomem *addr, gen8_pte_t pte)
static void dpt_insert_page(struct i915_address_space *vm,
dma_addr_t addr,
u64 offset,
enum i915_cache_level level,
unsigned int pat_index,
u32 flags)
{
struct i915_dpt *dpt = i915_vm_to_dpt(vm);
gen8_pte_t __iomem *base = dpt->iomem;

gen8_set_pte(base + offset / I915_GTT_PAGE_SIZE,
vm->pte_encode(addr, level, flags));
vm->pte_encode(addr, pat_index, flags));
}

static void dpt_insert_entries(struct i915_address_space *vm,
struct i915_vma_resource *vma_res,
enum i915_cache_level level,
unsigned int pat_index,
u32 flags)
{
struct i915_dpt *dpt = i915_vm_to_dpt(vm);
gen8_pte_t __iomem *base = dpt->iomem;
const gen8_pte_t pte_encode = vm->pte_encode(0, level, flags);
const gen8_pte_t pte_encode = vm->pte_encode(0, pat_index, flags);
struct sgt_iter sgt_iter;
dma_addr_t addr;
int i;
Expand All @@ -81,7 +81,7 @@ static void dpt_clear_range(struct i915_address_space *vm,
static void dpt_bind_vma(struct i915_address_space *vm,
struct i915_vm_pt_stash *stash,
struct i915_vma_resource *vma_res,
enum i915_cache_level cache_level,
unsigned int pat_index,
u32 flags)
{
u32 pte_flags;
Expand All @@ -96,7 +96,7 @@ static void dpt_bind_vma(struct i915_address_space *vm,
if (vma_res->bi.lmem)
pte_flags |= PTE_LM;

vm->insert_entries(vm, vma_res, cache_level, pte_flags);
vm->insert_entries(vm, vma_res, pat_index, pte_flags);

vma_res->page_sizes_gtt = I915_GTT_PAGE_SIZE;

Expand Down Expand Up @@ -298,7 +298,7 @@ intel_dpt_create(struct intel_framebuffer *fb)
vm->vma_ops.bind_vma = dpt_bind_vma;
vm->vma_ops.unbind_vma = dpt_unbind_vma;

vm->pte_encode = gen8_ggtt_pte_encode;
vm->pte_encode = vm->gt->ggtt->vm.pte_encode;

dpt->obj = dpt_obj;

Expand Down
38 changes: 38 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ struct create_ext {
unsigned int n_placements;
unsigned int placement_mask;
unsigned long flags;
unsigned int pat_index;
};

static void repr_placements(char *buf, size_t size,
Expand Down Expand Up @@ -393,11 +394,40 @@ static int ext_set_protected(struct i915_user_extension __user *base, void *data
return 0;
}

static int ext_set_pat(struct i915_user_extension __user *base, void *data)
{
struct create_ext *ext_data = data;
struct drm_i915_private *i915 = ext_data->i915;
struct drm_i915_gem_create_ext_set_pat ext;
unsigned int max_pat_index;

BUILD_BUG_ON(sizeof(struct drm_i915_gem_create_ext_set_pat) !=
offsetofend(struct drm_i915_gem_create_ext_set_pat, rsvd));

if (copy_from_user(&ext, base, sizeof(ext)))
return -EFAULT;

max_pat_index = INTEL_INFO(i915)->max_pat_index;

if (ext.pat_index > max_pat_index) {
drm_dbg(&i915->drm, "PAT index is invalid: %u\n",
ext.pat_index);
return -EINVAL;
}

ext_data->pat_index = ext.pat_index;

return 0;
}

static const i915_user_extension_fn create_extensions[] = {
[I915_GEM_CREATE_EXT_MEMORY_REGIONS] = ext_set_placements,
[I915_GEM_CREATE_EXT_PROTECTED_CONTENT] = ext_set_protected,
[I915_GEM_CREATE_EXT_SET_PAT] = ext_set_pat,
};

#define PAT_INDEX_NOT_SET 0xffff

/**
* Creates a new mm object and returns a handle to it.
* @dev: drm device pointer
Expand All @@ -417,6 +447,8 @@ i915_gem_create_ext_ioctl(struct drm_device *dev, void *data,
if (args->flags & ~I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS)
return -EINVAL;

ext_data.pat_index = PAT_INDEX_NOT_SET;

ret = i915_user_extensions(u64_to_user_ptr(args->extensions),
create_extensions,
ARRAY_SIZE(create_extensions),
Expand Down Expand Up @@ -453,5 +485,11 @@ i915_gem_create_ext_ioctl(struct drm_device *dev, void *data,
if (IS_ERR(obj))
return PTR_ERR(obj);

if (ext_data.pat_index != PAT_INDEX_NOT_SET) {
i915_gem_object_set_pat_index(obj, ext_data.pat_index);
/* Mark pat_index is set by UMD */
obj->cache_level = I915_CACHE_INVAL;
}

return i915_gem_publish(obj, file, &args->size, &args->handle);
}
27 changes: 9 additions & 18 deletions drivers/gpu/drm/i915/gem/i915_gem_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static bool gpu_write_needs_clflush(struct drm_i915_gem_object *obj)
if (IS_DGFX(i915))
return false;

return !(obj->cache_level == I915_CACHE_NONE ||
obj->cache_level == I915_CACHE_WT);
return !(i915_gem_object_has_cache_level(obj, I915_CACHE_NONE) ||
i915_gem_object_has_cache_level(obj, I915_CACHE_WT));
}

bool i915_gem_cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
Expand Down Expand Up @@ -265,7 +265,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
{
int ret;

if (obj->cache_level == cache_level)
if (i915_gem_object_has_cache_level(obj, cache_level))
return 0;

ret = i915_gem_object_wait(obj,
Expand All @@ -276,10 +276,8 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
return ret;

/* Always invalidate stale cachelines */
if (obj->cache_level != cache_level) {
i915_gem_object_set_cache_coherency(obj, cache_level);
obj->cache_dirty = true;
}
i915_gem_object_set_cache_coherency(obj, cache_level);
obj->cache_dirty = true;

/* The cache-level will be applied when each vma is rebound. */
return i915_gem_object_unbind(obj,
Expand All @@ -304,20 +302,13 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
goto out;
}

switch (obj->cache_level) {
case I915_CACHE_LLC:
case I915_CACHE_L3_LLC:
if (i915_gem_object_has_cache_level(obj, I915_CACHE_LLC) ||
i915_gem_object_has_cache_level(obj, I915_CACHE_L3_LLC))
args->caching = I915_CACHING_CACHED;
break;

case I915_CACHE_WT:
else if (i915_gem_object_has_cache_level(obj, I915_CACHE_WT))
args->caching = I915_CACHING_DISPLAY;
break;

default:
else
args->caching = I915_CACHING_NONE;
break;
}
out:
rcu_read_unlock();
return err;
Expand Down
10 changes: 6 additions & 4 deletions drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ static inline int use_cpu_reloc(const struct reloc_cache *cache,

return (cache->has_llc ||
obj->cache_dirty ||
obj->cache_level != I915_CACHE_NONE);
!i915_gem_object_has_cache_level(obj, I915_CACHE_NONE));
}

static int eb_reserve_vma(struct i915_execbuffer *eb,
Expand Down Expand Up @@ -1325,8 +1325,10 @@ static void *reloc_iomap(struct i915_vma *batch,
offset = cache->node.start;
if (drm_mm_node_allocated(&cache->node)) {
ggtt->vm.insert_page(&ggtt->vm,
i915_gem_object_get_dma_address(obj, page),
offset, I915_CACHE_NONE, 0);
i915_gem_object_get_dma_address(obj, page),
offset,
i915_gem_get_pat_index(ggtt->vm.i915, I915_CACHE_NONE),
0);
} else {
offset += page << PAGE_SHIFT;
}
Expand Down Expand Up @@ -1466,7 +1468,7 @@ eb_relocate_entry(struct i915_execbuffer *eb,
reloc_cache_unmap(&eb->reloc_cache);
mutex_lock(&vma->vm->mutex);
err = i915_vma_bind(target->vma,
target->vma->obj->cache_level,
target->vma->obj->pat_index,
PIN_GLOBAL, NULL, NULL);
mutex_unlock(&vma->vm->mutex);
reloc_cache_remap(&eb->reloc_cache, ev->vma->obj);
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/i915/gem/i915_gem_mman.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf)
}

/* Access to snoopable pages through the GTT is incoherent. */
if (obj->cache_level != I915_CACHE_NONE && !HAS_LLC(i915)) {
if (!(i915_gem_object_has_cache_level(obj, I915_CACHE_NONE) ||
HAS_LLC(i915))) {
ret = -EFAULT;
goto err_unpin;
}
Expand Down
67 changes: 66 additions & 1 deletion drivers/gpu/drm/i915/gem/i915_gem_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,34 @@ static struct kmem_cache *slab_objects;

static const struct drm_gem_object_funcs i915_gem_object_funcs;

unsigned int i915_gem_get_pat_index(struct drm_i915_private *i915,
enum i915_cache_level level)
{
if (drm_WARN_ON(&i915->drm, level >= I915_MAX_CACHE_LEVEL))
return 0;

return INTEL_INFO(i915)->cachelevel_to_pat[level];
}

bool i915_gem_object_has_cache_level(const struct drm_i915_gem_object *obj,
enum i915_cache_level lvl)
{
/*
* cache_level == I915_CACHE_INVAL indicates the UMD's have set the
* caching policy through pat_index, in which case the KMD should
* leave the coherency to be managed by user space, simply return
* true here.
*/
if (obj->cache_level == I915_CACHE_INVAL)
return true;

/*
* Otherwise the pat_index should have been converted from cache_level
* so that the following comparison is valid.
*/
return obj->pat_index == i915_gem_get_pat_index(obj_to_i915(obj), lvl);
}

struct drm_i915_gem_object *i915_gem_object_alloc(void)
{
struct drm_i915_gem_object *obj;
Expand Down Expand Up @@ -124,7 +152,7 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
{
struct drm_i915_private *i915 = to_i915(obj->base.dev);

obj->cache_level = cache_level;
obj->pat_index = i915_gem_get_pat_index(i915, cache_level);

if (cache_level != I915_CACHE_NONE)
obj->cache_coherent = (I915_BO_CACHE_COHERENT_FOR_READ |
Expand All @@ -139,6 +167,37 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
!IS_DGFX(i915);
}

/**
* i915_gem_object_set_pat_index - set PAT index to be used in PTE encode
* @obj: #drm_i915_gem_object
* @pat_index: PAT index
*
* This is a clone of i915_gem_object_set_cache_coherency taking pat index
* instead of cache_level as its second argument.
*/
void i915_gem_object_set_pat_index(struct drm_i915_gem_object *obj,
unsigned int pat_index)
{
struct drm_i915_private *i915 = to_i915(obj->base.dev);

if (obj->pat_index == pat_index)
return;

obj->pat_index = pat_index;

if (pat_index != i915_gem_get_pat_index(i915, I915_CACHE_NONE))
obj->cache_coherent = (I915_BO_CACHE_COHERENT_FOR_READ |
I915_BO_CACHE_COHERENT_FOR_WRITE);
else if (HAS_LLC(i915))
obj->cache_coherent = I915_BO_CACHE_COHERENT_FOR_READ;
else
obj->cache_coherent = 0;

obj->cache_dirty =
!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE) &&
!IS_DGFX(i915);
}

bool i915_gem_object_can_bypass_llc(struct drm_i915_gem_object *obj)
{
struct drm_i915_private *i915 = to_i915(obj->base.dev);
Expand All @@ -150,6 +209,12 @@ bool i915_gem_object_can_bypass_llc(struct drm_i915_gem_object *obj)
if (!(obj->flags & I915_BO_ALLOC_USER))
return false;

/*
* Always flush cache for UMD objects at creation time.
*/
if (obj->cache_level == I915_CACHE_INVAL)
return true;

/*
* EHL and JSL add the 'Bypass LLC' MOCS entry, which should make it
* possible for userspace to bypass the GTT caching bits set by the
Expand Down
8 changes: 8 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

enum intel_region_id;

#define obj_to_i915(obj__) to_i915((obj__)->base.dev)

static inline bool i915_gem_object_size_2big(u64 size)
{
struct drm_i915_gem_object *obj;
Expand All @@ -30,6 +32,10 @@ static inline bool i915_gem_object_size_2big(u64 size)
return false;
}

unsigned int i915_gem_get_pat_index(struct drm_i915_private *i915,
enum i915_cache_level level);
bool i915_gem_object_has_cache_level(const struct drm_i915_gem_object *obj,
enum i915_cache_level lvl);
void i915_gem_init__objects(struct drm_i915_private *i915);

void i915_objects_module_exit(void);
Expand Down Expand Up @@ -760,6 +766,8 @@ bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object *obj);

void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
unsigned int cache_level);
void i915_gem_object_set_pat_index(struct drm_i915_gem_object *obj,
unsigned int pat_index);
bool i915_gem_object_can_bypass_llc(struct drm_i915_gem_object *obj);
void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj);
void i915_gem_object_flush_if_display_locked(struct drm_i915_gem_object *obj);
Expand Down
Loading