Here are a few steps:
-STEP 1: test it
dial *#0*# (be patient, it might take a few seconds)
go to "sensors"
click on "gyro selfstest" under "gyroscope sensor"
If result is "fail", proceed with step 2
-STEP 2: boot in safe mode
just watch this video, as seeing it will be easier to understand...