From patchwork Sat Jan 2 14:19:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 11995177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FE2BC433E6 for ; Sat, 2 Jan 2021 14:19:57 +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 257A022482 for ; Sat, 2 Jan 2021 14:19:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 257A022482 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76BF189801; Sat, 2 Jan 2021 14:19:55 +0000 (UTC) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by gabe.freedesktop.org (Postfix) with ESMTPS id C574989739; Sat, 2 Jan 2021 14:19:53 +0000 (UTC) Received: by mail-wm1-x333.google.com with SMTP id q75so13674559wme.2; Sat, 02 Jan 2021 06:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EO/wWSEfiojNBhjbsuAnQ1uZN5JIWue6TqHVURU3Q2c=; b=ha7F76nygzZqzDrjrzOYhVuhPTAaBOTrwJs+Idcd/pTimNcER3wEa1PkIG0NLqFXjX 5WoQ6jl7TM3clv04gWiGmIMfuPYmndudxTEF0DIYClja0KIKaLn3ngJwX3Uv4tXIs/26 /vMGgO1F8RGd1NLNUiu4ifyt3wqCDpYc8wQ1mKT7ZIpe+Q3IG8ucwY6TMZLoZ9KB5Cwj 0f6xXOekVx8zUlL+H0/jdj27vWyo5nqy/gaysdmnFOL2rIAF0ZzUPufbYiDAm12d7HAY oGkTGeCoDC/pQOR+eTCIwQoYVcml3xY1wcv3lFy0uwsbDE9fEgnvjzg1wwbwCJ9jDqpa mrhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EO/wWSEfiojNBhjbsuAnQ1uZN5JIWue6TqHVURU3Q2c=; b=UnWt2OuYpyNeZp1QedZQKOhInvZhmjGUIU2+22eORnea08FzjYYCWJTO84wurXnCRk cm5529ugRIZKgeEODfbDAXnvHS8VopDplE2TsS1XWHd60AFFHOQAuFuYyYMz/kaYEWHs Tf4y9emv7GLU9wMsYnbly1Zz6u0rB7sT5gyJOT8KzBgW4s6KX9z1QmdsA4ylu8oMNuvq xGAjVyH0DUvT8g+pVP2sdTX3GLDBRAte4wqZeTa3BxxMel/teYcmqYhAMWcDE+f2yrQo Qmb9erhqNhOkasu3fGkKrTnE298kr7N3X64NCcteptAJxP8lbwkF7iWj+Ylr2dtANdyw 7New== X-Gm-Message-State: AOAM531FT8ra0AHhMsOFasL1GlCgdTIm5hiejDKq8ZC8IZsDE8Kn1uvQ XkET8skudHpfYtre92RwB/bnZ8E9Plc= X-Google-Smtp-Source: ABdhPJzF4BKsvIY28nGnd08cOyMm1GYd/KGdE+WhSm0C6cZxbD24Nu+S0AYyQ2qGcB9UPnds+I38LA== X-Received: by 2002:a7b:ce17:: with SMTP id m23mr19624541wmc.117.1609597192283; Sat, 02 Jan 2021 06:19:52 -0800 (PST) Received: from twisty.localdomain (dynamic-2a01-0c23-78d0-4200-6cbb-50d4-b91e-5b37.c23.pool.telefonica.de. [2a01:c23:78d0:4200:6cbb:50d4:b91e:5b37]) by smtp.gmail.com with ESMTPSA id y130sm23983683wmc.22.2021.01.02.06.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Jan 2021 06:19:51 -0800 (PST) From: Mario Kleiner To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH] drm: Allow format change during legacy page-flip if driver is atomic. Date: Sat, 2 Jan 2021 15:19:42 +0100 Message-Id: <20210102141942.29109-1-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Deucher , David Airlie Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This is a slight improvement for legacy flipping, but also an attempted fix for a bug/regression introduced into Linux 4.11-rc. Commit 816853f9dc4057b6c7ee3c45ca9bd5905 ("drm/amd/display: Set new format info for converted metadata.") fixes the getfb2 ioctl, but in exchange it completely breaks all pageflipping for classic user space, e.g., XOrg, as tested with both amdgpu-ddx and modesetting-ddx. This leads to massive tearing, broken visual timing/timestamping, and a xorg log flooded with error messages, as tested on Ubuntu 20.04.1-LTS with X-Server 1.20.8, Mesa 20.0.8, amdgpu-ddx 19.1.0 and also with the modesetting-ddx with/without atomic on a AMD Raven Ridge gpu. Changes to future Mesa Vulkan drivers beyond 20.0.8 may break (or already have broken?) page flipping on those as well. The reason is that the classic pageflip ioctl doesn't allow a fb format change during flip, and at least X uses classic pageflip ioctl and no atomic modesetting api for flipping, as do all inspected Vulkan drivers, e.g., anv, radv, amdvlk. Above commit assigns new fb->format for use of (retiling) DCC on AMD gpu's for some tiling flags, which is detected (and rejected) by the pageflip ioctl as a format change. However, current atomic kms drivers hook up the ->page_flip() driver function to the atomic helper function drm_atomic_helper_page_flip(), which implements the legacy flip as an atomic commit. My understanding is that a format change during flip via such an atomic commit is safe. Therefore only reject the legacy pageflip ioctl if a fb format change is requested on a kms driver which isn't DRIVER_ATOMIC. This makes "legacy" flipping work again on Linux 4.11 with amdgpu-kms and DisplayCore enabled. Fixes: 816853f9dc40 ("drm/amd/display: Set new format info for converted metadata.") Cc: Bas Nieuwenhuizen Cc: Alex Deucher Cc: David Airlie Cc: Ville Syrjälä Signed-off-by: Mario Kleiner --- drivers/gpu/drm/drm_plane.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index e6231947f987..4688360a078d 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -1163,7 +1163,11 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, if (ret) goto out; - if (old_fb->format != fb->format) { + /* + * Format change during legacy pageflip only works if page flip is done + * via an atomic commit, e.g., via drm_atomic_helper_page_flip() helper. + */ + if ((old_fb->format != fb->format) && !drm_drv_uses_atomic_modeset(dev)) { DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer format.\n"); ret = -EINVAL; goto out;