From patchwork Wed May 22 10:34:50 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: 164801 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp694815ili; Wed, 22 May 2019 03:36:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8Ldx3XMgjIjYfdAjQU3wSYr54f8qAoi6KOcg/rBkJGuBdryfsxsnBKeI+IJ8jrDeBHq7o X-Received: by 2002:a63:ef56:: with SMTP id c22mr2756801pgk.13.1558521406355; Wed, 22 May 2019 03:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558521406; cv=none; d=google.com; s=arc-20160816; b=aIbu1nAgOjY/dpLH4dj+izWG35XgEg/gntMCgHUMBAxJIUOV6dBc8Oi3qYrJUTDy0W XpauEY8ojVMqUyK7HSsKk+sUvjQfdvVjpWlJe5hipyvDwfmMj9B0Muvm0do+qs8NPwQm MJFWl1IKrLeOc8PeBI3DsdnpqAuC1FUTL0Br3F9IjMmcLOW9qMQQLqsg/q1WbMiIecia Tr3xM1Dh1YTfZwH9t0ZNgaSzPv9E634cPjHN2l6P1y+vTOfHeofHrjY/ztP+Vd6f4d5/ wdLVASjbVogbumQOxtRuqHQixc037xF4FuoIQxB8ReV0uCNyEIctjsiYjJBczkA6rXSD jYdA== 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=nYGUQgVSrKL0R35OdMR/IsiQPbXPyGjZ51cLoAYVH4w=; b=ubDYCFFarcKm5why2ttscIvr596ygsmfuqXpJz6EXJmS1IiCTKZ7LA9gCNtqmQwU1i VsECg2oUq4XLaQuo/xmf50cmHE+OFzRWR/r0H744ogBU7HY9CsNV6McjY52+US3hegFb HKW93BbaAJ3a3i/xN3ENFr+gqQMjTKA5ITKy3d+V1z3vZM6KMPGIBcOHuVtbEJyg+idx N98yorInLKJKWwwmtDOooPlf1iAw26tNVBXd7tjJCT3wuxMyvIiwaYPzhxvJuJzGpfum psHKadmnAs+yCNnzI3QBJaWzgzMFXZxRItrInrIOmfTPGZpuMbJadEgJMLCqlyiu7gQ2 CtGA== 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 h14si23800053plr.255.2019.05.22.03.36.45; Wed, 22 May 2019 03:36:46 -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 S1729395AbfEVKfn (ORCPT + 30 others); Wed, 22 May 2019 06:35:43 -0400 Received: from foss.arm.com ([217.140.101.70]:47094 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729347AbfEVKfk (ORCPT ); Wed, 22 May 2019 06:35:40 -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 57FD9341; Wed, 22 May 2019 03:35:40 -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 483293F575; Wed, 22 May 2019 03:35:39 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, Suzuki K Poulose Subject: [PATCH v4 17/30] coresight: Make device to CPU mapping generic Date: Wed, 22 May 2019 11:34:50 +0100 Message-Id: <1558521304-27469-18-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558521304-27469-1-git-send-email-suzuki.poulose@arm.com> References: <1558521304-27469-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. Reviewed-by: 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 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 5d78f4f..ba8c146 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 @@ -240,8 +241,6 @@ static int 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); @@ -300,6 +299,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) { @@ -318,6 +325,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)) ret = of_get_coresight_platform_data(dev, pdata); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index e2b95e0..98a4440 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -292,12 +292,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);