Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp41009ybh; Tue, 17 Mar 2020 17:43:52 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvmHK1r1bimQvJwkkhknE8KzGNGQg3MAHGHwmYOmN8o+1dhWbXrYt4wz6cJgTQoB75oofnJ X-Received: by 2002:a9d:8e4:: with SMTP id 91mr1853759otf.130.1584492232361; Tue, 17 Mar 2020 17:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584492232; cv=none; d=google.com; s=arc-20160816; b=Saj13goJftmpJ3hp5giBrW99JldfWE5FsuAxU6dDl0ClKM04rafURYZejzrySlqDND jV7JKil67XUU7rnpAruQ3MJPZqXT1PXvXfsbG4m6I2wlWp48MxgL6exVqxYtKur3e4g5 E0zbbNtiBCT8/v1JuramcTyqQhMp5zofDBN9VmXUAKwtKmlXdyhyoDmMNpz5ArDo/cTx /2PaycVg5GsHSrArLVc1cIqVGgx0SATM23RVSki85gjky9OUc0GZApfDA5mlnNZnmFm1 y7tmEHftVHz1ia84jIa4gGe8cit71HsAyY7FpCtP5gtLOwNhAGakGFqAYcE9bheQYIvF lUTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AHM7ZtQrqL66AlZLTkCny1wpuXE+O5sBh+lgMwRBnYc=; b=IYybDuwUc5YAEasY7wwaGenFVdUiOkloP7mHFkkVu5wU2dvDS46NiQt3aRhN0EqWYc cMQOVF+BRfeC8iS7kpFDq4Vb3HiiugoG8JuqJh3UQ0rgP9bQXeF2z6DOLTW+oPg5n1/W Fdek6GzX9eWzmc8Hffbbc2LoG+z0/8lEW0CGwpSpj0GM8rr8YG9zdB+1FneS/PH9vHnL QvaxwJW92aCYFAYjQxEzMi4WORlNfD8WulwV8yLm49nZ9U+LHsbSBddWc7rOb77zrX5p flnEnqqI1qUq/uwPUvsa/EIAJ3lRjNL02Q1y+F5O3e06G4HzPmgbulVJaV/snuBNRlYA h4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BqYiPZWj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v127si2524574oib.25.2020.03.17.17.43.40; Tue, 17 Mar 2020 17:43:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BqYiPZWj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727496AbgCRAmx (ORCPT + 99 others); Tue, 17 Mar 2020 20:42:53 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:44985 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727262AbgCRAmw (ORCPT ); Tue, 17 Mar 2020 20:42:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584492171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AHM7ZtQrqL66AlZLTkCny1wpuXE+O5sBh+lgMwRBnYc=; b=BqYiPZWjX21PM+Ov1xpcZE3dAMf9TjAq3/WF1mUXFhZL4BolXAoTBtmjHdRWwXWeKNnN8B 4z7zuUzQ3bxn7WftwREJgMiCr1/uLKG7lsqIo3xpsDqPRxzN9fGLEy0DhzZoqgS5V7kgil jjGz9tsxacUYVBGKLqAwQZtjyqvjMVw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-1NBXRDTAMhmC7bGiHxSluA-1; Tue, 17 Mar 2020 20:42:49 -0400 X-MC-Unique: 1NBXRDTAMhmC7bGiHxSluA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC4E3477; Wed, 18 Mar 2020 00:42:47 +0000 (UTC) Received: from whitewolf.redhat.com (ovpn-113-173.rdu2.redhat.com [10.10.113.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92B2A60BE0; Wed, 18 Mar 2020 00:42:46 +0000 (UTC) From: Lyude Paul To: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Ben Skeggs , David Airlie , Daniel Vetter , Ilia Mirkin , Pankaj Bharadiya , Sean Paul , Alex Deucher , Takashi Iwai , linux-kernel@vger.kernel.org Subject: [PATCH 6/9] drm/nouveau/kms/nv140-: Track wndw mappings in nv50_head_atom Date: Tue, 17 Mar 2020 20:41:03 -0400 Message-Id: <20200318004159.235623-7-lyude@redhat.com> In-Reply-To: <20200318004159.235623-1-lyude@redhat.com> References: <20200318004159.235623-1-lyude@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While we're not quite ready yet to add support for flexible wndw mappings, we are going to need to at least keep track of the static wndw mappings we're currently using in each head's atomic state. We'll likely use this in the future to implement real flexible window mapping, but the primary reason we'll need this is for CRC support. See: on nvidia hardware, each CRC entry in the CRC notifier dma context has a "tag". This tag corresponds to the nth update on a specific EVO/NvDisplay channel, which itself is referred to as the "controlling channel". For gf119+ this can be the core channel, ovly channel, or base channel. Since we don't expose CRC entry tags to userspace, we simply ignore this feature and always use the core channel as the controlling channel. Simple. Things get a little bit more complicated on gv100+ though. GV100+ only lets us set the controlling channel to a specific wndw channel, and that wndw must be owned by the head that we're grabbing CRCs when we enable CRC generation. Thus, we always need to make sure that each atomic head state has at least one wndw that is mapped to the head, which will be used as the controlling channel. Note that since we don't have flexible wndw mappings yet, we don't expect to run into any scenarios yet where we'd have a head with no mapped wndws. When we do add support for flexible wndw mappings however, we'll need to make sure that we handle reprogramming CRC capture if our controlling wndw is moved to another head (and potentially reject the new head state entirely if we can't find another available wndw to replace it). With that being said, nouveau currently tracks wndw visibility on heads. It does not keep track of the actual ownership mappings, which are (currently) statically programmed. To fix this, we introduce another bitmask into nv50_head_atom.wndw to keep track of ownership separately from visibility. We then introduce a nv50_head callback to handle populating the wndw ownership map, and call it during the atomic check phase when core->assign_windows is set to true. Signed-off-by: Lyude Paul --- drivers/gpu/drm/nouveau/dispnv50/atom.h | 1 + drivers/gpu/drm/nouveau/dispnv50/disp.c | 16 ++++++++++++++++ drivers/gpu/drm/nouveau/dispnv50/head.h | 2 ++ drivers/gpu/drm/nouveau/dispnv50/headc37d.c | 10 ++++++++++ drivers/gpu/drm/nouveau/dispnv50/headc57d.c | 2 ++ 5 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/nouveau/dispnv50/atom.h b/drivers/gpu/drm/no= uveau/dispnv50/atom.h index 24f7700768da..62faaf60f47a 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/atom.h +++ b/drivers/gpu/drm/nouveau/dispnv50/atom.h @@ -18,6 +18,7 @@ struct nv50_head_atom { =20 struct { u32 mask; + u32 owned; u32 olut; } wndw; =20 diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/no= uveau/dispnv50/disp.c index 4d1c58468dbc..f510eeafca4b 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -2253,12 +2253,28 @@ static int nv50_disp_atomic_check(struct drm_device *dev, struct drm_atomic_state *= state) { struct nv50_atom *atom =3D nv50_atom(state); + struct nv50_core *core =3D nv50_disp(dev)->core; struct drm_connector_state *old_connector_state, *new_connector_state; struct drm_connector *connector; struct drm_crtc_state *new_crtc_state; struct drm_crtc *crtc; + struct nv50_head *head; + struct nv50_head_atom *asyh; int ret, i; =20 + if (core->assign_windows && core->func->head->static_wndw_map) { + drm_for_each_crtc(crtc, dev) { + new_crtc_state =3D drm_atomic_get_crtc_state(state, + crtc); + if (IS_ERR(new_crtc_state)) + return PTR_ERR(new_crtc_state); + + head =3D nv50_head(crtc); + asyh =3D nv50_head_atom(new_crtc_state); + core->func->head->static_wndw_map(head, asyh); + } + } + /* We need to handle colour management on a per-plane basis. */ for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { if (new_crtc_state->color_mgmt_changed) { diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.h b/drivers/gpu/drm/no= uveau/dispnv50/head.h index c32b27cdaefc..c05bbba9e247 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/head.h +++ b/drivers/gpu/drm/nouveau/dispnv50/head.h @@ -40,6 +40,7 @@ struct nv50_head_func { void (*dither)(struct nv50_head *, struct nv50_head_atom *); void (*procamp)(struct nv50_head *, struct nv50_head_atom *); void (*or)(struct nv50_head *, struct nv50_head_atom *); + void (*static_wndw_map)(struct nv50_head *, struct nv50_head_atom *); }; =20 extern const struct nv50_head_func head507d; @@ -86,6 +87,7 @@ int headc37d_curs_format(struct nv50_head *, struct nv5= 0_wndw_atom *, void headc37d_curs_set(struct nv50_head *, struct nv50_head_atom *); void headc37d_curs_clr(struct nv50_head *); void headc37d_dither(struct nv50_head *, struct nv50_head_atom *); +void headc37d_static_wndw_map(struct nv50_head *, struct nv50_head_atom = *); =20 extern const struct nv50_head_func headc57d; #endif diff --git a/drivers/gpu/drm/nouveau/dispnv50/headc37d.c b/drivers/gpu/dr= m/nouveau/dispnv50/headc37d.c index 68920f8d9c79..cf5a68f4021a 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/headc37d.c +++ b/drivers/gpu/drm/nouveau/dispnv50/headc37d.c @@ -203,6 +203,15 @@ headc37d_view(struct nv50_head *head, struct nv50_he= ad_atom *asyh) } } =20 +void +headc37d_static_wndw_map(struct nv50_head *head, struct nv50_head_atom *= asyh) +{ + int i, end; + + for (i =3D head->base.index * 2, end =3D i + 2; i < end; i++) + asyh->wndw.owned |=3D BIT(i); +} + const struct nv50_head_func headc37d =3D { .view =3D headc37d_view, @@ -218,4 +227,5 @@ headc37d =3D { .dither =3D headc37d_dither, .procamp =3D headc37d_procamp, .or =3D headc37d_or, + .static_wndw_map =3D headc37d_static_wndw_map, }; diff --git a/drivers/gpu/drm/nouveau/dispnv50/headc57d.c b/drivers/gpu/dr= m/nouveau/dispnv50/headc57d.c index 0296cd1d761f..65e3b60804c6 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/headc57d.c +++ b/drivers/gpu/drm/nouveau/dispnv50/headc57d.c @@ -210,4 +210,6 @@ headc57d =3D { .dither =3D headc37d_dither, .procamp =3D headc57d_procamp, .or =3D headc57d_or, + /* TODO: flexible window mappings */ + .static_wndw_map =3D headc37d_static_wndw_map, }; --=20 2.24.1