6. Given the function of $x$, $y=m x^{2}-2 x+1$ $(0 \leqslant x \leqslant 2)$. Which of the following statements is correct? ( ).
(A) When $m=0$, there is no minimum value
(B) When $\frac{1}{2} \leqslant m<1$, $y_{\text {min }}=1$
(C) When $m<0$, $y_{\text {max }}=1-\frac{1}{m}$
(D) When $m \geqslant 1$, $y_{\text {max }}=4 m-3$
6. D.

When $m=0$, $y$ has a minimum value of -3; when $\frac{1}{2} \leqslant m<1$, from the graph and the monotonicity of the function, we know $y_{\text {min }}=1-\frac{1}{m}$;

When $m<0$, from the graph and the monotonicity of the function, we know $y_{\max }=1$;
When $m \geqslant 1$, $y_{\max }=4 m-3$.