[PATCH 16/19] drm/i915: Add new abstraction layer to handle pipe order for different joiners
Ankit Nautiyal
ankit.k.nautiyal at intel.com
Mon Sep 16 09:59:39 UTC 2024
From: Stanislav Lisovskiy <stanislav.lisovskiy at intel.com>
Ultrajoiner case requires special treatment where both reverse and
staight order iteration doesn't work(for instance disabling case requires
order to be: primary master, slaves, secondary master).
Lets unify our approach by combining the bigjoiner primary and
secondary masks into one, with one of them shifted up to some high bits,
and then iterate the combined bitmask either forward or backward.
This order works for nonjoiner, bigjoiner, or ultrajoiner case.
v2: Fix checkpatch warnings. (Ankit)
v3: Use combined bigjoiner masks to have two iterators for enable and
disable case. (Ville)
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy at intel.com>
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal at intel.com>
---
drivers/gpu/drm/i915/display/intel_ddi.c | 16 +++++----
drivers/gpu/drm/i915/display/intel_display.c | 36 +++++++++++---------
drivers/gpu/drm/i915/display/intel_display.h | 14 ++++++++
drivers/gpu/drm/i915/display/intel_dp_mst.c | 16 +++++----
4 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
index b1c294236cc8..df3483aee17f 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -3117,9 +3117,11 @@ static void intel_ddi_post_disable_hdmi_or_sst(struct intel_atomic_state *state,
{
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct intel_crtc *pipe_crtc;
+ u8 pipes;
+ int i;
- for_each_intel_crtc_in_pipe_mask(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(old_crtc_state)) {
+ for_each_crtc_in_masks(dev_priv, pipe_crtc, bigjoiner_primary_pipes(old_crtc_state),
+ bigjoiner_secondary_pipes(old_crtc_state), pipes, i) {
const struct intel_crtc_state *old_pipe_crtc_state =
intel_atomic_get_old_crtc_state(state, pipe_crtc);
@@ -3130,8 +3132,8 @@ static void intel_ddi_post_disable_hdmi_or_sst(struct intel_atomic_state *state,
intel_ddi_disable_transcoder_func(old_crtc_state);
- for_each_intel_crtc_in_pipe_mask(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(old_crtc_state)) {
+ for_each_crtc_in_masks(dev_priv, pipe_crtc, bigjoiner_primary_pipes(old_crtc_state),
+ bigjoiner_secondary_pipes(old_crtc_state), pipes, i) {
const struct intel_crtc_state *old_pipe_crtc_state =
intel_atomic_get_old_crtc_state(state, pipe_crtc);
@@ -3384,6 +3386,8 @@ static void intel_enable_ddi(struct intel_atomic_state *state,
{
struct drm_i915_private *i915 = to_i915(encoder->base.dev);
struct intel_crtc *pipe_crtc;
+ u8 pipes;
+ int i;
intel_ddi_enable_transcoder_func(encoder, crtc_state);
@@ -3394,8 +3398,8 @@ static void intel_enable_ddi(struct intel_atomic_state *state,
intel_ddi_wait_for_fec_status(encoder, crtc_state, true);
- for_each_intel_crtc_in_pipe_mask_reverse(&i915->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(crtc_state)) {
+ for_each_crtc_in_masks_reverse(i915, pipe_crtc, bigjoiner_primary_pipes(crtc_state),
+ bigjoiner_secondary_pipes(crtc_state), pipes, i) {
const struct intel_crtc_state *pipe_crtc_state =
intel_atomic_get_new_crtc_state(state, pipe_crtc);
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 768a87007369..b19c99313cec 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -259,7 +259,7 @@ static bool is_bigjoiner(const struct intel_crtc_state *crtc_state)
return hweight8(crtc_state->joiner_pipes) >= 2;
}
-static u8 bigjoiner_primary_pipes(const struct intel_crtc_state *crtc_state)
+u8 bigjoiner_primary_pipes(const struct intel_crtc_state *crtc_state)
{
if (!is_bigjoiner(crtc_state))
return 0;
@@ -267,7 +267,7 @@ static u8 bigjoiner_primary_pipes(const struct intel_crtc_state *crtc_state)
return crtc_state->joiner_pipes & (0b01010101 << joiner_primary_pipe(crtc_state));
}
-static u8 bigjoiner_secondary_pipes(const struct intel_crtc_state *crtc_state)
+u8 bigjoiner_secondary_pipes(const struct intel_crtc_state *crtc_state)
{
if (!is_bigjoiner(crtc_state))
return 0;
@@ -1746,18 +1746,20 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
enum transcoder cpu_transcoder = new_crtc_state->cpu_transcoder;
struct intel_crtc *pipe_crtc;
+ u8 pipes;
+ int i;
if (drm_WARN_ON(&dev_priv->drm, crtc->active))
return;
- for_each_intel_crtc_in_pipe_mask_reverse(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(new_crtc_state))
+ for_each_crtc_in_masks_reverse(dev_priv, pipe_crtc, bigjoiner_primary_pipes(new_crtc_state),
+ bigjoiner_secondary_pipes(new_crtc_state), pipes, i)
intel_dmc_enable_pipe(display, pipe_crtc->pipe);
intel_encoders_pre_pll_enable(state, crtc);
- for_each_intel_crtc_in_pipe_mask_reverse(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(new_crtc_state)) {
+ for_each_crtc_in_masks_reverse(dev_priv, pipe_crtc, bigjoiner_primary_pipes(new_crtc_state),
+ bigjoiner_secondary_pipes(new_crtc_state), pipes, i) {
const struct intel_crtc_state *pipe_crtc_state =
intel_atomic_get_new_crtc_state(state, pipe_crtc);
@@ -1767,8 +1769,8 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,
intel_encoders_pre_enable(state, crtc);
- for_each_intel_crtc_in_pipe_mask_reverse(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(new_crtc_state)) {
+ for_each_crtc_in_masks_reverse(dev_priv, pipe_crtc, bigjoiner_primary_pipes(new_crtc_state),
+ bigjoiner_secondary_pipes(new_crtc_state), pipes, i) {
const struct intel_crtc_state *pipe_crtc_state =
intel_atomic_get_new_crtc_state(state, pipe_crtc);
@@ -1786,8 +1788,8 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,
if (!transcoder_is_dsi(cpu_transcoder))
hsw_configure_cpu_transcoder(new_crtc_state);
- for_each_intel_crtc_in_pipe_mask_reverse(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(new_crtc_state)) {
+ for_each_crtc_in_masks_reverse(dev_priv, pipe_crtc, bigjoiner_primary_pipes(new_crtc_state),
+ bigjoiner_secondary_pipes(new_crtc_state), pipes, i) {
const struct intel_crtc_state *pipe_crtc_state =
intel_atomic_get_new_crtc_state(state, pipe_crtc);
@@ -1822,8 +1824,8 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,
intel_encoders_enable(state, crtc);
- for_each_intel_crtc_in_pipe_mask_reverse(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(new_crtc_state)) {
+ for_each_crtc_in_masks_reverse(dev_priv, pipe_crtc, bigjoiner_primary_pipes(new_crtc_state),
+ bigjoiner_secondary_pipes(new_crtc_state), pipes, i) {
const struct intel_crtc_state *pipe_crtc_state =
intel_atomic_get_new_crtc_state(state, pipe_crtc);
enum pipe hsw_workaround_pipe;
@@ -1910,6 +1912,8 @@ static void hsw_crtc_disable(struct intel_atomic_state *state,
const struct intel_crtc_state *old_crtc_state =
intel_atomic_get_old_crtc_state(state, crtc);
struct intel_crtc *pipe_crtc;
+ u8 pipes;
+ int i;
/*
* FIXME collapse everything to one hook.
@@ -1918,8 +1922,8 @@ static void hsw_crtc_disable(struct intel_atomic_state *state,
intel_encoders_disable(state, crtc);
intel_encoders_post_disable(state, crtc);
- for_each_intel_crtc_in_pipe_mask(&i915->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(old_crtc_state)) {
+ for_each_crtc_in_masks(i915, pipe_crtc, bigjoiner_primary_pipes(old_crtc_state),
+ bigjoiner_secondary_pipes(old_crtc_state), pipes, i) {
const struct intel_crtc_state *old_pipe_crtc_state =
intel_atomic_get_old_crtc_state(state, pipe_crtc);
@@ -1928,8 +1932,8 @@ static void hsw_crtc_disable(struct intel_atomic_state *state,
intel_encoders_post_pll_disable(state, crtc);
- for_each_intel_crtc_in_pipe_mask(&i915->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(old_crtc_state))
+ for_each_crtc_in_masks(i915, pipe_crtc, bigjoiner_primary_pipes(old_crtc_state),
+ bigjoiner_secondary_pipes(old_crtc_state), pipes, i)
intel_dmc_disable_pipe(display, pipe_crtc->pipe);
}
diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
index b5cafc2f1141..767e555ed50d 100644
--- a/drivers/gpu/drm/i915/display/intel_display.h
+++ b/drivers/gpu/drm/i915/display/intel_display.h
@@ -275,6 +275,18 @@ enum phy_fia {
&(dev)->mode_config.crtc_list, \
base.head)
+#define for_each_crtc_in_masks(__dev_priv, crtc, first_pipes, second_pipes, pipes, i) \
+ for ((i) = 0, (pipes) = ((first_pipes) | ((second_pipes) << 4)) ? ((first_pipes) | ((second_pipes) << 4)) : 0xF; \
+ (i) < 8 && ((crtc) = intel_crtc_for_pipe(to_intel_display(&__dev_priv->drm), (i) & 3), 1); \
+ (i)++) \
+ for_each_if((crtc) && (pipes) & BIT(i))
+
+#define for_each_crtc_in_masks_reverse(__dev_priv, crtc, first_pipes, second_pipes, pipes, i) \
+ for ((i) = 7, (pipes) = ((first_pipes) | ((second_pipes) << 4)) ? ((first_pipes) | ((second_pipes) << 4)) : 0xF; \
+ (i) >= 0 && ((crtc) = intel_crtc_for_pipe(to_intel_display(&__dev_priv->drm), (i) & 3), 1); \
+ (i)--) \
+ for_each_if((crtc) && (pipes) & BIT(i))
+
#define for_each_intel_crtc_in_pipe_mask(dev, intel_crtc, pipe_mask) \
list_for_each_entry(intel_crtc, \
&(dev)->mode_config.crtc_list, \
@@ -592,5 +604,7 @@ bool assert_port_valid(struct drm_i915_private *i915, enum port port);
bool intel_scanout_needs_vtd_wa(struct drm_i915_private *i915);
int intel_crtc_num_joined_pipes(const struct intel_crtc_state *crtc_state);
+u8 bigjoiner_primary_pipes(const struct intel_crtc_state *crtc_state);
+u8 bigjoiner_secondary_pipes(const struct intel_crtc_state *crtc_state);
#endif
diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
index 3285b3e6c489..64abdaa0475e 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -1005,6 +1005,8 @@ static void intel_mst_post_disable_dp(struct intel_atomic_state *state,
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_crtc *pipe_crtc;
bool last_mst_stream;
+ u8 pipes;
+ int i;
intel_dp->active_mst_links--;
last_mst_stream = intel_dp->active_mst_links == 0;
@@ -1012,8 +1014,8 @@ static void intel_mst_post_disable_dp(struct intel_atomic_state *state,
DISPLAY_VER(dev_priv) >= 12 && last_mst_stream &&
!intel_dp_mst_is_master_trans(old_crtc_state));
- for_each_intel_crtc_in_pipe_mask(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(old_crtc_state)) {
+ for_each_crtc_in_masks(dev_priv, pipe_crtc, bigjoiner_primary_pipes(old_crtc_state),
+ bigjoiner_secondary_pipes(old_crtc_state), pipes, i) {
const struct intel_crtc_state *old_pipe_crtc_state =
intel_atomic_get_old_crtc_state(state, pipe_crtc);
@@ -1037,8 +1039,8 @@ static void intel_mst_post_disable_dp(struct intel_atomic_state *state,
intel_ddi_disable_transcoder_func(old_crtc_state);
- for_each_intel_crtc_in_pipe_mask(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(old_crtc_state)) {
+ for_each_crtc_in_masks(dev_priv, pipe_crtc, bigjoiner_primary_pipes(old_crtc_state),
+ bigjoiner_secondary_pipes(old_crtc_state), pipes, i) {
const struct intel_crtc_state *old_pipe_crtc_state =
intel_atomic_get_old_crtc_state(state, pipe_crtc);
@@ -1257,6 +1259,8 @@ static void intel_mst_enable_dp(struct intel_atomic_state *state,
enum transcoder trans = pipe_config->cpu_transcoder;
bool first_mst_stream = intel_dp->active_mst_links == 1;
struct intel_crtc *pipe_crtc;
+ u8 pipes;
+ int i;
int ret;
drm_WARN_ON(&dev_priv->drm, pipe_config->has_pch_encoder);
@@ -1304,8 +1308,8 @@ static void intel_mst_enable_dp(struct intel_atomic_state *state,
intel_enable_transcoder(pipe_config);
- for_each_intel_crtc_in_pipe_mask_reverse(&dev_priv->drm, pipe_crtc,
- intel_crtc_joined_pipe_mask(pipe_config)) {
+ for_each_crtc_in_masks_reverse(dev_priv, pipe_crtc, bigjoiner_primary_pipes(pipe_config),
+ bigjoiner_secondary_pipes(pipe_config), pipes, i) {
const struct intel_crtc_state *pipe_crtc_state =
intel_atomic_get_new_crtc_state(state, pipe_crtc);
--
2.45.2
More information about the Intel-gfx-trybot
mailing list