So here is something i have been thinking on for a while and never get around to actually code it until recently. I needed|wanted it as i was working on improved GPU reset. Issue i faced is that despite trying hard to make clean code reusable btw asic we ended up with some messy code path (especially in error path) and you basicly have to write for each asic a special function handling initialization+ finalization add 2 other for suspend/resume and finaly add one for reset and one for power management.
So the idea of unit is to give each unit a set of function : init,fini,suspend,resume,hold,unhold Unit are things like : CP, MC, MemoryManager, GEM, CLK, ... Now instead of writing one init/fini/suspend/resume function you just provide for each asic the following : struct radeon_unit_funcs *r100_units[] = { ???????&r100_unit_errata, ???????&r100_unit_vga, ???????&r100_unit_common, ???????&radeon_unit_scratch, ???????&radeon_unit_sr, ???????&radeon_unit_surface, ???????&radeon_unit_reset, ???????&radeon_unit_bios, ???????&r100_unit_clock, ???????&r100_unit_mc, ???????&radeon_unit_fence, ???????&radeon_unit_irq, ???????&radeon_unit_mm, ???????&radeon_unit_agp, ???????&r100_unit_gart, ???????&r100_unit_irq, ???????&radeon_unit_gem, ???????&r100_unit_cs, ???????&r100_unit_cp, ???????&r100_unit_ib, ???????NULL }; and a common helper function just go through the list and init each unit, for fini it goes in reverse order. resume/suspend are like init/fini, suspend goes in reverse order while resume goes in normal order radeon_unit_sr is a fake helper unit just to know from which point you start/end suspend/resume, same for radeon_unit_reset So with that approach i think it's lot easier to figure out dependency btw unit and in which order things get call. I think it will help to untangle some of the code path that are tricky today to follow. Thought there is a downside any change like this is likely to introduce regression and i hate those like others, anyway i think the longterm benefit are greater than the temporary disturbance we can even have the unit path coexist with current code and allow it to stabilize on its own before switching over and removing old path. So before i go any further what is your opinion on this ? Attached is a patch which shows the approach for r100/r200 asic (tested and it works) as you can see it can be done without touching the old path and we can also add an option to select btw old/new path. Cheers, Jerome -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 0001-WIP-breakdown-GPU-into-unit.patch URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20100712/a44d1272/attachment.txt>