Skip to content

Commit

Permalink
Merge tag 'drm-intel-next-2024-06-28' of https://gitlab.freedesktop.o…
Browse files Browse the repository at this point in the history
…rg/drm/i915/kernel into drm-next

drm/i915 feature pull #2 for v6.11:

Features and functionality:
- More eDP Panel Replay enabling (Jouni)
- Add async flip and flip done tracepoints (Ville)

Refactoring and cleanups:
- Clean up BDW+ pipe interrupt register definitions (Ville)
- Prep work for DSB based plane programming (Ville)
- Relocate encoder suspend/shutdown helpers (Imre)
- Polish plane surface alignment handling (Ville)

Fixes:
- Enable more fault interrupts on TGL+/MTL+ (Ville)
- Fix CMRR 32-bit build (Mitul)
- Fix PSR Selective Update Region Scan Line Capture Indication (Jouni)
- Fix cursor fb unpinning (Maarten, Ville)
- Fix Cx0 PHY PLL state verification in TBT mode (Imre)
- Fix unnecessary MG DP programming on MTL+ Type-C (Imre)

DRM changes:
- Rename drm_plane_check_pixel_format() to drm_plane_has_format() and export
  (Ville)
- Add drm_vblank_work_flush_all() (Maarten)

Xe driver changes:
- Call encoder .suspend_complete() hook also on Xe (Imre)

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
From: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/875xttazx2.fsf@intel.com
  • Loading branch information
danvet committed Jul 10, 2024
2 parents 62a05f4 + 32a120f commit dbf35b4
Show file tree
Hide file tree
Showing 48 changed files with 873 additions and 391 deletions.
7 changes: 2 additions & 5 deletions drivers/gpu/drm/drm_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state,
unsigned int fb_width, fb_height;
struct drm_mode_rect *clips;
uint32_t num_clips;
int ret;

/* either *both* CRTC and FB must be set, or neither */
if (crtc && !fb) {
Expand All @@ -635,14 +634,12 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state,
}

/* Check whether this plane supports the fb pixel format. */
ret = drm_plane_check_pixel_format(plane, fb->format->format,
fb->modifier);
if (ret) {
if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) {
drm_dbg_atomic(plane->dev,
"[PLANE:%d:%s] invalid pixel format %p4cc, modifier 0x%llx\n",
plane->base.id, plane->name,
&fb->format->format, fb->modifier);
return ret;
return -EINVAL;
}

/* Give drivers some help against integer overflows */
Expand Down
6 changes: 2 additions & 4 deletions drivers/gpu/drm/drm_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,12 +789,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
* case.
*/
if (!plane->format_default) {
ret = drm_plane_check_pixel_format(plane,
fb->format->format,
fb->modifier);
if (ret) {
if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) {
drm_dbg_kms(dev, "Invalid pixel format %p4cc, modifier 0x%llx\n",
&fb->format->format, fb->modifier);
ret = -EINVAL;
goto out;
}
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/drm_crtc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
/* drm_plane.c */
int drm_plane_register_all(struct drm_device *dev);
void drm_plane_unregister_all(struct drm_device *dev);
int drm_plane_check_pixel_format(struct drm_plane *plane,
u32 format, u64 modifier);
struct drm_mode_rect *
__drm_plane_get_damage_clips(const struct drm_plane_state *state);

Expand Down
32 changes: 20 additions & 12 deletions drivers/gpu/drm/drm_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,17 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
return 0;
}

int drm_plane_check_pixel_format(struct drm_plane *plane,
u32 format, u64 modifier)
/**
* drm_plane_has_format - Check whether the plane supports this format and modifier combination
* @plane: drm plane
* @format: pixel format (DRM_FORMAT_*)
* @modifier: data layout modifier
*
* Returns:
* Whether the plane supports the specified format and modifier combination.
*/
bool drm_plane_has_format(struct drm_plane *plane,
u32 format, u64 modifier)
{
unsigned int i;

Expand All @@ -887,25 +896,26 @@ int drm_plane_check_pixel_format(struct drm_plane *plane,
break;
}
if (i == plane->format_count)
return -EINVAL;
return false;

if (plane->funcs->format_mod_supported) {
if (!plane->funcs->format_mod_supported(plane, format, modifier))
return -EINVAL;
return false;
} else {
if (!plane->modifier_count)
return 0;
return true;

for (i = 0; i < plane->modifier_count; i++) {
if (modifier == plane->modifiers[i])
break;
}
if (i == plane->modifier_count)
return -EINVAL;
return false;
}

return 0;
return true;
}
EXPORT_SYMBOL(drm_plane_has_format);

static int __setplane_check(struct drm_plane *plane,
struct drm_crtc *crtc,
Expand All @@ -924,12 +934,10 @@ static int __setplane_check(struct drm_plane *plane,
}

/* Check whether this plane supports the fb pixel format. */
ret = drm_plane_check_pixel_format(plane, fb->format->format,
fb->modifier);
if (ret) {
if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) {
DRM_DEBUG_KMS("Invalid pixel format %p4cc, modifier 0x%llx\n",
&fb->format->format, fb->modifier);
return ret;
return -EINVAL;
}

/* Give drivers some help against integer overflows */
Expand Down Expand Up @@ -964,7 +972,7 @@ bool drm_any_plane_has_format(struct drm_device *dev,
struct drm_plane *plane;

drm_for_each_plane(plane, dev) {
if (drm_plane_check_pixel_format(plane, format, modifier) == 0)
if (drm_plane_has_format(plane, format, modifier))
return true;
}

Expand Down
22 changes: 22 additions & 0 deletions drivers/gpu/drm/drm_vblank_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
}
EXPORT_SYMBOL(drm_vblank_work_flush);

/**
* drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
* @crtc: crtc for which vblank work to flush
*
* Wait until all currently queued vblank work on @crtc
* has finished executing once.
*/
void drm_vblank_work_flush_all(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct drm_vblank_crtc *vblank = &dev->vblank[drm_crtc_index(crtc)];

spin_lock_irq(&dev->event_lock);
wait_event_lock_irq(vblank->work_wait_queue,
list_empty(&vblank->pending_work),
dev->event_lock);
spin_unlock_irq(&dev->event_lock);

kthread_flush_worker(vblank->worker);
}
EXPORT_SYMBOL(drm_vblank_work_flush_all);

/**
* drm_vblank_work_init - initialize a vblank work item
* @work: vblank work item
Expand Down
75 changes: 72 additions & 3 deletions drivers/gpu/drm/i915/display/i9xx_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ static u32 i9xx_plane_ctl(const struct intel_crtc_state *crtc_state,

int i9xx_check_plane_surface(struct intel_plane_state *plane_state)
{
struct drm_i915_private *dev_priv =
to_i915(plane_state->uapi.plane->dev);
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
const struct drm_framebuffer *fb = plane_state->hw.fb;
int src_x, src_y, src_w;
u32 offset;
Expand Down Expand Up @@ -267,7 +267,7 @@ int i9xx_check_plane_surface(struct intel_plane_state *plane_state)
* despite them not using the linear offset anymore.
*/
if (DISPLAY_VER(dev_priv) >= 4 && fb->modifier == I915_FORMAT_MOD_X_TILED) {
unsigned int alignment = intel_surf_alignment(fb, 0);
unsigned int alignment = plane->min_alignment(plane, fb, 0);
int cpp = fb->format->cpp[0];

while ((src_x + src_w) * cpp > plane_state->view.color_plane[0].mapping_stride) {
Expand Down Expand Up @@ -764,6 +764,66 @@ i8xx_plane_max_stride(struct intel_plane *plane,
return 8 * 1024;
}

static unsigned int vlv_primary_min_alignment(struct intel_plane *plane,
const struct drm_framebuffer *fb,
int color_plane)
{
struct drm_i915_private *i915 = to_i915(plane->base.dev);

switch (fb->modifier) {
case I915_FORMAT_MOD_X_TILED:
if (HAS_ASYNC_FLIPS(i915))
return 256 * 1024;
return 4 * 1024;
case DRM_FORMAT_MOD_LINEAR:
return 128 * 1024;
default:
MISSING_CASE(fb->modifier);
return 0;
}
}

static unsigned int g4x_primary_min_alignment(struct intel_plane *plane,
const struct drm_framebuffer *fb,
int color_plane)
{
struct drm_i915_private *i915 = to_i915(plane->base.dev);

switch (fb->modifier) {
case I915_FORMAT_MOD_X_TILED:
if (HAS_ASYNC_FLIPS(i915))
return 256 * 1024;
return 4 * 1024;
case DRM_FORMAT_MOD_LINEAR:
return 4 * 1024;
default:
MISSING_CASE(fb->modifier);
return 0;
}
}

static unsigned int i965_plane_min_alignment(struct intel_plane *plane,
const struct drm_framebuffer *fb,
int color_plane)
{
switch (fb->modifier) {
case I915_FORMAT_MOD_X_TILED:
return 4 * 1024;
case DRM_FORMAT_MOD_LINEAR:
return 128 * 1024;
default:
MISSING_CASE(fb->modifier);
return 0;
}
}

static unsigned int i9xx_plane_min_alignment(struct intel_plane *plane,
const struct drm_framebuffer *fb,
int color_plane)
{
return 0;
}

static const struct drm_plane_funcs i965_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
Expand Down Expand Up @@ -869,6 +929,15 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
plane->max_stride = ilk_primary_max_stride;
}

if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
plane->min_alignment = vlv_primary_min_alignment;
else if (DISPLAY_VER(dev_priv) >= 5 || IS_G4X(dev_priv))
plane->min_alignment = g4x_primary_min_alignment;
else if (DISPLAY_VER(dev_priv) == 4)
plane->min_alignment = i965_plane_min_alignment;
else
plane->min_alignment = i9xx_plane_min_alignment;

if (IS_I830(dev_priv) || IS_I845G(dev_priv)) {
plane->update_arm = i830_plane_update_arm;
} else {
Expand Down
9 changes: 5 additions & 4 deletions drivers/gpu/drm/i915/display/intel_alpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ static int _lnl_compute_aux_less_wake_time(int port_clock)
t1 + tcds, 1000);
}

static int _lnl_compute_aux_less_alpm_params(struct intel_dp *intel_dp,
struct intel_crtc_state *crtc_state)
static int
_lnl_compute_aux_less_alpm_params(struct intel_dp *intel_dp,
const struct intel_crtc_state *crtc_state)
{
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
int aux_less_wake_time, aux_less_wake_lines, silence_period,
Expand Down Expand Up @@ -168,7 +169,7 @@ static int _lnl_compute_aux_less_alpm_params(struct intel_dp *intel_dp,
}

static bool _lnl_compute_alpm_params(struct intel_dp *intel_dp,
struct intel_crtc_state *crtc_state)
const struct intel_crtc_state *crtc_state)
{
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
int check_entry_lines;
Expand Down Expand Up @@ -220,7 +221,7 @@ static int io_buffer_wake_time(const struct intel_crtc_state *crtc_state)
}

bool intel_alpm_compute_params(struct intel_dp *intel_dp,
struct intel_crtc_state *crtc_state)
const struct intel_crtc_state *crtc_state)
{
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
int io_wake_lines, io_wake_time, fast_wake_lines, fast_wake_time;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/display/intel_alpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct intel_connector;

void intel_alpm_init_dpcd(struct intel_dp *intel_dp);
bool intel_alpm_compute_params(struct intel_dp *intel_dp,
struct intel_crtc_state *crtc_state);
const struct intel_crtc_state *crtc_state);
void intel_alpm_lobf_compute_config(struct intel_dp *intel_dp,
struct intel_crtc_state *crtc_state,
struct drm_connector_state *conn_state);
Expand Down
35 changes: 29 additions & 6 deletions drivers/gpu/drm/i915/display/intel_atomic_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "i9xx_plane_regs.h"
#include "intel_atomic_plane.h"
#include "intel_cdclk.h"
#include "intel_cursor.h"
#include "intel_display_rps.h"
#include "intel_display_trace.h"
#include "intel_display_types.h"
Expand Down Expand Up @@ -801,18 +802,30 @@ void intel_plane_update_noarm(struct intel_plane *plane,
plane->update_noarm(plane, crtc_state, plane_state);
}

void intel_plane_async_flip(struct intel_plane *plane,
const struct intel_crtc_state *crtc_state,
const struct intel_plane_state *plane_state,
bool async_flip)
{
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);

trace_intel_plane_async_flip(plane, crtc, async_flip);
plane->async_flip(plane, crtc_state, plane_state, async_flip);
}

void intel_plane_update_arm(struct intel_plane *plane,
const struct intel_crtc_state *crtc_state,
const struct intel_plane_state *plane_state)
{
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);

trace_intel_plane_update_arm(plane, crtc);
if (crtc_state->do_async_flip && plane->async_flip) {
intel_plane_async_flip(plane, crtc_state, plane_state, true);
return;
}

if (crtc_state->do_async_flip && plane->async_flip)
plane->async_flip(plane, crtc_state, plane_state, true);
else
plane->update_arm(plane, crtc_state, plane_state);
trace_intel_plane_update_arm(plane, crtc);
plane->update_arm(plane, crtc_state, plane_state);
}

void intel_plane_disable_arm(struct intel_plane *plane,
Expand Down Expand Up @@ -1189,7 +1202,6 @@ intel_cleanup_plane_fb(struct drm_plane *plane,

intel_display_rps_mark_interactive(dev_priv, state, false);

/* Should only be called after a successful intel_prepare_plane_fb()! */
intel_plane_unpin_fb(old_plane_state);
}

Expand All @@ -1202,3 +1214,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
{
drm_plane_helper_add(&plane->base, &intel_plane_helper_funcs);
}

void intel_plane_init_cursor_vblank_work(struct intel_plane_state *old_plane_state,
struct intel_plane_state *new_plane_state)
{
if (!old_plane_state->ggtt_vma ||
old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
return;

drm_vblank_work_init(&old_plane_state->unpin_work, old_plane_state->uapi.crtc,
intel_cursor_unpin_work);
}
6 changes: 6 additions & 0 deletions drivers/gpu/drm/i915/display/intel_atomic_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
struct intel_crtc *crtc);
void intel_plane_copy_hw_state(struct intel_plane_state *plane_state,
const struct intel_plane_state *from_plane_state);
void intel_plane_async_flip(struct intel_plane *plane,
const struct intel_crtc_state *crtc_state,
const struct intel_plane_state *plane_state,
bool async_flip);
void intel_plane_update_noarm(struct intel_plane *plane,
const struct intel_crtc_state *crtc_state,
const struct intel_plane_state *plane_state);
Expand Down Expand Up @@ -67,5 +71,7 @@ void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
struct intel_plane_state *plane_state);
void intel_plane_helper_add(struct intel_plane *plane);
bool intel_plane_needs_physical(struct intel_plane *plane);
void intel_plane_init_cursor_vblank_work(struct intel_plane_state *old_plane_state,
struct intel_plane_state *new_plane_state);

#endif /* __INTEL_ATOMIC_PLANE_H__ */
Loading

0 comments on commit dbf35b4

Please sign in to comment.