Let $p$ be an odd prime. Denote $e(x):=e^{2\pi i\frac{x}{p}}$. Let $n\ge 2$ be an integer. Consider the exponential sum $$ S(f,g)=\sum_{g(x_1,\dots,x_n)=0, x_i\in\mathbb{F}_p}e(f(x_1,\dots,x_n)), $$ where $f$ and $g$ are polynomials of $n$ variables.

Such $S(f,g)$ is common. For example, Kloosterman sum can be written in this form.

I am seeking conditions on $f$ and $g$ so that we have the optimal estimate \begin{equation} S(f,g)\ll p^{(n-1)/2}. \end{equation} My thoughts so far: if from $g(x_1,\dots,x_n)=0$ we can write $x_1$ in terms of other variables in a polynomial way, then $S(f,g)$ becomes a sum over the full $(n-1)$-dim space $\mathbb{F}_p^{n-1}$ and $f$ becomes a polynomial of $n-1$ variables. Then a theorem of Deligne says that we just need to check whether the homogeneous leading term of $f$ defines a smooth projective hypersurface. But I do not know how to deal with general (or other) $g$. For example, what about the case $g(x_1,\dots,x_n)=h(x_1)+\dots+h(x_n)$ for some single-variable polynomial $h$? If $h$ is quadratic, then we can't write $x_1$ in terms of other variables in a polynomial way at all.

It seems to me that Deligne's paper already considers a much more general sum than $S(f,g)$. But the Deligne's criterion to get the optimal estimate is abstract and hard to check for people who do not know algebraic geometry. I hope that in the simpler case of $S(f,g)$ there is an easy-to-check criterion on $f$ and $g$.