From patchwork Tue Dec 1 15:29:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 7738141 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4605A9F3E6 for ; Tue, 1 Dec 2015 15:29:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6095820674 for ; Tue, 1 Dec 2015 15:29:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F246A20553 for ; Tue, 1 Dec 2015 15:29:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 752D06E85C; Tue, 1 Dec 2015 07:29:39 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 492006E85C for ; Tue, 1 Dec 2015 07:29:38 -0800 (PST) Received: by wmec201 with SMTP id c201so210921617wme.0 for ; Tue, 01 Dec 2015 07:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p1EpkuQ3Oe+qNuLwSV7SjnUvpPTOLmCKv1dbChY3R5k=; b=SJM52JfcslyWEhyDuan3N3QtuGtFGwFh4VRDLYcOWWNmN0kEu1wVfI6tcAdAr3rrT5 uML5QisjRs9HieANt3ZVn7enHwXnpCJ8WO0q6chSkKONinn/QRpLN5FGBYYtb8bLx2Nz t0foCiZLEyvYc2OV6XI2xViSsTHiNiRKJKHa4= 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:in-reply-to :references; bh=p1EpkuQ3Oe+qNuLwSV7SjnUvpPTOLmCKv1dbChY3R5k=; b=OGS1N8xo/P5tWB7EsIkHZtcZDacTgRF/BzlnlXDSmPespA34N6mF43nKm69XQ/SaKi m2feQMUHsiqPPJQdmz0csfBC53F8sll8uVAnkV0WoUzTCXvWvUrA/et72i1NAs8Q2Bvt t7Pc6u8eYkUrd+a0czn6XwBpGJlw5z/DGvxnHgS3wk00URwYCs4NBER/Bp9H+PPpVBiZ 38PRI8mIzqtupzYw0A3Yn18YNnyTxQCB5/YJMCevRFeXb/RsdR1zImpH3BijbUD+loe5 Lt4PgTmBG6R1x0LR/lQgVyzZF9ycoxm8SeSD5JxaeObeCOdwGlz6yKHCoP7i4O5IDGkb nrFw== X-Gm-Message-State: ALoCoQkRB+MGrfIpOTBkjPaEIqDHpXQR6jcRzYffFZu4pDpriKtnh0vXtmPqTdjWPDOo2gW2/Nrs X-Received: by 10.28.222.138 with SMTP id v132mr37954112wmg.23.1448983776865; Tue, 01 Dec 2015 07:29:36 -0800 (PST) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id w67sm26659648wmw.17.2015.12.01.07.29.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Dec 2015 07:29:36 -0800 (PST) From: Daniel Vetter To: LKML Date: Tue, 1 Dec 2015 16:29:28 +0100 Message-Id: <1448983768-22324-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1448983768-22324-1-git-send-email-daniel.vetter@ffwll.ch> References: <1448983768-22324-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , DRI Development , Daniel Vetter , Andrew Morton , Arjan van de Ven , Thomas Gleixner Subject: [Intel-gfx] [PATCH 2/2] drm/edid: report latency due to reading edids X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 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=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 A forced EDID read takes 22.5ms best-case, and that's per 128byte block. HDMI screens tend to have 2-3 of those. Mutliply that by a few outputs and then it's clear that userspace really never ever should re-probe connector state on its own and trust the kernel to tell it when anything changed. The only exception is a manual reprobe button that the user must press itself (for extremely shitty KVM switches that don't wire up hotplug handling properly). There have been bugs in the past, but we're slowly fixing them up. To the point even that some of the most abused interfaces (e.g. in sysfs) have been changed to only return the cached state ever due to too much polling by userspace. But there's other places where we can't pull these tricks, so give userspace the tools to notice their abuse and expose delays due to EDID reads in latencytop. Cc: Thomas Gleixner Cc: Arjan van de Ven Cc: Andrew Morton Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_edid.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index c214f1246cb4..370003e0cc69 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1272,14 +1273,17 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, int i, j = 0, valid_extensions = 0; u8 *block, *new; bool print_bad_edid = !connector->bad_edid_counter || (drm_debug & DRM_UT_KMS); + u64 before, after; if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) return NULL; + before = ktime_get_raw_ns(); + /* base block fetch */ for (i = 0; i < 4; i++) { if (get_edid_block(data, block, 0, EDID_LENGTH)) - goto out; + goto none; if (drm_edid_block_valid(block, 0, print_bad_edid, &connector->edid_corrupt)) break; @@ -1293,11 +1297,11 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, /* if there's no extensions, we're done */ if (block[0x7e] == 0) - return (struct edid *)block; + goto out; new = krealloc(block, (block[0x7e] + 1) * EDID_LENGTH, GFP_KERNEL); if (!new) - goto out; + goto none; block = new; for (j = 1; j <= block[0x7e]; j++) { @@ -1305,7 +1309,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, if (get_edid_block(data, block + (valid_extensions + 1) * EDID_LENGTH, j, EDID_LENGTH)) - goto out; + goto none; if (drm_edid_block_valid(block + (valid_extensions + 1) * EDID_LENGTH, j, print_bad_edid, @@ -1329,11 +1333,11 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, block[0x7e] = valid_extensions; new = krealloc(block, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL); if (!new) - goto out; + goto none; block = new; } - return (struct edid *)block; + goto out; carp: if (print_bad_edid) { @@ -1342,9 +1346,16 @@ carp: } connector->bad_edid_counter++; -out: +none: kfree(block); - return NULL; + block = NULL; + +out: + after = ktime_get_raw_ns(); + + account_latency(DIV_ROUND_UP_ULL(after - before, 1000)); + + return (struct edid *)block; } EXPORT_SYMBOL_GPL(drm_do_get_edid);