Commit d8f60cfc authored by Alex Deucher's avatar Alex Deucher Committed by Dave Airlie

drm/radeon/kms: Add support for interrupts on r6xx/r7xx chips (v3)

This enables the use of interrupts on r6xx/r7xx hardware.
Interrupts are implemented via a ring buffer.  The GPU adds
interrupts vectors to the ring and the host reads them off
in the interrupt handler.  The interrupt controller requires
firmware like the CP.  This firmware must be installed and
accessble to the firmware loader for interrupts to function.

MSIs don't seem to work on my RS780.  They work fine on all
my discrete cards.  I'm not sure about other RS780s or
RS880s.  I've disabled MSIs on RS780 and RS880, but it would
probably be worth checking on some other systems.

v2 - fix some checkpatch.pl problems;
     re-read the disp int status reg if we restart the ih;

v3 - remove the irq handler if r600_irq_init() fails;
     remove spinlock in r600_ih_ring_fini();
     move ih rb overflow check to r600_get_ih_wptr();
     move irq ack to separate function;
Signed-off-by: default avatarAlex Deucher <alexdeucher@gmail.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 50dafba6
This diff is collapsed.
...@@ -569,9 +569,9 @@ int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes) ...@@ -569,9 +569,9 @@ int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes)
ring_size = num_loops * dwords_per_loop; ring_size = num_loops * dwords_per_loop;
/* set default + shaders */ /* set default + shaders */
ring_size += 40; /* shaders + def state */ ring_size += 40; /* shaders + def state */
ring_size += 3; /* fence emit for VB IB */ ring_size += 5; /* fence emit for VB IB */
ring_size += 5; /* done copy */ ring_size += 5; /* done copy */
ring_size += 3; /* fence emit for done copy */ ring_size += 5; /* fence emit for done copy */
r = radeon_ring_lock(rdev, ring_size); r = radeon_ring_lock(rdev, ring_size);
WARN_ON(r); WARN_ON(r);
......
This diff is collapsed.
...@@ -399,6 +399,23 @@ struct radeon_cp { ...@@ -399,6 +399,23 @@ struct radeon_cp {
bool ready; bool ready;
}; };
/*
* R6xx+ IH ring
*/
struct r600_ih {
struct radeon_object *ring_obj;
volatile uint32_t *ring;
unsigned rptr;
unsigned wptr;
unsigned wptr_old;
unsigned ring_size;
uint64_t gpu_addr;
uint32_t align_mask;
uint32_t ptr_mask;
spinlock_t lock;
bool enabled;
};
struct r600_blit { struct r600_blit {
struct radeon_object *shader_obj; struct radeon_object *shader_obj;
u64 shader_gpu_addr; u64 shader_gpu_addr;
...@@ -792,8 +809,10 @@ struct radeon_device { ...@@ -792,8 +809,10 @@ struct radeon_device {
struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES]; struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
const struct firmware *me_fw; /* all family ME firmware */ const struct firmware *me_fw; /* all family ME firmware */
const struct firmware *pfp_fw; /* r6/700 PFP firmware */ const struct firmware *pfp_fw; /* r6/700 PFP firmware */
const struct firmware *rlc_fw; /* r6/700 RLC firmware */
struct r600_blit r600_blit; struct r600_blit r600_blit;
int msi_enabled; /* msi enabled */ int msi_enabled; /* msi enabled */
struct r600_ih ih; /* r6/700 interrupt ring */
}; };
int radeon_device_init(struct radeon_device *rdev, int radeon_device_init(struct radeon_device *rdev,
...@@ -1108,7 +1127,12 @@ extern void r600_wb_disable(struct radeon_device *rdev); ...@@ -1108,7 +1127,12 @@ extern void r600_wb_disable(struct radeon_device *rdev);
extern void r600_scratch_init(struct radeon_device *rdev); extern void r600_scratch_init(struct radeon_device *rdev);
extern int r600_blit_init(struct radeon_device *rdev); extern int r600_blit_init(struct radeon_device *rdev);
extern void r600_blit_fini(struct radeon_device *rdev); extern void r600_blit_fini(struct radeon_device *rdev);
extern int r600_cp_init_microcode(struct radeon_device *rdev); extern int r600_init_microcode(struct radeon_device *rdev);
extern int r600_gpu_reset(struct radeon_device *rdev); extern int r600_gpu_reset(struct radeon_device *rdev);
/* r600 irq */
extern int r600_irq_init(struct radeon_device *rdev);
extern void r600_irq_fini(struct radeon_device *rdev);
extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size);
extern int r600_irq_set(struct radeon_device *rdev);
#endif #endif
...@@ -480,6 +480,7 @@ static struct radeon_asic r600_asic = { ...@@ -480,6 +480,7 @@ static struct radeon_asic r600_asic = {
.ring_ib_execute = &r600_ring_ib_execute, .ring_ib_execute = &r600_ring_ib_execute,
.irq_set = &r600_irq_set, .irq_set = &r600_irq_set,
.irq_process = &r600_irq_process, .irq_process = &r600_irq_process,
.get_vblank_counter = &rs600_get_vblank_counter,
.fence_ring_emit = &r600_fence_ring_emit, .fence_ring_emit = &r600_fence_ring_emit,
.cs_parse = &r600_cs_parse, .cs_parse = &r600_cs_parse,
.copy_blit = &r600_copy_blit, .copy_blit = &r600_copy_blit,
...@@ -520,6 +521,7 @@ static struct radeon_asic rv770_asic = { ...@@ -520,6 +521,7 @@ static struct radeon_asic rv770_asic = {
.ring_ib_execute = &r600_ring_ib_execute, .ring_ib_execute = &r600_ring_ib_execute,
.irq_set = &r600_irq_set, .irq_set = &r600_irq_set,
.irq_process = &r600_irq_process, .irq_process = &r600_irq_process,
.get_vblank_counter = &rs600_get_vblank_counter,
.fence_ring_emit = &r600_fence_ring_emit, .fence_ring_emit = &r600_fence_ring_emit,
.cs_parse = &r600_cs_parse, .cs_parse = &r600_cs_parse,
.copy_blit = &r600_copy_blit, .copy_blit = &r600_copy_blit,
......
...@@ -562,6 +562,8 @@ int radeon_device_init(struct radeon_device *rdev, ...@@ -562,6 +562,8 @@ int radeon_device_init(struct radeon_device *rdev,
mutex_init(&rdev->cs_mutex); mutex_init(&rdev->cs_mutex);
mutex_init(&rdev->ib_pool.mutex); mutex_init(&rdev->ib_pool.mutex);
mutex_init(&rdev->cp.mutex); mutex_init(&rdev->cp.mutex);
if (rdev->family >= CHIP_R600)
spin_lock_init(&rdev->ih.lock);
rwlock_init(&rdev->fence_drv.lock); rwlock_init(&rdev->fence_drv.lock);
INIT_LIST_HEAD(&rdev->gem.objects); INIT_LIST_HEAD(&rdev->gem.objects);
......
...@@ -1104,7 +1104,6 @@ extern u32 radeon_get_scratch(drm_radeon_private_t *dev_priv, int index); ...@@ -1104,7 +1104,6 @@ extern u32 radeon_get_scratch(drm_radeon_private_t *dev_priv, int index);
# define R600_IT_WAIT_REG_MEM 0x00003C00 # define R600_IT_WAIT_REG_MEM 0x00003C00
# define R600_IT_MEM_WRITE 0x00003D00 # define R600_IT_MEM_WRITE 0x00003D00
# define R600_IT_INDIRECT_BUFFER 0x00003200 # define R600_IT_INDIRECT_BUFFER 0x00003200
# define R600_IT_CP_INTERRUPT 0x00004000
# define R600_IT_SURFACE_SYNC 0x00004300 # define R600_IT_SURFACE_SYNC 0x00004300
# define R600_CB0_DEST_BASE_ENA (1 << 6) # define R600_CB0_DEST_BASE_ENA (1 << 6)
# define R600_TC_ACTION_ENA (1 << 23) # define R600_TC_ACTION_ENA (1 << 23)
......
...@@ -168,37 +168,6 @@ bool radeon_fence_signaled(struct radeon_fence *fence) ...@@ -168,37 +168,6 @@ bool radeon_fence_signaled(struct radeon_fence *fence)
return signaled; return signaled;
} }
int r600_fence_wait(struct radeon_fence *fence, bool intr, bool lazy)
{
struct radeon_device *rdev;
int ret = 0;
rdev = fence->rdev;
__set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
while (1) {
if (radeon_fence_signaled(fence))
break;
if (time_after_eq(jiffies, fence->timeout)) {
ret = -EBUSY;
break;
}
if (lazy)
schedule_timeout(1);
if (intr && signal_pending(current)) {
ret = -ERESTARTSYS;
break;
}
}
__set_current_state(TASK_RUNNING);
return ret;
}
int radeon_fence_wait(struct radeon_fence *fence, bool intr) int radeon_fence_wait(struct radeon_fence *fence, bool intr)
{ {
struct radeon_device *rdev; struct radeon_device *rdev;
...@@ -216,13 +185,6 @@ int radeon_fence_wait(struct radeon_fence *fence, bool intr) ...@@ -216,13 +185,6 @@ int radeon_fence_wait(struct radeon_fence *fence, bool intr)
return 0; return 0;
} }
if (rdev->family >= CHIP_R600) {
r = r600_fence_wait(fence, intr, 0);
if (r == -ERESTARTSYS)
return -EBUSY;
return r;
}
retry: retry:
cur_jiffies = jiffies; cur_jiffies = jiffies;
timeout = HZ / 100; timeout = HZ / 100;
......
...@@ -94,10 +94,18 @@ int radeon_irq_kms_init(struct radeon_device *rdev) ...@@ -94,10 +94,18 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
} }
/* enable msi */ /* enable msi */
rdev->msi_enabled = 0; rdev->msi_enabled = 0;
if (rdev->family >= CHIP_RV380) { /* MSIs don't seem to work on my rs780;
* not sure about rs880 or other rs780s.
* Needs more investigation.
*/
if ((rdev->family >= CHIP_RV380) &&
(rdev->family != CHIP_RS780) &&
(rdev->family != CHIP_RS880)) {
int ret = pci_enable_msi(rdev->pdev); int ret = pci_enable_msi(rdev->pdev);
if (!ret) if (!ret) {
rdev->msi_enabled = 1; rdev->msi_enabled = 1;
DRM_INFO("radeon: using MSI.\n");
}
} }
drm_irq_install(rdev->ddev); drm_irq_install(rdev->ddev);
rdev->irq.installed = true; rdev->irq.installed = true;
......
...@@ -887,6 +887,16 @@ static int rv770_startup(struct radeon_device *rdev) ...@@ -887,6 +887,16 @@ static int rv770_startup(struct radeon_device *rdev)
return r; return r;
} }
/* Enable IRQ */
rdev->irq.sw_int = true;
r = r600_irq_init(rdev);
if (r) {
DRM_ERROR("radeon: IH init failed (%d).\n", r);
radeon_irq_kms_fini(rdev);
return r;
}
r600_irq_set(rdev);
r = radeon_ring_init(rdev, rdev->cp.ring_size); r = radeon_ring_init(rdev, rdev->cp.ring_size);
if (r) if (r)
return r; return r;
...@@ -1005,11 +1015,19 @@ int rv770_init(struct radeon_device *rdev) ...@@ -1005,11 +1015,19 @@ int rv770_init(struct radeon_device *rdev)
r = radeon_object_init(rdev); r = radeon_object_init(rdev);
if (r) if (r)
return r; return r;
r = radeon_irq_kms_init(rdev);
if (r)
return r;
rdev->cp.ring_obj = NULL; rdev->cp.ring_obj = NULL;
r600_ring_init(rdev, 1024 * 1024); r600_ring_init(rdev, 1024 * 1024);
if (!rdev->me_fw || !rdev->pfp_fw) { rdev->ih.ring_obj = NULL;
r = r600_cp_init_microcode(rdev); r600_ih_ring_init(rdev, 64 * 1024);
if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
r = r600_init_microcode(rdev);
if (r) { if (r) {
DRM_ERROR("Failed to load firmware!\n"); DRM_ERROR("Failed to load firmware!\n");
return r; return r;
...@@ -1055,6 +1073,8 @@ void rv770_fini(struct radeon_device *rdev) ...@@ -1055,6 +1073,8 @@ void rv770_fini(struct radeon_device *rdev)
rv770_suspend(rdev); rv770_suspend(rdev);
r600_blit_fini(rdev); r600_blit_fini(rdev);
r600_irq_fini(rdev);
radeon_irq_kms_fini(rdev);
radeon_ring_fini(rdev); radeon_ring_fini(rdev);
r600_wb_fini(rdev); r600_wb_fini(rdev);
rv770_pcie_gart_fini(rdev); rv770_pcie_gart_fini(rdev);
......
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