Do not divide by clflush_add when the CPU has no CLFLUSH support. The
cache-line size is initialized only on the CLFLUSH path. Calculate the
iteration count inside the conditional block that actually uses it.
This is independent of the directory-entry mapping lifetime fix.

Fixes: 8c8f1c958ab5 ("gma500: introduce the GTT and MMU handling logic")
Signed-off-by: Gabriel Gama <[email protected]>
---
diff --git a/drivers/gpu/drm/gma500/mmu.c b/drivers/gpu/drm/gma500/mmu.c
index 
de2dd41ad23884afa486162d3fe8f9c3a4149684..34ae0f125b83380b735ae454c775775cd74d0f62
 100644
--- a/drivers/gpu/drm/gma500/mmu.c
+++ b/drivers/gpu/drm/gma500/mmu.c
@@ -265,7 +265,7 @@
        struct psb_mmu_pt *pt = kmalloc_obj(*pt);
        void *v;
        uint32_t clflush_add = pd->driver->clflush_add >> PAGE_SHIFT;
-       uint32_t clflush_count = PAGE_SIZE / clflush_add;
+       u32 clflush_count;
        spinlock_t *lock = &pd->driver->lock;
        uint8_t *clf;
        uint32_t *ptes;
@@ -289,6 +289,7 @@
                *ptes++ = pd->invalid_pte;
 
        if (pd->driver->has_clflush && pd->hw_context != -1) {
+               clflush_count = PAGE_SIZE / clflush_add;
                mb();
                for (i = 0; i < clflush_count; ++i) {
                        psb_clflush(clf);

Reply via email to