Another way:
Let \( t=cosx \), then \( at^2-at+1\geq0 \).
The solutions for the cuadratic equation are \( t=\displaystyle\frac{1}{2}\pm\displaystyle\frac{1}{2}\sqrt[ ]{\displaystyle\frac{a-4}{a}} \).
1) For any \( t\in\mathbb R \) there is only one ore no solution provided \( \displaystyle\frac{a-4}{a}\leq0 \), that is, \( a\in(0,4] \), so the parabola lies on the upper y-plane. This is part of the solution.
2) If \( a<0 \) the radical always exists in \( \mathbb R \), but it is easy to find that we need \( \displaystyle\frac{1}{2}-\displaystyle\frac{1}{2}\sqrt[ ]{\displaystyle\frac{a-4}{a}}\leq t\leq \displaystyle\frac{1}{2}+\displaystyle\frac{1}{2}\sqrt[ ]{\displaystyle\frac{a-4}{a}} \) to achieve the original inequality. This means \( t=cosx \) must be between both roots for all \( x\in \mathbb R \); and, due to the fact that \( -1\leq t=cosx\leq 1 \), it is mandatory to have \( \displaystyle\frac{1}{2}-\displaystyle\frac{1}{2}\sqrt[ ]{\displaystyle\frac{a-4}{a}}\leq -1 \) and \( \displaystyle\frac{1}{2}+\displaystyle\frac{1}{2}\sqrt[ ]{\displaystyle\frac{a-4}{a}}\geq 1 \). The second one always works, as it is low limited by a horizontal asymptote in \( y=1 \); but the first one only works for \( a\geq-1/2 \), as one can easily prove. So we can add the interval \( [-1/2,0) \) to the solution.
3) If \( a>4 \), both roots are always positive and make \( t \) lie in the range \( (0,1) \). Now we need \( \displaystyle\frac{1}{2}-\displaystyle\frac{1}{2}\sqrt[ ]{\displaystyle\frac{a-4}{a}}\geq t\geq \displaystyle\frac{1}{2}+\displaystyle\frac{1}{2}\sqrt[ ]{\displaystyle\frac{a-4}{a}} \). With this conditions, it is impossible for \( t \) to be within this range for all \( x\in \mathbb R \), so there is no solution here.
4) If \( a=0 \) we have \( 1\geq0 \), which is obviously always true, so we add \( a=0 \) to the solution.
With 1), 2), 3) and 4) we conclude that the range of \( a\in [-1/2,4] \).
For a visual interpretation, here we can see the graph of the two roots \( f(a) \) with respect to \( a \) (horizontal axis). The solution range of \( a \) is the interval in which the curves of \( f(a) \) stay completely out of the range \( [-1,1] \) of the cosine:

And the Geogebra animation shows how exactly the function \( acos^2x-acosx+1\geq0 \) behaves for many values of \( a \). We can see it is always on the upper y-plane only when \( a\in [-1/2,4] \).

Regards.