Received: by 10.192.165.148 with SMTP id m20csp4713060imm; Tue, 1 May 2018 02:18:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoGZXlR4KfF1G4q4xf877JFiLxm8vXQ6exiluHI/A66Yp7I/C/HqeIaYp9SGmeXYIu1zDQR X-Received: by 2002:a17:902:d882:: with SMTP id b2-v6mr15359698plz.381.1525166310678; Tue, 01 May 2018 02:18:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525166310; cv=none; d=google.com; s=arc-20160816; b=DtTs3rkzasfeY26HimtiqfpMvXqdeIn1lDqgf+XSJXge9UztZlltmBdDeFWjQb2uIh 6/roz8iHMjydChYOQyyemVQ8FzrckPi2iJfic0S7WMr7Xj9nFzqH/n9hElei7mv+Du1X A8qUc0wQ/UJX2pTL1FqOjMPe6xyEm+eWN6rTK32AIwJnwe6JucdgkHvQZ7h1mEqfwwkV AZdg6jyZvgDzR/Xni7v1c5J8aSm6m6SdogSehl5sZEZR/oJlNAQzEwaWmuSeNGWsFtbi DQBHaxdnQct5lJjt8Mvf7shOrT1txg2V9kPM0UVwuXOMQ5l0T93Tjn/Vvqs7dTUn/aZu CdYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=E1HW5l8k5kPcGTgDeOePe6vPVNnWL1vpn+Yt7OOi7cY=; b=VuYQvLU43Z8ggG35yZTcuABOVFiWMLB69nnGrd9cBuGA2diviwS7SAiBseflMcdQcW v5yGsJjvn8/l+v6gdbjojF5uLgZx9N2XcHCpklDyD21wWPypYBVXmgRSLnRfR/cmlh8d y4+VwcWMwE/mGnfNvHHgU2tlzKYnRJXh7bRmHZH42sdDlshDi0qeOmKRpNAOKE8JTTpP mmjwuqEVoAlDGZKZFvt2O0Hm7KAUsSonS7jaLj3iZqcNpHbi1ZVmTHyPDuhfQeNHJQLw H2Vjg5xz/rfjBU2aEGgYaKC+hcsQ4zlmPZOwBAfK6WsEiYc2vMwo1oiAGLkmTaeJRjQd TT7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j91-v6si3047861pld.402.2018.05.01.02.18.16; Tue, 01 May 2018 02:18:30 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753848AbeEAJLU (ORCPT + 99 others); Tue, 1 May 2018 05:11:20 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44050 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751920AbeEAJLQ (ORCPT ); Tue, 1 May 2018 05:11:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C900115BE; Tue, 1 May 2018 02:11:15 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 95AE73F487; Tue, 1 May 2018 02:11:13 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, mike.leach@linaro.org, robert.walker@arm.com, mark.rutland@arm.com, will.deacon@arm.com, robin.murphy@arm.com, sudeep.holla@arm.com, frowand.list@gmail.com, robh@kernel.org, john.horley@arm.com, Suzuki K Poulose Subject: [PATCH v2 03/27] coresight: Add helper device type Date: Tue, 1 May 2018 10:10:33 +0100 Message-Id: <1525165857-11096-4-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525165857-11096-1-git-send-email-suzuki.poulose@arm.com> References: <1525165857-11096-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new coresight device type, which do not belong to any of the existing types, i.e, source, sink, link etc. A helper device could be connected to a coresight device, which could augment the functionality of the coresight device. This is intended to cover Coresight Address Translation Unit (CATU) devices, which provide improved Scatter Gather mechanism for TMC ETR. The idea is that the helper device could be controlled by the driver of the device it is attached to (in this case ETR), transparent to the generic coresight driver (and paths). The operations include enable(), disable(), both of which could accept a device specific "data" which the driving device and the helper device could share. Since they don't appear in the coresight "path" tracked by software, we have to ensure that they are powered up/down whenever the master device is turned on. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight.c | 46 ++++++++++++++++++++++++++++++--- include/linux/coresight.h | 24 +++++++++++++++++ 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 389c4ba..fd0251e 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -430,6 +430,43 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate) return dev ? to_coresight_device(dev) : NULL; } +/* + * coresight_prepare_device - Prepare this device and any of the helper + * devices connected to it for trace operation. Since the helper devices + * don't appear on the trace path, they should be handled along with the + * the master device. + */ +static void coresight_prepare_device(struct coresight_device *csdev) +{ + int i; + + for (i = 0; i < csdev->nr_outport; i++) { + struct coresight_device *child = csdev->conns[i].child_dev; + + if (child && child->type == CORESIGHT_DEV_TYPE_HELPER) + pm_runtime_get_sync(child->dev.parent); + } + + pm_runtime_get_sync(csdev->dev.parent); +} + +/* + * coresight_release_device - Release this device and any of the helper + * devices connected to it for trace operation. + */ +static void coresight_release_device(struct coresight_device *csdev) +{ + int i; + + for (i = 0; i < csdev->nr_outport; i++) { + struct coresight_device *child = csdev->conns[i].child_dev; + + if (child && child->type == CORESIGHT_DEV_TYPE_HELPER) + pm_runtime_put(child->dev.parent); + } + pm_runtime_put(csdev->dev.parent); +} + /** * _coresight_build_path - recursively build a path from a @csdev to a sink. * @csdev: The device to start from. @@ -480,8 +517,7 @@ static int _coresight_build_path(struct coresight_device *csdev, node->csdev = csdev; list_add(&node->link, path); - pm_runtime_get_sync(csdev->dev.parent); - + coresight_prepare_device(csdev); return 0; } @@ -524,7 +560,7 @@ void coresight_release_path(struct list_head *path) list_for_each_entry_safe(nd, next, path, link) { csdev = nd->csdev; - pm_runtime_put_sync(csdev->dev.parent); + coresight_release_device(csdev); list_del(&nd->link); kfree(nd); } @@ -775,6 +811,10 @@ static struct device_type coresight_dev_type[] = { .name = "source", .groups = coresight_source_groups, }, + { + .name = "helper", + }, + }; static void coresight_device_release(struct device *dev) diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 556fe59..5e926f7 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -47,6 +47,7 @@ enum coresight_dev_type { CORESIGHT_DEV_TYPE_LINK, CORESIGHT_DEV_TYPE_LINKSINK, CORESIGHT_DEV_TYPE_SOURCE, + CORESIGHT_DEV_TYPE_HELPER, }; enum coresight_dev_subtype_sink { @@ -69,6 +70,10 @@ enum coresight_dev_subtype_source { CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE, }; +enum coresight_dev_subtype_helper { + CORESIGHT_DEV_SUBTYPE_HELPER_NONE, +}; + /** * union coresight_dev_subtype - further characterisation of a type * @sink_subtype: type of sink this component is, as defined @@ -77,6 +82,8 @@ enum coresight_dev_subtype_source { * by @coresight_dev_subtype_link. * @source_subtype: type of source this component is, as defined * by @coresight_dev_subtype_source. + * @helper_subtype: type of helper this component is, as defined + * by @coresight_dev_subtype_helper. */ union coresight_dev_subtype { /* We have some devices which acts as LINK and SINK */ @@ -85,6 +92,7 @@ union coresight_dev_subtype { enum coresight_dev_subtype_link link_subtype; }; enum coresight_dev_subtype_source source_subtype; + enum coresight_dev_subtype_helper helper_subtype; }; /** @@ -181,6 +189,7 @@ struct coresight_device { #define source_ops(csdev) csdev->ops->source_ops #define sink_ops(csdev) csdev->ops->sink_ops #define link_ops(csdev) csdev->ops->link_ops +#define helper_ops(csdev) csdev->ops->helper_ops /** * struct coresight_ops_sink - basic operations for a sink @@ -240,10 +249,25 @@ struct coresight_ops_source { struct perf_event *event); }; +/** + * struct coresight_ops_helper - Operations for a helper device. + * + * All operations could pass in a device specific data, which could + * help the helper device to determine what to do. + * + * @enable : Turn the device ON. + * @disable : Turn the device OFF. + */ +struct coresight_ops_helper { + int (*enable)(struct coresight_device *csdev, void *data); + int (*disable)(struct coresight_device *csdev, void *data); +}; + struct coresight_ops { const struct coresight_ops_sink *sink_ops; const struct coresight_ops_link *link_ops; const struct coresight_ops_source *source_ops; + const struct coresight_ops_helper *helper_ops; }; #ifdef CONFIG_CORESIGHT -- 2.7.4