From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 886D2EEC3 for ; Fri, 1 May 2026 21:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777672754; cv=none; b=kWPGN71dnpFPzoR1upc5xLZg3Do8dtadPTbsryuHobZkP8xhXiNrc94FYl4S3P+AKGx5i1tNEPlN6Bh1xncJ80DghPgeKj5DLnR606DeOtd4X69j5YQeehDjuP45rkXE15sCTze+wmUKBpGn47liPK660QlZWz5y5vPtXnwFpAI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777672754; c=relaxed/simple; bh=m3LN0xXXm9+rBQF5Rrrqlbu8tvLR83mAQ/0wm1msF1I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Bv72JDxQ93mr/zE8rrj3c/WaSJ/A8/dXKyMWmjpUVyotbP3PSC2qPU5OyvmFQxNykDTw2Na/Mp6+zVwbd0KpxafW8cofooQlQhfcnHHqSalyJ93UTa5ZmTNPNMXTpNRnidWrPP9gONoAWMscMz3YIt5vKy7Lu/cltIQvOMFJxm8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OnRVwRrh; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OnRVwRrh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777672751; 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; bh=/w4qNCZg0K61tLxc2dmtZAH4YsoauH0iGhCHk3w+L3w=; b=OnRVwRrh07S7bvSORPJikZuRA+EpmTX6om68LBHPypkTecNLAtCegRvoNjzewDo9mrgqgk IilmXCiN4R8vvmY0lp1SKzRQ/sNAEem20Jo9hyXpREMOPQK9KAThtws6kH0l4hVY5e236X xu7m6zLqUi0FK95piGA+xzi62HJ+1ec= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-EOEI6xEhPveiyKAC_70A7w-1; Fri, 01 May 2026 17:59:07 -0400 X-MC-Unique: EOEI6xEhPveiyKAC_70A7w-1 X-Mimecast-MFC-AGG-ID: EOEI6xEhPveiyKAC_70A7w_1777672745 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6533D1800473; Fri, 1 May 2026 21:59:04 +0000 (UTC) Received: from GoldenWind.lan (unknown [10.22.64.61]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D382130001A1; Fri, 1 May 2026 21:59:01 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Dave Airlie , Danilo Krummrich , Dave Airlie , Timur Tabi , Suraj Kandpal , James Jones , Faith Ekstrand , stable@vger.kernel.org, "Maarten Lankhorst" , "Ben Skeggs" , "Simona Vetter" , "Thomas Zimmermann" , "Maxime Ripard" , "Lyude Paul" Subject: [PATCH] drm/nouveau/kms/nvd9-: Use contiguous memory for CRC notifier context Date: Fri, 1 May 2026 17:58:55 -0400 Message-ID: <20260501215856.840898-1-lyude@redhat.com> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 It looks like CRC read back has been slightly broken for a while now, in particular on GPUs using GSP. On my test machines, it's worked normally when attempting to use it from fbcon. After gnome-shell gets started however, attempting to read /sys/kernel/debug/dri/$CARD/$CRTC/crc/data just returns -EINVAL. It turns out what's been happening is that since we've been using nvif_mem_ctor_map() to both allocate and map the CRC notifier region - we haven't actually asked for a contiguous allocation, and simply ask for whatever type of memory allocation nouveau can find first. This doesn't work because the CRC engine on nvidia GPUs doesn't support non-contiguous allocations, which also causes us to fail setting up the kmsCrcNtfyCtxDma object on pre-blackwell platforms since we don't have a single memory address we can point nvif_object_ctor() to. Instead, ctx->mem.addr gets set to ~0ULL. It does however, seem to work when fbcon is running. The only reason I can think of this is that before we start up a display environment, there is pretty much nothing allocated in our VRAM that wasn't allocated by nouveau itself - making it dramatically more likely that we end up finding a contiguous allocation by default. So, fix this by manually requesting a contiguous allocation when we allocate our context notifiers. Signed-off-by: Lyude Paul Fixes: 12885ecbfe62 ("drm/nouveau/kms/nvd9-: Add CRC support") Cc: Lyude Paul Cc: Dave Airlie Cc: Danilo Krummrich Cc: Dave Airlie Cc: Timur Tabi Cc: Suraj Kandpal Cc: James Jones Cc: Faith Ekstrand Cc: dri-devel@lists.freedesktop.org Cc: nouveau@lists.freedesktop.org Cc: # v5.9+ --- drivers/gpu/drm/nouveau/dispnv50/crc.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c index deb6af40ef328..5817f39934a8b 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/crc.c +++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -499,16 +500,24 @@ nv50_crc_raster_type(enum nv50_crc_source source) * notifier needs it's own handle */ static inline int -nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu, +nv50_crc_ctx_init(struct drm_device *dev, struct nv50_head *head, struct nvif_mmu *mmu, struct nv50_crc_notifier_ctx *ctx, size_t len, int idx) { - struct nv50_core *core = nv50_disp(head->base.base.dev)->core; + struct nv50_core *core = nv50_disp(dev)->core; int ret; - ret = nvif_mem_ctor_map(mmu, "kmsCrcNtfy", NVIF_MEM_VRAM, len, &ctx->mem); + /* The display engine requires a contiguous region of memory for the CRC notifier context */ + ret = nvif_mem_ctor(mmu, "kmsCrcNtfy", mmu->mem, NVIF_MEM_VRAM | NVIF_MEM_MAPPABLE, 0, len, + &(struct gf100_mem_v0) { + .contig = true, + }, sizeof(struct gf100_mem_v0), &ctx->mem); if (ret) return ret; + ret = nvif_object_map(&ctx->mem.object, NULL, 0); + if (ret) + goto fail_fini; + /* No CTXDMAs on Blackwell. */ if (core->chan.base.user.oclass >= GB202_DISP_CORE_CHANNEL_DMA) return 0; @@ -576,7 +585,7 @@ int nv50_crc_set_source(struct drm_crtc *crtc, const char *source_str) if (source) { for (i = 0; i < ARRAY_SIZE(head->crc.ctx); i++) { - ret = nv50_crc_ctx_init(head, mmu, &crc->ctx[i], + ret = nv50_crc_ctx_init(dev, head, mmu, &crc->ctx[i], func->notifier_len, i); if (ret) goto out_ctx_fini; base-commit: 29d6da40d0b8bf3bbc3dcd1d2198434a0e1f71b0 -- 2.54.0