From patchwork Mon Dec 9 15:01:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 11279557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9ED21575 for ; Mon, 9 Dec 2019 15:01:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D138D207FD for ; Mon, 9 Dec 2019 15:01:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D138D207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 224EF6E491; Mon, 9 Dec 2019 15:01:48 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC81E6E491 for ; Mon, 9 Dec 2019 15:01:46 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2019 07:01:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,296,1571727600"; d="scan'208";a="215114925" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga006.jf.intel.com with SMTP; 09 Dec 2019 07:01:38 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 09 Dec 2019 17:01:37 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Date: Mon, 9 Dec 2019 17:01:36 +0200 Message-Id: <20191209150137.18578-1-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH xf86-video-intel 1/2] sna: Fix dirtyfb detection X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä Fix the accidentally swapped bpp and depth values passed to the addfb ioctl when we're testing for dirtyfb presence. Currently the addfb fails every time so we don't even test the actual dirtyfb ioctl. Signed-off-by: Ville Syrjälä Reviewed-by: Chris Wilson --- src/sna/kgem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 9c0708a635fb..6a35067c4107 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1538,8 +1538,8 @@ static bool test_has_dirtyfb(struct kgem *kgem) create.width = 32; create.height = 32; create.pitch = 4*32; - create.bpp = 24; - create.depth = 32; /* {bpp:24, depth:32} -> x8r8g8b8 */ + create.bpp = 32; + create.depth = 24; /* {bpp:32, depth:24} -> x8r8g8b8 */ create.handle = gem_create(kgem->fd, 1); if (create.handle == 0) return false; From patchwork Mon Dec 9 15:01:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 11279555 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C50F1575 for ; Mon, 9 Dec 2019 15:01:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00FA7207FD for ; Mon, 9 Dec 2019 15:01:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00FA7207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A12EE6E48F; Mon, 9 Dec 2019 15:01:44 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A6A26E48F for ; Mon, 9 Dec 2019 15:01:43 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2019 07:01:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,296,1571727600"; d="scan'208";a="244474942" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga002.fm.intel.com with SMTP; 09 Dec 2019 07:01:41 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 09 Dec 2019 17:01:40 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Date: Mon, 9 Dec 2019 17:01:37 +0200 Message-Id: <20191209150137.18578-2-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191209150137.18578-1-ville.syrjala@linux.intel.com> References: <20191209150137.18578-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH xf86-video-intel 2/2] sna: Eliminate sna_mode_wants_tear_free() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä The modparam checks performed by sna_mode_wants_tear_free() don't generally work when the server is running as a regular user. Hence we can't rely on them to indicate whether FBC/PSR/etc is enabled. A lso the "Panel Self-Refresh" connector property doesn't actually exist so we can nuke that part as well. Let's just nuke the whole thing and assume we want dirtyfb always when tearfree is not enabled. I'll anyway want to enable FBC by default across the board soonish so the check wouldn't really buy us much (would just exclude i830 and a few old desktop chipsets which don't have FBC hardware). Additionally if we don't have working dirtyfb we really should enable tearfree by default because otherwise we're going to get horrible lag due to missing frontbuffer flushes. Without WC mmaps we could in theory rely on the hw gtt tracking except the kernel no longer differentiates between GTT/WC/CPU access in its software frontbuffer tracking code so it'll just deactivate FBC even for a GTT mmap and potentially never re-enable it due to the missing frontbuffer flush from dirtyfb. So dirtyfb is always needed. Signed-off-by: Ville Syrjälä --- src/sna/sna_display.c | 59 ------------------------------------------- src/sna/sna_driver.c | 8 ++---- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 874292bcab31..966ad9638a2a 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -7951,65 +7951,6 @@ bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna) return scrn->modes != NULL; } -bool -sna_mode_wants_tear_free(struct sna *sna) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn); - bool found = false; - FILE *file; - int i; - - file = fopen("/sys/module/i915/parameters/enable_fbc", "r"); - if (file) { - int fbc_enabled = 0; - int value; - - if (fscanf(file, "%d", &value) == 1) - fbc_enabled = value > 0; - fclose(file); - - DBG(("%s: module parameter 'enable_fbc' enabled? %d\n", - __FUNCTION__, fbc_enabled)); - - if (fbc_enabled) - return true; - } - - for (i = 0; i < sna->mode.num_real_output; i++) { - struct sna_output *output = to_sna_output(config->output[i]); - int id = find_property(sna, output, "Panel Self-Refresh"); - if (id == -1) - continue; - - found = true; - if (output->prop_values[id] != -1) { - DBG(("%s: Panel Self-Refresh detected on %s\n", - __FUNCTION__, config->output[i]->name)); - return true; - } - } - - if (!found) { - file = fopen("/sys/module/i915/parameters/enable_psr", "r"); - if (file) { - int psr_enabled = 0; - int value; - - if (fscanf(file, "%d", &value) == 1) - psr_enabled = value > 0; - fclose(file); - - DBG(("%s: module parameter 'enable_psr' enabled? %d\n", - __FUNCTION__, psr_enabled)); - - if (psr_enabled) - return true; - } - } - - return false; -} - void sna_mode_set_primary(struct sna *sna) { diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 4f8895f1eda2..2f61de63072f 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -459,11 +459,7 @@ static bool enable_tear_free(struct sna *sna) if (sna->flags & SNA_LINEAR_FB) return false; - /* Under certain conditions, we should enable TearFree by default, - * for example when the hardware requires pageflipping to run within - * its power/performance budget. - */ - if (sna_mode_wants_tear_free(sna)) + if (!sna->kgem.has_dirtyfb) return true; return ENABLE_TEAR_FREE; @@ -663,7 +659,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int probe) } scrn->currentMode = scrn->modes; - if (!setup_tear_free(sna) && sna_mode_wants_tear_free(sna)) + if (!setup_tear_free(sna)) sna->kgem.needs_dirtyfb = sna->kgem.has_dirtyfb; xf86SetGamma(scrn, zeros);