I have fixed boot loop on mi 5 in following way:
1. Backup data in twrp
2. Wipe: system, data, cache, dalvik cache
3. Reboot into system
4. Reboot into twrp
5. Restore data
6. Remove lockscreen password by removing following files in /data/system
gatekeeper.password.key
gatekeeper.pattern.key...