From patchwork Mon Apr 15 16:04:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 162230 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3107943jan; Mon, 15 Apr 2019 09:08:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTEYaP6En8fYg2LH/Gnnu2YlY0Nn24s8HP2hGJW2qOnLGO17XecRjxVc82bZVOTP/ciark X-Received: by 2002:a63:1d4f:: with SMTP id d15mr44274034pgm.347.1555344493141; Mon, 15 Apr 2019 09:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344493; cv=none; d=google.com; s=arc-20160816; b=TIVxUb/3+eZezrngBKxccHJlPJDDpRIcgqAX6ftRqLgMODw/kAn7gycOhuDQKUD3qH Ex6BhydwBn7ionhcFzdxIIvmSuaYhaFsZfoHFndZHrMf+G9237/XuqkwFQsefr/3s08w YHf5ramGaO8of9z2evHgBzRoyeWWNa8lqPYG4mFQSvSFgRgG4kI2ailEdAs3HYNTRgh1 nmheGRFsjGkXWu/m69+z2U2Lx28nV33E4SjTOSJgbKkHxEchV8DZyas2zHIf/v85BYHN r3v7jvRKk0FmsY46BIW0u9oI4Aqz77yTnxAmhBSs6ctzyYalOCZQHAbLWRx61S6i6MRv 99OA== 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; bh=tA15Va5g+P9Unr3Yz1jot6YxtujOcJKWn7ZFDO3vc8Q=; b=enKMvDOHw9EHWaIEitoQxMoEo6EEPro++/NDzyxP6VtxIV7ot1dkH8OogswGrtOFuj 7fySIvfsbTupGDT24aqjvQpdRuKRynhRQBR38rK0whkK1TqD1bgeiNq5UiVCLgMEq6Vy hD8lUV4wc5PqpG8fbUdLngnyznRlDuzTfsADXR00SzqfO33VB0rItz5O2RA4jUUJgU8K wweLTVPZR8zFuQUnhUiu3xUDJufqDi59RazvNh8tqCxxOF7p/TutEyM/2NTh9DFQfgXy fRsO+X8dT5fSU50p8/M87wLOf51oM52SEOWIaPcE+XVPIBrxxlpjs3cCiOt/tLbzgkJ3 vVAA== 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 m16si43259655pls.150.2019.04.15.09.08.12; Mon, 15 Apr 2019 09:08:13 -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 S1727798AbfDOQIL (ORCPT + 30 others); Mon, 15 Apr 2019 12:08:11 -0400 Received: from foss.arm.com ([217.140.101.70]:37902 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727999AbfDOQGU (ORCPT ); Mon, 15 Apr 2019 12:06:20 -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 E89A2168F; Mon, 15 Apr 2019 09:06:19 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6EF6F3F68F; Mon, 15 Apr 2019 09:06:18 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org, mike.leach@linaro.org, rjw@rjwysocki.net, robert.walker@arm.com, Suzuki K Poulose Subject: [PATCH v2 20/36] coresight: Make device to CPU mapping generic Date: Mon, 15 Apr 2019 17:04:03 +0100 Message-Id: <1555344260-12375-21-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> References: <1555344260-12375-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 The CoreSight components ETM and CPU-Debug are always associated with CPUs. Replace the of_coresight_get_cpu() with a platform agnostic helper, in preparation to add ACPI support. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-cpu-debug.c | 3 +-- drivers/hwtracing/coresight/coresight-platform.c | 18 +++++++++++++----- include/linux/coresight.h | 7 +------ 3 files changed, 15 insertions(+), 13 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c index e8819d7..07a1367 100644 --- a/drivers/hwtracing/coresight/coresight-cpu-debug.c +++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c @@ -572,14 +572,13 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id) struct device *dev = &adev->dev; struct debug_drvdata *drvdata; struct resource *res = &adev->res; - struct device_node *np = adev->dev.of_node; int ret; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; - drvdata->cpu = np ? of_coresight_get_cpu(np) : 0; + drvdata->cpu = coresight_get_cpu(dev); if (per_cpu(debug_drvdata, drvdata->cpu)) { dev_err(dev, "CPU%d drvdata has already been initialized\n", drvdata->cpu); diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 25a1838..8a86ba3 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -151,12 +151,14 @@ static void of_coresight_get_ports(const struct device_node *node, } } -int of_coresight_get_cpu(const struct device_node *node) +static int of_coresight_get_cpu(struct device *dev) { int cpu; struct device_node *dn; - dn = of_parse_phandle(node, "cpu", 0); + if (!dev->of_node) + return 0; + dn = of_parse_phandle(dev->of_node, "cpu", 0); /* Affinity defaults to CPU0 */ if (!dn) return 0; @@ -166,7 +168,6 @@ int of_coresight_get_cpu(const struct device_node *node) /* Affinity to CPU0 if no cpu nodes are found */ return (cpu < 0) ? 0 : cpu; } -EXPORT_SYMBOL_GPL(of_coresight_get_cpu); /* * of_coresight_parse_endpoint : Parse the given output endpoint @ep @@ -241,8 +242,6 @@ of_get_coresight_platform_data(struct device *dev, bool legacy_binding = false; struct device_node *node = dev->of_node; - pdata->cpu = of_coresight_get_cpu(node); - /* Get the number of input and output port for this component */ of_coresight_get_ports(node, &pdata->nr_inport, &pdata->nr_outport); @@ -294,6 +293,14 @@ of_get_coresight_platform_data(struct device *dev, } #endif +int coresight_get_cpu(struct device *dev) +{ + if (is_of_node(dev->fwnode)) + return of_coresight_get_cpu(dev); + return 0; +} +EXPORT_SYMBOL_GPL(coresight_get_cpu); + struct coresight_platform_data * coresight_get_platform_data(struct device *dev) { @@ -309,6 +316,7 @@ coresight_get_platform_data(struct device *dev) /* Use device name as sysfs handle */ pdata->name = dev_name(dev); + pdata->cpu = coresight_get_cpu(dev); if (is_of_node(fwnode)) return of_get_coresight_platform_data(dev, pdata); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 5b29255..a48cd9b 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -291,12 +291,7 @@ static inline void coresight_disclaim_device_unlocked(void __iomem *base) {} #endif -#ifdef CONFIG_OF -extern int of_coresight_get_cpu(const struct device_node *node); -#else -static inline int of_coresight_get_cpu(const struct device_node *node) -{ return 0; } -#endif +extern int coresight_get_cpu(struct device *dev); struct coresight_platform_data *coresight_get_platform_data(struct device *dev);