Commit fcd1b2b9 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'drm-fixes-2022-07-15' of git://anongit.freedesktop.org/drm/drm

Pull drm fixes from Dave Airlie:
 "This is the regular fixes pull for this week. This has a bunch of
  amdgpu fixes, major one reverts the buddy allocator until it can be
  tested more, otherwise just small ones, then i915 has a bunch of
  fixes.

  The outstanding firmware regressions reported by phoronix will
  hopefully be dealt with ASAP.

  amdgpu:
   - revert buddy allocator support for now
   - DP MST blank screen fix for specific platforms
   - MEC firmware check fix for GC 10.3.7
   - Deep color fix for DCE
   - Fix possible divide by 0
   - Coverage blend mode fix
   - Fix cursor only commit timestamps

  i915:
   - Selftest fix
   - TTM fix sg_table construction
   - Error return fixes
   - Fix a performance regression related to waitboost
   - Fix GT resets"

* tag 'drm-fixes-2022-07-15' of git://anongit.freedesktop.org/drm/drm:
  drm/amd/display: Ensure valid event timestamp for cursor-only commits
  drm/amd/display: correct check of coverage blend mode
  drm/amd/pm: Prevent divide by zero
  drm/amd/display: Only use depth 36 bpp linebuffers on DCN display engines.
  drm/amdkfd: correct the MEC atomic support firmware checking for GC 10.3.7
  drm/amd/display: Ignore First MST Sideband Message Return Error
  drm/i915/selftests: fix subtraction overflow bug
  drm/i915/gem: Look for waitboosting across the whole object prior to individual waits
  drm/i915/gt: Serialize TLB invalidates with GT resets
  drm/i915/gt: Serialize GRDOM access between multiple engine resets
  drm/i915/ttm: fix sg_table construction
  drm/i915/selftests: fix a couple IS_ERR() vs NULL tests
  drm/i915: Fix vm use-after-free in vma destruction
  drm/i915/guc: ADL-N should use the same GuC FW as ADL-S
  drm/i915: fix a possible refcount leak in intel_dp_add_mst_connector()
  drm/i915/gvt: IS_ERR() vs NULL bug in intel_gvt_update_reg_whitelist()
  Revert "drm/amdgpu: add drm buddy support to amdgpu"
parents 862161e8 093f8d8f
...@@ -256,7 +256,6 @@ config DRM_AMDGPU ...@@ -256,7 +256,6 @@ config DRM_AMDGPU
select HWMON select HWMON
select BACKLIGHT_CLASS_DEVICE select BACKLIGHT_CLASS_DEVICE
select INTERVAL_TREE select INTERVAL_TREE
select DRM_BUDDY
help help
Choose this option if you have a recent AMD Radeon graphics card. Choose this option if you have a recent AMD Radeon graphics card.
......
...@@ -30,15 +30,12 @@ ...@@ -30,15 +30,12 @@
#include <drm/ttm/ttm_resource.h> #include <drm/ttm/ttm_resource.h>
#include <drm/ttm/ttm_range_manager.h> #include <drm/ttm/ttm_range_manager.h>
#include "amdgpu_vram_mgr.h"
/* state back for walking over vram_mgr and gtt_mgr allocations */ /* state back for walking over vram_mgr and gtt_mgr allocations */
struct amdgpu_res_cursor { struct amdgpu_res_cursor {
uint64_t start; uint64_t start;
uint64_t size; uint64_t size;
uint64_t remaining; uint64_t remaining;
void *node; struct drm_mm_node *node;
uint32_t mem_type;
}; };
/** /**
...@@ -55,63 +52,27 @@ static inline void amdgpu_res_first(struct ttm_resource *res, ...@@ -55,63 +52,27 @@ static inline void amdgpu_res_first(struct ttm_resource *res,
uint64_t start, uint64_t size, uint64_t start, uint64_t size,
struct amdgpu_res_cursor *cur) struct amdgpu_res_cursor *cur)
{ {
struct drm_buddy_block *block;
struct list_head *head, *next;
struct drm_mm_node *node; struct drm_mm_node *node;
if (!res) if (!res || res->mem_type == TTM_PL_SYSTEM) {
goto fallback; cur->start = start;
cur->size = size;
BUG_ON(start + size > res->num_pages << PAGE_SHIFT);
cur->mem_type = res->mem_type;
switch (cur->mem_type) {
case TTM_PL_VRAM:
head = &to_amdgpu_vram_mgr_resource(res)->blocks;
block = list_first_entry_or_null(head,
struct drm_buddy_block,
link);
if (!block)
goto fallback;
while (start >= amdgpu_vram_mgr_block_size(block)) {
start -= amdgpu_vram_mgr_block_size(block);
next = block->link.next;
if (next != head)
block = list_entry(next, struct drm_buddy_block, link);
}
cur->start = amdgpu_vram_mgr_block_start(block) + start;
cur->size = min(amdgpu_vram_mgr_block_size(block) - start, size);
cur->remaining = size;
cur->node = block;
break;
case TTM_PL_TT:
node = to_ttm_range_mgr_node(res)->mm_nodes;
while (start >= node->size << PAGE_SHIFT)
start -= node++->size << PAGE_SHIFT;
cur->start = (node->start << PAGE_SHIFT) + start;
cur->size = min((node->size << PAGE_SHIFT) - start, size);
cur->remaining = size; cur->remaining = size;
cur->node = node; cur->node = NULL;
break; WARN_ON(res && start + size > res->num_pages << PAGE_SHIFT);
default: return;
goto fallback;
} }
return; BUG_ON(start + size > res->num_pages << PAGE_SHIFT);
fallback: node = to_ttm_range_mgr_node(res)->mm_nodes;
cur->start = start; while (start >= node->size << PAGE_SHIFT)
cur->size = size; start -= node++->size << PAGE_SHIFT;
cur->start = (node->start << PAGE_SHIFT) + start;
cur->size = min((node->size << PAGE_SHIFT) - start, size);
cur->remaining = size; cur->remaining = size;
cur->node = NULL; cur->node = node;
WARN_ON(res && start + size > res->num_pages << PAGE_SHIFT);
return;
} }
/** /**
...@@ -124,9 +85,7 @@ static inline void amdgpu_res_first(struct ttm_resource *res, ...@@ -124,9 +85,7 @@ static inline void amdgpu_res_first(struct ttm_resource *res,
*/ */
static inline void amdgpu_res_next(struct amdgpu_res_cursor *cur, uint64_t size) static inline void amdgpu_res_next(struct amdgpu_res_cursor *cur, uint64_t size)
{ {
struct drm_buddy_block *block; struct drm_mm_node *node = cur->node;
struct drm_mm_node *node;
struct list_head *next;
BUG_ON(size > cur->remaining); BUG_ON(size > cur->remaining);
...@@ -140,27 +99,9 @@ static inline void amdgpu_res_next(struct amdgpu_res_cursor *cur, uint64_t size) ...@@ -140,27 +99,9 @@ static inline void amdgpu_res_next(struct amdgpu_res_cursor *cur, uint64_t size)
return; return;
} }
switch (cur->mem_type) { cur->node = ++node;
case TTM_PL_VRAM: cur->start = node->start << PAGE_SHIFT;
block = cur->node; cur->size = min(node->size << PAGE_SHIFT, cur->remaining);
next = block->link.next;
block = list_entry(next, struct drm_buddy_block, link);
cur->node = block;
cur->start = amdgpu_vram_mgr_block_start(block);
cur->size = min(amdgpu_vram_mgr_block_size(block), cur->remaining);
break;
case TTM_PL_TT:
node = cur->node;
cur->node = ++node;
cur->start = node->start << PAGE_SHIFT;
cur->size = min(node->size << PAGE_SHIFT, cur->remaining);
break;
default:
return;
}
} }
#endif #endif
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <linux/dma-direction.h> #include <linux/dma-direction.h>
#include <drm/gpu_scheduler.h> #include <drm/gpu_scheduler.h>
#include "amdgpu_vram_mgr.h"
#include "amdgpu.h" #include "amdgpu.h"
#define AMDGPU_PL_GDS (TTM_PL_PRIV + 0) #define AMDGPU_PL_GDS (TTM_PL_PRIV + 0)
...@@ -39,6 +38,15 @@ ...@@ -39,6 +38,15 @@
#define AMDGPU_POISON 0xd0bed0be #define AMDGPU_POISON 0xd0bed0be
struct amdgpu_vram_mgr {
struct ttm_resource_manager manager;
struct drm_mm mm;
spinlock_t lock;
struct list_head reservations_pending;
struct list_head reserved_pages;
atomic64_t vis_usage;
};
struct amdgpu_gtt_mgr { struct amdgpu_gtt_mgr {
struct ttm_resource_manager manager; struct ttm_resource_manager manager;
struct drm_mm mm; struct drm_mm mm;
......
/* SPDX-License-Identifier: MIT
* Copyright 2021 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __AMDGPU_VRAM_MGR_H__
#define __AMDGPU_VRAM_MGR_H__
#include <drm/drm_buddy.h>
struct amdgpu_vram_mgr {
struct ttm_resource_manager manager;
struct drm_buddy mm;
/* protects access to buffer objects */
struct mutex lock;
struct list_head reservations_pending;
struct list_head reserved_pages;
atomic64_t vis_usage;
u64 default_page_size;
};
struct amdgpu_vram_mgr_resource {
struct ttm_resource base;
struct list_head blocks;
unsigned long flags;
};
static inline u64 amdgpu_vram_mgr_block_start(struct drm_buddy_block *block)
{
return drm_buddy_block_offset(block);
}
static inline u64 amdgpu_vram_mgr_block_size(struct drm_buddy_block *block)
{
return PAGE_SIZE << drm_buddy_block_order(block);
}
static inline struct drm_buddy_block *
amdgpu_vram_mgr_first_block(struct list_head *list)
{
return list_first_entry_or_null(list, struct drm_buddy_block, link);
}
static inline bool amdgpu_is_vram_mgr_blocks_contiguous(struct list_head *head)
{
struct drm_buddy_block *block;
u64 start, size;
block = amdgpu_vram_mgr_first_block(head);
if (!block)
return false;
while (head != block->link.next) {
start = amdgpu_vram_mgr_block_start(block);
size = amdgpu_vram_mgr_block_size(block);
block = list_entry(block->link.next, struct drm_buddy_block, link);
if (start + size != amdgpu_vram_mgr_block_start(block))
return false;
}
return true;
}
static inline struct amdgpu_vram_mgr_resource *
to_amdgpu_vram_mgr_resource(struct ttm_resource *res)
{
return container_of(res, struct amdgpu_vram_mgr_resource, base);
}
#endif
...@@ -184,6 +184,8 @@ static void kfd_device_info_init(struct kfd_dev *kfd, ...@@ -184,6 +184,8 @@ static void kfd_device_info_init(struct kfd_dev *kfd,
/* Navi2x+, Navi1x+ */ /* Navi2x+, Navi1x+ */
if (gc_version == IP_VERSION(10, 3, 6)) if (gc_version == IP_VERSION(10, 3, 6))
kfd->device_info.no_atomic_fw_version = 14; kfd->device_info.no_atomic_fw_version = 14;
else if (gc_version == IP_VERSION(10, 3, 7))
kfd->device_info.no_atomic_fw_version = 3;
else if (gc_version >= IP_VERSION(10, 3, 0)) else if (gc_version >= IP_VERSION(10, 3, 0))
kfd->device_info.no_atomic_fw_version = 92; kfd->device_info.no_atomic_fw_version = 92;
else if (gc_version >= IP_VERSION(10, 1, 1)) else if (gc_version >= IP_VERSION(10, 1, 1))
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/component.h> #include <linux/component.h>
#include <linux/dmi.h>
#include <drm/display/drm_dp_mst_helper.h> #include <drm/display/drm_dp_mst_helper.h>
#include <drm/display/drm_hdmi_helper.h> #include <drm/display/drm_hdmi_helper.h>
...@@ -462,6 +463,26 @@ static void dm_pflip_high_irq(void *interrupt_params) ...@@ -462,6 +463,26 @@ static void dm_pflip_high_irq(void *interrupt_params)
vrr_active, (int) !e); vrr_active, (int) !e);
} }
static void dm_crtc_handle_vblank(struct amdgpu_crtc *acrtc)
{
struct drm_crtc *crtc = &acrtc->base;
struct drm_device *dev = crtc->dev;
unsigned long flags;
drm_crtc_handle_vblank(crtc);
spin_lock_irqsave(&dev->event_lock, flags);
/* Send completion event for cursor-only commits */
if (acrtc->event && acrtc->pflip_status != AMDGPU_FLIP_SUBMITTED) {
drm_crtc_send_vblank_event(crtc, acrtc->event);
drm_crtc_vblank_put(crtc);
acrtc->event = NULL;
}
spin_unlock_irqrestore(&dev->event_lock, flags);
}
static void dm_vupdate_high_irq(void *interrupt_params) static void dm_vupdate_high_irq(void *interrupt_params)
{ {
struct common_irq_params *irq_params = interrupt_params; struct common_irq_params *irq_params = interrupt_params;
...@@ -500,7 +521,7 @@ static void dm_vupdate_high_irq(void *interrupt_params) ...@@ -500,7 +521,7 @@ static void dm_vupdate_high_irq(void *interrupt_params)
* if a pageflip happened inside front-porch. * if a pageflip happened inside front-porch.
*/ */
if (vrr_active) { if (vrr_active) {
drm_crtc_handle_vblank(&acrtc->base); dm_crtc_handle_vblank(acrtc);
/* BTR processing for pre-DCE12 ASICs */ /* BTR processing for pre-DCE12 ASICs */
if (acrtc->dm_irq_params.stream && if (acrtc->dm_irq_params.stream &&
...@@ -552,7 +573,7 @@ static void dm_crtc_high_irq(void *interrupt_params) ...@@ -552,7 +573,7 @@ static void dm_crtc_high_irq(void *interrupt_params)
* to dm_vupdate_high_irq after end of front-porch. * to dm_vupdate_high_irq after end of front-porch.
*/ */
if (!vrr_active) if (!vrr_active)
drm_crtc_handle_vblank(&acrtc->base); dm_crtc_handle_vblank(acrtc);
/** /**
* Following stuff must happen at start of vblank, for crc * Following stuff must happen at start of vblank, for crc
...@@ -1382,6 +1403,41 @@ static bool dm_should_disable_stutter(struct pci_dev *pdev) ...@@ -1382,6 +1403,41 @@ static bool dm_should_disable_stutter(struct pci_dev *pdev)
return false; return false;
} }
static const struct dmi_system_id hpd_disconnect_quirk_table[] = {
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3660"),
},
},
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3260"),
},
},
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3460"),
},
},
{}
};
static void retrieve_dmi_info(struct amdgpu_display_manager *dm)
{
const struct dmi_system_id *dmi_id;
dm->aux_hpd_discon_quirk = false;
dmi_id = dmi_first_match(hpd_disconnect_quirk_table);
if (dmi_id) {
dm->aux_hpd_discon_quirk = true;
DRM_INFO("aux_hpd_discon_quirk attached\n");
}
}
static int amdgpu_dm_init(struct amdgpu_device *adev) static int amdgpu_dm_init(struct amdgpu_device *adev)
{ {
struct dc_init_data init_data; struct dc_init_data init_data;
...@@ -1508,6 +1564,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev) ...@@ -1508,6 +1564,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
} }
INIT_LIST_HEAD(&adev->dm.da_list); INIT_LIST_HEAD(&adev->dm.da_list);
retrieve_dmi_info(&adev->dm);
/* Display Core create. */ /* Display Core create. */
adev->dm.dc = dc_create(&init_data); adev->dm.dc = dc_create(&init_data);
...@@ -5407,7 +5466,7 @@ fill_blending_from_plane_state(const struct drm_plane_state *plane_state, ...@@ -5407,7 +5466,7 @@ fill_blending_from_plane_state(const struct drm_plane_state *plane_state,
} }
} }
if (per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) if (*per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE)
*pre_multiplied_alpha = false; *pre_multiplied_alpha = false;
} }
...@@ -9135,6 +9194,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, ...@@ -9135,6 +9194,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
struct amdgpu_bo *abo; struct amdgpu_bo *abo;
uint32_t target_vblank, last_flip_vblank; uint32_t target_vblank, last_flip_vblank;
bool vrr_active = amdgpu_dm_vrr_active(acrtc_state); bool vrr_active = amdgpu_dm_vrr_active(acrtc_state);
bool cursor_update = false;
bool pflip_present = false; bool pflip_present = false;
struct { struct {
struct dc_surface_update surface_updates[MAX_SURFACES]; struct dc_surface_update surface_updates[MAX_SURFACES];
...@@ -9170,8 +9230,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, ...@@ -9170,8 +9230,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
struct dm_plane_state *dm_new_plane_state = to_dm_plane_state(new_plane_state); struct dm_plane_state *dm_new_plane_state = to_dm_plane_state(new_plane_state);
/* Cursor plane is handled after stream updates */ /* Cursor plane is handled after stream updates */
if (plane->type == DRM_PLANE_TYPE_CURSOR) if (plane->type == DRM_PLANE_TYPE_CURSOR) {
if ((fb && crtc == pcrtc) ||
(old_plane_state->fb && old_plane_state->crtc == pcrtc))
cursor_update = true;
continue; continue;
}
if (!fb || !crtc || pcrtc != crtc) if (!fb || !crtc || pcrtc != crtc)
continue; continue;
...@@ -9334,6 +9399,17 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, ...@@ -9334,6 +9399,17 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
bundle->stream_update.vrr_infopacket = bundle->stream_update.vrr_infopacket =
&acrtc_state->stream->vrr_infopacket; &acrtc_state->stream->vrr_infopacket;
} }
} else if (cursor_update && acrtc_state->active_planes > 0 &&
!acrtc_state->force_dpms_off &&
acrtc_attach->base.state->event) {
drm_crtc_vblank_get(pcrtc);
spin_lock_irqsave(&pcrtc->dev->event_lock, flags);
acrtc_attach->event = acrtc_attach->base.state->event;
acrtc_attach->base.state->event = NULL;
spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags);
} }
/* Update the planes if changed or disable if we don't have any. */ /* Update the planes if changed or disable if we don't have any. */
......
...@@ -540,6 +540,14 @@ struct amdgpu_display_manager { ...@@ -540,6 +540,14 @@ struct amdgpu_display_manager {
* last successfully applied backlight values. * last successfully applied backlight values.
*/ */
u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP]; u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP];
/**
* @aux_hpd_discon_quirk:
*
* quirk for hpd discon while aux is on-going.
* occurred on certain intel platform
*/
bool aux_hpd_discon_quirk;
}; };
enum dsc_clock_force_state { enum dsc_clock_force_state {
......
...@@ -56,6 +56,8 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -56,6 +56,8 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
ssize_t result = 0; ssize_t result = 0;
struct aux_payload payload; struct aux_payload payload;
enum aux_return_code_type operation_result; enum aux_return_code_type operation_result;
struct amdgpu_device *adev;
struct ddc_service *ddc;
if (WARN_ON(msg->size > 16)) if (WARN_ON(msg->size > 16))
return -E2BIG; return -E2BIG;
...@@ -74,6 +76,21 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -74,6 +76,21 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
result = dc_link_aux_transfer_raw(TO_DM_AUX(aux)->ddc_service, &payload, result = dc_link_aux_transfer_raw(TO_DM_AUX(aux)->ddc_service, &payload,
&operation_result); &operation_result);
/*
* w/a on certain intel platform where hpd is unexpected to pull low during
* 1st sideband message transaction by return AUX_RET_ERROR_HPD_DISCON
* aux transaction is succuess in such case, therefore bypass the error
*/
ddc = TO_DM_AUX(aux)->ddc_service;
adev = ddc->ctx->driver_context;
if (adev->dm.aux_hpd_discon_quirk) {
if (msg->address == DP_SIDEBAND_MSG_DOWN_REQ_BASE &&
operation_result == AUX_RET_ERROR_HPD_DISCON) {
result = 0;
operation_result = AUX_RET_SUCCESS;
}
}
if (payload.write && result >= 0) if (payload.write && result >= 0)
result = msg->size; result = msg->size;
......
...@@ -1117,12 +1117,13 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx) ...@@ -1117,12 +1117,13 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
* on certain displays, such as the Sharp 4k. 36bpp is needed * on certain displays, such as the Sharp 4k. 36bpp is needed
* to support SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 and * to support SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 and
* SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 with actual > 10 bpc * SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 with actual > 10 bpc
* precision on at least DCN display engines. However, at least * precision on DCN display engines, but apparently not for DCE, as
* Carrizo with DCE_VERSION_11_0 does not like 36 bpp lb depth, * far as testing on DCE-11.2 and DCE-8 showed. Various DCE parts have
* so use only 30 bpp on DCE_VERSION_11_0. Testing with DCE 11.2 and 8.3 * problems: Carrizo with DCE_VERSION_11_0 does not like 36 bpp lb depth,
* did not show such problems, so this seems to be the exception. * neither do DCE-8 at 4k resolution, or DCE-11.2 (broken identify pixel
* passthrough). Therefore only use 36 bpp on DCN where it is actually needed.
*/ */
if (plane_state->ctx->dce_version > DCE_VERSION_11_0) if (plane_state->ctx->dce_version > DCE_VERSION_MAX)
pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_36BPP; pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_36BPP;
else else
pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_30BPP; pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_30BPP;
......
...@@ -1228,6 +1228,8 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu, ...@@ -1228,6 +1228,8 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,
uint32_t crystal_clock_freq = 2500; uint32_t crystal_clock_freq = 2500;
uint32_t tach_period; uint32_t tach_period;
if (speed == 0)
return -EINVAL;
/* /*
* To prevent from possible overheat, some ASICs may have requirement * To prevent from possible overheat, some ASICs may have requirement
* for minimum fan speed: * for minimum fan speed:
......
...@@ -620,10 +620,15 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj, ...@@ -620,10 +620,15 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj,
struct ttm_resource *res) struct ttm_resource *res)
{ {
struct ttm_buffer_object *bo = i915_gem_to_ttm(obj); struct ttm_buffer_object *bo = i915_gem_to_ttm(obj);
u64 page_alignment;
if (!i915_ttm_gtt_binds_lmem(res)) if (!i915_ttm_gtt_binds_lmem(res))
return i915_ttm_tt_get_st(bo->ttm); return i915_ttm_tt_get_st(bo->ttm);
page_alignment = bo->page_alignment << PAGE_SHIFT;
if (!page_alignment)
page_alignment = obj->mm.region->min_page_size;
/* /*
* If CPU mapping differs, we need to add the ttm_tt pages to * If CPU mapping differs, we need to add the ttm_tt pages to
* the resulting st. Might make sense for GGTT. * the resulting st. Might make sense for GGTT.
...@@ -634,7 +639,8 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj, ...@@ -634,7 +639,8 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj,
struct i915_refct_sgt *rsgt; struct i915_refct_sgt *rsgt;
rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region, rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region,
res); res,
page_alignment);
if (IS_ERR(rsgt)) if (IS_ERR(rsgt))
return rsgt; return rsgt;
...@@ -643,7 +649,8 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj, ...@@ -643,7 +649,8 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj,
return i915_refct_sgt_get(obj->ttm.cached_io_rsgt); return i915_refct_sgt_get(obj->ttm.cached_io_rsgt);
} }
return intel_region_ttm_resource_to_rsgt(obj->mm.region, res); return intel_region_ttm_resource_to_rsgt(obj->mm.region, res,
page_alignment);
} }
static int i915_ttm_truncate(struct drm_i915_gem_object *obj) static int i915_ttm_truncate(struct drm_i915_gem_object *obj)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include "gt/intel_engine.h" #include "gt/intel_engine.h"
#include "gt/intel_rps.h"
#include "i915_gem_ioctls.h" #include "i915_gem_ioctls.h"
#include "i915_gem_object.h" #include "i915_gem_object.h"
...@@ -31,6 +32,37 @@ i915_gem_object_wait_fence(struct dma_fence *fence, ...@@ -31,6 +32,37 @@ i915_gem_object_wait_fence(struct dma_fence *fence,
timeout); timeout);
} }
static void
i915_gem_object_boost(struct dma_resv *resv, unsigned int flags)
{
struct dma_resv_iter cursor;
struct dma_fence *fence;
/*
* Prescan all fences for potential boosting before we begin waiting.
*
* When we wait, we wait on outstanding fences serially. If the
* dma-resv contains a sequence such as 1:1, 1:2 instead of a reduced
* form 1:2, then as we look at each wait in turn we see that each
* request is currently executing and not worthy of boosting. But if
* we only happen to look at the final fence in the sequence (because
* of request coalescing or splitting between read/write arrays by
* the iterator), then we would boost. As such our decision to boost
* or not is delicately balanced on the order we wait on fences.
*
* So instead of looking for boosts sequentially, look for all boosts
* upfront and then wait on the outstanding fences.
*/
dma_resv_iter_begin(&cursor, resv,
dma_resv_usage_rw(flags & I915_WAIT_ALL));
dma_resv_for_each_fence_unlocked(&cursor, fence)
if (dma_fence_is_i915(fence) &&
!i915_request_started(to_request(fence)))
intel_rps_boost(to_request(fence));
dma_resv_iter_end(&cursor);
}
static long static long
i915_gem_object_wait_reservation(struct dma_resv *resv, i915_gem_object_wait_reservation(struct dma_resv *resv,
unsigned int flags, unsigned int flags,
...@@ -40,6 +72,8 @@ i915_gem_object_wait_reservation(struct dma_resv *resv, ...@@ -40,6 +72,8 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,
struct dma_fence *fence; struct dma_fence *fence;
long ret = timeout ?: 1; long ret = timeout ?: 1;
i915_gem_object_boost(resv, flags);
dma_resv_iter_begin(&cursor, resv, dma_resv_iter_begin(&cursor, resv,
dma_resv_usage_rw(flags & I915_WAIT_ALL)); dma_resv_usage_rw(flags & I915_WAIT_ALL));
dma_resv_for_each_fence_unlocked(&cursor, fence) { dma_resv_for_each_fence_unlocked(&cursor, fence) {
......
...@@ -1209,6 +1209,20 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt) ...@@ -1209,6 +1209,20 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
mutex_lock(&gt->tlb_invalidate_lock); mutex_lock(&gt->tlb_invalidate_lock);
intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL); intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
spin_lock_irq(&uncore->lock); /* serialise invalidate with GT reset */
for_each_engine(engine, gt, id) {
struct reg_and_bit rb;
rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num);
if (!i915_mmio_reg_offset(rb.reg))
continue;
intel_uncore_write_fw(uncore, rb.reg, rb.bit);
}
spin_unlock_irq(&uncore->lock);
for_each_engine(engine, gt, id) { for_each_engine(engine, gt, id) {
/* /*
* HW architecture suggest typical invalidation time at 40us, * HW architecture suggest typical invalidation time at 40us,
...@@ -1223,7 +1237,6 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt) ...@@ -1223,7 +1237,6 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
if (!i915_mmio_reg_offset(rb.reg)) if (!i915_mmio_reg_offset(rb.reg))
continue; continue;
intel_uncore_write_fw(uncore, rb.reg, rb.bit);
if (__intel_wait_for_register_fw(uncore, if (__intel_wait_for_register_fw(uncore,
rb.reg, rb.bit, 0, rb.reg, rb.bit, 0,
timeout_us, timeout_ms, timeout_us, timeout_ms,
......
...@@ -300,9 +300,9 @@ static int gen6_hw_domain_reset(struct intel_gt *gt, u32 hw_domain_mask) ...@@ -300,9 +300,9 @@ static int gen6_hw_domain_reset(struct intel_gt *gt, u32 hw_domain_mask)
return err; return err;
} }
static int gen6_reset_engines(struct intel_gt *gt, static int __gen6_reset_engines(struct intel_gt *gt,
intel_engine_mask_t engine_mask, intel_engine_mask_t engine_mask,
unsigned int retry) unsigned int retry)
{ {
struct intel_engine_cs *engine; struct intel_engine_cs *engine;
u32 hw_mask; u32 hw_mask;
...@@ -321,6 +321,20 @@ static int gen6_reset_engines(struct intel_gt *gt, ...@@ -321,6 +321,20 @@ static int gen6_reset_engines(struct intel_gt *gt,
return gen6_hw_domain_reset(gt, hw_mask); return gen6_hw_domain_reset(gt, hw_mask);
} }
static int gen6_reset_engines(struct intel_gt *gt,
intel_engine_mask_t engine_mask,
unsigned int retry)
{
unsigned long flags;
int ret;
spin_lock_irqsave(&gt->uncore->lock, flags);
ret = __gen6_reset_engines(gt, engine_mask, retry);
spin_unlock_irqrestore(&gt->uncore->lock, flags);
return ret;
}
static struct intel_engine_cs *find_sfc_paired_vecs_engine(struct intel_engine_cs *engine) static struct intel_engine_cs *find_sfc_paired_vecs_engine(struct intel_engine_cs *engine)
{ {
int vecs_id; int vecs_id;
...@@ -487,9 +501,9 @@ static void gen11_unlock_sfc(struct intel_engine_cs *engine) ...@@ -487,9 +501,9 @@ static void gen11_unlock_sfc(struct intel_engine_cs *engine)
rmw_clear_fw(uncore, sfc_lock.lock_reg, sfc_lock.lock_bit); rmw_clear_fw(uncore, sfc_lock.lock_reg, sfc_lock.lock_bit);
} }
static int gen11_reset_engines(struct intel_gt *gt, static int __gen11_reset_engines(struct intel_gt *gt,
intel_engine_mask_t engine_mask, intel_engine_mask_t engine_mask,
unsigned int retry) unsigned int retry)
{ {
struct intel_engine_cs *engine; struct intel_engine_cs *engine;
intel_engine_mask_t tmp; intel_engine_mask_t tmp;
...@@ -583,8 +597,11 @@ static int gen8_reset_engines(struct intel_gt *gt, ...@@ -583,8 +597,11 @@ static int gen8_reset_engines(struct intel_gt *gt,
struct intel_engine_cs *engine; struct intel_engine_cs *engine;
const bool reset_non_ready = retry >= 1; const bool reset_non_ready = retry >= 1;
intel_engine_mask_t tmp; intel_engine_mask_t tmp;
unsigned long flags;
int ret; int ret;
spin_lock_irqsave(&gt->uncore->lock, flags);
for_each_engine_masked(engine, gt, engine_mask, tmp) { for_each_engine_masked(engine, gt, engine_mask, tmp) {
ret = gen8_engine_reset_prepare(engine); ret = gen8_engine_reset_prepare(engine);
if (ret && !reset_non_ready) if (ret && !reset_non_ready)
...@@ -612,17 +629,19 @@ static int gen8_reset_engines(struct intel_gt *gt, ...@@ -612,17 +629,19 @@ static int gen8_reset_engines(struct intel_gt *gt,
* This is best effort, so ignore any error from the initial reset. * This is best effort, so ignore any error from the initial reset.
*/ */
if (IS_DG2(gt->i915) && engine_mask == ALL_ENGINES) if (IS_DG2(gt->i915) && engine_mask == ALL_ENGINES)
gen11_reset_engines(gt, gt->info.engine_mask, 0); __gen11_reset_engines(gt, gt->info.engine_mask, 0);
if (GRAPHICS_VER(gt->i915) >= 11) if (GRAPHICS_VER(gt->i915) >= 11)
ret = gen11_reset_engines(gt, engine_mask, retry); ret = __gen11_reset_engines(gt, engine_mask, retry);
else else
ret = gen6_reset_engines(gt, engine_mask, retry); ret = __gen6_reset_engines(gt, engine_mask, retry);
skip_reset: skip_reset:
for_each_engine_masked(engine, gt, engine_mask, tmp) for_each_engine_masked(engine, gt, engine_mask, tmp)
gen8_engine_reset_cancel(engine); gen8_engine_reset_cancel(engine);
spin_unlock_irqrestore(&gt->uncore->lock, flags);
return ret; return ret;
} }
......
...@@ -176,8 +176,8 @@ static int live_lrc_layout(void *arg) ...@@ -176,8 +176,8 @@ static int live_lrc_layout(void *arg)
continue; continue;
hw = shmem_pin_map(engine->default_state); hw = shmem_pin_map(engine->default_state);
if (IS_ERR(hw)) { if (!hw) {
err = PTR_ERR(hw); err = -ENOMEM;
break; break;
} }
hw += LRC_STATE_OFFSET / sizeof(*hw); hw += LRC_STATE_OFFSET / sizeof(*hw);
...@@ -365,8 +365,8 @@ static int live_lrc_fixed(void *arg) ...@@ -365,8 +365,8 @@ static int live_lrc_fixed(void *arg)
continue; continue;
hw = shmem_pin_map(engine->default_state); hw = shmem_pin_map(engine->default_state);
if (IS_ERR(hw)) { if (!hw) {
err = PTR_ERR(hw); err = -ENOMEM;
break; break;
} }
hw += LRC_STATE_OFFSET / sizeof(*hw); hw += LRC_STATE_OFFSET / sizeof(*hw);
......
...@@ -3117,9 +3117,9 @@ void intel_gvt_update_reg_whitelist(struct intel_vgpu *vgpu) ...@@ -3117,9 +3117,9 @@ void intel_gvt_update_reg_whitelist(struct intel_vgpu *vgpu)
continue; continue;
vaddr = shmem_pin_map(engine->default_state); vaddr = shmem_pin_map(engine->default_state);
if (IS_ERR(vaddr)) { if (!vaddr) {
gvt_err("failed to map %s->default state, err:%zd\n", gvt_err("failed to map %s->default state\n",
engine->name, PTR_ERR(vaddr)); engine->name);
return; return;
} }
......
...@@ -68,6 +68,7 @@ void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size) ...@@ -68,6 +68,7 @@ void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size)
* drm_mm_node * drm_mm_node
* @node: The drm_mm_node. * @node: The drm_mm_node.
* @region_start: An offset to add to the dma addresses of the sg list. * @region_start: An offset to add to the dma addresses of the sg list.
* @page_alignment: Required page alignment for each sg entry. Power of two.
* *
* Create a struct sg_table, initializing it from a struct drm_mm_node, * Create a struct sg_table, initializing it from a struct drm_mm_node,
* taking a maximum segment length into account, splitting into segments * taking a maximum segment length into account, splitting into segments
...@@ -77,15 +78,18 @@ void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size) ...@@ -77,15 +78,18 @@ void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size)
* error code cast to an error pointer on failure. * error code cast to an error pointer on failure.
*/ */
struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
u64 region_start) u64 region_start,
u64 page_alignment)
{ {
const u64 max_segment = SZ_1G; /* Do we have a limit on this? */ const u64 max_segment = round_down(UINT_MAX, page_alignment);
u64 segment_pages = max_segment >> PAGE_SHIFT; u64 segment_pages = max_segment >> PAGE_SHIFT;
u64 block_size, offset, prev_end; u64 block_size, offset, prev_end;
struct i915_refct_sgt *rsgt; struct i915_refct_sgt *rsgt;
struct sg_table *st; struct sg_table *st;
struct scatterlist *sg; struct scatterlist *sg;
GEM_BUG_ON(!max_segment);
rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL); rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL);
if (!rsgt) if (!rsgt)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -112,6 +116,8 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, ...@@ -112,6 +116,8 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
sg = __sg_next(sg); sg = __sg_next(sg);
sg_dma_address(sg) = region_start + offset; sg_dma_address(sg) = region_start + offset;
GEM_BUG_ON(!IS_ALIGNED(sg_dma_address(sg),
page_alignment));
sg_dma_len(sg) = 0; sg_dma_len(sg) = 0;
sg->length = 0; sg->length = 0;
st->nents++; st->nents++;
...@@ -138,6 +144,7 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, ...@@ -138,6 +144,7 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
* i915_buddy_block list * i915_buddy_block list
* @res: The struct i915_ttm_buddy_resource. * @res: The struct i915_ttm_buddy_resource.
* @region_start: An offset to add to the dma addresses of the sg list. * @region_start: An offset to add to the dma addresses of the sg list.
* @page_alignment: Required page alignment for each sg entry. Power of two.
* *
* Create a struct sg_table, initializing it from struct i915_buddy_block list, * Create a struct sg_table, initializing it from struct i915_buddy_block list,
* taking a maximum segment length into account, splitting into segments * taking a maximum segment length into account, splitting into segments
...@@ -147,11 +154,12 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, ...@@ -147,11 +154,12 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
* error code cast to an error pointer on failure. * error code cast to an error pointer on failure.
*/ */
struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
u64 region_start) u64 region_start,
u64 page_alignment)
{ {
struct i915_ttm_buddy_resource *bman_res = to_ttm_buddy_resource(res); struct i915_ttm_buddy_resource *bman_res = to_ttm_buddy_resource(res);
const u64 size = res->num_pages << PAGE_SHIFT; const u64 size = res->num_pages << PAGE_SHIFT;
const u64 max_segment = rounddown(UINT_MAX, PAGE_SIZE); const u64 max_segment = round_down(UINT_MAX, page_alignment);
struct drm_buddy *mm = bman_res->mm; struct drm_buddy *mm = bman_res->mm;
struct list_head *blocks = &bman_res->blocks; struct list_head *blocks = &bman_res->blocks;
struct drm_buddy_block *block; struct drm_buddy_block *block;
...@@ -161,6 +169,7 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, ...@@ -161,6 +169,7 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
resource_size_t prev_end; resource_size_t prev_end;
GEM_BUG_ON(list_empty(blocks)); GEM_BUG_ON(list_empty(blocks));
GEM_BUG_ON(!max_segment);
rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL); rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL);
if (!rsgt) if (!rsgt)
...@@ -191,6 +200,8 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, ...@@ -191,6 +200,8 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
sg = __sg_next(sg); sg = __sg_next(sg);
sg_dma_address(sg) = region_start + offset; sg_dma_address(sg) = region_start + offset;
GEM_BUG_ON(!IS_ALIGNED(sg_dma_address(sg),
page_alignment));
sg_dma_len(sg) = 0; sg_dma_len(sg) = 0;
sg->length = 0; sg->length = 0;
st->nents++; st->nents++;
......
...@@ -213,9 +213,11 @@ static inline void __i915_refct_sgt_init(struct i915_refct_sgt *rsgt, ...@@ -213,9 +213,11 @@ static inline void __i915_refct_sgt_init(struct i915_refct_sgt *rsgt,
void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size); void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size);
struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
u64 region_start); u64 region_start,
u64 page_alignment);
struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
u64 region_start); u64 region_start,
u64 page_alignment);
#endif #endif
...@@ -152,6 +152,7 @@ int intel_region_ttm_fini(struct intel_memory_region *mem) ...@@ -152,6 +152,7 @@ int intel_region_ttm_fini(struct intel_memory_region *mem)
* Convert an opaque TTM resource manager resource to a refcounted sg_table. * Convert an opaque TTM resource manager resource to a refcounted sg_table.
* @mem: The memory region. * @mem: The memory region.
* @res: The resource manager resource obtained from the TTM resource manager. * @res: The resource manager resource obtained from the TTM resource manager.
* @page_alignment: Required page alignment for each sg entry. Power of two.
* *
* The gem backends typically use sg-tables for operations on the underlying * The gem backends typically use sg-tables for operations on the underlying
* io_memory. So provide a way for the backends to translate the * io_memory. So provide a way for the backends to translate the
...@@ -161,16 +162,19 @@ int intel_region_ttm_fini(struct intel_memory_region *mem) ...@@ -161,16 +162,19 @@ int intel_region_ttm_fini(struct intel_memory_region *mem)
*/ */
struct i915_refct_sgt * struct i915_refct_sgt *
intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem, intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
struct ttm_resource *res) struct ttm_resource *res,
u64 page_alignment)
{ {
if (mem->is_range_manager) { if (mem->is_range_manager) {
struct ttm_range_mgr_node *range_node = struct ttm_range_mgr_node *range_node =
to_ttm_range_mgr_node(res); to_ttm_range_mgr_node(res);
return i915_rsgt_from_mm_node(&range_node->mm_nodes[0], return i915_rsgt_from_mm_node(&range_node->mm_nodes[0],
mem->region.start); mem->region.start,
page_alignment);
} else { } else {
return i915_rsgt_from_buddy_resource(res, mem->region.start); return i915_rsgt_from_buddy_resource(res, mem->region.start,
page_alignment);
} }
} }
......
...@@ -24,7 +24,8 @@ int intel_region_ttm_fini(struct intel_memory_region *mem); ...@@ -24,7 +24,8 @@ int intel_region_ttm_fini(struct intel_memory_region *mem);
struct i915_refct_sgt * struct i915_refct_sgt *
intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem, intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
struct ttm_resource *res); struct ttm_resource *res,
u64 page_alignment);
void intel_region_ttm_resource_free(struct intel_memory_region *mem, void intel_region_ttm_resource_free(struct intel_memory_region *mem,
struct ttm_resource *res); struct ttm_resource *res);
......
...@@ -742,7 +742,7 @@ static int pot_hole(struct i915_address_space *vm, ...@@ -742,7 +742,7 @@ static int pot_hole(struct i915_address_space *vm,
u64 addr; u64 addr;
for (addr = round_up(hole_start + min_alignment, step) - min_alignment; for (addr = round_up(hole_start + min_alignment, step) - min_alignment;
addr <= round_down(hole_end - (2 * min_alignment), step) - min_alignment; hole_end > addr && hole_end - addr >= 2 * min_alignment;
addr += step) { addr += step) {
err = i915_vma_pin(vma, 0, 0, addr | flags); err = i915_vma_pin(vma, 0, 0, addr | flags);
if (err) { if (err) {
......
...@@ -451,7 +451,6 @@ static int igt_mock_splintered_region(void *arg) ...@@ -451,7 +451,6 @@ static int igt_mock_splintered_region(void *arg)
static int igt_mock_max_segment(void *arg) static int igt_mock_max_segment(void *arg)
{ {
const unsigned int max_segment = rounddown(UINT_MAX, PAGE_SIZE);
struct intel_memory_region *mem = arg; struct intel_memory_region *mem = arg;
struct drm_i915_private *i915 = mem->i915; struct drm_i915_private *i915 = mem->i915;
struct i915_ttm_buddy_resource *res; struct i915_ttm_buddy_resource *res;
...@@ -460,7 +459,10 @@ static int igt_mock_max_segment(void *arg) ...@@ -460,7 +459,10 @@ static int igt_mock_max_segment(void *arg)
struct drm_buddy *mm; struct drm_buddy *mm;
struct list_head *blocks; struct list_head *blocks;
struct scatterlist *sg; struct scatterlist *sg;
I915_RND_STATE(prng);
LIST_HEAD(objects); LIST_HEAD(objects);
unsigned int max_segment;
unsigned int ps;
u64 size; u64 size;
int err = 0; int err = 0;
...@@ -472,7 +474,13 @@ static int igt_mock_max_segment(void *arg) ...@@ -472,7 +474,13 @@ static int igt_mock_max_segment(void *arg)
*/ */
size = SZ_8G; size = SZ_8G;
mem = mock_region_create(i915, 0, size, PAGE_SIZE, 0, 0); ps = PAGE_SIZE;
if (i915_prandom_u64_state(&prng) & 1)
ps = SZ_64K; /* For something like DG2 */
max_segment = round_down(UINT_MAX, ps);
mem = mock_region_create(i915, 0, size, ps, 0, 0);
if (IS_ERR(mem)) if (IS_ERR(mem))
return PTR_ERR(mem); return PTR_ERR(mem);
...@@ -498,12 +506,21 @@ static int igt_mock_max_segment(void *arg) ...@@ -498,12 +506,21 @@ static int igt_mock_max_segment(void *arg)
} }
for (sg = obj->mm.pages->sgl; sg; sg = sg_next(sg)) { for (sg = obj->mm.pages->sgl; sg; sg = sg_next(sg)) {
dma_addr_t daddr = sg_dma_address(sg);
if (sg->length > max_segment) { if (sg->length > max_segment) {
pr_err("%s: Created an oversized scatterlist entry, %u > %u\n", pr_err("%s: Created an oversized scatterlist entry, %u > %u\n",
__func__, sg->length, max_segment); __func__, sg->length, max_segment);
err = -EINVAL; err = -EINVAL;
goto out_close; goto out_close;
} }
if (!IS_ALIGNED(daddr, ps)) {
pr_err("%s: Created an unaligned scatterlist entry, addr=%pa, ps=%u\n",
__func__, &daddr, ps);
err = -EINVAL;
goto out_close;
}
} }
out_close: out_close:
......
...@@ -33,7 +33,8 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj) ...@@ -33,7 +33,8 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj)
return PTR_ERR(obj->mm.res); return PTR_ERR(obj->mm.res);
obj->mm.rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region, obj->mm.rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region,
obj->mm.res); obj->mm.res,
obj->mm.region->min_page_size);
if (IS_ERR(obj->mm.rsgt)) { if (IS_ERR(obj->mm.rsgt)) {
err = PTR_ERR(obj->mm.rsgt); err = PTR_ERR(obj->mm.rsgt);
goto err_free_resource; goto err_free_resource;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment