Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp33643466rwd; Sat, 8 Jul 2023 17:28:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlGnUImC5vzbXg2QWSHgK9r9Fn08KrU3p0ZbKSgbdKbaBsKoShp0YYxFqCLjgqbzqM8ZsWLv X-Received: by 2002:a05:6a20:1605:b0:12f:4d11:5f74 with SMTP id l5-20020a056a20160500b0012f4d115f74mr7876279pzj.58.1688862512995; Sat, 08 Jul 2023 17:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688862512; cv=none; d=google.com; s=arc-20160816; b=jo0uO61eBL1QXw/IgYXoBYvtgSgwco7Qfi2251JXgsO1dww6m7bOxGQ6h6zsbMJ/zQ DmhaMR8jKst/I0ycJ0IRpWm403JhEXbaguvWYP656cGRUE6txCgzXXFfqJZpaIGKbiLz d+OXC8qN0KGdt500xo2j0TLykhO7vhfJ8AA6b4PbKBgxxy43j9vwNVGDPGwJ0vArVr3d swbULLC7l7CU/N+zr/xleJj4BBJK99yLagxS6TkRFZvNFLSE79//ExdpcOgS7WLpsgLH yjF16gZqgLtldV2N1WPOTo9aaGEi57waH/kl41YD7Z2MosPb7+au7lu5b1AjxUVRmWnl Y7Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zuXUWar5it67xzTLsfG6dq75MzwcYYcoVnZ3Qa6+OwQ=; fh=ZFpq5Q9TzZJqzMhScaUm8WqAuwV153Y4VZzGEDpw6vA=; b=GQPdi+ay9RZSPpUKdQmdDI0YtRC7uEfMd9ErdYbHAljYzLCGyKAbvwnEVjiyjmu4TR QorSxvLeGD381kk8+hd6t7+KdDC8l3TjB43f1zGufT8V34fZNKOEDXw26Rr3Gpzlf/WU 3pYOer8/t/jHWDSgQFSB91EDvACt/FS5HmUvHH5ZG/Td42MbITL60Osa+hpxC75z2hZZ 10TH3Qyl8YAOfYaeXk4DTbSe6wtmrdAVCr+1s9hofUfKFE4MTg8WYR71DS5SZnckR6yA eukAyEI3aMFt0h0NU2EMyoSCrQZDNLFL4dRq93bT+OUmJgEVNbqHDpeEwaWNZqpLwFWm SZDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SHHzqVH1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8-20020a63e348000000b005576ebe803fsi6298806pgj.318.2023.07.08.17.28.20; Sat, 08 Jul 2023 17:28:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SHHzqVH1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229899AbjGHXnP (ORCPT + 99 others); Sat, 8 Jul 2023 19:43:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjGHXnO (ORCPT ); Sat, 8 Jul 2023 19:43:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA4C1E44 for ; Sat, 8 Jul 2023 16:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688859745; 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=zuXUWar5it67xzTLsfG6dq75MzwcYYcoVnZ3Qa6+OwQ=; b=SHHzqVH1AEimF8aLlsct+dPPJL0b6Z9XvjKNNsi8tjtffaMikU/JWwSR0gX1EY+7vldm6X tbcHjLShx198WfpGT1YnalwaVqG7GBueJCrbCRu6xNrehXD8y2/vfjOkCnat1GIB2DIbtr WnKnxyPEAyWJyflGaGiTWL9rdGm9LM8= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-AcumLT-vPJm0tC5oPjrh2w-1; Sat, 08 Jul 2023 19:42:23 -0400 X-MC-Unique: AcumLT-vPJm0tC5oPjrh2w-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2b04d5ed394so5412981fa.1 for ; Sat, 08 Jul 2023 16:42:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688859742; x=1691451742; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zuXUWar5it67xzTLsfG6dq75MzwcYYcoVnZ3Qa6+OwQ=; b=D7hPtQwy5HGknujAvBclcz/Ud6dtfe/evdI+RE7BEsDp6X1JTJu+mh8TWomsLpNyN3 MFdbW5AaZABRTh3hiwr9cwRu8P5GXqGCg7p4SjHemARx6u69LlSlf/bKL6QIyUkm4RuG kRJO0Y4iVDhuhmJ+kzb2lvtiwa2um9ETBa364+YxcqD/dX7M3IXNOCifscizb8BZknLV dHQJ4U6yD/o8/qkyieNAyHvhO77j9ifXGpN0SYurTcYzzyl8iZsgRO5wzyjsSE6VWyB/ wiLCT9YQ6+9QEbw55SLYT6ZL6GT2/Pa1PdwdiFIqFAbOYb5UIHuWMhfWQFYLHntZFUIO 9Abg== X-Gm-Message-State: ABy/qLZyWZiG7t+mi2Tg2v+l3PytwOlJ8j7Hb7RgWCXFLJqWjzvgwPRQ r2fIn2Cioyrdo2NtS4KGfO/eZtkb8ILMHp+kmO7mIGzLg0VnwBDyYrA2Thkf8z4ffWMXO38nOfc xEzRsNPNs8R8CWfnsnlELCzqyFfU73eh9Up9Y4OLx X-Received: by 2002:a2e:a10b:0:b0:2b6:9a47:c4bd with SMTP id s11-20020a2ea10b000000b002b69a47c4bdmr7458199ljl.1.1688859742161; Sat, 08 Jul 2023 16:42:22 -0700 (PDT) X-Received: by 2002:a2e:a10b:0:b0:2b6:9a47:c4bd with SMTP id s11-20020a2ea10b000000b002b69a47c4bdmr7458188ljl.1.1688859741870; Sat, 08 Jul 2023 16:42:21 -0700 (PDT) MIME-Version: 1.0 References: <20230707215851.590754-1-lyude@redhat.com> In-Reply-To: <20230707215851.590754-1-lyude@redhat.com> From: Karol Herbst Date: Sun, 9 Jul 2023 01:42:10 +0200 Message-ID: Subject: Re: [PATCH] drm/nouveau/nvkm/dp: Add hack to fix DP 1.3+ DPCD issues To: Lyude Paul Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Ben Skeggs , David Airlie , Daniel Vetter , Dave Airlie , open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 7, 2023 at 11:58=E2=80=AFPM Lyude Paul wrote= : > > Currently we use the drm_dp_dpcd_read_caps() helper in the DRM side of > nouveau in order to read the DPCD of a DP connector, which makes sure we = do > the right thing and also check for extended DPCD caps. However, it turns > out we're not currently doing this on the nvkm side since we don't have > access to the drm_dp_aux structure there - which means that the DRM side = of > the driver and the NVKM side can end up with different DPCD capabilities > for the same connector. > > Ideally to fix this, we want to start setting up the drm_dp_aux device in > NVKM before we've made contact with the DRM side - which should be pretty > easy to accomplish (I'm already working on it!). Until then however, let'= s > workaround this problem by porting a copy of drm_dp_read_dpcd_caps() into > NVKM - which should fix this issue. > > Issue: https://gitlab.freedesktop.org/drm/nouveau/-/issues/211 Should a Fixes: or Cc: stable tag be added so it gets backported? > Signed-off-by: Lyude Paul > --- > drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c | 48 ++++++++++++++++++- > 1 file changed, 47 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c b/drivers/gpu/= drm/nouveau/nvkm/engine/disp/dp.c > index 40c8ea43c42f..b8ac66b4a2c4 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c > +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c > @@ -26,6 +26,8 @@ > #include "head.h" > #include "ior.h" > > +#include > + > #include > #include > #include > @@ -634,6 +636,50 @@ nvkm_dp_enable_supported_link_rates(struct nvkm_outp= *outp) > return outp->dp.rates !=3D 0; > } > > +/* XXX: This is a big fat hack, and this is just drm_dp_read_dpcd_caps() Well.. maybe we should rephrase that _if_ we want to see it backported. But is this code really that bad? It kinda looks reasonable enough. > + * converted to work inside nvkm. This is a temporary holdover until we = start > + * passing the drm_dp_aux device through NVKM > + */ > +static int > +nvkm_dp_read_dpcd_caps(struct nvkm_outp *outp) > +{ > + struct nvkm_i2c_aux *aux =3D outp->dp.aux; > + u8 dpcd_ext[DP_RECEIVER_CAP_SIZE]; > + int ret; > + > + ret =3D nvkm_rdaux(aux, DPCD_RC00_DPCD_REV, outp->dp.dpcd, DP_REC= EIVER_CAP_SIZE); > + if (ret < 0) > + return ret; > + > + /* > + * Prior to DP1.3 the bit represented by > + * DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT was reserved. > + * If it is set DP_DPCD_REV at 0000h could be at a value less tha= n > + * the true capability of the panel. The only way to check is to > + * then compare 0000h and 2200h. > + */ > + if (!(outp->dp.dpcd[DP_TRAINING_AUX_RD_INTERVAL] & > + DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT)) > + return 0; > + > + ret =3D nvkm_rdaux(aux, DP_DP13_DPCD_REV, dpcd_ext, sizeof(dpcd_e= xt)); > + if (ret < 0) > + return ret; > + > + if (outp->dp.dpcd[DP_DPCD_REV] > dpcd_ext[DP_DPCD_REV]) { > + OUTP_DBG(outp, "Extended DPCD rev less than base DPCD rev= (%d > %d)\n", > + outp->dp.dpcd[DP_DPCD_REV], dpcd_ext[DP_DPCD_REV= ]); > + return 0; > + } > + > + if (!memcmp(outp->dp.dpcd, dpcd_ext, sizeof(dpcd_ext))) > + return 0; > + > + memcpy(outp->dp.dpcd, dpcd_ext, sizeof(dpcd_ext)); > + > + return 0; > +} > + > void > nvkm_dp_enable(struct nvkm_outp *outp, bool auxpwr) > { > @@ -689,7 +735,7 @@ nvkm_dp_enable(struct nvkm_outp *outp, bool auxpwr) > memset(outp->dp.lttpr, 0x00, sizeof(outp->dp.lttp= r)); > } > > - if (!nvkm_rdaux(aux, DPCD_RC00_DPCD_REV, outp->dp.dpcd, s= izeof(outp->dp.dpcd))) { > + if (!nvkm_dp_read_dpcd_caps(outp)) { > const u8 rates[] =3D { 0x1e, 0x14, 0x0a, 0x06, 0 = }; > const u8 *rate; > int rate_max; > -- > 2.40.1 >