From patchwork Fri Aug 28 04:10:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 52782 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 78EAD22E9F for ; Fri, 28 Aug 2015 04:13:41 +0000 (UTC) Received: by wicne3 with SMTP id ne3sf3751917wic.1 for ; Thu, 27 Aug 2015 21:13:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Osy3JaFNJ1l2X75EvWkdMYwSjUzGLeS2TTDRt5q7Vtk=; b=J0nn8WZ5lTBFUOtKps7gPGzWJjtQ5e5JJqBK0Z0IMCNVCRYN2wdBCQ7gpySia0veZJ 3AhONSrnCyyvp7cJNdUtlEV44lpJ+gUY6zEOyLZ6Vt2LEmXWG2d2HCIvlS6TjA5SvJDd IBIcWtiEBUmz10JCH9HC6/Jv6fYesMJrc1K0b0AnXr15KVSY0IRy03qCG0vLqCPA8We3 A/bgGTRo6PW8anfiuHeHblNWp61mLu+BFVXHl3bV+AutazZyY0hD9NOzJaND3L7TNWiz Lk6H6JyGlEKHzpXHR6oqhHeDUhc3EP2EPAYa73EQzBuErlRG1PAceTZazFaLnbXz8ay/ Y8RA== X-Gm-Message-State: ALoCoQnnVcOKoBwK/z0aec+UjillYfNMZ4vcMOQwSILA+T7nhaG4k8m+dkHNviMCfHVAG6j12rA8 X-Received: by 10.112.132.105 with SMTP id ot9mr2097980lbb.21.1440735220298; Thu, 27 Aug 2015 21:13:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.99 with SMTP id p3ls131984laj.57.gmail; Thu, 27 Aug 2015 21:13:40 -0700 (PDT) X-Received: by 10.152.27.38 with SMTP id q6mr4071292lag.24.1440735220138; Thu, 27 Aug 2015 21:13:40 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id rd5si4614304lac.9.2015.08.27.21.13.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 21:13:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by laba3 with SMTP id a3so24931017lab.1 for ; Thu, 27 Aug 2015 21:13:40 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr4210048lbc.32.1440735219959; Thu, 27 Aug 2015 21:13:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.151.194 with SMTP id us2csp249089lbb; Thu, 27 Aug 2015 21:13:38 -0700 (PDT) X-Received: by 10.68.250.5 with SMTP id yy5mr12481673pbc.34.1440735218771; Thu, 27 Aug 2015 21:13:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13si7539454pbt.124.2015.08.27.21.13.20; Thu, 27 Aug 2015 21:13:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbbH1EMt (ORCPT + 28 others); Fri, 28 Aug 2015 00:12:49 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:33510 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750698AbbH1EMr (ORCPT ); Fri, 28 Aug 2015 00:12:47 -0400 Received: by padfo6 with SMTP id fo6so9541137pad.0 for ; Thu, 27 Aug 2015 21:12:47 -0700 (PDT) X-Received: by 10.66.118.39 with SMTP id kj7mr11820883pab.115.1440735167199; Thu, 27 Aug 2015 21:12:47 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id qb9sm4039319pbb.95.2015.08.27.21.12.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Aug 2015 21:12:46 -0700 (PDT) From: Chunyan Zhang To: gregkh@linuxfoundation.org, mathieu.poirier@linaro.org Cc: broonie@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] Coresight: ETMv4: Prevent TRCRSCTLR0&1 from being accessed Date: Fri, 28 Aug 2015 12:10:01 +0800 Message-Id: <1440735001-29760-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhang.chunyan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 1. TRCRSCTLRn - Resource Selection Control Registers n=0~1 are reserved, we shouldn't access them. 2. The max number of 'n' here is defined in TRCIDR4.NUMRSPAIR whoes value indicates the number of resource selection *pairs*, and 0 indicates one resource selection pair, 1 indicates two pairs, and so on ... So, the total number of resource selection control registers which we can access is (TRCIDR4.NUMRSPAIR * 2) Signed-off-by: Chunyan Zhang --- drivers/hwtracing/coresight/coresight-etm4x.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 1312e99..fe93b47 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -136,7 +136,9 @@ static void etm4_enable_hw(void *info) writel_relaxed(drvdata->cntr_val[i], drvdata->base + TRCCNTVRn(i)); } - for (i = 0; i < drvdata->nr_resource; i++) + + /* Resource selector pair 0 is always implemented and reserved */ + for (i = 2; i < drvdata->nr_resource * 2; i++) writel_relaxed(drvdata->res_ctrl[i], drvdata->base + TRCRSCTLRn(i)); @@ -489,8 +491,9 @@ static ssize_t reset_store(struct device *dev, drvdata->cntr_val[i] = 0x0; } - drvdata->res_idx = 0x0; - for (i = 0; i < drvdata->nr_resource; i++) + /* Resource selector pair 0 is always implemented and reserved */ + drvdata->res_idx = 0x2; + for (i = 2; i < drvdata->nr_resource * 2; i++) drvdata->res_ctrl[i] = 0x0; for (i = 0; i < drvdata->nr_ss_cmp; i++) { @@ -1729,7 +1732,7 @@ static ssize_t res_idx_store(struct device *dev, if (kstrtoul(buf, 16, &val)) return -EINVAL; /* Resource selector pair 0 is always implemented and reserved */ - if ((val == 0) || (val >= drvdata->nr_resource)) + if (val < 2 || val >= drvdata->nr_resource * 2) return -EINVAL; /* @@ -2410,8 +2413,8 @@ static void etm4_init_arch_data(void *info) drvdata->nr_addr_cmp = BMVAL(etmidr4, 0, 3); /* NUMPC, bits[15:12] number of PE comparator inputs for tracing */ drvdata->nr_pe_cmp = BMVAL(etmidr4, 12, 15); - /* NUMRSPAIR, bits[19:16] the number of resource pairs for tracing */ - drvdata->nr_resource = BMVAL(etmidr4, 16, 19); + /* NUMRSPAIR, bits[19:16] the number of resource pairs minus one */ + drvdata->nr_resource = BMVAL(etmidr4, 16, 19) + 1; /* * NUMSSCC, bits[23:20] the number of single-shot * comparator control for tracing @@ -2498,6 +2501,8 @@ static void etm4_init_default_data(struct etmv4_drvdata *drvdata) drvdata->cntr_val[i] = 0x0; } + /* Resource selector pair 0 is always implemented and reserved */ + drvdata->res_idx = 0x2; for (i = 2; i < drvdata->nr_resource * 2; i++) drvdata->res_ctrl[i] = 0x0;