Fail to enter loiter mode in the air, but okay on the ground

It’s so strange, everything is prefect on the ground, but when I take off, always fail to switch from Alt_hold to loiter mode. and the log fils also shows this error message "fail to switch mode."
Can anyone help to look at the logs and give me some instructions?
Logs file link~
https://drive.google.com/open?id=1pSml78UCWkajxbqbipPxutQTA_GpmgqN

No GPS lock perhaps? It won’t enter Loiter without GPS.

But I saw the telem message shows my GPS status is 3D fix.

Yes, but only 6 satelites and HDOP of 1.24. That is better than your GPS_HDOP_GOOD parameter which is 140 (1.4) but only just. You might need to get a better GPS signal.

This will need to go into the Wiki if it is not already there.
On the ground, before you arm, switch to loiter (or any other guided mode) to see if the EKF is happy with the GPS signal and will allow the mode change.

A 3D fix does NOT guarantee the EKF is happy with the GPS solution.