Measurements of quarkonia produced in ultrarelativistic Pb+Pb collisions provide a means to probe the properties and evolution of the hot and dense medium created in those collisions. Promptly produced quarkonia are directly affected by the interaction with the hot nuclear matter, while non-prompt production allows for the study of $b$-quark energy loss. The studies of quarkonia production are complemented by measurements of the azimuthal modulation of $J/\psi$ production. Studies of quarkonia and open charm production in $p$+Pb collisions provide an additional insight, as they directly probe cold nuclear matter effects.
This talk will report on the most recent ATLAS measurements of charmonia production and flow in Pb+Pb collisions, as well as charmonia and bottomonia production in $p$+Pb collisions. In addition, results on $D$ meson production and flow will be presented.