My bf couldn't keep it up

I've never been in this situation before. Everything was going well. We were kissing I was talking dirty to him I caressed his penis with my knee while were were lying in bed. It was hard so I have him a bj. We had intercourse dr a couple minutes but then it all went downhill. I tried to get it back up but it was impossible. 
​Any advice on what to do if this happens again? I was thinking dressing up for him