The mishna describes a situation where reuven and shimon share a house, reuven lives on the lower floor and shimon lives on the upper floor. If the house falls down and reuven refuses to contribute toward reconstructing the ground floor, so that shimon cannot rebuild the upper floor, the tana kama says that shimon can rebuild the ground floor and live there until reuven compensates him for the expense. Rav Yehuda argues - אף זה דר בתוך של חבירו צריך להעלות לו שכר, and holds that shimon can rebuild the entire house and then live in the upper floor (according to tosafos) not allowing reuven into the ground floor until he compensates him for the expense.
Rashi explains that R' Yehuda doesn't allow shimon to live in the ground floor because it is considered ribbis. Meaning, we view it as if shimon lent money to reuven by reconstructing his house. Eventually, reuven will compensate shimon for expenses, so if shimon also benefits by being able to live in reuven's house he is essentially taking ribbis from reuven. Tosafos disagrees because this is not at all considered a loan from reuven to shimon. Tosafos holds that if a fire were to break out in the lower house, it would be shimon's loss, not reuven's. However, R' Shlomo Villna in the cheshek shlomo cites from baba kama 20b that the house is in fact the responsibility of reuven, so that reuven would suffer a loss if the house were to burn down. Based on this, when shimon rebuilds the house for reuven it should be viewed as a loan, so that when shimon would receive compensation in addition to living there it should be a ribbis violation. Why then does the tana kama allow shimon to just rebuild the ground floor and live there until reuven fully compensates him?
The Cheshek Shlomo holds that the opiniono of the tana kama in the mishna is a strong proof to the Rif in teshuvos cited by ba'al ha'terumos that any loan that is given as a benefit to the lender rather than the borrower is not considered a loan in the context of ribbis violations. Even though it is technically a loan and reuven would suffer the loss in case of fire, reuven is not interested in borrowing, rather shimon was interested in lending - there wouldn't be any ribbis violation with this type of loan. He then concludes that the gr"a in shulchan aruch 166 actually cites our mishna as the source of the rif's opinion.