On Fri, Sep 05, 2014 at 11:55:19AM +0100, Thomas Wood wrote: > Avoid calling functions in igt_reset_connectors that are not safe to use > in signal handlers by keeping a list of connectors that have been > modified, instead of enumerating all connectors. > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83498 > Cc: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx> > Signed-off-by: Thomas Wood <thomas.wood@xxxxxxxxx> > --- > lib/igt_kms.c | 50 +++++++++++++++++++++++++++++++++----------------- > 1 file changed, 33 insertions(+), 17 deletions(-) > > diff --git a/lib/igt_kms.c b/lib/igt_kms.c > index f483e2d..933e6fb 100644 > --- a/lib/igt_kms.c > +++ b/lib/igt_kms.c > @@ -54,6 +54,9 @@ > #define DRM_PLANE_TYPE_PRIMARY 1 > #define DRM_PLANE_TYPE_CURSOR 2 > > +/* list of connectors that need resetting on exit */ > +#define MAX_CONNECTORS 32 > +static char *forced_connectors[MAX_CONNECTORS]; Need to leave space for the sentinel NULL value. static char *forced_connectors[MAX_CONNECTORS + 1]; > /** > @@ -341,9 +344,9 @@ static char* get_debugfs_connector_path(int drm_fd, drmModeConnector *connector, > bool kmstest_force_connector(int drm_fd, drmModeConnector *connector, > enum kmstest_force_connector_state state) > { > - char *path; > + char *path, **tmp; > const char *value; > - int debugfs_fd, ret; > + int debugfs_fd, ret, len; > > switch (state) { > case FORCE_CONNECTOR_ON: > @@ -364,7 +367,6 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector, > > path = get_debugfs_connector_path(drm_fd, connector, "force"); > debugfs_fd = open(path, O_WRONLY | O_TRUNC); > - free(path); > > if (debugfs_fd == -1) { > return false; > @@ -373,6 +375,27 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector, > ret = write(debugfs_fd, value, strlen(value)); > close(debugfs_fd); > > + for (len = 0, tmp = forced_connectors; *tmp; tmp++) { > + /* check the connector is not already present */ > + if (strcmp(*tmp, path) == 0) { > + len = -1; > + break; > + } > + len++; > + } if (len >= MAX_CONNECTORS) len = -1; -Chris -- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx