From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-op-o10.zoho.com (sender4-op-o10.zoho.com [136.143.188.10]) (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 0785725B083 for ; Tue, 11 Aug 2026 01:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.10 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786410111; cv=pass; b=VZdeSossLcMfk32g+1YPmcJl2XuX91sH1odXYUBK6gxyFbSbzTLQyE61BURxX2vUyueINzq10jDOeuXJYndvPMIPYENrH1PfBbcSfu5RW2Yftl7mtfylNmZiv9D38pejrmKf7azCHJ7cxAXsrI79A4oD6OlyF1FUbo6kG4Ergl0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786410111; c=relaxed/simple; bh=nxJfCCyOvHITzXM/yGm53r+tSVhpyjZW0cZrAs2PA0c=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=hpYrRSg2hYHUrdAhZxbVUJf+K9z5QkjOZ6ewX6uutoZiOLlFRE+WaHLyeC6iWnL3tDLQnF5u+4dYtj3DEP9cC+jBIXP7u7Or2pr3VxBTCbGT4HjcduQR/TmShm0N7t1q1h/eN4jUfQ3g9eH9XnVW0dc5VLEPoMlEDkxJ7k8GA9o= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=faith.ekstrand@collabora.com header.b=W6imkZE4; arc=pass smtp.client-ip=136.143.188.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=faith.ekstrand@collabora.com header.b="W6imkZE4" ARC-Seal: i=1; a=rsa-sha256; t=1786410080; cv=none; d=zohomail.com; s=zohoarc; b=naHig9FKg+UwziJFBLMOKCamqd1aWyc403juo0pkOIf13in5mptCkrxB/gQmGe3unp+OXRdFl348Lrnhxp+ivnoXvIZ6YWCLBmnIGJyM/aeXv7wIB5vpOUsKtbwTv+wD+OTMJRbMVB/eCPoAlqzFCMhXrsVcvr426kiCVOLOwZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786410080; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=JGKBQYYb1upxXdsc1VDTCgRhH60CNH1HNvdXsZhZhkA=; b=Guqucqu2vdFaz2YUbEF0whFCwbiPOdMRB4rEvGqEMcberzBNv6CzWRXgjopQBwnUH6nImOczCl6199CcMAhlRpA3+DswXAQx14BZtEDGiJX2fyoER6StxoLU6ScYd4bZgic80umH/oH6bflhWU/JcRjvANU85OId9ufAui3eSdc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=faith.ekstrand@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1786410080; s=zohomail; d=collabora.com; i=faith.ekstrand@collabora.com; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=JGKBQYYb1upxXdsc1VDTCgRhH60CNH1HNvdXsZhZhkA=; b=W6imkZE43LfuKP5ONqCe6NZbvuomHMrWJRSZbg/nT68fKKpHdYYnPYOnaLUf+8zu dUitS2cXsqUH+044nz3uRr7X2MwARDHdU+CyBnP8K8LmJ3XWK3us9eTYJYDaCEcdyJB SwEP0K5F4/Tzo2HItTsHJCdpdbDnna/loX/yGmh0= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1786410080037397.08614927222334; Mon, 10 Aug 2026 18:01:20 -0700 (PDT) Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1786410078818973.1558608767025; Mon, 10 Aug 2026 18:01:18 -0700 (PDT) Date: Mon, 10 Aug 2026 21:01:18 -0400 From: Faith Ekstrand To: "Aaron Kling" Cc: "dev" , "Lyude Paul" , "Danilo Krummrich" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "dri-devel" , "nouveau" , "linux-kernel" , "Karol Herbst" Message-ID: <19fee56924f.82459cc61103651.6241601648149454872@collabora.com> In-Reply-To: References: <20260725-tegra-coherent-wc-v1-1-dfdcc929c21b@gmail.com> <67fe34eebafe657b3221ac39838440b294c60444.camel@lynxeye.de> Subject: Re: [PATCH RFC] drm/nouveau: Use write-combined maps for coherent on Tegra Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail ~Faith Ekstrand From: Aaron Kling To: Cc: "Lyude Paul", "Danilo Krummrich", "M= aarten Lankhorst", "Maxime Ripard", "Thomas Zimmermann", "David Airlie", "Simona Vetter", , , = , "Faith Ekstrand" Date: Sun, 09 Aug 2026 02:06:51 -0400 Subject: Re: [PATCH RFC] drm/nouveau: Use write-combined maps for coherent = on Tegra > On Tue, Jul 28, 2026 at 3:38=E2=80=AFAM Lucas Stach wro= te:=20 > >=20 > > Am Samstag, dem 25.07.2026 um 18:28 -0500 schrieb Aaron Kling via B4= =20 > > Relay:=20 > > > From: Faith Ekstrand =20 > > >=20 > > > On Tegra devices, uncached maps traslate to device memory, causing= =20 > > > unaligned accesses by userspace resulting in a SIGBUS. Instead, use= =20 > > > write-combined maps to ensure proper access.=20 > > >=20 > > This is not only an issue on Tegra. All ARM64 platforms translate=20 > > uncached to device memory, which does not support unaligned access. So= =20 > > the issue could happen in the same way when connecting a discrete GPU= =20 > > to a ARM64 platform with PCIe support.=20 > >=20 > > I would argue that there is no downside to always using write combined= =20 > > memory for coherent buffers. You gain potentially faster writes while= =20 > > the only issue is that writes may get delayed visibility at the device= =20 > > side. However, I don't think anyone uses coherent buffers to modify th= e=20 > > content from the CPU side while the device is operating on the buffer.= =20 > > For all regular use-case the memory barrier in FIRE_RING() will make= =20 > > sure that the buffered writes are visible to the device before the=20 > > commands using the buffer are made visible to the device.=20 > =20 > Should I send a new revision that sets write combined for all coherent= =20 > then? I only have Tegra devices to verify this on, so I can't attest=20 > to how this affects discrete cards.=20 Yeah, generally we should be using WC on discrete cards, too. The big ques= tion is if nouveau is doing some shenanigans behind the scnenes with cache = types. I'm pretty sure I've had this discussion with nouveau people and we= came to the conclusion that uncached mapped to WC on discrete for some rea= son. If we're getting actual uncached maps instead of WC on discrete GPUs,= that's a serious performance problem but I don't think we are. I've CC'd = Karol in case he remembers what's going on here. ~Faith > Aaron=20 > =20 > > Regards,=20 > > Lucas=20 > >=20 > > > Signed-off-by: Faith Ekstrand =20 > > > Co-developed-by: Aaron Kling =20 > > > Signed-off-by: Aaron Kling =20 > > > ---=20 > > > This patch is marked RFC because there is not complete confidence th= at=20 > > > the change is correct. Without this change, nouveau can easily hit= =20 > > > sigbus errors in Android UI rendering via nvk or running vulkan deqp= =20 > > > tests on Tegra. Changing coherent maps to use write-combined stops t= he=20 > > > crashing, but it is unknown what the performance impact is, if any.= =20 > > > ---=20 > > > drivers/gpu/drm/nouveau/nouveau_sgdma.c | 9 ++++++---=20 > > > 1 file changed, 6 insertions(+), 3 deletions(-)=20 > > >=20 > > > diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/d= rm/nouveau/nouveau_sgdma.c=20 > > > index fa3b4ebf38a83..10f6ef1c541bd 100644=20 > > > --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c=20 > > > +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c=20 > > > @@ -72,9 +72,12 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object= *bo, uint32_t page_flags)=20 > > > struct nouveau_sgdma_be *nvbe;=20 > > > enum ttm_caching caching;=20 > > >=20 > > > - if (nvbo->force_coherent)=20 > > > - caching =3D ttm_uncached;=20 > > > - else if (drm->agp.bridge)=20 > > > + if (nvbo->force_coherent) {=20 > > > + if (drm->client.device.info.platform =3D=3D NV_DEVICE_= INFO_V0_SOC)=20 > > > + caching =3D ttm_write_combined;=20 > > > + else=20 > > > + caching =3D ttm_uncached;=20 > > > + } else if (drm->agp.bridge)=20 > > > caching =3D ttm_write_combined;=20 > > > else=20 > > > caching =3D ttm_cached;=20 > > >=20 > > > ---=20 > > > base-commit: 1a1757b76427f6201bfe0bf1bea9f7574f332a93=20 > > > change-id: 20260725-tegra-coherent-wc-19941d1a5a60=20 > > >=20 > > > Best regards,=20 >=20