I think I posted this before in some other thread, but one time back when I used to use Ubuntu, I opened my laptop and the screen was upside-down. Everything worked perfectly, but just upside-down. I went through every display setting I could find, trawled through forums for hours (on a different, non upside-down computer) and got absolutely nowhere. It was at the point where I was thinking I'll probably have to reformat and start over and this will forever be a mystery.
Then I accidentally solved it when my Playstation controller battery got low and I plugged it into the nearest USB port to charge, which was my laptop. As soon as I plugged it it, the screen flipped back the right way. As it turned out, Ubuntu was talking to the controller and had for some reason interpreted the gyroscope movement as 'rotate screen' the last time I charged it. After a couple of minutes of waving the controller around and watching the desktop spin while going "huh", I just unplugged it when it the right way round and crisis averted!