Message ID | 20180718105627.27023-1-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Quoting Chris Wilson (2018-07-18 11:56:27) > Only pm_rpm still uses the igt_trash_aperture() and so we can remove it > from the lib and in the process convert it over from the legacy > libdrm_intel. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Michał Winiarski <michal.winiarski@intel.com> Hi Michał, will you be my victim for today? -Chris
On Wed, Jul 18, 2018 at 11:56:27AM +0100, Chris Wilson wrote: > Only pm_rpm still uses the igt_trash_aperture() and so we can remove it > from the lib and in the process convert it over from the legacy > libdrm_intel. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Michał Winiarski <michal.winiarski@intel.com> I'm not sure what the test is testing exactly, but since it's a straight forward conversion from libdrm_intel with no functional changes: Reviewed-by: Michał Winiarski <michal.winiarski@intel.com> -Michał > --- > lib/igt_aux.c | 57 -------------------------------------------------- > lib/igt_aux.h | 10 +-------- > tests/pm_rpm.c | 31 ++++++++++++++++++--------- > 3 files changed, 22 insertions(+), 76 deletions(-) > > diff --git a/lib/igt_aux.c b/lib/igt_aux.c > index d9dbf7ced..1250d5c5f 100644 > --- a/lib/igt_aux.c > +++ b/lib/igt_aux.c > @@ -682,63 +682,6 @@ void igt_print_activity(void) > igt_interactive_info("."); > } > > -/* mappable aperture trasher helper */ > -drm_intel_bo **trash_bos; > -int num_trash_bos; > - > -/** > - * igt_init_aperture_trashers: > - * @bufmgr: libdrm buffer manager > - * > - * Initialize the aperture trasher using @bufmgr, which can then be run with > - * igt_trash_aperture(). > - */ > -void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr) > -{ > - int i; > - > - num_trash_bos = gem_mappable_aperture_size() / (1024*1024); > - > - trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *)); > - igt_assert(trash_bos); > - > - for (i = 0; i < num_trash_bos; i++) > - trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096); > -} > - > -/** > - * igt_trash_aperture: > - * > - * Trash the aperture by walking a set of GTT memory mapped objects. > - */ > -void igt_trash_aperture(void) > -{ > - int i; > - uint8_t *gtt_ptr; > - > - for (i = 0; i < num_trash_bos; i++) { > - drm_intel_gem_bo_map_gtt(trash_bos[i]); > - gtt_ptr = trash_bos[i]->virtual; > - *gtt_ptr = 0; > - drm_intel_gem_bo_unmap_gtt(trash_bos[i]); > - } > -} > - > -/** > - * igt_cleanup_aperture_trashers: > - * > - * Clean up all aperture trasher state set up with igt_init_aperture_trashers(). > - */ > -void igt_cleanup_aperture_trashers(void) > -{ > - int i; > - > - for (i = 0; i < num_trash_bos; i++) > - drm_intel_bo_unreference(trash_bos[i]); > - > - free(trash_bos); > -} > - > static int autoresume_delay; > > static const char *suspend_state_name[] = { > diff --git a/lib/igt_aux.h b/lib/igt_aux.h > index 639a90778..ef89faa9b 100644 > --- a/lib/igt_aux.h > +++ b/lib/igt_aux.h > @@ -28,16 +28,13 @@ > #ifndef IGT_AUX_H > #define IGT_AUX_H > > -#include <intel_bufmgr.h> > #include <inttypes.h> > #include <stdbool.h> > +#include <stddef.h> > #include <sys/time.h> > > #include <i915/gem_submission.h> > > -extern drm_intel_bo **trash_bos; > -extern int num_trash_bos; > - > /* signal interrupt helpers */ > #define gettid() syscall(__NR_gettid) > #define sigev_notify_thread_id _sigev_un._tid > @@ -122,11 +119,6 @@ bool igt_check_boolean_env_var(const char *env_var, bool default_value); > > bool igt_aub_dump_enabled(void); > > -/* helpers based upon the libdrm buffer manager */ > -void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr); > -void igt_trash_aperture(void); > -void igt_cleanup_aperture_trashers(void); > - > /* suspend/hibernate and auto-resume system */ > > /** > diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c > index 1f2647be1..4268bb19a 100644 > --- a/tests/pm_rpm.c > +++ b/tests/pm_rpm.c > @@ -1295,25 +1295,36 @@ static void gem_idle_subtest(void) > > static void gem_evict_pwrite_subtest(void) > { > - static drm_intel_bufmgr *bufmgr; > + struct { > + uint32_t handle; > + uint32_t *ptr; > + } *trash_bos; > + unsigned int num_trash_bos, n; > uint32_t buf; > - int i; > > - bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); > - igt_assert(bufmgr); > - igt_init_aperture_trashers(bufmgr); > + num_trash_bos = gem_mappable_aperture_size() / (1024*1024) + 1; > + trash_bos = malloc(num_trash_bos * sizeof(*trash_bos)); > + igt_assert(trash_bos); > > - igt_trash_aperture(); > + for (n = 0; n < num_trash_bos; n++) { > + trash_bos[n].handle = gem_create(drm_fd, 1024*1024); > + trash_bos[n].ptr = gem_mmap__gtt(drm_fd, trash_bos[n].handle, > + 1024*1024, PROT_WRITE); > + *trash_bos[n].ptr = 0; > + } > > disable_or_dpms_all_screens_and_wait(&ms_data, true); > igt_assert(wait_for_suspended()); > > buf = 0; > - for (i = 0; i < num_trash_bos; i++) > - gem_write(drm_fd, trash_bos[i]->handle, 0, &buf, sizeof(buf)); > + for (n = 0; n < num_trash_bos; n++) > + gem_write(drm_fd, trash_bos[n].handle, 0, &buf, sizeof(buf)); > > - igt_cleanup_aperture_trashers(); > - drm_intel_bufmgr_destroy(bufmgr); > + for (n = 0; n < num_trash_bos; n++) { > + munmap(trash_bos[n].ptr, 1024*1024); > + gem_close(drm_fd, trash_bos[n].handle); > + } > + free(trash_bos); > } > > /* This also triggered WARNs on dmesg at some point. */ > -- > 2.18.0 >
Quoting Michał Winiarski (2018-07-19 11:24:05) > On Wed, Jul 18, 2018 at 11:56:27AM +0100, Chris Wilson wrote: > > Only pm_rpm still uses the igt_trash_aperture() and so we can remove it > > from the lib and in the process convert it over from the legacy > > libdrm_intel. > > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Michał Winiarski <michal.winiarski@intel.com> > > I'm not sure what the test is testing exactly, but since it's a straight forward > conversion from libdrm_intel with no functional changes: Yeah, I guess it's trying to cover paths through pwrite+rpm. I don't really see it as a tractable problem without using say kprobe+bpf to steer us? -Chris
diff --git a/lib/igt_aux.c b/lib/igt_aux.c index d9dbf7ced..1250d5c5f 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -682,63 +682,6 @@ void igt_print_activity(void) igt_interactive_info("."); } -/* mappable aperture trasher helper */ -drm_intel_bo **trash_bos; -int num_trash_bos; - -/** - * igt_init_aperture_trashers: - * @bufmgr: libdrm buffer manager - * - * Initialize the aperture trasher using @bufmgr, which can then be run with - * igt_trash_aperture(). - */ -void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr) -{ - int i; - - num_trash_bos = gem_mappable_aperture_size() / (1024*1024); - - trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *)); - igt_assert(trash_bos); - - for (i = 0; i < num_trash_bos; i++) - trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096); -} - -/** - * igt_trash_aperture: - * - * Trash the aperture by walking a set of GTT memory mapped objects. - */ -void igt_trash_aperture(void) -{ - int i; - uint8_t *gtt_ptr; - - for (i = 0; i < num_trash_bos; i++) { - drm_intel_gem_bo_map_gtt(trash_bos[i]); - gtt_ptr = trash_bos[i]->virtual; - *gtt_ptr = 0; - drm_intel_gem_bo_unmap_gtt(trash_bos[i]); - } -} - -/** - * igt_cleanup_aperture_trashers: - * - * Clean up all aperture trasher state set up with igt_init_aperture_trashers(). - */ -void igt_cleanup_aperture_trashers(void) -{ - int i; - - for (i = 0; i < num_trash_bos; i++) - drm_intel_bo_unreference(trash_bos[i]); - - free(trash_bos); -} - static int autoresume_delay; static const char *suspend_state_name[] = { diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 639a90778..ef89faa9b 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -28,16 +28,13 @@ #ifndef IGT_AUX_H #define IGT_AUX_H -#include <intel_bufmgr.h> #include <inttypes.h> #include <stdbool.h> +#include <stddef.h> #include <sys/time.h> #include <i915/gem_submission.h> -extern drm_intel_bo **trash_bos; -extern int num_trash_bos; - /* signal interrupt helpers */ #define gettid() syscall(__NR_gettid) #define sigev_notify_thread_id _sigev_un._tid @@ -122,11 +119,6 @@ bool igt_check_boolean_env_var(const char *env_var, bool default_value); bool igt_aub_dump_enabled(void); -/* helpers based upon the libdrm buffer manager */ -void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr); -void igt_trash_aperture(void); -void igt_cleanup_aperture_trashers(void); - /* suspend/hibernate and auto-resume system */ /** diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index 1f2647be1..4268bb19a 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -1295,25 +1295,36 @@ static void gem_idle_subtest(void) static void gem_evict_pwrite_subtest(void) { - static drm_intel_bufmgr *bufmgr; + struct { + uint32_t handle; + uint32_t *ptr; + } *trash_bos; + unsigned int num_trash_bos, n; uint32_t buf; - int i; - bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); - igt_assert(bufmgr); - igt_init_aperture_trashers(bufmgr); + num_trash_bos = gem_mappable_aperture_size() / (1024*1024) + 1; + trash_bos = malloc(num_trash_bos * sizeof(*trash_bos)); + igt_assert(trash_bos); - igt_trash_aperture(); + for (n = 0; n < num_trash_bos; n++) { + trash_bos[n].handle = gem_create(drm_fd, 1024*1024); + trash_bos[n].ptr = gem_mmap__gtt(drm_fd, trash_bos[n].handle, + 1024*1024, PROT_WRITE); + *trash_bos[n].ptr = 0; + } disable_or_dpms_all_screens_and_wait(&ms_data, true); igt_assert(wait_for_suspended()); buf = 0; - for (i = 0; i < num_trash_bos; i++) - gem_write(drm_fd, trash_bos[i]->handle, 0, &buf, sizeof(buf)); + for (n = 0; n < num_trash_bos; n++) + gem_write(drm_fd, trash_bos[n].handle, 0, &buf, sizeof(buf)); - igt_cleanup_aperture_trashers(); - drm_intel_bufmgr_destroy(bufmgr); + for (n = 0; n < num_trash_bos; n++) { + munmap(trash_bos[n].ptr, 1024*1024); + gem_close(drm_fd, trash_bos[n].handle); + } + free(trash_bos); } /* This also triggered WARNs on dmesg at some point. */
Only pm_rpm still uses the igt_trash_aperture() and so we can remove it from the lib and in the process convert it over from the legacy libdrm_intel. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Michał Winiarski <michal.winiarski@intel.com> --- lib/igt_aux.c | 57 -------------------------------------------------- lib/igt_aux.h | 10 +-------- tests/pm_rpm.c | 31 ++++++++++++++++++--------- 3 files changed, 22 insertions(+), 76 deletions(-)