[igt-dev] [PATCH igt] igt/gen7_forcewake_mt: Make the mmio register as volatile

Chris Wilson chris at chris-wilson.co.uk
Tue Mar 6 11:10:23 UTC 2018


Quoting Chris Wilson (2018-03-06 10:41:41)
>  static void *thread(void *arg)
>  {
> +       static const char acquire_error[] = "acquire";
> +       static const char release_error[] = "release";
> +
>         struct thread *t = arg;
> -       uint32_t *forcewake_mt = (uint32_t *)((char *)t->mmio + FORCEWAKE_MT);
> -       uint32_t bit = 1 << t->bit;
> +       const uint32_t bit = 1 << t->bit;
> +       volatile uint32_t *forcewake_mt = t->forcewake_mt;
> +       void *result = NULL;
> +
> +       while (!result && !READ_ONCE(t->done)) {
> +               /*
> +                * The HW is fubar; concurrent mmio access to even
> +                * the FORCEWAKE_MT results in a machine lockup, nullifying
> +                * the entire purpose of FORCEWAKE_MT... Sigh.
> +                */
> +               pthread_mutex_lock(t->lock);
>  
> -       while (1) {
>                 *forcewake_mt = bit << 16 | bit;
> -               igt_assert(*forcewake_mt & bit);
> +               if (!igt_wait(*forcewake_mt & bit, 50, 1))
> +                       result = (void *)acquire_error;
> +

Imagine there was
               pthread_mutex_unlock(t->lock);
	       usleep(10000);
               pthread_mutex_lock(t->lock);
here.

>                 *forcewake_mt = bit << 16;
> -               igt_assert((*forcewake_mt & bit) == 0);
> +               if (!igt_wait((*forcewake_mt & bit) == 0, 50, 1))
> +                       result = (void *)release_error;
> +
> +               pthread_mutex_unlock(t->lock);
>         }
-Chris


More information about the igt-dev mailing list