From patchwork Tue Dec 10 17:42:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 3319651 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E582E9F1F0 for ; Tue, 10 Dec 2013 17:42:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D107F20511 for ; Tue, 10 Dec 2013 17:42:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 98BA7204D3 for ; Tue, 10 Dec 2013 17:42:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E41EFA323; Tue, 10 Dec 2013 09:42:53 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yh0-f53.google.com (mail-yh0-f53.google.com [209.85.213.53]) by gabe.freedesktop.org (Postfix) with ESMTP id 6BABAFA323 for ; Tue, 10 Dec 2013 09:42:51 -0800 (PST) Received: by mail-yh0-f53.google.com with SMTP id b20so4027479yha.26 for ; Tue, 10 Dec 2013 09:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=QYPIDjtdSdtdUSidShUkG1ArM7E5uenwtPHrBCXw4gs=; b=f8Wev/7JT6rNVCi7ixfAIaEMsf/bIhet+WVoHn4kTCzvXjwaE6bOnY+F7Aw+hE6VAx VI9WauPoGwmOVJg4QpnymF5beyEQY/ZoKfbj2DB28HRiHceEdnbi454Dt4P8viZOqhNc u50QUcjBSnJyEWYCaLYengFw4i+sU/XL7WMnvyXvnF2Q5tX1TrJwTzsbToAHZCuIc4S5 QQD796AFzzRIM5AI/YX9tH+YXSx6z0gqQZSiURE2GzYRwWraNDO7He/+tnK2TNVnN5pX fbNdFISPlj91fmirJxyKYMDKp2kRVE2Tp611UomjsyHFHEGDBgFYnYpe2ctseMriifHz wJ0g== X-Received: by 10.236.138.202 with SMTP id a50mr1032341yhj.156.1386697371009; Tue, 10 Dec 2013 09:42:51 -0800 (PST) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by mx.google.com with ESMTPSA id e39sm23561408yhq.15.2013.12.10.09.42.50 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2013 09:42:50 -0800 (PST) From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH] radeon: avoid possible divide by 0 in surface manager Date: Tue, 10 Dec 2013 12:42:43 -0500 Message-Id: <1386697363-19329-1-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 1.8.3.1 Cc: Alex Deucher X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 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@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some users report hitting a divide by 0 with the tile split in certain apps. Tile_split shouldn't ever be 0 unless the surface structure was not properly initialized. I think there may be some cases where mesa uses an improperly initialized surface struct, but I haven't had time to track it down. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72425 Signed-off-by: Alex Deucher Reviewed-by: Marek Olšák --- radeon/radeon_surface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/radeon/radeon_surface.c b/radeon/radeon_surface.c index dcbbfdc..15127d4 100644 --- a/radeon/radeon_surface.c +++ b/radeon/radeon_surface.c @@ -655,7 +655,7 @@ static int eg_surface_init_2d(struct radeon_surface_manager *surf_man, tileb = tilew * tileh * bpe * surf->nsamples; /* slices per tile */ slice_pt = 1; - if (tileb > tile_split) { + if (tileb > tile_split && tile_split) { slice_pt = tileb / tile_split; } tileb = tileb / slice_pt; @@ -1621,7 +1621,7 @@ static int si_surface_init_2d(struct radeon_surface_manager *surf_man, tileb = tilew * tileh * bpe * surf->nsamples; /* slices per tile */ slice_pt = 1; - if (tileb > tile_split) { + if (tileb > tile_split && tile_split) { slice_pt = tileb / tile_split; } tileb = tileb / slice_pt; @@ -2223,7 +2223,7 @@ static int cik_surface_init_2d(struct radeon_surface_manager *surf_man, /* slices per tile */ slice_pt = 1; - if (tileb > tile_split) { + if (tileb > tile_split && tile_split) { slice_pt = tileb / tile_split; tileb = tileb / slice_pt; }