From patchwork Sun Aug 23 00:57:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 7056811 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4F140C05AC for ; Sun, 23 Aug 2015 00:57:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A2F220693 for ; Sun, 23 Aug 2015 00:57:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 65E8C20689 for ; Sun, 23 Aug 2015 00:57:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 874F56E872; Sat, 22 Aug 2015 17:57:51 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED9196E069 for ; Sat, 22 Aug 2015 17:57:44 -0700 (PDT) Received: by widdq5 with SMTP id dq5so19864632wid.1 for ; Sat, 22 Aug 2015 17:57:43 -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=RXZGtCzIAA5jtMqIG5OfohDpo0BA9Ye+GlWJ/MlAWF0=; b=vR/twRJM6UfjUDmy3BtQ5XKZf2/dbmJPeg4zp7bsGSe/rUkLtPyy3eor9SuQ4Ms4/Y uGPvLLkUGiBSFfyVOabXs83Vgi2bJ/MUti5LxHp91SEWtqPgSyASNj4UKlM0++8PYYGY wxaeRZpkvxJBlckRPI9CzWSF4Y2lU2ZP9AcG2SI8enRDjC893Od1M+Dyv3j4vo811Tos BfDILCG2CgME7H8NEinEBRt5oBtbLIvdzyNrAdJQhk8Uw/evP6sKMvPEhl8pay2OPnWY UR6ZkVMpf00T25H49aTTnmoWNaL/7afIr4hyTONLefwlbdfJ1Zl3AKXeCqdfSt+DiN2i +p6w== X-Received: by 10.194.24.196 with SMTP id w4mr27889858wjf.137.1440291463481; Sat, 22 Aug 2015 17:57:43 -0700 (PDT) Received: from localhost.localdomain ([5.20.220.27]) by smtp.gmail.com with ESMTPSA id gt10sm9453176wib.20.2015.08.22.17.57.42 (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 2/4] drm/radeon: split evergreen_cs_check_reg Date: Sun, 23 Aug 2015 03:57:36 +0300 Message-Id: <1440291458-11602-3-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 evergreen_cs_check_reg() is a large function and gcc doesn't want to inline it. It has a quick check for reg_safe_bm[] to see if register needs special handling, which often results in early exit. However because the function is large, it has a long prologue/epilogue to save/restore all the callee-save registers which according to perf is taking significant amount of time. To avoid this, we can reuse evergreen_is_safe_reg() to do the early check directly in register loop. Signed-off-by: Grazvydas Ignotas --- drivers/gpu/drm/radeon/evergreen_cs.c | 49 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c index 5c840da..4453799 100644 --- a/drivers/gpu/drm/radeon/evergreen_cs.c +++ b/drivers/gpu/drm/radeon/evergreen_cs.c @@ -1086,30 +1086,18 @@ static int evergreen_cs_parse_packet0(struct radeon_cs_parser *p, } /** - * evergreen_cs_check_reg() - check if register is authorized or not + * evergreen_cs_handle_reg() - process registers that need special handling. * @parser: parser structure holding parsing context * @reg: register we are testing * @idx: index into the cs buffer - * - * This function will test against evergreen_reg_safe_bm and return 0 - * if register is safe. If register is not flag as safe this function - * will test it against a list of register needind special handling. */ -static int evergreen_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx) +static int evergreen_cs_handle_reg(struct radeon_cs_parser *p, u32 reg, u32 idx) { struct evergreen_cs_track *track = (struct evergreen_cs_track *)p->track; struct radeon_bo_list *reloc; - u32 m, i, tmp, *ib; + u32 tmp, *ib; int r; - i = (reg >> 7); - if (unlikely(i >= REG_SAFE_BM_SIZE)) { - dev_warn(p->dev, "forbidden register 0x%08x at %d\n", reg, idx); - return -EINVAL; - } - m = 1 << ((reg >> 2) & 31); - if (!(track->reg_safe_bm[i] & m)) - return 0; ib = p->ib.ptr; switch (reg) { /* force following reg to 0 in an attempt to disable out buffer @@ -1756,20 +1744,27 @@ static int evergreen_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx) return 0; } -static bool evergreen_is_safe_reg(struct radeon_cs_parser *p, u32 reg, u32 idx) +/** + * evergreen_is_safe_reg() - check if register is authorized or not + * @parser: parser structure holding parsing context + * @reg: register we are testing + * + * This function will test against reg_safe_bm and return true + * if register is safe or false otherwise. + */ +static inline bool evergreen_is_safe_reg(struct radeon_cs_parser *p, u32 reg) { struct evergreen_cs_track *track = p->track; u32 m, i; i = (reg >> 7); if (unlikely(i >= REG_SAFE_BM_SIZE)) { - dev_warn(p->dev, "forbidden register 0x%08x at %d\n", reg, idx); return false; } m = 1 << ((reg >> 2) & 31); if (!(track->reg_safe_bm[i] & m)) return true; - dev_warn(p->dev, "forbidden register 0x%08x at %d\n", reg, idx); + return false; } @@ -2306,7 +2301,9 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p, } for (i = 0; i < pkt->count; i++) { reg = start_reg + (4 * i); - r = evergreen_cs_check_reg(p, reg, idx+1+i); + if (evergreen_is_safe_reg(p, reg)) + continue; + r = evergreen_cs_handle_reg(p, reg, idx + 1 + i); if (r) return r; } @@ -2322,7 +2319,9 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p, } for (i = 0; i < pkt->count; i++) { reg = start_reg + (4 * i); - r = evergreen_cs_check_reg(p, reg, idx+1+i); + if (evergreen_is_safe_reg(p, reg)) + continue; + r = evergreen_cs_handle_reg(p, reg, idx + 1 + i); if (r) return r; } @@ -2577,8 +2576,11 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p, } else { /* SRC is a reg. */ reg = radeon_get_ib_value(p, idx+1) << 2; - if (!evergreen_is_safe_reg(p, reg, idx+1)) + if (!evergreen_is_safe_reg(p, reg)) { + dev_warn(p->dev, "forbidden register 0x%08x at %d\n", + reg, idx + 1); return -EINVAL; + } } if (idx_value & 0x2) { u64 offset; @@ -2601,8 +2603,11 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p, } else { /* DST is a reg. */ reg = radeon_get_ib_value(p, idx+3) << 2; - if (!evergreen_is_safe_reg(p, reg, idx+3)) + if (!evergreen_is_safe_reg(p, reg)) { + dev_warn(p->dev, "forbidden register 0x%08x at %d\n", + reg, idx + 3); return -EINVAL; + } } break; case PACKET3_NOP: