From patchwork Wed Oct 27 05:44:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 284822 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9R5j1Iu025153 for ; Wed, 27 Oct 2010 05:45:21 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1AE719E814 for ; Tue, 26 Oct 2010 22:45:01 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qw0-f49.google.com (mail-qw0-f49.google.com [209.85.216.49]) by gabe.freedesktop.org (Postfix) with ESMTP id EA4BF9F030 for ; Tue, 26 Oct 2010 22:44:43 -0700 (PDT) Received: by qwh6 with SMTP id 6so317052qwh.36 for ; Tue, 26 Oct 2010 22:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=LQ43UwAS/nmYBFlhJtv3gMFYizYlz8qtCDE1lqKpMhg=; b=QfM5uXk0eLJZwbnFSbOKJe+gTYu1UN+zLLteBZuVcAtryUQlPjqqVSwaWUWOgp+UBN H+vlx/G3CbObmWxSdxDdV0r+/3+WG5Fh7r3WWpHEJXTEMkP4AMhE2TuCLB9oLsjSPWT6 DSH6qmYRTcFldHuFFTR+4Z9EvuG09HdX02Cv4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=o3Iu0j5kqT499VIaX2EGPI3O4v2YXOS72R92R6F2eZukpddDd/3et6bdjz+I40Gc1m pyETr5jgDMTiqcu5vwRG/ONggysZFHKWJCxB7cWPFuyB8PUQJt2HQCqhTu3lrLW7iHiB AGg+rhYZUMmmfXx7UGtM63ykKZdoOoZwJi2ck= Received: by 10.224.216.6 with SMTP id hg6mr2134427qab.112.1288158283011; Tue, 26 Oct 2010 22:44:43 -0700 (PDT) Received: from localhost.localdomain (static-74-96-105-7.washdc.fios.verizon.net [74.96.105.7]) by mx.google.com with ESMTPS id l14sm8247940qck.41.2010.10.26.22.44.41 (version=SSLv3 cipher=RC4-MD5); Tue, 26 Oct 2010 22:44:42 -0700 (PDT) From: Alex Deucher To: airlied@gmail.com, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/radeon/kms: fix tiled db height calculation on 6xx/7xx Date: Wed, 27 Oct 2010 01:44:35 -0400 Message-Id: <1288158275-8656-1-git-send-email-alexdeucher@gmail.com> X-Mailer: git-send-email 1.7.1.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 27 Oct 2010 05:45:22 +0000 (UTC) diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c index 0d29065..6291278 100644 --- a/drivers/gpu/drm/radeon/r600_cs.c +++ b/drivers/gpu/drm/radeon/r600_cs.c @@ -310,7 +310,7 @@ static int r600_cs_track_check(struct radeon_cs_parser *p) /* Check depth buffer */ if (G_028800_STENCIL_ENABLE(track->db_depth_control) || G_028800_Z_ENABLE(track->db_depth_control)) { - u32 nviews, bpe, ntiles, pitch, pitch_align, height, size; + u32 nviews, bpe, ntiles, pitch, pitch_align, height, size, slice_tile_max; if (track->db_bo == NULL) { dev_warn(p->dev, "z/stencil with no depth buffer\n"); return -EINVAL; @@ -354,11 +354,11 @@ static int r600_cs_track_check(struct radeon_cs_parser *p) } else { size = radeon_bo_size(track->db_bo); pitch = G_028000_PITCH_TILE_MAX(track->db_depth_size) + 1; - height = size / (pitch * 8 * bpe); - height &= ~0x7; - if (!height) - height = 8; - + slice_tile_max = G_028000_SLICE_TILE_MAX(track->db_depth_size) + 1; + slice_tile_max *= 64; + height = slice_tile_max / (pitch * 8); + if (height > 8192) + height = 8192; switch (G_028010_ARRAY_MODE(track->db_depth_info)) { case V_028010_ARRAY_1D_TILED_THIN1: pitch_align = (max((u32)8, (u32)(track->group_size / (8 * bpe))) / 8); @@ -367,6 +367,8 @@ static int r600_cs_track_check(struct radeon_cs_parser *p) __func__, __LINE__, pitch); return -EINVAL; } + /* don't break userspace */ + height &= ~0x7; if (!IS_ALIGNED(height, 8)) { dev_warn(p->dev, "%s:%d db height (%d) invalid\n", __func__, __LINE__, height);