From patchwork Fri Sep 5 10:55:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 4851461 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 812F3C0338 for ; Fri, 5 Sep 2014 10:55:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A362201EF for ; Fri, 5 Sep 2014 10:55:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 22A1D200D5 for ; Fri, 5 Sep 2014 10:55:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE1686E847; Fri, 5 Sep 2014 03:55:26 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 981976E847 for ; Fri, 5 Sep 2014 03:55:25 -0700 (PDT) Received: by mail-wi0-f171.google.com with SMTP id hi2so596685wib.4 for ; Fri, 05 Sep 2014 03:55:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wkiuMrUhsUWiz5c8pDxBRo4ObwIpMfamnPfyxk0hKz0=; b=SB2dKCjzkT7RyWfkiUi1LHdXlwh379vXdjdCAmf8cjDQDw5yF8eqVLSwFZmQKrx1u/ d6JLtAbc57cLp42I6oqjxx8OcLn9lLAEQq8Xg1FWR//VZWpaG0B/MbqLK2P2GPBxH0fm ak1DtdfYIIyja34paK/MYkU0TvJA9ldLUraCfPfySmjVpRh2fIsaWB96FwKmFO4S3iF4 oGFfeK/B2XbAXgx3anCkVt5c9GsAR9/cJqp4sEckSu3cnBd8sGNKhi2OU0K1oHikVElm Ls3y8GbvWJEvYBwlIMRbAOd64GAEV4QWjYuZ1T2PAwpU1D1Krn5/ImsnQdLpCxaw/B/Q ZXBw== X-Gm-Message-State: ALoCoQn60p6dDIFukPkYQ32JXcFyTZ/Ex8zXzk9zoD9HS83eoshocWa9p/cVKJWKu3rghulXIcJH X-Received: by 10.180.149.244 with SMTP id ud20mr2597197wib.55.1409914521135; Fri, 05 Sep 2014 03:55:21 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id n3sm1587670wiy.10.2014.09.05.03.55.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Sep 2014 03:55:20 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Fri, 5 Sep 2014 11:55:19 +0100 Message-Id: <1409914519-15683-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.3 Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH i-g-t] lib: keep a list of modified connectors to reset X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Thomas Wood --- 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]; /** @@ -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 != -1) + forced_connectors[len] = path; + + igt_debug("Connector %s is now forced %s\n", path, value); + igt_debug("Current forced connectors:\n"); + tmp = forced_connectors; + while (*tmp) { + igt_debug("\t%s\n", *tmp); + tmp++; + } + + igt_assert(ret != -1); return (ret == -1) ? false : true; } @@ -1643,21 +1666,14 @@ void igt_enable_connectors(void) */ void igt_reset_connectors(void) { - drmModeRes *res; - drmModeConnector *c; - int drm_fd; - - drm_fd = drm_open_any(); - res = drmModeGetResources(drm_fd); - - for (int i = 0; i < res->count_connectors; i++) { - - c = drmModeGetConnector(drm_fd, res->connectors[i]); + char **tmp; - kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_UNSPECIFIED); + /* reset the connectors stored in forced_connectors, avoiding any + * functions that are not safe to call in signal handlers */ - drmModeFreeConnector(c); + for (tmp = forced_connectors; *tmp; tmp++) { + int fd = open(*tmp, O_WRONLY | O_TRUNC); + write(fd, "unspecified", 11); + close(fd); } - - close(drm_fd); }