The gemara says that when R' Gamliel blinded the eye of Tevi his slave, he was "very happy". Rashi explains that he was happy because he really wanted to set him free, but was unable to do so since freeing a slave is a violation of an aseh, but since he blinded him, he would be free. [The ya'avetz raises a technical problem - R' Gamliel certainly didn't blind him intentionally since that would be assur, rather it was done accidentally (a proof to this is that he didn't do it until now), but the gemara says on 26b that he would only go free if he "intended to destroy him".]
It seems that Rashi would disagree with the Ran (gittin 20b b'dafei ha'rif) who says that freeing a slave follows the same rules as "lo sei'chanem", that it is only prohibited if done for the purpose of the eved, but not if done for the need of the master. Based on the Ran it should have been permitted for R' Gamliel to free his slave since it brings joy to himself and is not for the benefit of the slave. Can we deduce from this rashi that he disagrees with the Ran and maintains that it is assur even for the benefit of the master? It seems to me that Rashi here is not necessarily against the Ran (meaning that even the Ran would hold that R' Gamliel wouldn't be allowed to free his slave for the purpose of giving him joy). The joy that R' Gamliel had was not a selfish joy, rather it is because he loved tevi so much that he wanted to set him free for his own sake. Even the Ran would agree that if the only benefit to the master is that he is happy to benefit the slave, would not qualify as a selfish benefit to permit the freeing of a slave.