From patchwork Sun Oct 18 18:24:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 55207 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f71.google.com (mail-lf0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 1FAEE22FFA for ; Sun, 18 Oct 2015 18:29:19 +0000 (UTC) Received: by lffv3 with SMTP id v3sf32569528lff.1 for ; Sun, 18 Oct 2015 11:29:17 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=tEbWpGmRvV9r/tL1j8lOmPCV/z/+hsE2QeWSD37EEQ4=; b=RZOHn6jWSHhWh7t0Vy4Ko7sjaBsWrftmL/iIwWKoAU0kbsJlNOz3Ms/trzHWFIp204 10RKZWeu0l6OpJ4g50HGNYkF7UNNK5nvqrbL71VZyVdEdHMTgrBrYoazd3OcJdi2swW4 H+jNyLT8Y2vRBOWVgqhvC8S+88y5hLA0O9CFC0LbetDxeMNa7vYI0c5dOsQWErymV54b yHTWdVErDS1fLVj7hyv3RTf6rpR7yr7ky9OBnpZTTGJRHnofUrKrr0iq7nbv2L+oXXSF e4xmLMHOSbhtIboMwTX9r/4w2TepQz57WlEfS65MUg8WUj+vgY2oE82VheSSEG2mEcyX P/NA== X-Gm-Message-State: ALoCoQlMa6fzwbdTvxJH5w1LPtsiKENQDJtUOtOSgymCEPrr//B3bdV29efZETiYd/qu2RSbnYKL X-Received: by 10.194.240.230 with SMTP id wd6mr5930109wjc.0.1445192957947; Sun, 18 Oct 2015 11:29:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.158.146 with SMTP id h140ls507099lfe.108.gmail; Sun, 18 Oct 2015 11:29:17 -0700 (PDT) X-Received: by 10.25.148.196 with SMTP id w187mr8442724lfd.77.1445192957755; Sun, 18 Oct 2015 11:29:17 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id f189si20127157lfb.73.2015.10.18.11.29.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 11:29:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbcao8 with SMTP id ao8so127470510lbc.3 for ; Sun, 18 Oct 2015 11:29:17 -0700 (PDT) X-Received: by 10.112.132.7 with SMTP id oq7mr12910238lbb.32.1445192957635; Sun, 18 Oct 2015 11:29:17 -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.59.35 with SMTP id w3csp1078753lbq; Sun, 18 Oct 2015 11:29:16 -0700 (PDT) X-Received: by 10.68.69.35 with SMTP id b3mr30355712pbu.22.1445192956528; Sun, 18 Oct 2015 11:29:16 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tb8si46439388pab.225.2015.10.18.11.29.16; Sun, 18 Oct 2015 11:29:16 -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 S1753144AbbJRS3N (ORCPT + 28 others); Sun, 18 Oct 2015 14:29:13 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35628 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752429AbbJRS0F (ORCPT ); Sun, 18 Oct 2015 14:26:05 -0400 Received: by pasz6 with SMTP id z6so6767638pas.2 for ; Sun, 18 Oct 2015 11:26:05 -0700 (PDT) X-Received: by 10.68.183.5 with SMTP id ei5mr30018672pbc.124.1445192765286; Sun, 18 Oct 2015 11:26:05 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [184.64.168.246]) by smtp.gmail.com with ESMTPSA id hq1sm20402076pbb.43.2015.10.18.11.26.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Oct 2015 11:26:04 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org, a.p.zijlstra@chello.nl, alexander.shishkin@linux.intel.com, acme@kernel.org, mingo@redhat.com, corbet@lwn.net, nicolas.pitre@linaro.org Cc: adrian.hunter@intel.com, zhang.chunyan@linaro.org, mike.leach@arm.com, tor@ti.com, al.grant@arm.com, pawel.moll@arm.com, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH V2 19/30] coresight: etb10: implementing the setup_aux() API Date: Sun, 18 Oct 2015 12:24:36 -0600 Message-Id: <1445192687-24112-20-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445192687-24112-1-git-send-email-mathieu.poirier@linaro.org> References: <1445192687-24112-1-git-send-email-mathieu.poirier@linaro.org> 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: mathieu.poirier@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.217.176 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: , Adding an ETB10 specific auxiliary area setup operation to be used by the perf framework when events are initialised. Part of this operation involves modeling the mmap'ed area based on the specific ways a sink buffer gathers information. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etb10.c | 55 +++++++++++++++++++++++++++ include/linux/coresight.h | 3 ++ 2 files changed, 58 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index ecdbe0dd4d08..7f34e7af465e 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -27,6 +27,9 @@ #include #include #include +#include + +#include #include "coresight-priv.h" @@ -64,6 +67,32 @@ #define ETB_FRAME_SIZE_WORDS 4 /** + * struct cs_buffer - keep track of a recording session' specifics + * @cur: index of the current buffer + * @nr_pages: max number of pages granted to us + * @nr_bufs: number of clustered pages + * @offset: offset within the current buffer + * @size: how much space we have for this run + * @data_size: how much we collected in this run + * @head: head of the ring buffer + * @lost: other than zero if we had a HW buffer wrap around + * @snapshot: is this run in snapshot mode + * @addr: virtual address this buffer starts at + */ +struct cs_buffers { + unsigned int cur; + unsigned int nr_pages; + unsigned int nr_bufs; + unsigned long offset; + unsigned long size; + local_t data_size; + local_t head; + local_t lost; + bool snapshot; + void *addr[0]; +}; + +/** * struct etb_drvdata - specifics associated to an ETB component * @base: memory mapped base address for this component. * @dev: the device entity associated to this component. @@ -252,9 +281,35 @@ static void etb_disable(struct coresight_device *csdev) dev_info(drvdata->dev, "ETB disabled\n"); } +static void *etb_setup_aux(struct coresight_device *csdev, int cpu, + void **pages, int nr_pages, bool overwrite) +{ + int node, pg; + struct cs_buffers *buf; + + if (cpu == -1) + cpu = smp_processor_id(); + node = cpu_to_node(cpu); + + buf = kzalloc_node(offsetof(struct cs_buffers, addr[nr_pages]), + GFP_KERNEL, node); + if (!buf) + return NULL; + + buf->snapshot = overwrite; + buf->nr_pages = nr_pages; + + /* Record information about buffers */ + for (pg = 0; pg < buf->nr_pages; pg++) + buf->addr[pg] = pages[pg]; + + return buf; +} + static const struct coresight_ops_sink etb_sink_ops = { .enable = etb_enable, .disable = etb_disable, + .setup_aux = etb_setup_aux, }; static const struct coresight_ops etb_cs_ops = { diff --git a/include/linux/coresight.h b/include/linux/coresight.h index dd530a6d3e21..b1c25eba83b4 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -187,10 +187,13 @@ struct coresight_device { * Operations available for sinks * @enable: enables the sink. * @disable: disables the sink. + * @setup_aux: initialises perf's ring buffer for trace collection. */ struct coresight_ops_sink { int (*enable)(struct coresight_device *csdev); void (*disable)(struct coresight_device *csdev); + void *(*setup_aux)(struct coresight_device *csdev, int cpu, + void **pages, int nr_pages, bool overwrite); }; /**