From patchwork Tue Jul 7 08:41:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 6731251 Return-Path: X-Original-To: patchwork-linux-arm@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 C8A67C05AC for ; Tue, 7 Jul 2015 08:46:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E76E0204FF for ; Tue, 7 Jul 2015 08:46:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10877204D6 for ; Tue, 7 Jul 2015 08:46:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZCOUL-00014H-MA; Tue, 07 Jul 2015 08:44:25 +0000 Received: from mail-pa0-f51.google.com ([209.85.220.51]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZCOTs-0000Vk-Di for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2015 08:43:57 +0000 Received: by pacgz10 with SMTP id gz10so36151448pac.3 for ; Tue, 07 Jul 2015 01:43:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w03jNpmEn95r7GT/2FaPxJvaONSZyKq9e+oMVwqaLiI=; b=l038SS/hqpB3n3Wt+m1yOoTv2KS0EDegtI692JTo3IDrRWucvnEIaNgu2BB/WDg2eg 2MqDuImYRM104wFNf0f35e7Tjghsftgd2eIpDaONJiPsAGaaCcKgaiMSh/aOgTz45Jq7 Th0zNYu1wFT4EX6bT9k6KbvPyXZpp10bRcgwdPjArQ76bvnvruoOJ2/iZ+LyknlTFBRt RBAap6NtD5HMlvSHUNAhsiBJtkZMM/5YKJOzZX1AA1aOVZNbpTFy4nrSZ4EV7iHXJOdi GedIT0+NR9ev+LChxYZ4+j8+RtcfkTov5pjhe9bavX0sbs1df4SWweIp11ZJMUdUKsVc O4dg== X-Gm-Message-State: ALoCoQl6RUAOer7x0YKM8aAoeAM9d2Wm6oKIP8FDUcfFJMPgmTDjU+V8r7saGmEg/7B+QQuxK02I X-Received: by 10.66.222.161 with SMTP id qn1mr6811023pac.66.1436258615765; Tue, 07 Jul 2015 01:43:35 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id k3sm21037825pde.18.2015.07.07.01.43.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jul 2015 01:43:35 -0700 (PDT) From: Chunyan Zhang To: mathieu.poirier@linaro.org, gregkh@linuxfoundation.org Subject: [PATCH 5/5] coresight-etm4x: Support context-ID tracing when PID namespace is enabled Date: Tue, 7 Jul 2015 16:41:58 +0800 Message-Id: <1436258518-9339-6-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436258518-9339-1-git-send-email-zhang.chunyan@linaro.org> References: <1436258518-9339-1-git-send-email-zhang.chunyan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150707_014356_492792_76D9FE38 X-CRM114-Status: GOOD ( 14.97 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhang.lyra@gmail.com, linux-kernel@vger.kernel.org, broonie@kernel.org, linux-api@vger.kernel.org, serge.broslavsky@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Like ETTv3, ETMv4 also needs the similar modifications to support Context ID tracing when PID namespace is enabled. Signed-off-by: Chunyan Zhang --- drivers/hwtracing/coresight/coresight-etm4x.c | 21 +++++++++++++++------ drivers/hwtracing/coresight/coresight-etm4x.h | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 9afbda5..254a81a 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -506,8 +506,11 @@ static ssize_t reset_store(struct device *dev, } drvdata->ctxid_idx = 0x0; - for (i = 0; i < drvdata->numcidc; i++) + for (i = 0; i < drvdata->numcidc; i++) { drvdata->ctxid_pid[i] = 0x0; + drvdata->ctxid_vpid[i] = 0x0; + } + drvdata->ctxid_mask0 = 0x0; drvdata->ctxid_mask1 = 0x0; @@ -1825,7 +1828,7 @@ static ssize_t ctxid_pid_show(struct device *dev, spin_lock(&drvdata->spinlock); idx = drvdata->ctxid_idx; - val = (unsigned long)drvdata->ctxid_pid[idx]; + val = (unsigned long)drvdata->ctxid_vpid[idx]; spin_unlock(&drvdata->spinlock); return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); } @@ -1835,7 +1838,7 @@ static ssize_t ctxid_pid_store(struct device *dev, const char *buf, size_t size) { u8 idx; - unsigned long val; + unsigned long vpid, pid; struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent); /* @@ -1845,12 +1848,15 @@ static ssize_t ctxid_pid_store(struct device *dev, */ if (!drvdata->ctxid_size || !drvdata->numcidc) return -EINVAL; - if (kstrtoul(buf, 16, &val)) + if (kstrtoul(buf, 16, &vpid)) return -EINVAL; + pid = coresight_vpid_to_pid(vpid); + spin_lock(&drvdata->spinlock); idx = drvdata->ctxid_idx; - drvdata->ctxid_pid[idx] = (u64)val; + drvdata->ctxid_pid[idx] = (u64)pid; + drvdata->ctxid_vpid[idx] = (u64)vpid; spin_unlock(&drvdata->spinlock); return size; } @@ -2513,8 +2519,11 @@ static void etm4_init_default_data(struct etmv4_drvdata *drvdata) drvdata->addr_type[1] = ETM_ADDR_TYPE_RANGE; } - for (i = 0; i < drvdata->numcidc; i++) + for (i = 0; i < drvdata->numcidc; i++) { drvdata->ctxid_pid[i] = 0x0; + drvdata->ctxid_vpid[i] = 0x0; + } + drvdata->ctxid_mask0 = 0x0; drvdata->ctxid_mask1 = 0x0; diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 1e8fb36..c341002 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -266,6 +266,8 @@ * @ctxid_idx: Context ID index selector. * @ctxid_size: Size of the context ID field to consider. * @ctxid_pid: Value of the context ID comparator. + * @ctxid_vpid: Virtual PID seen by users if PID namespace is enabled, otherwise + * the same value of ctxid_pid. * @ctxid_mask0:Context ID comparator mask for comparator 0-3. * @ctxid_mask1:Context ID comparator mask for comparator 4-7. * @vmid_idx: VM ID index selector. @@ -353,6 +355,7 @@ struct etmv4_drvdata { u8 ctxid_idx; u8 ctxid_size; u64 ctxid_pid[ETMv4_MAX_CTXID_CMP]; + u64 ctxid_vpid[ETMv4_MAX_CTXID_CMP]; u32 ctxid_mask0; u32 ctxid_mask1; u8 vmid_idx;