Reversible and irreversible degradation of perovskite solar cells