Unit initialization infrastructure
Subsystems (2)
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
Quoted 1 line
From
898c464d926d72b3c52e030c8f730c5cbf14eb26Mon Sep 17 00:00:00 2001
From: Jerome Glisse <[email protected]>
Date: Mon, 12 Jul 2010 15:14:26 -0400
Subject: [PATCH] WIP breakdown GPU into unit
radeon GPU family have lot of similarity accross generations and it can be isolated as unit performing one task (CP, MC, HDP, ...). This patch try to reflect this by introducing the unit infrastructure.
Each unit has 6 functions :
- init one time initialization
- fini one time finalization (cleanup + deallocation ....)
- suspend suspend the unit stop it and put it in safe default
- resume resume the unit (start it and test it works properly)
- hold hold the unit activity for power management
- unhold obvious
The main purpose for introducing this infrastructure is proper unit reset and proper ordering in reset, initialization of the unit the number of code path we have made the initialization and reset order sometime tricky/confusing or different from one path to the other.
--- drivers/gpu/drm/radeon/Makefile | 2 +- drivers/gpu/drm/radeon/r100.c | 2 +- drivers/gpu/drm/radeon/radeon.h | 70 +++- drivers/gpu/drm/radeon/radeon_asic.c | 20 +- drivers/gpu/drm/radeon/radeon_asic.h | 5 + drivers/gpu/drm/radeon/radeon_unit.c | 860 ++++++++++++++++++++++++++++++++++ 6 files changed, 946 insertions(+), 13 deletions(-) create mode 100644 drivers/gpu/drm/radeon/radeon_unit.c
drivers/gpu/drm/radeon/Makefile +1 -1
@@ -65,7 +65,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \ rs400.o rs600.o rs690.o rv515.o r520.o r600.o rv770.o radeon_test.o \ r200.o radeon_legacy_tv.o r600_cs.o r600_blit.o r600_blit_shaders.o \ r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o \ - evergreen.o evergreen_cs.o + evergreen.o evergreen_cs.o radeon_unit.o radeon-$(CONFIG_COMPAT) += radeon_ioc32.o radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o
drivers/gpu/drm/radeon/r100.c +1 -1
@@ -3677,7 +3677,7 @@ static void r100_debugfs(struct radeon_device *rdev)dev_warn (rdev->dev,"Failed to create r100_mc debugfs file.\n" ); } -static void r100_mc_program (struct radeon_device *rdev) +void r100_mc_program (struct radeon_device *rdev) {struct r100_mc_save save;
drivers/gpu/drm/radeon/radeon.h +67 -3
94 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_asic.c +12 -8
@@ -128,11 +128,13 @@ void radeon_agp_disable(struct radeon_device *rdev)/* * ASIC */ +extern struct radeon_unit_funcs **r100_units; +static struct radeon_asic r100_asic = { - .init = &r100_init, - .fini = &r100_fini, - .suspend = &r100_suspend, - .resume = &r100_resume, + .init = &radeon_init_unit, + .fini = &radeon_fini_unit, + .suspend = &radeon_suspend_unit, + .resume = &radeon_resume_unit, .vga_set_state = &r100_vga_set_state, .gpu_is_lockup = &r100_gpu_is_lockup, .asic_reset = &r100_asic_reset,
@@ -171,13 +173,14 @@ static struct radeon_asic r100_asic = { .pm_finish = &r100_pm_finish, .pm_init_profile = &r100_pm_init_profile, .pm_get_dynpm_state = &r100_pm_get_dynpm_state, + .units = &r100_units, };static struct radeon_asic r200_asic = { - .init = &r100_init, - .fini = &r100_fini, - .suspend = &r100_suspend, - .resume = &r100_resume, + .init = &radeon_init_unit, + .fini = &radeon_fini_unit, + .suspend = &radeon_suspend_unit, + .resume = &radeon_resume_unit, .vga_set_state = &r100_vga_set_state, .gpu_is_lockup = &r100_gpu_is_lockup, .asic_reset = &r100_asic_reset,
@@ -215,6 +218,7 @@ static struct radeon_asic r200_asic = { .pm_finish = &r100_pm_finish, .pm_init_profile = &r100_pm_init_profile, .pm_get_dynpm_state = &r100_pm_get_dynpm_state, + .units = &r100_units, };static struct radeon_asic r300_asic = {
drivers/gpu/drm/radeon/radeon_asic.h +5 -0
@@ -319,4 +319,9 @@ extern void evergreen_pm_misc(struct radeon_device *rdev);extern void evergreen_pm_prepare (struct radeon_device *rdev);extern void evergreen_pm_finish (struct radeon_device *rdev); +extern int radeon_init_unit (struct radeon_device *rdev); +extern void radeon_fini_unit (struct radeon_device *rdev); +extern int radeon_suspend_unit (struct radeon_device *rdev); +extern int radeon_resume_unit (struct radeon_device *rdev); +#endif
drivers/gpu/drm/radeon/radeon_unit.c new file +860 -0
860 lines not on this page · raw message
Signature · 1 line
1.7.0.1
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerQuoted 52 lines · Jerome Glisse
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,unholdUnit are things like : CP, MC, MemoryManager, GEM, CLK, ... Now instead of writing one
init/fini/suspend/resumefunction 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_sris a fake helper unit just to know from which point you start/end suspend/resume, same forradeon_unit_resetSo with that approach i think it's lot easier to
figure out dependency btw unit and in which order
things get call.
Quoted 9 lines
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.
No. not again, move on and fix something more important, this is just busy work at this point.
This is like the 4-5th attempt at making these codepaths work, and everyone of them has not worked and you've redesigned it, and I've spent months fixing regressions upstream on crappy hw.
So lets not, we have codepaths that work, the only way anything like this is interesting is if it
a) solves lots of bugs are seeing (i.e. you write it all, get 15 tested-by, fixes lines).
b) it actually makes gpu reset work this time.
Also the whole two codepaths thing was a broken mess the last time we did this, and it makes shit impossible to bisect across, as the bisects all ended at the enable new codepaths for rs400 commit.
If you are going to do this, you need to do it in a step by step fashion, add one unit, convert all GPUs to use it, finish it all, get it tested by lots of people, and then maybe I'll put it in d-r-t, I'd much rather we got past the kernel code and worked on the important stuff first.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Jerome Glisse
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.
I haven't really had a chance to process this yet, but while we are thinking about this sort of thing, I think we should also fix up the radeon_asic handling. Rather than having a static set of radeon_asic pointer tables in the driver, we really sure just allocate one per card when loading the driver. Right now, we edit some of the tables at load time to work around certain quirks on some asics which could break things when multiple cards are installed.
The other issue is the debugfs support is not multi-card aware.
Alex
Quoted 60 lines
So the idea of unit is to give each unit a set of function :
init,fini,suspend,resume,hold,unholdUnit are things like : CP, MC, MemoryManager, GEM, CLK, ... Now instead of writing one
init/fini/suspend/resumefunction 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_sris a fake helper unit just to know from which point you start/end suspend/resume, same forradeon_unit_resetSo 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.
Quoted 3 lines
Cheers,
Jerome
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel