]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/drm/radeon/r100.c
Merge branch 'linus' into perf/urgent
[karo-tx-linux.git] / drivers / gpu / drm / radeon / r100.c
index fe33d35dae8c6ca851103e476426e12194d7d4b1..fb44e7e49083ac71702fd79bd402c451aa75e29d 100644 (file)
@@ -139,9 +139,9 @@ int r100_reloc_pitch_offset(struct radeon_cs_parser *p,
                }
 
                tmp |= tile_flags;
-               p->ib->ptr[idx] = (value & 0x3fc00000) | tmp;
+               p->ib.ptr[idx] = (value & 0x3fc00000) | tmp;
        } else
-               p->ib->ptr[idx] = (value & 0xffc00000) | tmp;
+               p->ib.ptr[idx] = (value & 0xffc00000) | tmp;
        return 0;
 }
 
@@ -156,7 +156,7 @@ int r100_packet3_load_vbpntr(struct radeon_cs_parser *p,
        volatile uint32_t *ib;
        u32 idx_value;
 
-       ib = p->ib->ptr;
+       ib = p->ib.ptr;
        track = (struct r100_cs_track *)p->track;
        c = radeon_get_ib_value(p, idx++) & 0x1F;
        if (c > 16) {
@@ -660,7 +660,7 @@ int r100_pci_gart_enable(struct radeon_device *rdev)
        tmp = RREG32(RADEON_AIC_CNTL) | RADEON_PCIGART_TRANSLATE_EN;
        WREG32(RADEON_AIC_CNTL, tmp);
        r100_pci_gart_tlb_flush(rdev);
-       DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
+       DRM_INFO("PCI GART of %uM enabled (table at 0x%016llX).\n",
                 (unsigned)(rdev->mc.gtt_size >> 20),
                 (unsigned long long)rdev->gart.table_addr);
        rdev->gart.ready = true;
@@ -1180,6 +1180,10 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
        WREG32(RADEON_CP_RB_WPTR_DELAY, 0);
        WREG32(RADEON_CP_CSQ_MODE, 0x00004D4D);
        WREG32(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM);
+
+       /* at this point everything should be setup correctly to enable master */
+       pci_set_master(rdev->pdev);
+
        radeon_ring_start(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
        r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, ring);
        if (r) {
@@ -1271,7 +1275,7 @@ void r100_cs_dump_packet(struct radeon_cs_parser *p,
        unsigned i;
        unsigned idx;
 
-       ib = p->ib->ptr;
+       ib = p->ib.ptr;
        idx = pkt->idx;
        for (i = 0; i <= (pkt->count + 1); i++, idx++) {
                DRM_INFO("ib[%d]=0x%08X\n", idx, ib[idx]);
@@ -1350,7 +1354,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
        uint32_t header, h_idx, reg;
        volatile uint32_t *ib;
 
-       ib = p->ib->ptr;
+       ib = p->ib.ptr;
 
        /* parse the wait until */
        r = r100_cs_packet_parse(p, &waitreloc, p->idx);
@@ -1529,7 +1533,7 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
        u32 tile_flags = 0;
        u32 idx_value;
 
-       ib = p->ib->ptr;
+       ib = p->ib.ptr;
        track = (struct r100_cs_track *)p->track;
 
        idx_value = radeon_get_ib_value(p, idx);
@@ -1885,7 +1889,7 @@ static int r100_packet3_check(struct radeon_cs_parser *p,
        volatile uint32_t *ib;
        int r;
 
-       ib = p->ib->ptr;
+       ib = p->ib.ptr;
        idx = pkt->idx + 1;
        track = (struct r100_cs_track *)p->track;
        switch (pkt->opcode) {
@@ -2004,6 +2008,8 @@ int r100_cs_parse(struct radeon_cs_parser *p)
        int r;
 
        track = kzalloc(sizeof(*track), GFP_KERNEL);
+       if (!track)
+               return -ENOMEM;
        r100_cs_track_clear(p->rdev, track);
        p->track = track;
        do {
@@ -2155,79 +2161,18 @@ int r100_mc_wait_for_idle(struct radeon_device *rdev)
        return -1;
 }
 
-void r100_gpu_lockup_update(struct r100_gpu_lockup *lockup, struct radeon_ring *ring)
-{
-       lockup->last_cp_rptr = ring->rptr;
-       lockup->last_jiffies = jiffies;
-}
-
-/**
- * r100_gpu_cp_is_lockup() - check if CP is lockup by recording information
- * @rdev:      radeon device structure
- * @lockup:    r100_gpu_lockup structure holding CP lockup tracking informations
- * @cp:                radeon_cp structure holding CP information
- *
- * We don't need to initialize the lockup tracking information as we will either
- * have CP rptr to a different value of jiffies wrap around which will force
- * initialization of the lockup tracking informations.
- *
- * A possible false positivie is if we get call after while and last_cp_rptr ==
- * the current CP rptr, even if it's unlikely it might happen. To avoid this
- * if the elapsed time since last call is bigger than 2 second than we return
- * false and update the tracking information. Due to this the caller must call
- * r100_gpu_cp_is_lockup several time in less than 2sec for lockup to be reported
- * the fencing code should be cautious about that.
- *
- * Caller should write to the ring to force CP to do something so we don't get
- * false positive when CP is just gived nothing to do.
- *
- **/
-bool r100_gpu_cp_is_lockup(struct radeon_device *rdev, struct r100_gpu_lockup *lockup, struct radeon_ring *ring)
-{
-       unsigned long cjiffies, elapsed;
-
-       cjiffies = jiffies;
-       if (!time_after(cjiffies, lockup->last_jiffies)) {
-               /* likely a wrap around */
-               lockup->last_cp_rptr = ring->rptr;
-               lockup->last_jiffies = jiffies;
-               return false;
-       }
-       if (ring->rptr != lockup->last_cp_rptr) {
-               /* CP is still working no lockup */
-               lockup->last_cp_rptr = ring->rptr;
-               lockup->last_jiffies = jiffies;
-               return false;
-       }
-       elapsed = jiffies_to_msecs(cjiffies - lockup->last_jiffies);
-       if (elapsed >= 10000) {
-               dev_err(rdev->dev, "GPU lockup CP stall for more than %lumsec\n", elapsed);
-               return true;
-       }
-       /* give a chance to the GPU ... */
-       return false;
-}
-
 bool r100_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
 {
        u32 rbbm_status;
-       int r;
 
        rbbm_status = RREG32(R_000E40_RBBM_STATUS);
        if (!G_000E40_GUI_ACTIVE(rbbm_status)) {
-               r100_gpu_lockup_update(&rdev->config.r100.lockup, ring);
+               radeon_ring_lockup_update(ring);
                return false;
        }
        /* force CP activities */
-       r = radeon_ring_lock(rdev, ring, 2);
-       if (!r) {
-               /* PACKET2 NOP */
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_unlock_commit(rdev, ring);
-       }
-       ring->rptr = RREG32(ring->rptr_reg);
-       return r100_gpu_cp_is_lockup(rdev, &rdev->config.r100.lockup, ring);
+       radeon_ring_force_activity(rdev, ring);
+       return radeon_ring_test_lockup(rdev, ring);
 }
 
 void r100_bm_disable(struct radeon_device *rdev)
@@ -2296,7 +2241,6 @@ int r100_asic_reset(struct radeon_device *rdev)
        if (G_000E40_SE_BUSY(status) || G_000E40_RE_BUSY(status) ||
                G_000E40_TAM_BUSY(status) || G_000E40_PB_BUSY(status)) {
                dev_err(rdev->dev, "failed to reset GPU\n");
-               rdev->gpu_lockup = true;
                ret = -1;
        } else
                dev_info(rdev->dev, "GPU reset succeed\n");
@@ -3742,7 +3686,7 @@ void r100_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
 
 int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
 {
-       struct radeon_ib *ib;
+       struct radeon_ib ib;
        uint32_t scratch;
        uint32_t tmp = 0;
        unsigned i;
@@ -3758,22 +3702,22 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
        if (r) {
                return r;
        }
-       ib->ptr[0] = PACKET0(scratch, 0);
-       ib->ptr[1] = 0xDEADBEEF;
-       ib->ptr[2] = PACKET2(0);
-       ib->ptr[3] = PACKET2(0);
-       ib->ptr[4] = PACKET2(0);
-       ib->ptr[5] = PACKET2(0);
-       ib->ptr[6] = PACKET2(0);
-       ib->ptr[7] = PACKET2(0);
-       ib->length_dw = 8;
-       r = radeon_ib_schedule(rdev, ib);
+       ib.ptr[0] = PACKET0(scratch, 0);
+       ib.ptr[1] = 0xDEADBEEF;
+       ib.ptr[2] = PACKET2(0);
+       ib.ptr[3] = PACKET2(0);
+       ib.ptr[4] = PACKET2(0);
+       ib.ptr[5] = PACKET2(0);
+       ib.ptr[6] = PACKET2(0);
+       ib.ptr[7] = PACKET2(0);
+       ib.length_dw = 8;
+       r = radeon_ib_schedule(rdev, &ib);
        if (r) {
                radeon_scratch_free(rdev, scratch);
                radeon_ib_free(rdev, &ib);
                return r;
        }
-       r = radeon_fence_wait(ib->fence, false);
+       r = radeon_fence_wait(ib.fence, false);
        if (r) {
                return r;
        }
@@ -3965,12 +3909,9 @@ static int r100_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }