If one of the generation of quarks(say up and down) is massless then cp-violation is still there in quark sector?
Yes, nothing changes about the general rules if $m_u=m_d=0$. The CKM matrix is still the $SU(3)$ matrix transforming the up-type quark mass eigenstate to the up-electroweak-partners of the down-type quark mass eigenstates. The general CKM matrix distinguishes the phase.
However, the CKM matrix becomes ambiguous and the number of generations is effectively reduced (and the CKM phase becomes unphysical, CP-violation can be redefined away) if two of the three down-type mass eigenvalues coincide (whether they're zero or not); or if there's the same coincidence for the up-type ones.