From patchwork Sun Aug 23 00:57:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 7056801 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 180EC9F695 for ; Sun, 23 Aug 2015 00:57:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52A34206E0 for ; Sun, 23 Aug 2015 00:57:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 286B120693 for ; Sun, 23 Aug 2015 00:57:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5118E6E871; Sat, 22 Aug 2015 17:57:49 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E5626E86E for ; Sat, 22 Aug 2015 17:57:45 -0700 (PDT) Received: by widdq5 with SMTP id dq5so19864724wid.1 for ; Sat, 22 Aug 2015 17:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PgnaogvnjRSnj0CVXi8zPpI89SXgITkJu8VnvoYRYBY=; b=NpWFxYTw3/DrbsKfDZTRA8yTpkvK8dXrjlB9/Iz9ckDWf4wRdenNq06Y8U5siGn8VN IFQitCcIj3jJal688gk0H075ED+aAE+JXwe6dUel3YFjqcbM8v+K1VOoXhWtnaNrv2tw EwzzMclY5evHQIEZ1TIC8s1R/c5E/vpre/IgSsIMhIKCEd4ze/OjFL0C8heJHil3PXRs 4Ho1K2H3pXIZSB3CUisywavWxwSnzPL2TyuosAkDrEl9hBct6V36F1leh8ga+IROspif 9UIlFnEdu8MjTRX/gKue0qU1zQRnAtdP08zyFMrzS2EvChaowKWCaSLil7Cq6bOM/BtQ QTjw== X-Received: by 10.194.205.37 with SMTP id ld5mr29454820wjc.14.1440291464251; Sat, 22 Aug 2015 17:57:44 -0700 (PDT) Received: from localhost.localdomain ([5.20.220.27]) by smtp.gmail.com with ESMTPSA id gt10sm9453176wib.20.2015.08.22.17.57.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 22 Aug 2015 17:57:43 -0700 (PDT) From: Grazvydas Ignotas To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/radeon: refactor register check loop Date: Sun, 23 Aug 2015 03:57:37 +0300 Message-Id: <1440291458-11602-4-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440291458-11602-1-git-send-email-notasas@gmail.com> References: <1440291458-11602-1-git-send-email-notasas@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.0 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 After this patch the register check loop does the same thing as before, except that now gcc does better job optimizing it: it now sees that end_reg was already checked against PACKET3_SET_CONTEXT_REG_END and can optimize REG_SAFE_BM_SIZE comparison out of evergreen_is_safe_reg() as (PACKET3_SET_CONTEXT_REG_END >> 7) < REG_SAFE_BM_SIZE. Signed-off-by: Grazvydas Ignotas --- drivers/gpu/drm/radeon/evergreen_cs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c index 4453799..e31076e 100644 --- a/drivers/gpu/drm/radeon/evergreen_cs.c +++ b/drivers/gpu/drm/radeon/evergreen_cs.c @@ -2299,11 +2299,10 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p, DRM_ERROR("bad PACKET3_SET_CONFIG_REG\n"); return -EINVAL; } - for (i = 0; i < pkt->count; i++) { - reg = start_reg + (4 * i); + for (reg = start_reg, idx++; reg <= end_reg; reg += 4, idx++) { if (evergreen_is_safe_reg(p, reg)) continue; - r = evergreen_cs_handle_reg(p, reg, idx + 1 + i); + r = evergreen_cs_handle_reg(p, reg, idx); if (r) return r; } @@ -2317,11 +2316,10 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p, DRM_ERROR("bad PACKET3_SET_CONTEXT_REG\n"); return -EINVAL; } - for (i = 0; i < pkt->count; i++) { - reg = start_reg + (4 * i); + for (reg = start_reg, idx++; reg <= end_reg; reg += 4, idx++) { if (evergreen_is_safe_reg(p, reg)) continue; - r = evergreen_cs_handle_reg(p, reg, idx + 1 + i); + r = evergreen_cs_handle_reg(p, reg, idx); if (r) return r; }