I imagine you would need to get up to your ceiling and scrape off all the loose paint that you can. Then the best way is probably to use a skim coat of plaster to fill the sections without paint and sand smooth so you no longer have the paint edges showing. Then you would be best to apply an undercoat because of the difference between the painted and plastered sections ... then paint with you top coat.
Sounds fun ... enjoy!