Skip to content

Commit

Permalink
drm/i915: Hold struct_mutex during i915_save_state/i915_restore_state
Browse files Browse the repository at this point in the history
Lots of register access in these functions, some of which requires the
struct mutex.

These functions now hold the struct mutex across the calls to
i915_save_display and i915_restore_display, and so the internal mutex
calls in those functions have been removed. To ensure that no-one else
was calling them (and hence violating the new required locking
invarient), those functions have been made static.

gen6_enable_rps locks the struct mutex, and so i915_restore_state
unlocks the mutex around calls to that function.

Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
Keith Packard committed Jun 29, 2011
1 parent 0d72c6f commit d70bed1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 0 additions & 2 deletions drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,6 @@ extern unsigned int i915_enable_fbc;

extern int i915_suspend(struct drm_device *dev, pm_message_t state);
extern int i915_resume(struct drm_device *dev);
extern void i915_save_display(struct drm_device *dev);
extern void i915_restore_display(struct drm_device *dev);
extern int i915_master_create(struct drm_device *dev, struct drm_master *master);
extern void i915_master_destroy(struct drm_device *dev, struct drm_master *master);

Expand Down
19 changes: 13 additions & 6 deletions drivers/gpu/drm/i915/i915_suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ static void i915_restore_modeset_reg(struct drm_device *dev)
return;
}

void i915_save_display(struct drm_device *dev)
static void i915_save_display(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;

Expand Down Expand Up @@ -678,7 +678,6 @@ void i915_save_display(struct drm_device *dev)
}

/* VGA state */
mutex_lock(&dev->struct_mutex);
dev_priv->saveVGA0 = I915_READ(VGA0);
dev_priv->saveVGA1 = I915_READ(VGA1);
dev_priv->saveVGA_PD = I915_READ(VGA_PD);
Expand All @@ -688,10 +687,9 @@ void i915_save_display(struct drm_device *dev)
dev_priv->saveVGACNTRL = I915_READ(VGACNTRL);

i915_save_vga(dev);
mutex_unlock(&dev->struct_mutex);
}

void i915_restore_display(struct drm_device *dev)
static void i915_restore_display(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;

Expand Down Expand Up @@ -783,15 +781,13 @@ void i915_restore_display(struct drm_device *dev)
else
I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL);

mutex_lock(&dev->struct_mutex);
I915_WRITE(VGA0, dev_priv->saveVGA0);
I915_WRITE(VGA1, dev_priv->saveVGA1);
I915_WRITE(VGA_PD, dev_priv->saveVGA_PD);
POSTING_READ(VGA_PD);
udelay(150);

i915_restore_vga(dev);
mutex_unlock(&dev->struct_mutex);
}

int i915_save_state(struct drm_device *dev)
Expand All @@ -801,6 +797,8 @@ int i915_save_state(struct drm_device *dev)

pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB);

mutex_lock(&dev->struct_mutex);

/* Hardware status page */
dev_priv->saveHWS = I915_READ(HWS_PGA);

Expand Down Expand Up @@ -840,6 +838,8 @@ int i915_save_state(struct drm_device *dev)
for (i = 0; i < 3; i++)
dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2));

mutex_unlock(&dev->struct_mutex);

return 0;
}

Expand All @@ -850,6 +850,8 @@ int i915_restore_state(struct drm_device *dev)

pci_write_config_byte(dev->pdev, LBB, dev_priv->saveLBB);

mutex_lock(&dev->struct_mutex);

/* Hardware status page */
I915_WRITE(HWS_PGA, dev_priv->saveHWS);

Expand All @@ -867,6 +869,7 @@ int i915_restore_state(struct drm_device *dev)
I915_WRITE(IER, dev_priv->saveIER);
I915_WRITE(IMR, dev_priv->saveIMR);
}
mutex_unlock(&dev->struct_mutex);

intel_init_clock_gating(dev);

Expand All @@ -878,6 +881,8 @@ int i915_restore_state(struct drm_device *dev)
if (IS_GEN6(dev))
gen6_enable_rps(dev_priv);

mutex_lock(&dev->struct_mutex);

/* Cache mode state */
I915_WRITE (CACHE_MODE_0, dev_priv->saveCACHE_MODE_0 | 0xffff0000);

Expand All @@ -891,6 +896,8 @@ int i915_restore_state(struct drm_device *dev)
for (i = 0; i < 3; i++)
I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]);

mutex_unlock(&dev->struct_mutex);

intel_i2c_reset(dev);

return 0;
Expand Down

0 comments on commit d70bed1

Please sign in to comment.