drm/i915: properly wait for SBI status

Somehow this went unnoticed in the past reviews, but the condition would
never timeout properly.

This was initially introduced in the v2 of original SBI enabling patch.
Highly embarrassing.

Note that we now actually time out for the read, which resulted in gcc
complaining that we can now return unitialized garbage if that
happens. There's not much we can do here because there's not much
point in thread -EIO all the way down through these functions. Hence
simply shut up the compiler.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
[danvet: Added note and squashed uninitialized value shut-up into this
patch.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Eugeni Dodonov 2012-06-08 16:43:19 -03:00 коммит произвёл Daniel Vetter
Родитель aaa377302b
Коммит 39fb50f617
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -1350,7 +1350,7 @@ intel_sbi_write(struct drm_i915_private *dev_priv, u16 reg, u32 value)
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&dev_priv->dpio_lock, flags); spin_lock_irqsave(&dev_priv->dpio_lock, flags);
if (wait_for((I915_READ(SBI_CTL_STAT) & SBI_READY) == 0, if (wait_for((I915_READ(SBI_CTL_STAT) & SBI_BUSY) == 0,
100)) { 100)) {
DRM_ERROR("timeout waiting for SBI to become ready\n"); DRM_ERROR("timeout waiting for SBI to become ready\n");
goto out_unlock; goto out_unlock;
@ -1364,7 +1364,7 @@ intel_sbi_write(struct drm_i915_private *dev_priv, u16 reg, u32 value)
SBI_BUSY | SBI_BUSY |
SBI_CTL_OP_CRWR); SBI_CTL_OP_CRWR);
if (wait_for((I915_READ(SBI_CTL_STAT) & (SBI_READY | SBI_RESPONSE_SUCCESS)) == 0, if (wait_for((I915_READ(SBI_CTL_STAT) & (SBI_BUSY | SBI_RESPONSE_FAIL)) == 0,
100)) { 100)) {
DRM_ERROR("timeout waiting for SBI to complete write transaction\n"); DRM_ERROR("timeout waiting for SBI to complete write transaction\n");
goto out_unlock; goto out_unlock;
@ -1378,10 +1378,10 @@ static u32
intel_sbi_read(struct drm_i915_private *dev_priv, u16 reg) intel_sbi_read(struct drm_i915_private *dev_priv, u16 reg)
{ {
unsigned long flags; unsigned long flags;
u32 value; u32 value = 0;
spin_lock_irqsave(&dev_priv->dpio_lock, flags); spin_lock_irqsave(&dev_priv->dpio_lock, flags);
if (wait_for((I915_READ(SBI_CTL_STAT) & SBI_READY) == 0, if (wait_for((I915_READ(SBI_CTL_STAT) & SBI_BUSY) == 0,
100)) { 100)) {
DRM_ERROR("timeout waiting for SBI to become ready\n"); DRM_ERROR("timeout waiting for SBI to become ready\n");
goto out_unlock; goto out_unlock;
@ -1393,7 +1393,7 @@ intel_sbi_read(struct drm_i915_private *dev_priv, u16 reg)
SBI_BUSY | SBI_BUSY |
SBI_CTL_OP_CRRD); SBI_CTL_OP_CRRD);
if (wait_for((I915_READ(SBI_CTL_STAT) & (SBI_READY | SBI_RESPONSE_SUCCESS)) == 0, if (wait_for((I915_READ(SBI_CTL_STAT) & (SBI_BUSY | SBI_RESPONSE_FAIL)) == 0,
100)) { 100)) {
DRM_ERROR("timeout waiting for SBI to complete read transaction\n"); DRM_ERROR("timeout waiting for SBI to complete read transaction\n");
goto out_unlock; goto out_unlock;