From patchwork Tue Jan 15 23:07:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10765233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE74817FB for ; Tue, 15 Jan 2019 23:08:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD0062E496 for ; Tue, 15 Jan 2019 23:08:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C10702E499; Tue, 15 Jan 2019 23:08:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FBDE2E4AA for ; Tue, 15 Jan 2019 23:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=T27JHMHOIEbkpJHdLA/FjO8rmA942YTmBu//2AVeM/Y=; b=YVlH7AFTOa6IoKssQYu1k7UdSV uupAMNMEzbf02hlMHaduQDBhNtpzDwbBfgEGXl3bFFE/fjA9yJg+rN4hXpaxGWnxPeFg8Y2JKPIp2 ijL9EX9IsXpf3XuRnIICBtfAv7LTPPcm0+EiIOOgKc9oGZy5UzoL8NJrab4zKsfHBQkdIDRlTXz7d 5v9z8ReNEEMz/kkytENIUT0giXFSOdnPYxT3TFOL9t5tg/Skw5KbC86PWNZNOVoFgvH5VwNTx1m6q KZ2L7FxEjKkorUdgzPsSN6FaU66ob92JTGDWyDSixf2oOgBl65KBWiKLshgcKWZbhqkI75Tb0ATAQ gxIDpSPA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjXp3-0005fq-19; Tue, 15 Jan 2019 23:08:41 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjXoV-00058R-CL for linux-arm-kernel@bombadil.infradead.org; Tue, 15 Jan 2019 23:08:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XDWNDjej1vaQghEKuWRObLfufBBUVnZJNWEVf/9UfwU=; b=xFo+5yhDBgtCd8e7+sc63ItTX zapYlmWrCBv9WzYvuxBOxVk8OLDa3cp5ftM6lvoJJY4kXhAXp6fD/U3WtJgkbEBhNStM+mjr4oMrG +X0BN8oMgzLduA6MjMNkgKFv1kQUoAIdhLTrpQ2Hn3e6pinxWWkWthsBDDW4W24b1XIhaUyII4Rr9 +KnrLT+KVLG8ocVl2D5zbjaSxEOF4Get3t1UOMg+IAVfM5JRC/NtUQ/IB+6tbeKn41TWBK38Olo2F BOhp3LsKjbqiAwImTd+EOciYca87HxgCdjKmANpPc/4AQZ46yEvQflmRxAPw89RlAx+xLfwRZ68WV rqfq09vYA==; Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjXoO-0006JQ-RJ for linux-arm-kernel@lists.infradead.org; Tue, 15 Jan 2019 23:08:02 +0000 Received: by mail-pl1-x644.google.com with SMTP id z23so2017185plo.0 for ; Tue, 15 Jan 2019 15:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XDWNDjej1vaQghEKuWRObLfufBBUVnZJNWEVf/9UfwU=; b=b84JmktbH4LgEz2UKivbHhzC09x3UMXzJaMj8si6l+upZCirCs1QoNgBzprVBbDy9w FBzU4OKP2qSRSptbvbFV2QWDV8g/43fxihmkXRshEECSB0uW5kShD9zVMOAupagb+fO0 6GZki9k1wHHPDcr8WnLZ05pU620ghVn4IrqLY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XDWNDjej1vaQghEKuWRObLfufBBUVnZJNWEVf/9UfwU=; b=n+dZrD+icKjZSFPBtrZhEj47pe1OQ5h11smyn2Ll51dNAWS3kyJZILuE0CswJlF1WG YqUDCQeDRWcSFQZ3HxzfucS2ikYvzK8XCZaSuiOUZbk0dJB9Y+UPxsbh+kJhvOYc7tDb oksKQTTyIapppm1CXDft7Q4ZEl96yuL58p2opDu7O3IwBy4Xy37uOMHgdxUY4GgqgWHG CYIAK7FWJ2wLamfR3blCE46KVparjzpJk5Ylf8OxqnhjTu4xWOGFm84at61tw+cgf/6z 0i5DwLwpu1Mrr2bGBLxdUsdw9W6ycUxl5d3GqdwhhcurkSt05HbP4pjGKizGLv7vBIET D5dw== X-Gm-Message-State: AJcUukeRIlPTFGKp+KWj6Kk7hTzi9HyfHrp4Lkc0IUxEK9bsECZLOE/m y02o+Qqot6aqHN8l8ZdlgRsA5g== X-Google-Smtp-Source: ALg8bN5+djzWfwdKN+1jr2ma77gjFXRvNidqYQRQLiVLUdyF0vHH/cEgLfKuCL/zbwxyDXXNiZ+QbA== X-Received: by 2002:a17:902:6b87:: with SMTP id p7mr6690582plk.282.1547593669668; Tue, 15 Jan 2019 15:07:49 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:48 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Subject: [PATCH 2/7] coresight: perf: Add "sinks" group to PMU directory Date: Tue, 15 Jan 2019 16:07:37 -0700 Message-Id: <20190115230742.13730-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190115_180800_903066_CD408C21 X-CRM114-Status: GOOD ( 19.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-s390@vger.kernel.org, suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, will.deacon@arm.com, heiko.carstens@de.ibm.com, adrian.hunter@intel.com, ast@kernel.org, mingo@redhat.com, linux-arm-kernel@lists.infradead.org, hpa@zytor.com, schwidefsky@de.ibm.com, namhyung@kernel.org, tglx@linutronix.de, jolsa@redhat.com, linux-kernel@vger.kernel.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-Virus-Scanned: ClamAV using ClamSMTP Add a "sinks" directory entry so that users can see all the sinks available in the system in a single place. Individual sink are added as they are registered with the coresight bus. Signed-off-by: Mathieu Poirier --- .../hwtracing/coresight/coresight-etm-perf.c | 43 +++++++++++++++++++ .../hwtracing/coresight/coresight-etm-perf.h | 1 + drivers/hwtracing/coresight/coresight.c | 17 ++++++++ 3 files changed, 61 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index f21eb28b6782..292bd409a68c 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -43,8 +44,18 @@ static const struct attribute_group etm_pmu_format_group = { .attrs = etm_config_formats_attr, }; +static struct attribute *etm_config_sinks_attr[] = { + NULL, +}; + +static const struct attribute_group etm_pmu_sinks_group = { + .name = "sinks", + .attrs = etm_config_sinks_attr, +}; + static const struct attribute_group *etm_pmu_attr_groups[] = { &etm_pmu_format_group, + &etm_pmu_sinks_group, NULL, }; @@ -479,6 +490,38 @@ int etm_perf_symlink(struct coresight_device *csdev, bool link) return 0; } +static ssize_t etm_perf_sink_name_show(struct device *dev, + struct device_attribute *dattr, + char *buf) +{ + /* See function coresight_sink_by_id() to know where this is used */ + u32 hash = hashlen_hash(hashlen_string(NULL, dattr->attr.name)); + + return scnprintf(buf, PAGE_SIZE, "%x\n", hash); +} + +int etm_perf_symlink_sink(struct coresight_device *csdev) +{ + struct device *pmu_dev = etm_pmu.dev; + struct device *pdev = csdev->dev.parent; + struct device_attribute *dev_attr; + + if (csdev->type != CORESIGHT_DEV_TYPE_SINK && + csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) + return -EINVAL; + + if (!etm_perf_up) + return -EPROBE_DEFER; + + dev_attr = kzalloc(sizeof(*dev_attr), GFP_KERNEL); + dev_attr->attr.name = kstrdup(dev_name(pdev), GFP_KERNEL); + dev_attr->attr.mode = 0444; + dev_attr->show = etm_perf_sink_name_show; + + return sysfs_add_file_to_group(&pmu_dev->kobj, + &dev_attr->attr, "sinks"); +} + static int __init etm_perf_init(void) { int ret; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwtracing/coresight/coresight-etm-perf.h index da7d9336a15c..529a47285c0f 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -59,6 +59,7 @@ struct etm_event_data { #ifdef CONFIG_CORESIGHT int etm_perf_symlink(struct coresight_device *csdev, bool link); +int etm_perf_symlink_sink(struct coresight_device *csdev); static inline void *etm_perf_sink_config(struct perf_output_handle *handle) { struct etm_event_data *data = perf_get_aux(handle); diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 2b0df1a0a8df..526f122a38ee 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -18,6 +18,7 @@ #include #include +#include "coresight-etm-perf.h" #include "coresight-priv.h" static DEFINE_MUTEX(coresight_mutex); @@ -1167,6 +1168,22 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) goto err_out; } + if (csdev->type == CORESIGHT_DEV_TYPE_SINK || + csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) { + ret = etm_perf_symlink_sink(csdev); + + if (ret) { + device_unregister(&csdev->dev); + /* + * As with the above, all resources are free'd + * explicitly via coresight_device_release() triggered + * from put_device(), which is in turn called from + * function device_unregister(). + */ + goto err_out; + } + } + mutex_lock(&coresight_mutex); coresight_fixup_device_conns(csdev);