Commit d2d551c0 authored by Daniele Ceraolo Spurio's avatar Daniele Ceraolo Spurio Committed by Chris Wilson

drm/i915: intel_wait_for_register_fw to uncore

The intel_uncore structure is the owner of register access, so
subclass the function to it.

While at it, use a local uncore var and switch to the new read/write
functions where it makes sense.
Signed-off-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190325214940.23632-8-daniele.ceraolospurio@intel.com
parent 4319382e
...@@ -245,10 +245,12 @@ static int ironlake_do_reset(struct drm_i915_private *dev_priv, ...@@ -245,10 +245,12 @@ static int ironlake_do_reset(struct drm_i915_private *dev_priv,
unsigned int engine_mask, unsigned int engine_mask,
unsigned int retry) unsigned int retry)
{ {
struct intel_uncore *uncore = &dev_priv->uncore;
int ret; int ret;
I915_WRITE_FW(ILK_GDSR, ILK_GRDOM_RENDER | ILK_GRDOM_RESET_ENABLE); intel_uncore_write_fw(uncore, ILK_GDSR,
ret = __intel_wait_for_register_fw(dev_priv, ILK_GDSR, ILK_GRDOM_RENDER | ILK_GRDOM_RESET_ENABLE);
ret = __intel_wait_for_register_fw(uncore, ILK_GDSR,
ILK_GRDOM_RESET_ENABLE, 0, ILK_GRDOM_RESET_ENABLE, 0,
5000, 0, 5000, 0,
NULL); NULL);
...@@ -257,8 +259,9 @@ static int ironlake_do_reset(struct drm_i915_private *dev_priv, ...@@ -257,8 +259,9 @@ static int ironlake_do_reset(struct drm_i915_private *dev_priv,
goto out; goto out;
} }
I915_WRITE_FW(ILK_GDSR, ILK_GRDOM_MEDIA | ILK_GRDOM_RESET_ENABLE); intel_uncore_write_fw(uncore, ILK_GDSR,
ret = __intel_wait_for_register_fw(dev_priv, ILK_GDSR, ILK_GRDOM_MEDIA | ILK_GRDOM_RESET_ENABLE);
ret = __intel_wait_for_register_fw(uncore, ILK_GDSR,
ILK_GRDOM_RESET_ENABLE, 0, ILK_GRDOM_RESET_ENABLE, 0,
5000, 0, 5000, 0,
NULL); NULL);
...@@ -268,8 +271,8 @@ static int ironlake_do_reset(struct drm_i915_private *dev_priv, ...@@ -268,8 +271,8 @@ static int ironlake_do_reset(struct drm_i915_private *dev_priv,
} }
out: out:
I915_WRITE_FW(ILK_GDSR, 0); intel_uncore_write_fw(uncore, ILK_GDSR, 0);
POSTING_READ_FW(ILK_GDSR); intel_uncore_posting_read_fw(uncore, ILK_GDSR);
return ret; return ret;
} }
...@@ -277,6 +280,7 @@ static int ironlake_do_reset(struct drm_i915_private *dev_priv, ...@@ -277,6 +280,7 @@ static int ironlake_do_reset(struct drm_i915_private *dev_priv,
static int gen6_hw_domain_reset(struct drm_i915_private *dev_priv, static int gen6_hw_domain_reset(struct drm_i915_private *dev_priv,
u32 hw_domain_mask) u32 hw_domain_mask)
{ {
struct intel_uncore *uncore = &dev_priv->uncore;
int err; int err;
/* /*
...@@ -284,10 +288,10 @@ static int gen6_hw_domain_reset(struct drm_i915_private *dev_priv, ...@@ -284,10 +288,10 @@ static int gen6_hw_domain_reset(struct drm_i915_private *dev_priv,
* for fifo space for the write or forcewake the chip for * for fifo space for the write or forcewake the chip for
* the read * the read
*/ */
I915_WRITE_FW(GEN6_GDRST, hw_domain_mask); intel_uncore_write_fw(uncore, GEN6_GDRST, hw_domain_mask);
/* Wait for the device to ack the reset requests */ /* Wait for the device to ack the reset requests */
err = __intel_wait_for_register_fw(dev_priv, err = __intel_wait_for_register_fw(uncore,
GEN6_GDRST, hw_domain_mask, 0, GEN6_GDRST, hw_domain_mask, 0,
500, 0, 500, 0,
NULL); NULL);
...@@ -330,6 +334,7 @@ static int gen6_reset_engines(struct drm_i915_private *i915, ...@@ -330,6 +334,7 @@ static int gen6_reset_engines(struct drm_i915_private *i915,
static u32 gen11_lock_sfc(struct drm_i915_private *dev_priv, static u32 gen11_lock_sfc(struct drm_i915_private *dev_priv,
struct intel_engine_cs *engine) struct intel_engine_cs *engine)
{ {
struct intel_uncore *uncore = &dev_priv->uncore;
u8 vdbox_sfc_access = RUNTIME_INFO(dev_priv)->vdbox_sfc_access; u8 vdbox_sfc_access = RUNTIME_INFO(dev_priv)->vdbox_sfc_access;
i915_reg_t sfc_forced_lock, sfc_forced_lock_ack; i915_reg_t sfc_forced_lock, sfc_forced_lock_ack;
u32 sfc_forced_lock_bit, sfc_forced_lock_ack_bit; u32 sfc_forced_lock_bit, sfc_forced_lock_ack_bit;
...@@ -377,10 +382,9 @@ static u32 gen11_lock_sfc(struct drm_i915_private *dev_priv, ...@@ -377,10 +382,9 @@ static u32 gen11_lock_sfc(struct drm_i915_private *dev_priv,
* ends up being locked to the engine we want to reset, we have to reset * ends up being locked to the engine we want to reset, we have to reset
* it as well (we will unlock it once the reset sequence is completed). * it as well (we will unlock it once the reset sequence is completed).
*/ */
I915_WRITE_FW(sfc_forced_lock, intel_uncore_rmw_or_fw(uncore, sfc_forced_lock, sfc_forced_lock_bit);
I915_READ_FW(sfc_forced_lock) | sfc_forced_lock_bit);
if (__intel_wait_for_register_fw(dev_priv, if (__intel_wait_for_register_fw(uncore,
sfc_forced_lock_ack, sfc_forced_lock_ack,
sfc_forced_lock_ack_bit, sfc_forced_lock_ack_bit,
sfc_forced_lock_ack_bit, sfc_forced_lock_ack_bit,
...@@ -389,7 +393,7 @@ static u32 gen11_lock_sfc(struct drm_i915_private *dev_priv, ...@@ -389,7 +393,7 @@ static u32 gen11_lock_sfc(struct drm_i915_private *dev_priv,
return 0; return 0;
} }
if (I915_READ_FW(sfc_usage) & sfc_usage_bit) if (intel_uncore_read_fw(uncore, sfc_usage) & sfc_usage_bit)
return sfc_reset_bit; return sfc_reset_bit;
return 0; return 0;
...@@ -465,13 +469,13 @@ static int gen11_reset_engines(struct drm_i915_private *i915, ...@@ -465,13 +469,13 @@ static int gen11_reset_engines(struct drm_i915_private *i915,
static int gen8_engine_reset_prepare(struct intel_engine_cs *engine) static int gen8_engine_reset_prepare(struct intel_engine_cs *engine)
{ {
struct drm_i915_private *dev_priv = engine->i915; struct intel_uncore *uncore = &engine->i915->uncore;
int ret; int ret;
I915_WRITE_FW(RING_RESET_CTL(engine->mmio_base), intel_uncore_write_fw(uncore, RING_RESET_CTL(engine->mmio_base),
_MASKED_BIT_ENABLE(RESET_CTL_REQUEST_RESET)); _MASKED_BIT_ENABLE(RESET_CTL_REQUEST_RESET));
ret = __intel_wait_for_register_fw(dev_priv, ret = __intel_wait_for_register_fw(uncore,
RING_RESET_CTL(engine->mmio_base), RING_RESET_CTL(engine->mmio_base),
RESET_CTL_READY_TO_RESET, RESET_CTL_READY_TO_RESET,
RESET_CTL_READY_TO_RESET, RESET_CTL_READY_TO_RESET,
......
...@@ -383,7 +383,8 @@ static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv, ...@@ -383,7 +383,8 @@ static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,
* The flag should get set in 100us according to the HW team, but * The flag should get set in 100us according to the HW team, but
* use 1ms due to occasional timeouts observed with that. * use 1ms due to occasional timeouts observed with that.
*/ */
if (intel_wait_for_register_fw(dev_priv, BXT_PORT_CL1CM_DW0(phy), if (intel_wait_for_register_fw(&dev_priv->uncore,
BXT_PORT_CL1CM_DW0(phy),
PHY_RESERVED | PHY_POWER_GOOD, PHY_RESERVED | PHY_POWER_GOOD,
PHY_POWER_GOOD, PHY_POWER_GOOD,
1)) 1))
......
...@@ -817,20 +817,20 @@ u64 intel_engine_get_last_batch_head(const struct intel_engine_cs *engine) ...@@ -817,20 +817,20 @@ u64 intel_engine_get_last_batch_head(const struct intel_engine_cs *engine)
int intel_engine_stop_cs(struct intel_engine_cs *engine) int intel_engine_stop_cs(struct intel_engine_cs *engine)
{ {
struct drm_i915_private *dev_priv = engine->i915; struct intel_uncore *uncore = &engine->i915->uncore;
const u32 base = engine->mmio_base; const u32 base = engine->mmio_base;
const i915_reg_t mode = RING_MI_MODE(base); const i915_reg_t mode = RING_MI_MODE(base);
int err; int err;
if (INTEL_GEN(dev_priv) < 3) if (INTEL_GEN(engine->i915) < 3)
return -ENODEV; return -ENODEV;
GEM_TRACE("%s\n", engine->name); GEM_TRACE("%s\n", engine->name);
I915_WRITE_FW(mode, _MASKED_BIT_ENABLE(STOP_RING)); intel_uncore_write_fw(uncore, mode, _MASKED_BIT_ENABLE(STOP_RING));
err = 0; err = 0;
if (__intel_wait_for_register_fw(dev_priv, if (__intel_wait_for_register_fw(uncore,
mode, MODE_IDLE, MODE_IDLE, mode, MODE_IDLE, MODE_IDLE,
1000, 0, 1000, 0,
NULL)) { NULL)) {
...@@ -839,7 +839,7 @@ int intel_engine_stop_cs(struct intel_engine_cs *engine) ...@@ -839,7 +839,7 @@ int intel_engine_stop_cs(struct intel_engine_cs *engine)
} }
/* A final mmio read to let GPU writes be hopefully flushed to memory */ /* A final mmio read to let GPU writes be hopefully flushed to memory */
POSTING_READ_FW(mode); intel_uncore_posting_read_fw(uncore, mode);
return err; return err;
} }
......
...@@ -398,6 +398,7 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len, ...@@ -398,6 +398,7 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len,
u32 *response_buf, u32 response_buf_size) u32 *response_buf, u32 response_buf_size)
{ {
struct drm_i915_private *dev_priv = guc_to_i915(guc); struct drm_i915_private *dev_priv = guc_to_i915(guc);
struct intel_uncore *uncore = &dev_priv->uncore;
u32 status; u32 status;
int i; int i;
int ret; int ret;
...@@ -414,12 +415,12 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len, ...@@ -414,12 +415,12 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len,
*action != INTEL_GUC_ACTION_DEREGISTER_COMMAND_TRANSPORT_BUFFER); *action != INTEL_GUC_ACTION_DEREGISTER_COMMAND_TRANSPORT_BUFFER);
mutex_lock(&guc->send_mutex); mutex_lock(&guc->send_mutex);
intel_uncore_forcewake_get(&dev_priv->uncore, guc->send_regs.fw_domains); intel_uncore_forcewake_get(uncore, guc->send_regs.fw_domains);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
I915_WRITE(guc_send_reg(guc, i), action[i]); intel_uncore_write(uncore, guc_send_reg(guc, i), action[i]);
POSTING_READ(guc_send_reg(guc, i - 1)); intel_uncore_posting_read(uncore, guc_send_reg(guc, i - 1));
intel_guc_notify(guc); intel_guc_notify(guc);
...@@ -427,7 +428,7 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len, ...@@ -427,7 +428,7 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len,
* No GuC command should ever take longer than 10ms. * No GuC command should ever take longer than 10ms.
* Fast commands should still complete in 10us. * Fast commands should still complete in 10us.
*/ */
ret = __intel_wait_for_register_fw(dev_priv, ret = __intel_wait_for_register_fw(uncore,
guc_send_reg(guc, 0), guc_send_reg(guc, 0),
INTEL_GUC_MSG_TYPE_MASK, INTEL_GUC_MSG_TYPE_MASK,
INTEL_GUC_MSG_TYPE_RESPONSE << INTEL_GUC_MSG_TYPE_RESPONSE <<
...@@ -454,7 +455,7 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len, ...@@ -454,7 +455,7 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len,
ret = INTEL_GUC_MSG_TO_DATA(status); ret = INTEL_GUC_MSG_TO_DATA(status);
out: out:
intel_uncore_forcewake_put(&dev_priv->uncore, guc->send_regs.fw_domains); intel_uncore_forcewake_put(uncore, guc->send_regs.fw_domains);
mutex_unlock(&guc->send_mutex); mutex_unlock(&guc->send_mutex);
return ret; return ret;
......
...@@ -106,41 +106,46 @@ static int huc_fw_xfer(struct intel_uc_fw *huc_fw, struct i915_vma *vma) ...@@ -106,41 +106,46 @@ static int huc_fw_xfer(struct intel_uc_fw *huc_fw, struct i915_vma *vma)
{ {
struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw); struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw);
struct drm_i915_private *dev_priv = huc_to_i915(huc); struct drm_i915_private *dev_priv = huc_to_i915(huc);
struct intel_uncore *uncore = &dev_priv->uncore;
unsigned long offset = 0; unsigned long offset = 0;
u32 size; u32 size;
int ret; int ret;
GEM_BUG_ON(huc_fw->type != INTEL_UC_FW_TYPE_HUC); GEM_BUG_ON(huc_fw->type != INTEL_UC_FW_TYPE_HUC);
intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL); intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
/* Set the source address for the uCode */ /* Set the source address for the uCode */
offset = intel_guc_ggtt_offset(&dev_priv->guc, vma) + offset = intel_guc_ggtt_offset(&dev_priv->guc, vma) +
huc_fw->header_offset; huc_fw->header_offset;
I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset)); intel_uncore_write(uncore, DMA_ADDR_0_LOW,
I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF); lower_32_bits(offset));
intel_uncore_write(uncore, DMA_ADDR_0_HIGH,
upper_32_bits(offset) & 0xFFFF);
/* Hardware doesn't look at destination address for HuC. Set it to 0, /*
* Hardware doesn't look at destination address for HuC. Set it to 0,
* but still program the correct address space. * but still program the correct address space.
*/ */
I915_WRITE(DMA_ADDR_1_LOW, 0); intel_uncore_write(uncore, DMA_ADDR_1_LOW, 0);
I915_WRITE(DMA_ADDR_1_HIGH, DMA_ADDRESS_SPACE_WOPCM); intel_uncore_write(uncore, DMA_ADDR_1_HIGH, DMA_ADDRESS_SPACE_WOPCM);
size = huc_fw->header_size + huc_fw->ucode_size; size = huc_fw->header_size + huc_fw->ucode_size;
I915_WRITE(DMA_COPY_SIZE, size); intel_uncore_write(uncore, DMA_COPY_SIZE, size);
/* Start the DMA */ /* Start the DMA */
I915_WRITE(DMA_CTRL, _MASKED_BIT_ENABLE(HUC_UKERNEL | START_DMA)); intel_uncore_write(uncore, DMA_CTRL,
_MASKED_BIT_ENABLE(HUC_UKERNEL | START_DMA));
/* Wait for DMA to finish */ /* Wait for DMA to finish */
ret = intel_wait_for_register_fw(dev_priv, DMA_CTRL, START_DMA, 0, 100); ret = intel_wait_for_register_fw(uncore, DMA_CTRL, START_DMA, 0, 100);
DRM_DEBUG_DRIVER("HuC DMA transfer wait over with ret %d\n", ret); DRM_DEBUG_DRIVER("HuC DMA transfer wait over with ret %d\n", ret);
/* Disable the bits once DMA is over */ /* Disable the bits once DMA is over */
I915_WRITE(DMA_CTRL, _MASKED_BIT_DISABLE(HUC_UKERNEL)); intel_uncore_write(uncore, DMA_CTRL, _MASKED_BIT_DISABLE(HUC_UKERNEL));
intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL); intel_uncore_forcewake_put(uncore, FORCEWAKE_ALL);
return ret; return ret;
} }
......
...@@ -348,7 +348,7 @@ gmbus_wait_idle(struct drm_i915_private *dev_priv) ...@@ -348,7 +348,7 @@ gmbus_wait_idle(struct drm_i915_private *dev_priv)
add_wait_queue(&dev_priv->gmbus_wait_queue, &wait); add_wait_queue(&dev_priv->gmbus_wait_queue, &wait);
I915_WRITE_FW(GMBUS4, irq_enable); I915_WRITE_FW(GMBUS4, irq_enable);
ret = intel_wait_for_register_fw(dev_priv, ret = intel_wait_for_register_fw(&dev_priv->uncore,
GMBUS2, GMBUS_ACTIVE, 0, GMBUS2, GMBUS_ACTIVE, 0,
10); 10);
......
...@@ -9687,7 +9687,7 @@ int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val ...@@ -9687,7 +9687,7 @@ int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val
I915_WRITE_FW(GEN6_PCODE_DATA1, 0); I915_WRITE_FW(GEN6_PCODE_DATA1, 0);
I915_WRITE_FW(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox); I915_WRITE_FW(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
if (__intel_wait_for_register_fw(dev_priv, if (__intel_wait_for_register_fw(&dev_priv->uncore,
GEN6_PCODE_MAILBOX, GEN6_PCODE_READY, 0, GEN6_PCODE_MAILBOX, GEN6_PCODE_READY, 0,
500, 0, NULL)) { 500, 0, NULL)) {
DRM_ERROR("timeout waiting for pcode read (from mbox %x) to finish for %ps\n", DRM_ERROR("timeout waiting for pcode read (from mbox %x) to finish for %ps\n",
...@@ -9735,7 +9735,7 @@ int sandybridge_pcode_write_timeout(struct drm_i915_private *dev_priv, ...@@ -9735,7 +9735,7 @@ int sandybridge_pcode_write_timeout(struct drm_i915_private *dev_priv,
I915_WRITE_FW(GEN6_PCODE_DATA1, 0); I915_WRITE_FW(GEN6_PCODE_DATA1, 0);
I915_WRITE_FW(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox); I915_WRITE_FW(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
if (__intel_wait_for_register_fw(dev_priv, if (__intel_wait_for_register_fw(&dev_priv->uncore,
GEN6_PCODE_MAILBOX, GEN6_PCODE_READY, 0, GEN6_PCODE_MAILBOX, GEN6_PCODE_READY, 0,
fast_timeout_us, slow_timeout_ms, fast_timeout_us, slow_timeout_ms,
NULL)) { NULL)) {
......
...@@ -2051,23 +2051,23 @@ int intel_ring_cacheline_align(struct i915_request *rq) ...@@ -2051,23 +2051,23 @@ int intel_ring_cacheline_align(struct i915_request *rq)
static void gen6_bsd_submit_request(struct i915_request *request) static void gen6_bsd_submit_request(struct i915_request *request)
{ {
struct drm_i915_private *dev_priv = request->i915; struct intel_uncore *uncore = &request->i915->uncore;
intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL); intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
/* Every tail move must follow the sequence below */ /* Every tail move must follow the sequence below */
/* Disable notification that the ring is IDLE. The GT /* Disable notification that the ring is IDLE. The GT
* will then assume that it is busy and bring it out of rc6. * will then assume that it is busy and bring it out of rc6.
*/ */
I915_WRITE_FW(GEN6_BSD_SLEEP_PSMI_CONTROL, intel_uncore_write_fw(uncore, GEN6_BSD_SLEEP_PSMI_CONTROL,
_MASKED_BIT_ENABLE(GEN6_BSD_SLEEP_MSG_DISABLE)); _MASKED_BIT_ENABLE(GEN6_BSD_SLEEP_MSG_DISABLE));
/* Clear the context id. Here be magic! */ /* Clear the context id. Here be magic! */
I915_WRITE64_FW(GEN6_BSD_RNCID, 0x0); intel_uncore_write64_fw(uncore, GEN6_BSD_RNCID, 0x0);
/* Wait for the ring not to be idle, i.e. for it to wake up. */ /* Wait for the ring not to be idle, i.e. for it to wake up. */
if (__intel_wait_for_register_fw(dev_priv, if (__intel_wait_for_register_fw(uncore,
GEN6_BSD_SLEEP_PSMI_CONTROL, GEN6_BSD_SLEEP_PSMI_CONTROL,
GEN6_BSD_SLEEP_INDICATOR, GEN6_BSD_SLEEP_INDICATOR,
0, 0,
...@@ -2080,10 +2080,10 @@ static void gen6_bsd_submit_request(struct i915_request *request) ...@@ -2080,10 +2080,10 @@ static void gen6_bsd_submit_request(struct i915_request *request)
/* Let the ring send IDLE messages to the GT again, /* Let the ring send IDLE messages to the GT again,
* and so let it sleep to conserve power when idle. * and so let it sleep to conserve power when idle.
*/ */
I915_WRITE_FW(GEN6_BSD_SLEEP_PSMI_CONTROL, intel_uncore_write_fw(uncore, GEN6_BSD_SLEEP_PSMI_CONTROL,
_MASKED_BIT_DISABLE(GEN6_BSD_SLEEP_MSG_DISABLE)); _MASKED_BIT_DISABLE(GEN6_BSD_SLEEP_MSG_DISABLE));
intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL); intel_uncore_forcewake_put(uncore, FORCEWAKE_ALL);
} }
static int mi_flush_dw(struct i915_request *rq, u32 flags) static int mi_flush_dw(struct i915_request *rq, u32 flags)
......
...@@ -1759,7 +1759,7 @@ int i915_reg_read_ioctl(struct drm_device *dev, ...@@ -1759,7 +1759,7 @@ int i915_reg_read_ioctl(struct drm_device *dev,
/** /**
* __intel_wait_for_register_fw - wait until register matches expected state * __intel_wait_for_register_fw - wait until register matches expected state
* @dev_priv: the i915 device * @uncore: the struct intel_uncore
* @reg: the register to read * @reg: the register to read
* @mask: mask to apply to register value * @mask: mask to apply to register value
* @value: expected value * @value: expected value
...@@ -1783,7 +1783,7 @@ int i915_reg_read_ioctl(struct drm_device *dev, ...@@ -1783,7 +1783,7 @@ int i915_reg_read_ioctl(struct drm_device *dev,
* *
* Returns 0 if the register matches the desired condition, or -ETIMEOUT. * Returns 0 if the register matches the desired condition, or -ETIMEOUT.
*/ */
int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv, int __intel_wait_for_register_fw(struct intel_uncore *uncore,
i915_reg_t reg, i915_reg_t reg,
u32 mask, u32 mask,
u32 value, u32 value,
...@@ -1792,7 +1792,7 @@ int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv, ...@@ -1792,7 +1792,7 @@ int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
u32 *out_value) u32 *out_value)
{ {
u32 uninitialized_var(reg_value); u32 uninitialized_var(reg_value);
#define done (((reg_value = I915_READ_FW(reg)) & mask) == value) #define done (((reg_value = intel_uncore_read_fw(uncore, reg)) & mask) == value)
int ret; int ret;
/* Catch any overuse of this function */ /* Catch any overuse of this function */
...@@ -1850,7 +1850,7 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv, ...@@ -1850,7 +1850,7 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv,
spin_lock_irq(&uncore->lock); spin_lock_irq(&uncore->lock);
intel_uncore_forcewake_get__locked(uncore, fw); intel_uncore_forcewake_get__locked(uncore, fw);
ret = __intel_wait_for_register_fw(dev_priv, ret = __intel_wait_for_register_fw(uncore,
reg, mask, value, reg, mask, value,
fast_timeout_us, 0, &reg_value); fast_timeout_us, 0, &reg_value);
...@@ -1858,7 +1858,8 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv, ...@@ -1858,7 +1858,8 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv,
spin_unlock_irq(&uncore->lock); spin_unlock_irq(&uncore->lock);
if (ret && slow_timeout_ms) if (ret && slow_timeout_ms)
ret = __wait_for(reg_value = I915_READ_NOTRACE(reg), ret = __wait_for(reg_value = intel_uncore_read_notrace(uncore,
reg),
(reg_value & mask) == value, (reg_value & mask) == value,
slow_timeout_ms * 1000, 10, 1000); slow_timeout_ms * 1000, 10, 1000);
......
...@@ -220,8 +220,8 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv, ...@@ -220,8 +220,8 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv,
unsigned int fast_timeout_us, unsigned int fast_timeout_us,
unsigned int slow_timeout_ms, unsigned int slow_timeout_ms,
u32 *out_value); u32 *out_value);
static inline static inline int
int intel_wait_for_register(struct drm_i915_private *dev_priv, intel_wait_for_register(struct drm_i915_private *dev_priv,
i915_reg_t reg, i915_reg_t reg,
u32 mask, u32 mask,
u32 value, u32 value,
...@@ -230,21 +230,22 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv, ...@@ -230,21 +230,22 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv,
return __intel_wait_for_register(dev_priv, reg, mask, value, 2, return __intel_wait_for_register(dev_priv, reg, mask, value, 2,
timeout_ms, NULL); timeout_ms, NULL);
} }
int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
int __intel_wait_for_register_fw(struct intel_uncore *uncore,
i915_reg_t reg, i915_reg_t reg,
u32 mask, u32 mask,
u32 value, u32 value,
unsigned int fast_timeout_us, unsigned int fast_timeout_us,
unsigned int slow_timeout_ms, unsigned int slow_timeout_ms,
u32 *out_value); u32 *out_value);
static inline static inline int
int intel_wait_for_register_fw(struct drm_i915_private *dev_priv, intel_wait_for_register_fw(struct intel_uncore *uncore,
i915_reg_t reg, i915_reg_t reg,
u32 mask, u32 mask,
u32 value, u32 value,
unsigned int timeout_ms) unsigned int timeout_ms)
{ {
return __intel_wait_for_register_fw(dev_priv, reg, mask, value, return __intel_wait_for_register_fw(uncore, reg, mask, value,
2, timeout_ms, NULL); 2, timeout_ms, NULL);
} }
...@@ -367,6 +368,13 @@ intel_uncore_read64_2x32(struct intel_uncore *uncore, ...@@ -367,6 +368,13 @@ intel_uncore_read64_2x32(struct intel_uncore *uncore,
#define intel_uncore_write64_fw(...) __raw_uncore_write64(__VA_ARGS__) #define intel_uncore_write64_fw(...) __raw_uncore_write64(__VA_ARGS__)
#define intel_uncore_posting_read_fw(...) ((void)intel_uncore_read_fw(__VA_ARGS__)) #define intel_uncore_posting_read_fw(...) ((void)intel_uncore_read_fw(__VA_ARGS__))
static inline void intel_uncore_rmw_or_fw(struct intel_uncore *uncore,
i915_reg_t reg, u32 or_val)
{
intel_uncore_write_fw(uncore, reg,
intel_uncore_read_fw(uncore, reg) | or_val);
}
#define raw_reg_read(base, reg) \ #define raw_reg_read(base, reg) \
readl(base + i915_mmio_reg_offset(reg)) readl(base + i915_mmio_reg_offset(reg))
#define raw_reg_write(base, reg, value) \ #define raw_reg_write(base, reg, value) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment