Skip to content

Commit

Permalink
drm/i915: add a dedicated mutex for VLV/CHV IOSF sideband
Browse files Browse the repository at this point in the history
The VLV/CHV IOSF sideband is unrelated to pcode. It's just confusing to
piggyback on the same mutex. Add a dedicated lock with init and cleanup
functions.

Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/31ccbf33c6b6114d0bcb40a2e174f19162d4e177.1730193891.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
  • Loading branch information
Jani Nikula committed Nov 5, 2024
1 parent f270857 commit a72e1c1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/i915_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
#include "intel_pcode.h"
#include "intel_region_ttm.h"
#include "intel_sbi.h"
#include "vlv_sideband.h"
#include "vlv_suspend.h"

static const struct drm_driver i915_drm_driver;
Expand Down Expand Up @@ -233,6 +234,7 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
spin_lock_init(&dev_priv->gpu_error.lock);

intel_sbi_init(dev_priv);
vlv_iosf_sb_init(dev_priv);
mutex_init(&dev_priv->sb_lock);
cpu_latency_qos_add_request(&dev_priv->sb_qos, PM_QOS_DEFAULT_VALUE);

Expand Down Expand Up @@ -294,6 +296,7 @@ static void i915_driver_late_release(struct drm_i915_private *dev_priv)

cpu_latency_qos_remove_request(&dev_priv->sb_qos);
mutex_destroy(&dev_priv->sb_lock);
vlv_iosf_sb_fini(dev_priv);
intel_sbi_fini(dev_priv);

i915_params_free(&dev_priv->params);
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ struct drm_i915_private {
/* LPT/WPT IOSF sideband protection */
struct mutex sbi_lock;

/* VLV/CHV IOSF sideband */
struct {
struct mutex lock; /* protect sideband access */
} vlv_iosf_sb;

/* Sideband mailbox protection */
struct mutex sb_lock;
struct pm_qos_request sb_qos;
Expand Down
18 changes: 15 additions & 3 deletions drivers/gpu/drm/i915/vlv_sideband.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ void vlv_iosf_sb_get(struct drm_i915_private *i915, unsigned long ports)
if (ports & BIT(VLV_IOSF_SB_PUNIT))
__vlv_punit_get(i915);

mutex_lock(&i915->sb_lock);
mutex_lock(&i915->vlv_iosf_sb.lock);
}

void vlv_iosf_sb_put(struct drm_i915_private *i915, unsigned long ports)
{
mutex_unlock(&i915->sb_lock);
mutex_unlock(&i915->vlv_iosf_sb.lock);

if (ports & BIT(VLV_IOSF_SB_PUNIT))
__vlv_punit_put(i915);
Expand All @@ -81,7 +81,7 @@ static int vlv_sideband_rw(struct drm_i915_private *i915,
const bool is_read = (opcode == SB_MRD_NP || opcode == SB_CRRDDA_NP);
int err;

lockdep_assert_held(&i915->sb_lock);
lockdep_assert_held(&i915->vlv_iosf_sb.lock);
if (port == IOSF_PORT_PUNIT)
iosf_mbi_assert_punit_acquired();

Expand Down Expand Up @@ -249,3 +249,15 @@ void vlv_flisdsi_write(struct drm_i915_private *i915, u32 reg, u32 val)
vlv_sideband_rw(i915, DPIO_DEVFN, IOSF_PORT_FLISDSI, SB_CRWRDA_NP,
reg, &val);
}

void vlv_iosf_sb_init(struct drm_i915_private *i915)
{
if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915))
mutex_init(&i915->vlv_iosf_sb.lock);
}

void vlv_iosf_sb_fini(struct drm_i915_private *i915)
{
if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915))
mutex_destroy(&i915->vlv_iosf_sb.lock);
}
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/vlv_sideband.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ enum {
VLV_IOSF_SB_PUNIT,
};

void vlv_iosf_sb_init(struct drm_i915_private *i915);
void vlv_iosf_sb_fini(struct drm_i915_private *i915);

void vlv_iosf_sb_get(struct drm_i915_private *i915, unsigned long ports);
void vlv_iosf_sb_put(struct drm_i915_private *i915, unsigned long ports);

Expand Down

0 comments on commit a72e1c1

Please sign in to comment.