From patchwork Wed Jun 28 21:22:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Herbst X-Patchwork-Id: 13296356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E850BEB64DA for ; Wed, 28 Jun 2023 21:23:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4680910E391; Wed, 28 Jun 2023 21:22:57 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 77EEE10E391 for ; Wed, 28 Jun 2023 21:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687987373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=35yLjXwmK+JFwMD6kxYKyYPiJnk3z5/P0tWTo/VOF6w=; b=LMsWvE6TuaVskBWM73K6Fb3+d0xHrQXcoCrUMxpM+npyP6pmYsveD5ARxVQ2W4BhwPikBz lsiPSZEBrKMneOH4YB2NxDXrfX80xA9EolEip+yz4IOA34r4WAtU4boWz15AGXluuzXQbM 6eKmAQBDABBDQUSaHjrxmGJ9v2IDBm4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-Ha26TF83MimCicKEvQLhmQ-1; Wed, 28 Jun 2023 17:22:51 -0400 X-MC-Unique: Ha26TF83MimCicKEvQLhmQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-313ecc94e23so682f8f.0 for ; Wed, 28 Jun 2023 14:22:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687987370; x=1690579370; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=35yLjXwmK+JFwMD6kxYKyYPiJnk3z5/P0tWTo/VOF6w=; b=Wpaqv2+TDc2nDNwbRCNKVprElEQTktp2A1ckZebrVi0lEMCMob1Bqd8Vx5JhXmrDpB CuAI2WIqxa2nNO6dW8JmT+zGkiRrv64IylLkXwMuPDb2WcAFRqzIWuD6gOxl13gHOShQ a/6F0UC3Mu+n9yTLMFkvO+sSO2yqhf+VHgRbqT4xfjVucfyEvFnHHRGTdm5HRHBQito6 jt+lF+mEhdBhUAR3Lq+Pk+raMOibE4SctTmdJKyUMtBv+wfZC6JMGnW22TPrm7FjEWgQ z7kY0km9RTvcWoPdm1RbLk6kIP43u601nJjm/8GjkyizXuFOQ6GH7SNlOkfEEXT3WjO1 WL5Q== X-Gm-Message-State: AC+VfDwlwFUAalPzNQfBkTBKE6WdvaD6vC9165513Uwz2qn6rlCQR0xC iXOHcmw+MPvN1YKiUgycNbgb+l+p+2q8mDv2Jant8Icl9m/asJyN2OZeottG2O3DeRwiExqQxep a4AuurwuocM4AMPXN1M7zNmdpSPA9 X-Received: by 2002:a5d:688c:0:b0:313:e8fb:b00f with SMTP id h12-20020a5d688c000000b00313e8fbb00fmr12064949wru.6.1687987370472; Wed, 28 Jun 2023 14:22:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4etKwVYGUIIKgW4+xNP19noBx/4crXKmYa7hOdvnL0JSt90wwvxFWoR/KRdnfuAOGnZNBW/g== X-Received: by 2002:a5d:688c:0:b0:313:e8fb:b00f with SMTP id h12-20020a5d688c000000b00313e8fbb00fmr12064938wru.6.1687987370225; Wed, 28 Jun 2023 14:22:50 -0700 (PDT) Received: from kherbst.pingu ([95.90.48.30]) by smtp.gmail.com with ESMTPSA id r3-20020adfda43000000b0030ae3a6be4asm14294323wrl.72.2023.06.28.14.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 14:22:49 -0700 (PDT) From: Karol Herbst To: linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drm/nouveau/disp: fix HDMI on gt215+ Date: Wed, 28 Jun 2023 23:22:46 +0200 Message-ID: <20230628212248.3798605-1-kherbst@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: nouveau@lists.freedesktop.org, Karol Herbst , dri-devel@lists.freedesktop.org, Ben Skeggs Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Cc: Ben Skeggs Cc: Lyude Paul Fixes: f530bc60a30b ("drm/nouveau/disp: move HDMI config into acquire + infoframe methods") Signed-off-by: Karol Herbst --- drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c index a2c7c6f83dcd..506ffbe7b842 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c @@ -125,7 +125,7 @@ gt215_sor_hdmi_infoframe_avi(struct nvkm_ior *ior, int head, void *data, u32 siz pack_hdmi_infoframe(&avi, data, size); nvkm_mask(device, 0x61c520 + soff, 0x00000001, 0x00000000); - if (size) + if (!size) return; nvkm_wr32(device, 0x61c528 + soff, avi.header); From patchwork Wed Jun 28 21:22:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Herbst X-Patchwork-Id: 13296357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D5CEBEB64DC for ; Wed, 28 Jun 2023 21:23:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A181510E3A1; Wed, 28 Jun 2023 21:23:00 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD81510E184 for ; Wed, 28 Jun 2023 21:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687987375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L25XPrE4POZxEhhk2/19p0p2PCDX/k5AJ4PHMsFVmoI=; b=BoKSULVxguSud07235RLRctOhRwU9j0pClqh2sITAUxOHhh42fNvpFoxnpYw4ctAEjNPdC vHc1O+Xp6gtVWlxaLav/waAoMyiUVmBOe1mei+6CT3QAPln8snz2IXjahqqLV0mnMTQdUS lPGg3551CgOb7RerwVTgHCKl18iSE5k= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-323-5BGTwETWPs-k8ksiE1BrtQ-1; Wed, 28 Jun 2023 17:22:52 -0400 X-MC-Unique: 5BGTwETWPs-k8ksiE1BrtQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fa982366acso7665e9.0 for ; Wed, 28 Jun 2023 14:22:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687987371; x=1690579371; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L25XPrE4POZxEhhk2/19p0p2PCDX/k5AJ4PHMsFVmoI=; b=ikEvN6NWvj6CX/ckfSn4GFpEsUVgSe9d/xINxVmrUQwoXtBCaiVkU0Mn0CgZowW/6n Y/7mE6Pk8R5yo1kkGAQxKjrIdmj3vaPSR+GrRy4UHGLX6eTBLHeSM89qYk1dRpLCKCGs U5rTu9WO4esDm6qsDLbocBlKoT5ZSKWsKeYOQjitFC0uotUkWfYpkypTz3GOMPgtNOEA g0AHIQngr638QXRmgs7YvqdWlDOdLhxgYmkabArmP5sgMQCvT6hlCw5/FIqW+AfKYBDy pzhKqXnjZJTk/818S6oujW5qCCf4Hy3/VjbO+qxYqV1Sb4QYiakxQoUG/8HuByEe3tMd GcXg== X-Gm-Message-State: AC+VfDzlhEcXvZ4YRcrznmGzFhIHWbLOiQ7froxHHbnJJRFIhuw8r/LX HVQM5hOFf1a9OkLXxXfk7bYOdiPdoZeqkrPJUEKPAAiHfGfo1TFieTkUeyCUSkJGR5VlsxF3z6j AlrKUtgNAUk+Rf0bVpHNYOwbIJTBM X-Received: by 2002:adf:f990:0:b0:313:edaa:24f3 with SMTP id f16-20020adff990000000b00313edaa24f3mr9337089wrr.5.1687987371819; Wed, 28 Jun 2023 14:22:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HubsUmqIJhwm4B7AbWuPZejQ5/Mr/9PKWcvbTsxn13ECBZOSCiJ2Y0q/28ms0yNC5JG/oVw== X-Received: by 2002:adf:f990:0:b0:313:edaa:24f3 with SMTP id f16-20020adff990000000b00313edaa24f3mr9337087wrr.5.1687987371669; Wed, 28 Jun 2023 14:22:51 -0700 (PDT) Received: from kherbst.pingu ([95.90.48.30]) by smtp.gmail.com with ESMTPSA id r3-20020adfda43000000b0030ae3a6be4asm14294323wrl.72.2023.06.28.14.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 14:22:50 -0700 (PDT) From: Karol Herbst To: linux-kernel@vger.kernel.org Subject: [PATCH 2/3] drm/nouveau/disp: drop unused argument in nv50_dp_mode_valid Date: Wed, 28 Jun 2023 23:22:47 +0200 Message-ID: <20230628212248.3798605-2-kherbst@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628212248.3798605-1-kherbst@redhat.com> References: <20230628212248.3798605-1-kherbst@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: nouveau@lists.freedesktop.org, Karol Herbst , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Karol Herbst --- drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dp.c | 3 +-- drivers/gpu/drm/nouveau/nouveau_encoder.h | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index 1637e08b548c..6221eaaad1b7 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -1127,7 +1127,7 @@ nv50_mstc_mode_valid(struct drm_connector *connector, * MSTB's max possible PBN */ - return nv50_dp_mode_valid(connector, outp, mode, NULL); + return nv50_dp_mode_valid(outp, mode, NULL); } static int diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index f75c6f09dd2a..22c42a5e184d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -1079,7 +1079,7 @@ nouveau_connector_mode_valid(struct drm_connector *connector, case DCB_OUTPUT_TV: return get_slave_funcs(encoder)->mode_valid(encoder, mode); case DCB_OUTPUT_DP: - return nv50_dp_mode_valid(connector, nv_encoder, mode, NULL); + return nv50_dp_mode_valid(nv_encoder, mode, NULL); default: BUG(); return MODE_BAD; diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index d49b4875fc3c..6a4980b2d4d4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c @@ -267,8 +267,7 @@ nouveau_dp_irq(struct work_struct *work) * yet) */ enum drm_mode_status -nv50_dp_mode_valid(struct drm_connector *connector, - struct nouveau_encoder *outp, +nv50_dp_mode_valid(struct nouveau_encoder *outp, const struct drm_display_mode *mode, unsigned *out_clock) { diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h b/drivers/gpu/drm/nouveau/nouveau_encoder.h index 70c1ad6c4d9d..bcba1a14cfab 100644 --- a/drivers/gpu/drm/nouveau/nouveau_encoder.h +++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h @@ -143,8 +143,7 @@ enum nouveau_dp_status { int nouveau_dp_detect(struct nouveau_connector *, struct nouveau_encoder *); bool nouveau_dp_link_check(struct nouveau_connector *); void nouveau_dp_irq(struct work_struct *); -enum drm_mode_status nv50_dp_mode_valid(struct drm_connector *, - struct nouveau_encoder *, +enum drm_mode_status nv50_dp_mode_valid(struct nouveau_encoder *, const struct drm_display_mode *, unsigned *clock); From patchwork Wed Jun 28 21:22:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Herbst X-Patchwork-Id: 13296358 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 58130C001B3 for ; Wed, 28 Jun 2023 21:23:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E10010E3B0; Wed, 28 Jun 2023 21:23:01 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id D798210E391 for ; Wed, 28 Jun 2023 21:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687987376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fP84djK5erd2GrrGFYuKnbHCuXvHXjeqzaJ4gXaZwiY=; b=ZNw578iToXhS8R0iXbKZePNvpuDfvvME3cKvSMt04ZzMJ5l8VCcZwNoL0U3wyd8WDmwdCY Bf9Py+L4jRtKcHa32kdSG5G3EJ4nBD4wMfxFUQppghFoWTSqbsi2UGbxq5n0y46lt+/Hwy nC8QLlvDTm3Q31oucmmR1sNllJwvsTc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-600-zON2l-LNNJCinGZNhVp-Hw-1; Wed, 28 Jun 2023 17:22:55 -0400 X-MC-Unique: zON2l-LNNJCinGZNhVp-Hw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-313e542e2f5so38567f8f.1 for ; Wed, 28 Jun 2023 14:22:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687987374; x=1690579374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fP84djK5erd2GrrGFYuKnbHCuXvHXjeqzaJ4gXaZwiY=; b=NYt2ii7QiumHrX48KRKqJuX0xIl1U0iX/w88H56uLhhLnHMOuRlAxR9cr0WP8n7vSv Q1BCGOQIrBbLvEf1wP4sD3tVlvlcmdXkX/EBvKZDojpx3v7BbIRR0en04ckPUde/STCC MWSbaKK6cpjWrLM+nQham06nkFyrT84+w6b5bkveJjTM+RtddSiqzzw+rHnhMsbXwfzG iimP2j/VhSGqeoaa36SuCXnONW7vf9902Na9CvAFTNYKCU7Fp0hN1qFjqfbDC7YkWuAx mhVAL1SfDUITNyMnbKyS76mTcdB6Ytd24h5DVpG7Wft0e68x3JUrMDfhdkvuzKWzg+cX mLag== X-Gm-Message-State: AC+VfDzgb3VFbM6YQMxcX6hTlVe2iCdDiIT30HiRoZNABdMGiYWfUpg4 bJufE5DfaX85ZFAD9I38+1LYs/8ZgklM70HtL1zPslVKxt0JwLmLNrUmB0LvJhZKxQxDpTqS/HJ T26LF94czNX0fFUMZkw1TTzdN5oOF X-Received: by 2002:a05:6000:151:b0:314:a77:b6c0 with SMTP id r17-20020a056000015100b003140a77b6c0mr2925783wrx.1.1687987373883; Wed, 28 Jun 2023 14:22:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dTARVZLT46r+M/QXdzbg3Pfto134Vfy7ETRKzO1nDBcz+HGLvTECmnUAAxcjTyp3OM3kxvg== X-Received: by 2002:a05:6000:151:b0:314:a77:b6c0 with SMTP id r17-20020a056000015100b003140a77b6c0mr2925773wrx.1.1687987373643; Wed, 28 Jun 2023 14:22:53 -0700 (PDT) Received: from kherbst.pingu ([95.90.48.30]) by smtp.gmail.com with ESMTPSA id r3-20020adfda43000000b0030ae3a6be4asm14294323wrl.72.2023.06.28.14.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 14:22:52 -0700 (PDT) From: Karol Herbst To: linux-kernel@vger.kernel.org Subject: [PATCH 3/3] drm/nouveau/disp: verify mode on atomic_check Date: Wed, 28 Jun 2023 23:22:48 +0200 Message-ID: <20230628212248.3798605-3-kherbst@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628212248.3798605-1-kherbst@redhat.com> References: <20230628212248.3798605-1-kherbst@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Karol Herbst , nouveau@lists.freedesktop.org, stable@vger.kernel.org, dri-devel@lists.freedesktop.org, Ben Skeggs Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We have to verify the selected mode as Userspace might request one which we can't configure the GPU for. X with the modesetting DDX is adding a bunch of modes, some so far outside of hardware limits that things simply break. Sadly we can't fix X this way as on start it sticks to one mode and ignores any error and there is really nothing we can do about this, but at least this way we won't let the GPU run into any errors caused by a non supported display mode. However this does prevent X from switching to such a mode, which to be fair is an improvement as well. Seen on one of my Tesla GPUs with a connected 4K display. Link: https://gitlab.freedesktop.org/drm/nouveau/-/issues/199 Cc: Ben Skeggs Cc: Lyude Paul Cc: stable@vger.kernel.org # v6.1+ Signed-off-by: Karol Herbst --- drivers/gpu/drm/nouveau/nouveau_connector.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 22c42a5e184d..edf490c1490c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -1114,6 +1114,25 @@ nouveau_connector_atomic_check(struct drm_connector *connector, struct drm_atomi struct drm_connector_state *conn_state = drm_atomic_get_new_connector_state(state, connector); + /* As we can get any random mode from Userspace, we have to make sure the to be set mode + * is valid and does not violate hardware constraints as we rely on it being sane. + */ + if (conn_state->crtc) { + struct drm_crtc_state *crtc_state = + drm_atomic_get_crtc_state(state, conn_state->crtc); + + if (IS_ERR(crtc_state)) + return PTR_ERR(crtc_state); + + if (crtc_state->enable && (crtc_state->mode_changed || + crtc_state->connectors_changed)) { + struct drm_display_mode *mode = &crtc_state->mode; + + if (connector->helper_private->mode_valid(connector, mode) != MODE_OK) + return -EINVAL; + } + } + if (!nv_conn->dp_encoder || !nv50_has_mst(nouveau_drm(connector->dev))) return 0;