If you look in the RAW’s descriptions of the plants, many of the ones farther down feed on “evil”. That seems to suggest some kind of ecosystem based on a pairing of magma-based food generation and some sort of magical energy field, perhaps with the magma heat acting in a similar way that light does for surface plants, with magical energy being absorbed ala water or cO2. However, because of gravity, this seems unlikely- how would a community be sustained via the bottom up? Instead, it makes much more sense to classify the underground much like a producer food chain- the main energy inputs being at the surface, and energy gradually descending the layers, often taking centuries, before the debris is finally absorbed by the bottom-most mushrooms and slimes along with their daily diet of demonic souls and pure magma.
The most likely method for the original input of nutrients is the surface- though entrances are sparse; the cave system is huge and world-spanning. There are many input points, and roaming animals such as giant bats can carry the input from, say, a dead elf corpse tossed in by an adventurer halfway across the world before being shot down and eaten by a ratman tribe, for example. Therefore the mushrooms at the top level are almost more common to trees than they are with their deeper cousins, feeding on water, air and nutrients provided by corpses, bat poop and the surrounding rock instead of dirt. In fact, these plants are probably descended on a completely different evolutionary branch than the deep-shrooms, coming from plants instead of…demons, I guess. Sedentary demons. Anyways. As these shrooms die, or the animals that consume them die, they gradually work their way down to layer two, which I would equate to about the mushrooms you find on your typical victory over the elves, er, dead tree. They are descended from the surface mushrooms, but do not need/need very small amounts of cO2, probably getting more rising up from the third cavern level’s magma pools then from the stagnant air currents from the surface/level one. In fact, the only air movement at all would be slight updrafts around magma pipes. These mushrooms would probably survive on rock nutrients and dead things from the upper levels. When these, in turn die, they get cast off into the third cavern layer. This, as said before, combines their nutrients with baby souls and magma heat to grow ungodly huge.
The big uncertainty in this, of course, is forgotten beasts. While megabeasts/semimegas would have a small impact on the environment (just adding more organics to layer one, really), I can easily imagine a long-lived forgotten beast supporting an entire miniature ecosystem with one of their odder traits. Even a forgotten beast that sweats acid could be useful to some species of DF shroom, I imagine, especially considering their rate of evolution (I guess a wizard did it or something).
Tl;dr: The mushrooms are eating our rocks!