Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2827360pxv; Mon, 12 Jul 2021 02:56:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9AJXmCoandeytygxtNPWCZbbxmXVtwW89kX4vyCcLurku080ryTx/NjVgn8FLOAU2uDmx X-Received: by 2002:a5d:858b:: with SMTP id f11mr39308553ioj.156.1626083780144; Mon, 12 Jul 2021 02:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083780; cv=none; d=google.com; s=arc-20160816; b=Hluptqn12eNit9D1O6MNE8XPJkhx2qBU8m47vnBE8LY6E28kxxlyFcZ/wgPJeNoinn ivV7kH/JE1NORW821Mp3kbbis9dVQ1Xbi64JyElF7hHVSM9DxSG998jbxfY1RkrJVxfT BoSo4QoVRk7e3Dc26G9Q3Qg0pllyT8OSfGUCBsKAGKpw0duvfcxeYvXRPSdDdf2/klw6 xWpxU54wlpFccuPnk0LpVGTx6nEBnAqS5c8RaMyRz+QUCk547swcU4rn7cKbDlqq/o/t uoUsh+0ah1SKkhfI+6Fq1sOfAYGgEgG2o76zJPYDtp53A0WmiBwpnNIuhU2v6CekcOEG kvOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=A7cudPepna9O32M6uK5QRxtmVmacR1aNvZWn/iEKPyY=; b=nYceA3/bbkoxALgroRj51AdI5FC96/xCliZ3OVCcbi8SpbOL0fExllZjpyLvj0IvC7 /0hWgL0ApndJ6eGzr+Z9mNGJaEYV3GQ4viQMymrYp5yoagx0qKPNirfHl7H9cFdgl9OS 869dzbaDcj67a+/Ib56pKTt4Qp2lCDsq6ohDZr+pmrrMmyKWvNR6fpLBgLVmEmzLKgDR Czrze2VBceZJn+02IC9lMVmk06SaKMyWGfvtl4OtDEhkOY5jllgqEGrwRsEGG7FDAjOe djWIU7waUZj/6lnECkQ7TypZEOV2PF4mx5wxOkO41nGqPQQHLRXik/N/p0Q/9zNnZguZ L/JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GFiBxvgh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si17860285jad.45.2021.07.12.02.56.08; Mon, 12 Jul 2021 02:56:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GFiBxvgh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242527AbhGLHAP (ORCPT + 99 others); Mon, 12 Jul 2021 03:00:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:36944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238733AbhGLGoO (ORCPT ); Mon, 12 Jul 2021 02:44:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC445611AF; Mon, 12 Jul 2021 06:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071997; bh=zyfh1XtR0ONsG//v+CK6t5EH1+y76L+PvkwBHzOQGGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GFiBxvghssPPNr0yiqAchJx7sMTNtL2SouTEO1leY4VurCbJserJmOHXVGOPWoNhT jkb8x9hATz1o0xJxTSZekDnxUVQ06rcfzm9F7mgVamebk8v81FCfEMxLbPeymA3xk1 6uJTCgMxs7pjLQa40vGlaBXqffn6Ihy8yuFYMlHI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Hellstrom , Charmaine Lee , Roland Scheidegger , Zack Rusin , Sasha Levin Subject: [PATCH 5.10 310/593] drm/vmwgfx: Fix cpu updates of coherent multisample surfaces Date: Mon, 12 Jul 2021 08:07:50 +0200 Message-Id: <20210712060919.316415192@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Hellstrom [ Upstream commit 88509f698c4e38e287e016e86a0445547824135c ] In cases where the dirty linear memory range spans multiple sample sheets in a surface, the dirty surface region is incorrectly computed. To do this correctly and in an optimized fashion we would have to compute the dirty region of each sample sheet and compute the union of those regions. But assuming that cpu writing to a multisample surface is rather a corner case than a common case, just set the dirty region to the full surface. This fixes OpenGL piglit errors with SVGA_FORCE_COHERENT=1 and the piglit test: fbo-depthstencil blit default_fb -samples=2 -auto Fixes: 9ca7d19ff8ba ("drm/vmwgfx: Add surface dirty-tracking callbacks") Signed-off-by: Thomas Hellstrom Reviewed-by: Charmaine Lee Reviewed-by: Roland Scheidegger Signed-off-by: Zack Rusin Link: https://patchwork.freedesktop.org/patch/msgid/20210505035740.286923-4-zackr@vmware.com Signed-off-by: Sasha Levin --- .../drm/vmwgfx/device_include/svga3d_surfacedefs.h | 8 ++++++-- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h b/drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h index 4db25bd9fa22..127eaf0a0a58 100644 --- a/drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h +++ b/drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h @@ -1467,6 +1467,7 @@ struct svga3dsurface_cache { /** * struct svga3dsurface_loc - Surface location + * @sheet: The multisample sheet. * @sub_resource: Surface subresource. Defined as layer * num_mip_levels + * mip_level. * @x: X coordinate. @@ -1474,6 +1475,7 @@ struct svga3dsurface_cache { * @z: Z coordinate. */ struct svga3dsurface_loc { + u32 sheet; u32 sub_resource; u32 x, y, z; }; @@ -1566,8 +1568,8 @@ svga3dsurface_get_loc(const struct svga3dsurface_cache *cache, u32 layer; int i; - if (offset >= cache->sheet_bytes) - offset %= cache->sheet_bytes; + loc->sheet = offset / cache->sheet_bytes; + offset -= loc->sheet * cache->sheet_bytes; layer = offset / cache->mip_chain_bytes; offset -= layer * cache->mip_chain_bytes; @@ -1631,6 +1633,7 @@ svga3dsurface_min_loc(const struct svga3dsurface_cache *cache, u32 sub_resource, struct svga3dsurface_loc *loc) { + loc->sheet = 0; loc->sub_resource = sub_resource; loc->x = loc->y = loc->z = 0; } @@ -1652,6 +1655,7 @@ svga3dsurface_max_loc(const struct svga3dsurface_cache *cache, const struct drm_vmw_size *size; u32 mip; + loc->sheet = 0; loc->sub_resource = sub_resource + 1; mip = sub_resource % cache->num_mip_levels; size = &cache->mip[mip].size; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 3914bfee0533..f493b20c7a38 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -1802,6 +1802,19 @@ static void vmw_surface_tex_dirty_range_add(struct vmw_resource *res, svga3dsurface_get_loc(cache, &loc2, end - 1); svga3dsurface_inc_loc(cache, &loc2); + if (loc1.sheet != loc2.sheet) { + u32 sub_res; + + /* + * Multiple multisample sheets. To do this in an optimized + * fashion, compute the dirty region for each sheet and the + * resulting union. Since this is not a common case, just dirty + * the whole surface. + */ + for (sub_res = 0; sub_res < dirty->num_subres; ++sub_res) + vmw_subres_dirty_full(dirty, sub_res); + return; + } if (loc1.sub_resource + 1 == loc2.sub_resource) { /* Dirty range covers a single sub-resource */ vmw_subres_dirty_add(dirty, &loc1, &loc2); -- 2.30.2