From patchwork Mon Apr 15 16:03:44 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: 162203 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3104825jan; Mon, 15 Apr 2019 09:05:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3S5e+LgFWJ4kzmE1oSxjmzXkM4SQUQCT1j779LJH50rdy582TMvKjxdylvwwnIL9jrO67 X-Received: by 2002:a63:2045:: with SMTP id r5mr56315592pgm.394.1555344352148; Mon, 15 Apr 2019 09:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344352; cv=none; d=google.com; s=arc-20160816; b=nA4PTimf1cks+/Zz3WixYhG0tJkuoavW+lS0z7dwbG71rsElA6PeauIkBq0Id4bbPp 85wLNOENpxAhW5eUb4MqLi02URKEDZSEm1nEe/4JeBH+0scfTY7wLpYRPld3D0zmtmcu 7JvviPGWUSDzn4AXC1ZJSkOI9EL3W/uK1Hyqi4v+4lxzEc2wSLmDK77/F1VTI5Ewpl8S GyiuL5Rh6630h67zHp0fxABCrjcPdhJRAO6x7noex83P87IFtHOwlfbHeMGw0J1C6Scd nttll4k0tAMCHJLXPKFq77rTGtaTyRu/hKd25pWqqV6nv6PEf8hoY7ROKbkTJaeL1I5m egOQ== 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=1uzAFYMmNX81I1knb0dzNVimTxcNrVPqlVBF4yo+Oh8=; b=nro4ikYJCMrk9FqEvhSLsie7bQVLycnFHttajOef2FvhWqxmhYHE2iD4C+R9I4zpBo 7JSPyDbsTQyMMMZ9tephXjVa8brtjjHDYkUzRAPZ6D7Hpl6MpGI7I/4oI1cVShoBfXsR 8KOT8uNZcor1rDwd/p5CGANAx/G6miMN1ZTR7n/gAwexMhrBYz1dwbCGogtWOxHOAixK 4HM5c/jZtCprR9HU2xeOv/xDheHt6nr9CYNVW/4WXSN18cjspfEuUOerWexYLUiBYApf vku3DopPD3It9nkQUA7e0+My5+baXoZXs6DSPXFugCdiAZpo+VGFk76L4T3q4X4ah0wx FLqg== 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 73si16547264plb.158.2019.04.15.09.05.51; Mon, 15 Apr 2019 09:05:52 -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 S1727386AbfDOQFt (ORCPT + 30 others); Mon, 15 Apr 2019 12:05:49 -0400 Received: from foss.arm.com ([217.140.101.70]:37644 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727143AbfDOQFq (ORCPT ); Mon, 15 Apr 2019 12:05:46 -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 611911684; Mon, 15 Apr 2019 09:05:46 -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 D22863F68F; Mon, 15 Apr 2019 09:05:44 -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 01/36] coresight: Fix freeing up the coresight connections Date: Mon, 15 Apr 2019 17:03:44 +0100 Message-Id: <1555344260-12375-2-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 With commit c2c729415b2d2132 ("coresight: platform: Cleanup coresight connection handling"), we switched to re-using coresight_connections for the coresight_device. However, that introduced a mismatch in the alloc/free of the connections. The allocation is made using devm_*, while we use kfree() to release the memory when a device is released (even though we don't support this at the moment). Fix this by leaving it to the automatic freeing of the memory. Fixes: c2c729415b2d2132 ("coresight: platform: Cleanup coresight connection handling") Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight.c | 1 - 1 file changed, 1 deletion(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 29cef89..55204dd 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -973,7 +973,6 @@ static void coresight_device_release(struct device *dev) { struct coresight_device *csdev = to_coresight_device(dev); - kfree(csdev->conns); kfree(csdev->refcnt); kfree(csdev); } From patchwork Mon Apr 15 16:03:45 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: 162239 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3109138jan; Mon, 15 Apr 2019 09:09:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0l18KBGtuyRLr3mqtnncSP1GHCTTjKgumR+Ik51cC3PfPPhUFC906fwjNCaomfr1KHZtS X-Received: by 2002:a63:87c1:: with SMTP id i184mr71721089pge.265.1555344550826; Mon, 15 Apr 2019 09:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344550; cv=none; d=google.com; s=arc-20160816; b=BA+nkVeskk5R4oswwaKy9lOCwwvLkkixXEwGN5DDMpotX+YcQ21xfLKXb6c6ZY0a6G S8fKOi3O8MPcbLKMTWqi1cJ30zv7W4x5l8B5j/ItkgkTzCY17fBqKR+utcd4/6B5iL1A 0VZ56Ic7rh835LqZWud4hxQM8ay6FBjtwQQh07hm6fSxL1YIIyqfUkCsCPhBxcOe2fZV Cftci51a+Ea4ljfuu/1/f0s7LyVkQGn6McvP/LsII9mE3BKgsUn8lSVWcVMHkpfPAVd4 /G7S/XTBCQUyqShFhr4v1LqPDwiA5BpVYvZTNx05dJpy28JII6MwP/E95IaoIbd8Ao1m tC1w== 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=hsOAMpyyEfEWOdOlRzDMt8RoU2py6ixkH/Xfb1+Peuw=; b=KGpW6oFZXQv6j55GZF7r7CYn/narDmmo+WiLeIFIktXz6rRmisPqXRilZgR0vwsrUt 2m6+m6Ahs5cK1nnrUAKTnrUI9pLjxAZD59mcpcmqdSA0BnNdjK8hfK0rWoowVU3v4dtM 6MNHslpa84plKDV9qr7gR33+C7YLhUDhLJlb6dbyB5/vN26GzzXNQDABMeq6kWKfdp2c dC/Re1cL7+mUz/R8EsFb3IOT9x2ZztQQG1flqgxEan8Rl9se3nTW/J6eRBb4Tv232hy3 YWQAShV1OWoA22AdreQxABEofqgk+z6agdxsCHykqegLShVfLaf3X6/FEZtzrL2G9OeG E+cw== 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 v12si38928910pga.148.2019.04.15.09.09.10; Mon, 15 Apr 2019 09:09:10 -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 S1728115AbfDOQJJ (ORCPT + 30 others); Mon, 15 Apr 2019 12:09:09 -0400 Received: from foss.arm.com ([217.140.101.70]:37656 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727696AbfDOQFs (ORCPT ); Mon, 15 Apr 2019 12:05:48 -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 2380280D; Mon, 15 Apr 2019 09:05:48 -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 9DE6C3F68F; Mon, 15 Apr 2019 09:05:46 -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 02/36] coresight: etb10: Cleanup power management Date: Mon, 15 Apr 2019 17:03:45 +0100 Message-Id: <1555344260-12375-3-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 We drop the power before we complete the probe successfully. We are supposed to drop it only when we are successful. Also, probing the etb_buffer_length happens with the power turned up. So we don't need to do that again in the helper. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etb10.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 105782e..13c0a60 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -93,17 +93,9 @@ struct etb_drvdata { static int etb_set_buffer(struct coresight_device *csdev, struct perf_output_handle *handle); -static unsigned int etb_get_buffer_depth(struct etb_drvdata *drvdata) +static inline unsigned int etb_get_buffer_depth(struct etb_drvdata *drvdata) { - u32 depth = 0; - - pm_runtime_get_sync(drvdata->dev); - - /* RO registers don't need locking */ - depth = readl_relaxed(drvdata->base + ETB_RAM_DEPTH_REG); - - pm_runtime_put(drvdata->dev); - return depth; + return readl_relaxed(drvdata->base + ETB_RAM_DEPTH_REG); } static void __etb_enable_hw(struct etb_drvdata *drvdata) @@ -720,7 +712,6 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&drvdata->spinlock); drvdata->buffer_depth = etb_get_buffer_depth(drvdata); - pm_runtime_put(&adev->dev); if (drvdata->buffer_depth & 0x80000000) return -EINVAL; @@ -747,6 +738,7 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) if (ret) goto err_misc_register; + pm_runtime_put(&adev->dev); return 0; err_misc_register: From patchwork Mon Apr 15 16:03:46 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: 162204 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3104849jan; Mon, 15 Apr 2019 09:05:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1kIO7LX1iIF3FYHMWE7eIPoahNXoQTaIRdd6hohs/f3lgAiD81k1N0Y/44PrAIX34xc9i X-Received: by 2002:a63:3dca:: with SMTP id k193mr69044891pga.146.1555344353457; Mon, 15 Apr 2019 09:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344353; cv=none; d=google.com; s=arc-20160816; b=B3F8gAlpTm9j6We5XgxyggwHJYZ/2gw03QA6pyXUq+7A0G5B6dewubzpsJe0K1Jjqo ga8hIe3aJzfz97Gbv36WnE4KaImzYxeyvXR48unHwM9/03G6mABl4dgJZ2NjmXVlyb4s qNw5B5E7ZsmBEQltpEn8X+xzsZ/AvK6Eo1+vSGKCRjZnJpz4TFORhQCxMCKzlFFB6xfb hbpGZa1ifrUdyc5p9+4i+3ddaROt8LNVWHayfzXX1cdYUXHWaN6Aq0qfBgCw9Z6vcQ+u gTJ3mJyntcIDnXagC4ejgF1+9aoR5qm7CGvOBpwlzTm+3NoF7hbKZ2efllDLBcjNnm07 SZHQ== 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=P7zZRig3LerlzOi0MDjoYOm2AcJJpDsYasfqmv/xPXQ=; b=D0IIe1wSy8q10vvVxLrG84xgW6ze2VBdGT8CqjXAun0RjbxomM3A93aL0/zb9zG8ab rPhMRSRXV8idZ6g2cq+XJX0De/fmQvpybGeVwWxJBYdoh3Dznha/LjoYNdohTwMBULIP 4Vs9uqryB/VMFE0t2Oh+qx3E09g4XbGGXkJk7M9bXC8A4TVttwa/JXO/GvDMJnu5cjnu uI8CAf5cAmU1aBqdVB314kgpd7WU1p4Ey/mvR1nm8929jNVck43g3J6yRT4CXJBB8/DX oLBhVX9g2SBQPfDVJHe7NHvXZQTd3ih3i//OaYtNs5TQS565z5pWsJqCLUKn7LZ68aLs hygQ== 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 73si16547264plb.158.2019.04.15.09.05.53; Mon, 15 Apr 2019 09:05:53 -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 S1727840AbfDOQFw (ORCPT + 30 others); Mon, 15 Apr 2019 12:05:52 -0400 Received: from foss.arm.com ([217.140.101.70]:37670 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727143AbfDOQFu (ORCPT ); Mon, 15 Apr 2019 12:05:50 -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 E2DDDA78; Mon, 15 Apr 2019 09:05:49 -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 602993F68F; Mon, 15 Apr 2019 09:05:48 -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 03/36] coresight: tpiu: Cleanup power management Date: Mon, 15 Apr 2019 17:03:46 +0100 Message-Id: <1555344260-12375-4-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 Drop the power only when we have successfully probed. Otherwise leave it to the amba probe to do the rest. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tpiu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index b2f72a1..4977467 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -153,7 +153,6 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) /* Disable tpiu to support older devices */ tpiu_disable_hw(drvdata); - pm_runtime_put(&adev->dev); desc.type = CORESIGHT_DEV_TYPE_SINK; desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_PORT; @@ -162,7 +161,12 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) desc.dev = dev; drvdata->csdev = coresight_register(&desc); - return PTR_ERR_OR_ZERO(drvdata->csdev); + if (!IS_ERR(drvdata->csdev)) { + pm_runtime_put(&adev->dev); + return 0; + } + + return PTR_ERR(drvdata->csdev); } #ifdef CONFIG_PM From patchwork Mon Apr 15 16:03:47 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: 162205 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3104898jan; Mon, 15 Apr 2019 09:05:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJMV4TQMbcnp/cWLmjeqnU+XiMdC9iobhz4tY7nFjUlpbsM63GIRvgHkhaj/9Z516SJ/MO X-Received: by 2002:aa7:8b4c:: with SMTP id i12mr70196257pfd.189.1555344355689; Mon, 15 Apr 2019 09:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344355; cv=none; d=google.com; s=arc-20160816; b=o80l63bMaMb+DShWqUM6KZfc6sBMg09CiKPeNE724arv0plHx1CGIi6vHYycn5a402 lm79hNxM07o3DL8wJ08pbI2wzLMT7YP4Avu4ljMU0ZWGTSqvEqpEAqNGdpEOUwTNMCPY HvbhBdP12TvqZ4UuYIM2yUwPgtuKVUyfOp/c/pufsxcGbdRN+WtwenH4t9Vt8HpYBAit mbYaCcecScM7sNOerq+ts447e17nY7R7u6ZpuR6A/LY7cRazIPWdvRwUZ0DbUfaBIK/2 kPIDEU+DfWyHR9IzR8AcJnJ/9oQbsbZRwqQK53yMClI36oQsNKCWBlhc/lmIUQo1744M Zksg== 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=DeZeRPZen73+TrzNi9rRybk2ZjsBxbjKko9nE3q6HmY=; b=pY1Zmiq/vWPaHhsZ7n1Ri6Szr8LD8aHqOF3/53Pb+39WguS5T0l9dNgglcUPSnjbzt BgfAgqqt1Jxmn29ttx/3oxzhV51+6c2qVOhx7c0vhvMmptPNXkSGIKUXZpS1T2+8saMr IZFlt1xF9Z/0yL/aRsSNx1m3wtsGBAcPovnoJdP/MCQMnnNLgbDB7QH4+UFL7O4MPPqX MeLYYeNOGpuido9mycYfIQZa/+5P3oE/H3SPgcRo6ihZGzY8/Bv4iofpsbRnWi1ogwFd O83U5KzaRHowCAgtGCf1Ch5LG6yV/I3Wn18jv5rJtxJbu/tf4LavLfm0i/lAAnnhLoCJ fv8Q== 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 w8si23771255pgr.529.2019.04.15.09.05.55; Mon, 15 Apr 2019 09:05:55 -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 S1727855AbfDOQFy (ORCPT + 30 others); Mon, 15 Apr 2019 12:05:54 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37688 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbfDOQFw (ORCPT ); Mon, 15 Apr 2019 12:05:52 -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 AE0DA80D; Mon, 15 Apr 2019 09:05:51 -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 2B7DE3F68F; Mon, 15 Apr 2019 09:05:50 -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 04/36] coresight: catu: Cleanup power management Date: Mon, 15 Apr 2019 17:03:47 +0100 Message-Id: <1555344260-12375-5-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 Drop the power handle only if we were successful. Otherwise the AMBA bus code would do the rest. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-catu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index 170fbb6..f2a6a8d 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -557,8 +557,9 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) drvdata->csdev = coresight_register(&catu_desc); if (IS_ERR(drvdata->csdev)) ret = PTR_ERR(drvdata->csdev); + else + pm_runtime_put(&adev->dev); out: - pm_runtime_put(&adev->dev); return ret; } From patchwork Mon Apr 15 16:03:48 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: 162206 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3104924jan; Mon, 15 Apr 2019 09:05:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9/RwBFWm/3fIbs3UkN2+y0VCfbQX2nT75eC1goOTE0OFl36d5HfIvb8sobkkrn7YYfjFH X-Received: by 2002:a65:4589:: with SMTP id o9mr54153503pgq.381.1555344356586; Mon, 15 Apr 2019 09:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344356; cv=none; d=google.com; s=arc-20160816; b=SoOEpZIkMZv+XbOwn+dixVc4RsfsyHpFPfwlye9EYC2YCiPde7y00uholADLllQHY3 sZ3dhzLm5exkYoQXgKxEhn25KhF0sUAvA+DpAW6KI1DxEcAeY5TTGDCMmS9V5BRthx9x aWv9Qm2p5jNCiV+kQgLmItktnGIkyEY3M8Yq2hQ30tTfptJpAZZdxviie1VkyAI54+Sq pTgMiIcV/kpnuAdkNNq4Mv+m3b2U+710mD1AsIH80oRc27SC8vDoLvzMaVBfAZ3PRvKg bmQoDjtsBoMa8qAJMqG/Oloe43NbFaOUKWWO0/NJN+RqQY8SBapNmXZNt0Q8M+lFKxcC CbaA== 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=5YRgV+d5Xo3QfgfN3QUlhr4n2vQSXrQXKW4VFQNiM6U=; b=a2E9UwqeAqsIxSLWPKU/GRAGc3fdad1m1DSUjnnduy2LEBNqRewxiC6SV2UC6by8hJ MxJS7IhfT0awL5sL7LDg6NuKr8lovUN9jAr8dn4Eotz4g4gfaH2I3vOicD+tUZ5i1byE zd0zYQCeU2rY9/25iy98GNWQdVkRb93301WJE1wi0KV9lTw+6Mn0/OjixaX7kky/4HuC SQIZZXWp9QPCSeIhYicvfv6Y0rls3R0Qrp3HQn0RJNOh4rps8fnHGsLpQs5aFyeC4CUk c+/m4QKeP3GamK8DfyFlCI908Qm1msDQLiKfZz5M4UCvCiu081BNvgSKHEJsgayZhI6x DXpw== 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 w8si23771255pgr.529.2019.04.15.09.05.56; Mon, 15 Apr 2019 09:05:56 -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 S1727870AbfDOQFz (ORCPT + 30 others); Mon, 15 Apr 2019 12:05:55 -0400 Received: from foss.arm.com ([217.140.101.70]:37704 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727853AbfDOQFx (ORCPT ); Mon, 15 Apr 2019 12:05:53 -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 7B692A78; Mon, 15 Apr 2019 09:05:53 -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 ECA6A3F68F; Mon, 15 Apr 2019 09:05:51 -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 05/36] coresight: tmc: Cleanup power management Date: Mon, 15 Apr 2019 17:03:48 +0100 Message-Id: <1555344260-12375-6-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 Drop the power only if we were successful in probing the device. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 647b6aa..c6a5462 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -432,8 +432,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4; } - pm_runtime_put(&adev->dev); - desc.pdata = pdata; desc.dev = dev; desc.groups = coresight_tmc_groups; @@ -476,6 +474,8 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) ret = misc_register(&drvdata->miscdev); if (ret) coresight_unregister(drvdata->csdev); + else + pm_runtime_put(&adev->dev); out: return ret; } From patchwork Mon Apr 15 16:03:49 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: 162237 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3108726jan; Mon, 15 Apr 2019 09:08:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHR+1aTqOuD6EXsVXhWsgOMzuiRHpWGNW0oUIshGlRxpUUSsafGaxt9q86TsaXTBoqGdDk X-Received: by 2002:a62:14d7:: with SMTP id 206mr74777416pfu.162.1555344531024; Mon, 15 Apr 2019 09:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344531; cv=none; d=google.com; s=arc-20160816; b=0Kxa0/WZInGJYFc6+cBCBvnKcStGYlWAe+gA5FaKwa5J363sGB4Yon4SwVnncu3B0W 2Tn6OpAxwJLFmTy1qWsmOWlZybvrbu//+PolRoTne3G1jl3Cd7JxxwCsAFx7RethymG6 aeyVzspd8zJwZrBx3RVFr8NL6PORIrZcNY6q6Ve3tlNMy65/DzIrukRWsrYyA2LN/Cx0 tJdURePzOwZx3KI3pO8K0HfG0D1cW78D8bW9lbgA83eYSVmN+zqXS1BxUVfMuzIg5nE4 u99anIYEOnsX58e89z5EoENjyPXoQyFaSJNavhtVwigBfuYZekMMU/S8tGNhOuKKpp20 rzmg== 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=I8B20Z3zpp4XTuuJBfXEFP6+PR/B6XhfMv5xfSKUsKU=; b=dk/ToSIlhtCka/NX2iAMe3TKBff8hw1bng+SVicwx913ZXP9iWD+b8AJanKXMf+tqw s9eW9dDXvvEkFTKLX+Xw0gQeifNxTUAAmFvILf4KNWOsocDBl72agqAqCfxGbUYtHwoZ fQLzp1g2+irwoGVNhVML3mKE+7oR3QHs0U/JtLGwh2SrRJUqf2SQGryv1HO+1GDAwjlN EizPsO7DCa90T4SKECMsagkhPrLB2ph5yKZxVxe+3CsR8fxEgMYfpYjUcUhPvov9fP7/ PByNYr9FxTEbDHyVhRPK2X/amJZs7d7nCrqnVOKvNo02HamDSQxZJmUrnmvESdOP3kj/ cVUA== 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 v10si47036438pgj.576.2019.04.15.09.08.50; Mon, 15 Apr 2019 09:08:51 -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 S1727889AbfDOQF7 (ORCPT + 30 others); Mon, 15 Apr 2019 12:05:59 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37718 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727853AbfDOQFz (ORCPT ); Mon, 15 Apr 2019 12:05:55 -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 3E4D31684; Mon, 15 Apr 2019 09:05:55 -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 B8E4C3F68F; Mon, 15 Apr 2019 09:05:53 -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 06/36] coresight: funnel: Clean up device book keeping Date: Mon, 15 Apr 2019 17:03:49 +0100 Message-Id: <1555344260-12375-7-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 In preparation to use a consistent device naming scheme, clean up the device link tracking in funnel driver. Use the "coresight" device instead of the "real" parent device for all internal purposes. All other requests (e.g, power management, DMA operations) must use the "real" device which is the parent device. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-funnel.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 9279251..1085f31 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -37,7 +37,6 @@ */ struct funnel_drvdata { void __iomem *base; - struct device *dev; struct clk *atclk; struct coresight_device *csdev; unsigned long priority; @@ -77,7 +76,7 @@ static int funnel_enable(struct coresight_device *csdev, int inport, rc = funnel_enable_hw(drvdata, inport); if (!rc) - dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport); + dev_dbg(&csdev->dev, "FUNNEL inport %d enabled\n", inport); return rc; } @@ -105,7 +104,7 @@ static void funnel_disable(struct coresight_device *csdev, int inport, funnel_disable_hw(drvdata, inport); - dev_dbg(drvdata->dev, "FUNNEL inport %d disabled\n", inport); + dev_dbg(&csdev->dev, "FUNNEL inport %d disabled\n", inport); } static const struct coresight_ops_link funnel_link_ops = { @@ -160,11 +159,11 @@ static ssize_t funnel_ctrl_show(struct device *dev, u32 val; struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent); - pm_runtime_get_sync(drvdata->dev); + pm_runtime_get_sync(dev->parent); val = get_funnel_ctrl_hw(drvdata); - pm_runtime_put(drvdata->dev); + pm_runtime_put(dev->parent); return sprintf(buf, "%#x\n", val); } @@ -199,7 +198,6 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) return -ENOMEM; - drvdata->dev = &adev->dev; drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); From patchwork Mon Apr 15 16:03: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: 162236 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3108645jan; Mon, 15 Apr 2019 09:08:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyB5JsZhJzWDJuCqqyAjG1YykzbMaI8aEtZt+Szpqn7lErVoZafJQiWSs5hrTcy/yFziJsl X-Received: by 2002:a62:6444:: with SMTP id y65mr76089566pfb.56.1555344527858; Mon, 15 Apr 2019 09:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344527; cv=none; d=google.com; s=arc-20160816; b=dQaI75mHoq8uOaqqNfA8uvGNENkDt7BAYYHMSIWemlQKnYTLv9iQVIv9LcVbIVvnsF MPdItF6PZN1wnXnyvdpmgSseJMwV++P0E8vlYgconQn79wGWaqjKHI4cs8oCMWW8t7TA YHPyvCZNdv6fynci9Sh09QogZjWSBLvRYFBxTRjDD/790l+485VVRrNhgtayifyNnkWw +lnwu6nPfz43w5gYBM4awL0J2H5HXuba6OEp+xrOfdd+EIEVGWzsGf7QE4Xe3JpKXaW9 aM7INHgD8JY81bTDKknlkYivbsCyuOuuh5NTYCPKfzzoTwVifuPUJsBiyFbzPTf7J8fu FwDQ== 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=IK699P3/WL6ouWxwIiLNGBD8n0pFyiTCXn8SQYF9fcY=; b=uOX+oMKzHVfuc/1CvYyBcWJfrOo7CyPWN0zi0utW+fY7RA3V5cx3h1R+nXrJWCrJCr l/JDbZzwxXTGaAlbSzTk8uQHTSQvLqSpBK2hyYD9hYY4/Y5sbaurv1BG0AYNFfUPKzSj 473zXmVnDdYeXxYpKz2PFWYGHmxgUyq38Y2HCVH7zRWmgsgidUo8oe+7YkxSz15B//LI z82xkEkbO9goJtPQ5Jy8+L+OyntcBbnfJly1WRXGbJHFS3h1Py3zdQlBTxHitP0NEaIo 4oFN/ASuhoGeRpsNoAE3r7WpIz/C2Dk0kvb/0Ks9R4prkbRPVwsXxkfyNqlCk2yD82qO yKwA== 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 v10si47036438pgj.576.2019.04.15.09.08.47; Mon, 15 Apr 2019 09:08:47 -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 S1727903AbfDOQGC (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:02 -0400 Received: from foss.arm.com ([217.140.101.70]:37730 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727876AbfDOQF5 (ORCPT ); Mon, 15 Apr 2019 12:05:57 -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 02A8480D; Mon, 15 Apr 2019 09:05:57 -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 7B0933F68F; Mon, 15 Apr 2019 09:05:55 -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 07/36] coresight: replicator: Cleanup device tracking Date: Mon, 15 Apr 2019 17:03:50 +0100 Message-Id: <1555344260-12375-8-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 In preparation to use a consistent device naming scheme, clean up the device link tracking in replicator driver. Use the "coresight" device instead of the "real" parent device for all internal purposes. All other requests (e.g, power management, DMA operations) must use the "real" device which is the parent device. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-replicator.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 4e0da85..8bbb008 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -26,13 +26,11 @@ * struct replicator_drvdata - specifics associated to a replicator component * @base: memory mapped base address for this component. Also indicates * whether this one is programmable or not. - * @dev: the device entity associated with this component * @atclk: optional clock for the core parts of the replicator. * @csdev: component vitals needed by the framework */ struct replicator_drvdata { void __iomem *base; - struct device *dev; struct clk *atclk; struct coresight_device *csdev; }; @@ -100,7 +98,7 @@ static int replicator_enable(struct coresight_device *csdev, int inport, if (drvdata->base) rc = dynamic_replicator_enable(drvdata, inport, outport); if (!rc) - dev_dbg(drvdata->dev, "REPLICATOR enabled\n"); + dev_dbg(&csdev->dev, "REPLICATOR enabled\n"); return rc; } @@ -139,7 +137,7 @@ static void replicator_disable(struct coresight_device *csdev, int inport, if (drvdata->base) dynamic_replicator_disable(drvdata, inport, outport); - dev_dbg(drvdata->dev, "REPLICATOR disabled\n"); + dev_dbg(&csdev->dev, "REPLICATOR disabled\n"); } static const struct coresight_ops_link replicator_link_ops = { @@ -193,7 +191,6 @@ static int replicator_probe(struct device *dev, struct resource *res) if (!drvdata) return -ENOMEM; - drvdata->dev = dev; drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); From patchwork Mon Apr 15 16:03:51 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: 162238 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3108817jan; Mon, 15 Apr 2019 09:08:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1gBeYEZS3kUD2T+V3xynDPqg/ThjCksODvrBT7KynMnkgaS2lwsCDidc6IYGyMXMEE1II X-Received: by 2002:a63:6844:: with SMTP id d65mr72102993pgc.393.1555344534987; Mon, 15 Apr 2019 09:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344534; cv=none; d=google.com; s=arc-20160816; b=MqtgSXI4Dxcy9IwT2QCPwVVxYhBMwsvbJzESNfIvpPPdkmr0/49mv4KdG5G44KjKah Qo4l7gbIidasHee8yQSqrWr8XdAgd1lfd6daFks0kxSZKui4CdhHrUJYr0E2/96sTLcc 6WmgaDRboBkHLRdL7/OiWPBAdEbWt22fKcKt9JnmuiPo8ZV8/5DMy2OnsLFHDY2r6Uis acxg9DgsvQjMJPnZKWha81+pK7rO0fGSpVft0MoLXAF77DeCSKZYzeykW7nwoWu6Ishe /x75O6asidxNTLjwZxgaAVrL6VHuZZ4cuqNxdR8wRtxxqJsDPOeJVAPVwBAnvacw9nla CKsA== 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=UgUi1mPph4Ok1iMDgU62tjs5msg68QHqxvPJb39EY1U=; b=jTPO9AV5BtCMbTpdesdNsxhTZHO0HsIa9U6vXeyyhsJK4/QCS7HwfxHljdbQPzUMua C7bbx2gs6pt8+k8gy5ITtIHuny/9N8KBo4utS2l1QHKTrP+Oc9+x5hmB8l0o1g6lUUsQ GtS9U9x4EGu63u84r4Lv5HQwpjQV8PoM1/yPOh2+XfGA6kz9h+6yxurjh8ygNMQyTc7z pAnPaHU7QIWeXwVekErsRfE7EUhLHfH5kGedhRzK6kuANXTipuvDVhyAB3DD9038Dz71 d7XTSGhz44IOlQXAXTLAb/fHwZW0jTyW8LIJ3sMZsTA1hUSADBgpk4mYhI5IGd4aTaAu S2uQ== 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 v12si38928910pga.148.2019.04.15.09.08.54; Mon, 15 Apr 2019 09:08:54 -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 S1727758AbfDOQIx (ORCPT + 30 others); Mon, 15 Apr 2019 12:08:53 -0400 Received: from foss.arm.com ([217.140.101.70]:37746 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbfDOQF7 (ORCPT ); Mon, 15 Apr 2019 12:05:59 -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 DDD62A78; Mon, 15 Apr 2019 09:05:58 -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 3F79A3F68F; Mon, 15 Apr 2019 09:05:57 -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 08/36] coresight: tmc: Clean up device specific data Date: Mon, 15 Apr 2019 17:03:51 +0100 Message-Id: <1555344260-12375-9-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 In preparation to use a consistent device naming scheme, clean up the device link tracking in replicator driver. Use the "coresight" device instead of the "real" parent device for all internal purposes. All other requests (e.g, power management, DMA operations) must use the "real" device which is the parent device. Since the CATU driver also uses the TMC-SG infrastructure, update the callers to ensure they pass the appropriate device argument for the tables. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-catu.c | 5 ++-- drivers/hwtracing/coresight/coresight-tmc-etf.c | 9 +++--- drivers/hwtracing/coresight/coresight-tmc-etr.c | 40 ++++++++++++++----------- drivers/hwtracing/coresight/coresight-tmc.c | 38 +++++++++++------------ drivers/hwtracing/coresight/coresight-tmc.h | 1 - 5 files changed, 47 insertions(+), 46 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index f2a6a8d..ba3c005 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -328,19 +328,18 @@ static int catu_alloc_etr_buf(struct tmc_drvdata *tmc_drvdata, struct etr_buf *etr_buf, int node, void **pages) { struct coresight_device *csdev; - struct device *catu_dev; struct tmc_sg_table *catu_table; struct catu_etr_buf *catu_buf; csdev = tmc_etr_get_catu_device(tmc_drvdata); if (!csdev) return -ENODEV; - catu_dev = csdev->dev.parent; catu_buf = kzalloc(sizeof(*catu_buf), GFP_KERNEL); if (!catu_buf) return -ENOMEM; - catu_table = catu_init_sg_table(catu_dev, node, etr_buf->size, pages); + catu_table = catu_init_sg_table(&csdev->dev, node, + etr_buf->size, pages); if (IS_ERR(catu_table)) { kfree(catu_buf); return PTR_ERR(catu_table); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index a5f053f..6f60606 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -251,7 +251,6 @@ static int tmc_enable_etf_sink(struct coresight_device *csdev, u32 mode, void *data) { int ret; - struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); switch (mode) { case CS_MODE_SYSFS: @@ -269,7 +268,7 @@ static int tmc_enable_etf_sink(struct coresight_device *csdev, if (ret) return ret; - dev_dbg(drvdata->dev, "TMC-ETB/ETF enabled\n"); + dev_dbg(&csdev->dev, "TMC-ETB/ETF enabled\n"); return 0; } @@ -292,7 +291,7 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev) spin_unlock_irqrestore(&drvdata->spinlock, flags); - dev_dbg(drvdata->dev, "TMC-ETB/ETF disabled\n"); + dev_dbg(&csdev->dev, "TMC-ETB/ETF disabled\n"); } static int tmc_enable_etf_link(struct coresight_device *csdev, @@ -314,7 +313,7 @@ static int tmc_enable_etf_link(struct coresight_device *csdev, spin_unlock_irqrestore(&drvdata->spinlock, flags); if (!ret) - dev_dbg(drvdata->dev, "TMC-ETF enabled\n"); + dev_dbg(&csdev->dev, "TMC-ETF enabled\n"); return ret; } @@ -334,7 +333,7 @@ static void tmc_disable_etf_link(struct coresight_device *csdev, drvdata->mode = CS_MODE_DISABLED; spin_unlock_irqrestore(&drvdata->spinlock, flags); - dev_dbg(drvdata->dev, "TMC-ETF disabled\n"); + dev_dbg(&csdev->dev, "TMC-ETF disabled\n"); } static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, int cpu, diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index f684283..0911f9c 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -153,10 +153,11 @@ static void tmc_pages_free(struct tmc_pages *tmc_pages, struct device *dev, enum dma_data_direction dir) { int i; + struct device *real_dev = dev->parent; for (i = 0; i < tmc_pages->nr_pages; i++) { if (tmc_pages->daddrs && tmc_pages->daddrs[i]) - dma_unmap_page(dev, tmc_pages->daddrs[i], + dma_unmap_page(real_dev, tmc_pages->daddrs[i], PAGE_SIZE, dir); if (tmc_pages->pages && tmc_pages->pages[i]) __free_page(tmc_pages->pages[i]); @@ -184,6 +185,7 @@ static int tmc_pages_alloc(struct tmc_pages *tmc_pages, int i, nr_pages; dma_addr_t paddr; struct page *page; + struct device *real_dev = dev->parent; nr_pages = tmc_pages->nr_pages; tmc_pages->daddrs = kcalloc(nr_pages, sizeof(*tmc_pages->daddrs), @@ -207,8 +209,8 @@ static int tmc_pages_alloc(struct tmc_pages *tmc_pages, page = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0); } - paddr = dma_map_page(dev, page, 0, PAGE_SIZE, dir); - if (dma_mapping_error(dev, paddr)) + paddr = dma_map_page(real_dev, page, 0, PAGE_SIZE, dir); + if (dma_mapping_error(real_dev, paddr)) goto err; tmc_pages->daddrs[i] = paddr; tmc_pages->pages[i] = page; @@ -295,7 +297,7 @@ static int tmc_alloc_data_pages(struct tmc_sg_table *sg_table, void **pages) * and data buffers. TMC writes to the data buffers and reads from the SG * Table pages. * - * @dev - Device to which page should be DMA mapped. + * @dev - Coresight device to which page should be DMA mapped. * @node - Numa node for mem allocations * @nr_tpages - Number of pages for the table entries. * @nr_dpages - Number of pages for Data buffer. @@ -339,13 +341,13 @@ void tmc_sg_table_sync_data_range(struct tmc_sg_table *table, { int i, index, start; int npages = DIV_ROUND_UP(size, PAGE_SIZE); - struct device *dev = table->dev; + struct device *real_dev = table->dev->parent; struct tmc_pages *data = &table->data_pages; start = offset >> PAGE_SHIFT; for (i = start; i < (start + npages); i++) { index = i % data->nr_pages; - dma_sync_single_for_cpu(dev, data->daddrs[index], + dma_sync_single_for_cpu(real_dev, data->daddrs[index], PAGE_SIZE, DMA_FROM_DEVICE); } } @@ -354,11 +356,11 @@ void tmc_sg_table_sync_data_range(struct tmc_sg_table *table, void tmc_sg_table_sync_table(struct tmc_sg_table *sg_table) { int i; - struct device *dev = sg_table->dev; + struct device *real_dev = sg_table->dev->parent; struct tmc_pages *table_pages = &sg_table->table_pages; for (i = 0; i < table_pages->nr_pages; i++) - dma_sync_single_for_device(dev, table_pages->daddrs[i], + dma_sync_single_for_device(real_dev, table_pages->daddrs[i], PAGE_SIZE, DMA_TO_DEVICE); } @@ -581,6 +583,7 @@ static int tmc_etr_alloc_flat_buf(struct tmc_drvdata *drvdata, void **pages) { struct etr_flat_buf *flat_buf; + struct device *real_dev = drvdata->csdev->dev.parent; /* We cannot reuse existing pages for flat buf */ if (pages) @@ -590,7 +593,7 @@ static int tmc_etr_alloc_flat_buf(struct tmc_drvdata *drvdata, if (!flat_buf) return -ENOMEM; - flat_buf->vaddr = dma_alloc_coherent(drvdata->dev, etr_buf->size, + flat_buf->vaddr = dma_alloc_coherent(real_dev, etr_buf->size, &flat_buf->daddr, GFP_KERNEL); if (!flat_buf->vaddr) { kfree(flat_buf); @@ -598,7 +601,7 @@ static int tmc_etr_alloc_flat_buf(struct tmc_drvdata *drvdata, } flat_buf->size = etr_buf->size; - flat_buf->dev = drvdata->dev; + flat_buf->dev = &drvdata->csdev->dev; etr_buf->hwaddr = flat_buf->daddr; etr_buf->mode = ETR_MODE_FLAT; etr_buf->private = flat_buf; @@ -608,9 +611,10 @@ static int tmc_etr_alloc_flat_buf(struct tmc_drvdata *drvdata, static void tmc_etr_free_flat_buf(struct etr_buf *etr_buf) { struct etr_flat_buf *flat_buf = etr_buf->private; + struct device *real_dev = flat_buf->dev->parent; if (flat_buf && flat_buf->daddr) - dma_free_coherent(flat_buf->dev, flat_buf->size, + dma_free_coherent(real_dev, flat_buf->size, flat_buf->vaddr, flat_buf->daddr); kfree(flat_buf); } @@ -657,8 +661,9 @@ static int tmc_etr_alloc_sg_buf(struct tmc_drvdata *drvdata, void **pages) { struct etr_sg_table *etr_table; + struct device *dev = &drvdata->csdev->dev; - etr_table = tmc_init_etr_sg_table(drvdata->dev, node, + etr_table = tmc_init_etr_sg_table(dev, node, etr_buf->size, pages); if (IS_ERR(etr_table)) return -ENOMEM; @@ -813,9 +818,10 @@ static struct etr_buf *tmc_alloc_etr_buf(struct tmc_drvdata *drvdata, bool has_etr_sg, has_iommu; bool has_sg, has_catu; struct etr_buf *etr_buf; + struct device *dev = &drvdata->csdev->dev; has_etr_sg = tmc_etr_has_cap(drvdata, TMC_ETR_SG); - has_iommu = iommu_get_domain_for_dev(drvdata->dev); + has_iommu = iommu_get_domain_for_dev(dev->parent); has_catu = !!tmc_etr_get_catu_device(drvdata); has_sg = has_catu || has_etr_sg; @@ -853,7 +859,7 @@ static struct etr_buf *tmc_alloc_etr_buf(struct tmc_drvdata *drvdata, return ERR_PTR(rc); } - dev_dbg(drvdata->dev, "allocated buffer of size %ldKB in mode %d\n", + dev_dbg(dev, "allocated buffer of size %ldKB in mode %d\n", (unsigned long)size >> 10, etr_buf->mode); return etr_buf; } @@ -1148,7 +1154,7 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev) tmc_etr_free_sysfs_buf(free_buf); if (!ret) - dev_dbg(drvdata->dev, "TMC-ETR enabled\n"); + dev_dbg(&csdev->dev, "TMC-ETR enabled\n"); return ret; } @@ -1217,7 +1223,7 @@ static void *tmc_alloc_etr_buffer(struct coresight_device *csdev, etr_perf = tmc_etr_setup_perf_buf(drvdata, cpu_to_node(cpu), nr_pages, pages, snapshot); if (IS_ERR(etr_perf)) { - dev_dbg(drvdata->dev, "Unable to allocate ETR buffer\n"); + dev_dbg(&csdev->dev, "Unable to allocate ETR buffer\n"); return NULL; } @@ -1411,7 +1417,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev) spin_unlock_irqrestore(&drvdata->spinlock, flags); - dev_dbg(drvdata->dev, "TMC-ETR disabled\n"); + dev_dbg(&csdev->dev, "TMC-ETR disabled\n"); } static const struct coresight_ops_sink tmc_etr_sink_ops = { diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index c6a5462..819873a 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -30,7 +30,7 @@ void tmc_wait_for_tmcready(struct tmc_drvdata *drvdata) /* Ensure formatter, unformatter and hardware fifo are empty */ if (coresight_timeout(drvdata->base, TMC_STS, TMC_STS_TMCREADY_BIT, 1)) { - dev_err(drvdata->dev, + dev_err(&drvdata->csdev->dev, "timeout while waiting for TMC to be Ready\n"); } } @@ -47,7 +47,7 @@ void tmc_flush_and_stop(struct tmc_drvdata *drvdata) /* Ensure flush completes */ if (coresight_timeout(drvdata->base, TMC_FFCR, TMC_FFCR_FLUSHMAN_BIT, 0)) { - dev_err(drvdata->dev, + dev_err(&drvdata->csdev->dev, "timeout while waiting for completion of Manual Flush\n"); } @@ -81,7 +81,7 @@ static int tmc_read_prepare(struct tmc_drvdata *drvdata) } if (!ret) - dev_dbg(drvdata->dev, "TMC read start\n"); + dev_dbg(&drvdata->csdev->dev, "TMC read start\n"); return ret; } @@ -103,7 +103,7 @@ static int tmc_read_unprepare(struct tmc_drvdata *drvdata) } if (!ret) - dev_dbg(drvdata->dev, "TMC read end\n"); + dev_dbg(&drvdata->csdev->dev, "TMC read end\n"); return ret; } @@ -120,7 +120,7 @@ static int tmc_open(struct inode *inode, struct file *file) nonseekable_open(inode, file); - dev_dbg(drvdata->dev, "%s: successfully opened\n", __func__); + dev_dbg(&drvdata->csdev->dev, "%s: successfully opened\n", __func__); return 0; } @@ -150,12 +150,13 @@ static ssize_t tmc_read(struct file *file, char __user *data, size_t len, return 0; if (copy_to_user(data, bufp, actual)) { - dev_dbg(drvdata->dev, "%s: copy_to_user failed\n", __func__); + dev_dbg(&drvdata->csdev->dev, + "%s: copy_to_user failed\n", __func__); return -EFAULT; } *ppos += actual; - dev_dbg(drvdata->dev, "%zu bytes copied\n", actual); + dev_dbg(&drvdata->csdev->dev, "%zu bytes copied\n", actual); return actual; } @@ -170,7 +171,7 @@ static int tmc_release(struct inode *inode, struct file *file) if (ret) return ret; - dev_dbg(drvdata->dev, "%s: released\n", __func__); + dev_dbg(&drvdata->csdev->dev, "%s: released\n", __func__); return 0; } @@ -330,24 +331,22 @@ const struct attribute_group *coresight_tmc_groups[] = { NULL, }; -static inline bool tmc_etr_can_use_sg(struct tmc_drvdata *drvdata) +static inline bool tmc_etr_can_use_sg(struct device *dev) { - return fwnode_property_present(drvdata->dev->fwnode, - "arm,scatter-gather"); + return fwnode_property_present(dev->fwnode, "arm,scatter-gather"); } /* Detect and initialise the capabilities of a TMC ETR */ -static int tmc_etr_setup_caps(struct tmc_drvdata *drvdata, - u32 devid, void *dev_caps) +static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps) { int rc; - u32 dma_mask = 0; + struct tmc_drvdata *drvdata = dev_get_drvdata(parent); /* Set the unadvertised capabilities */ tmc_etr_init_caps(drvdata, (u32)(unsigned long)dev_caps); - if (!(devid & TMC_DEVID_NOSCAT) && tmc_etr_can_use_sg(drvdata)) + if (!(devid & TMC_DEVID_NOSCAT) && tmc_etr_can_use_sg(parent)) tmc_etr_set_cap(drvdata, TMC_ETR_SG); /* Check if the AXI address width is available */ @@ -365,15 +364,15 @@ static int tmc_etr_setup_caps(struct tmc_drvdata *drvdata, case 44: case 48: case 52: - dev_info(drvdata->dev, "Detected dma mask %dbits\n", dma_mask); + dev_info(parent, "Detected dma mask %dbits\n", dma_mask); break; default: dma_mask = 40; } - rc = dma_set_mask_and_coherent(drvdata->dev, DMA_BIT_MASK(dma_mask)); + rc = dma_set_mask_and_coherent(parent, DMA_BIT_MASK(dma_mask)); if (rc) - dev_err(drvdata->dev, "Failed to setup DMA mask: %d\n", rc); + dev_err(parent, "Failed to setup DMA mask: %d\n", rc); return rc; } @@ -403,7 +402,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) goto out; - drvdata->dev = &adev->dev; dev_set_drvdata(dev, drvdata); /* Validity for the resource is already checked by the AMBA core */ @@ -446,7 +444,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) desc.type = CORESIGHT_DEV_TYPE_SINK; desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; desc.ops = &tmc_etr_cs_ops; - ret = tmc_etr_setup_caps(drvdata, devid, + ret = tmc_etr_setup_caps(dev, devid, coresight_get_uci_data(id)); if (ret) goto out; diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h index 487c537..3eeadcf 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -175,7 +175,6 @@ struct etr_buf { */ struct tmc_drvdata { void __iomem *base; - struct device *dev; struct coresight_device *csdev; struct miscdevice miscdev; spinlock_t spinlock; From patchwork Mon Apr 15 16:03:52 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: 162235 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3108574jan; Mon, 15 Apr 2019 09:08:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpkoKvSYtaHGJUKsolDHXOKV8VZYNJwcAstu2p/+knCs5MvHWEC6q2B64t06rKzPyxCMP1 X-Received: by 2002:a63:54b:: with SMTP id 72mr68262707pgf.323.1555344524699; Mon, 15 Apr 2019 09:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344524; cv=none; d=google.com; s=arc-20160816; b=mDPNU0ARh8Y7VIMyYbs5tnrbrMFo0SuWGof1kGAYmM/EUOdbQSaTRlWZj4gWjgjSkt TsiDeJypyd8AuizgdF2VfOIkTNF8x5pPPfJH20NYKEbinM3EY8NF8PkUQhOFWd6ZkEMl 5Ti0vxnKPasH4Ir/hKVIl8L0RhPlNn0WyqJyR2Y+0P7MvJunQM5lWux2K5qzehKt7hNM 9VgPHQyybLeN8hl1l/rwEgfHAyPfLPCoIka4p8ISR6h2QJ4kLm9X1r0fY2q/2wlErmEl CuBZKewHtNzo33JaHFF8ZK4b0NX6Mplmb/kqRXvUf3gIDv7LliKok3iAsI/PyEBAdOK5 pVlA== 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=z/PymDYVDiM9wVro/S63hhRt8/VwXeUWOIpIvobKO/s=; b=RZ9U0GqCM3SMz0VO6NCbnKbT2VYZvx6E6uswGl+iJUDXAkNdVcmM3Odnr9nkgq0+LL +63Obx7ZNJkERuQXc+Hk1JOUtpTAfgTk5UlFBc8s3Zt8wcLegKRb5ETBFCxbYZxEiAmk Km5CIatzjfmnA4XMPKeWD+1l2SmMa4PGov/bXDobF9d6BSgvE9DqPYhSsSRHSLKtVzlA tt7NMIg70sGH5DzuSPeExFGzziswrCulh3dEwc8DSlDSov82greWBNKkgzYruir1Jy4X GKwmofa1M/q3cKJxo90B3jV8MULJIQHrUbBjwAs/buZxqc8q9pytO2LbsEh9udYE9WFp qmCQ== 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 e15si34002643pfj.60.2019.04.15.09.08.44; Mon, 15 Apr 2019 09:08:44 -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 S1727919AbfDOQGD (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:03 -0400 Received: from foss.arm.com ([217.140.101.70]:37756 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727895AbfDOQGA (ORCPT ); Mon, 15 Apr 2019 12:06:00 -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 A178480D; Mon, 15 Apr 2019 09:06:00 -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 264493F68F; Mon, 15 Apr 2019 09:05:59 -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 09/36] coresight: catu: Cleanup device specific data Date: Mon, 15 Apr 2019 17:03:52 +0100 Message-Id: <1555344260-12375-10-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 Switch to using the CoreSight device instead of the real amba device. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-catu.c | 13 +++++++------ drivers/hwtracing/coresight/coresight-catu.h | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index ba3c005..14d1cf5 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -408,13 +408,14 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, void *data) int rc; u32 control, mode; struct etr_buf *etr_buf = data; + struct device *dev = &drvdata->csdev->dev; if (catu_wait_for_ready(drvdata)) - dev_warn(drvdata->dev, "Timeout while waiting for READY\n"); + dev_warn(dev, "Timeout while waiting for READY\n"); control = catu_read_control(drvdata); if (control & BIT(CATU_CONTROL_ENABLE)) { - dev_warn(drvdata->dev, "CATU is already enabled\n"); + dev_warn(dev, "CATU is already enabled\n"); return -EBUSY; } @@ -440,7 +441,7 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, void *data) catu_write_irqen(drvdata, 0); catu_write_mode(drvdata, mode); catu_write_control(drvdata, control); - dev_dbg(drvdata->dev, "Enabled in %s mode\n", + dev_dbg(dev, "Enabled in %s mode\n", (mode == CATU_MODE_PASS_THROUGH) ? "Pass through" : "Translate"); @@ -461,15 +462,16 @@ static int catu_enable(struct coresight_device *csdev, void *data) static int catu_disable_hw(struct catu_drvdata *drvdata) { int rc = 0; + struct device *dev = &drvdata->csdev->dev; catu_write_control(drvdata, 0); coresight_disclaim_device_unlocked(drvdata->base); if (catu_wait_for_ready(drvdata)) { - dev_info(drvdata->dev, "Timeout while waiting for READY\n"); + dev_info(dev, "Timeout while waiting for READY\n"); rc = -EAGAIN; } - dev_dbg(drvdata->dev, "Disabled\n"); + dev_dbg(dev, "Disabled\n"); return rc; } @@ -519,7 +521,6 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) goto out; } - drvdata->dev = dev; dev_set_drvdata(dev, drvdata); base = devm_ioremap_resource(dev, &adev->res); if (IS_ERR(base)) { diff --git a/drivers/hwtracing/coresight/coresight-catu.h b/drivers/hwtracing/coresight/coresight-catu.h index 1b281f0..96ea8c4 100644 --- a/drivers/hwtracing/coresight/coresight-catu.h +++ b/drivers/hwtracing/coresight/coresight-catu.h @@ -61,7 +61,6 @@ #define CATU_IRQEN_OFF 0x0 struct catu_drvdata { - struct device *dev; void __iomem *base; struct coresight_device *csdev; int irq; From patchwork Mon Apr 15 16:03:53 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: 162207 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105162jan; Mon, 15 Apr 2019 09:06:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVWSbA2SBc3AVBb3ufvBfEioX6AlCueyk2dry++zVytDjw8dbqw+HxIq8svCyO92OqDth8 X-Received: by 2002:a17:902:9b83:: with SMTP id y3mr73920954plp.165.1555344367507; Mon, 15 Apr 2019 09:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344367; cv=none; d=google.com; s=arc-20160816; b=qssJg68cleA9eQYR35SQnfT6byKzFiTdjOpUD/lIdIkpRJKp2s4Ukz2WpYfTu4LjCN 00fFAmbZjgku2hQxBUNHfpb3xfAX6pchwE1GfUG6l/3wxsSk6e/IN/MHOW1DoQgsP93V 2/Z8Sctm/BMsr4KUozWieCjBODE9pocrORF8NEnl/b+0ldnCXVVN2ztPDt8amm4w+udm gBnQ+NY/p8+3rI3lkyH4stNzfu8MHxp8Gas34z7js68nRdxdf9tfEKxzl6UEZ8gKDV/U 3orAeTLIt7oIiyU6jZ8p/F4lzdBUAgUfsbz+Xb1lZ9rZyiVoQSASRsnFH2V8ykDrJ2F6 sz6w== 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=WCaZTInCYANfs63po4GhktVqzOqU0nwfj55Sk+RxslA=; b=coxUfzNtM2re8dub7hluQillj9WClTa+CPWvRyEwD5DtiZBek4UJdCHL2X73CJ1bnq 1Cu3xtOOFIO98ZWUXiN3sNAczD0WakQ8wuQ5Lfv9lkejRdbs5vEEIOlsSxm9DwuJURzD qs3aqOqYjqZhO8xPutvUUomfgJbD5iznOpEacp0NCeL8+2BXElnX6VIZXJYkWFl3fnuW ZSUxZdYu3KHPgfKeg00zQZmQnZlzjkO93bIUtUlulSBFgf4v2QSQ53Njb6EqVXYpq6n4 duvgXioLiATu+ZhWb1q4VdxaGVo3cXQcHBNg2xaBE/9biOgrqtNWnNRWwP2VmcAOgntn 87Dg== 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 f2si22018404pgc.182.2019.04.15.09.06.06; Mon, 15 Apr 2019 09:06:07 -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 S1727934AbfDOQGF (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37764 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727904AbfDOQGC (ORCPT ); Mon, 15 Apr 2019 12:06:02 -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 682F91684; Mon, 15 Apr 2019 09:06:02 -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 DE2A33F68F; Mon, 15 Apr 2019 09:06:00 -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 10/36] coresight: tpiu: Clean up device specific data Date: Mon, 15 Apr 2019 17:03:53 +0100 Message-Id: <1555344260-12375-11-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 Switch to using the coresight device instead of the parent amba device. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tpiu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 4977467..96af7d5 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -54,7 +54,6 @@ */ struct tpiu_drvdata { void __iomem *base; - struct device *dev; struct clk *atclk; struct coresight_device *csdev; }; @@ -74,7 +73,7 @@ static int tpiu_enable(struct coresight_device *csdev, u32 mode, void *__unused) tpiu_enable_hw(drvdata); - dev_dbg(drvdata->dev, "TPIU enabled\n"); + dev_dbg(&csdev->dev, "TPIU enabled\n"); return 0; } @@ -100,7 +99,7 @@ static void tpiu_disable(struct coresight_device *csdev) tpiu_disable_hw(drvdata); - dev_dbg(drvdata->dev, "TPIU disabled\n"); + dev_dbg(&csdev->dev, "TPIU disabled\n"); } static const struct coresight_ops_sink tpiu_sink_ops = { @@ -134,7 +133,6 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) return -ENOMEM; - drvdata->dev = &adev->dev; drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); From patchwork Mon Apr 15 16:03:54 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: 162233 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3108370jan; Mon, 15 Apr 2019 09:08:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQr72ep/SXnishZ+ngzuYS2wGF+He6zSNt3VbFZ3bUElxlzEJJ9+YXu6ruggeSjF/9ffNq X-Received: by 2002:a63:360c:: with SMTP id d12mr67397157pga.404.1555344514747; Mon, 15 Apr 2019 09:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344514; cv=none; d=google.com; s=arc-20160816; b=oozv/EZSKWcXn8GEv7twIXxLbplywDrWxHySk6Vct3cCzIqWePykzLoy/xOB236Xxv wQAM7YlCe2otLKBQ6Venv4FG59iPY1q+SZmS6tu7hbqB8cqgX4yKg8hTebIFbenPDF9o R1H+PCihwvDe+hPXY8HyLDsu1KpyoQg9aEpQWLXHBFqOKYQ8CMghLBzg9YBXAwKKNsrH u9NITzDGhU7VJ6aMNWZMs1ohWAhvdpg9EZiNpejJNAdLzm0pSgAdWiO7IH8RvgNJUPGN eMfrGgsJNgmrhGgYtgvxnpnf5wHRb5bvFEzb7swlly4oBig3GAKIg3wAjQNFwIhnQbKT Dwhg== 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=iit1QsS2QyaN2cYAFGQQ64CnBlwy1tZL9YcLWBjvXok=; b=b74UEgZfLBcv0/EEyqIapTaKR/uMl6ctHLDMV7sxnEnHChWHvi5cWwSEhbMX/z7rKK X+UDuRFEPOZMuUjI3HDKyzvhAiHnMaDKbO6wQUNr5uLxOg1GeKQJCDJ3EGM2xGCJ6Wto 9V/GbSmFTvriWo1D7nxIVCcpf2/lUfk/XO2qYhnIQtVq9jiXIT53is0XO24LzJZaX6w5 BQNUrygU/9QSI9sgx6Wo9VlsBwi/6FCXGGkIs9zBCS8M6KbNtvXCAqVgwb/hpUQvv9UK W6f4iG9HbtQ5gDAjLe87Jd3nSTdPviofhzSOnDivIPOksOGBL3XG1XOvMRkc7UPX09cW Xkww== 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 d2si42993352pgq.129.2019.04.15.09.08.34; Mon, 15 Apr 2019 09:08:34 -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 S1727946AbfDOQGJ (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:09 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37782 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727924AbfDOQGE (ORCPT ); Mon, 15 Apr 2019 12:06:04 -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 2A5C71688; Mon, 15 Apr 2019 09:06:04 -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 A50383F68F; Mon, 15 Apr 2019 09:06:02 -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 11/36] coresight: stm: Cleanup device specific data Date: Mon, 15 Apr 2019 17:03:54 +0100 Message-Id: <1555344260-12375-12-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 Keep track of the STM coresight device which is a child device of the AMBA device. Since we can get to the coresight_device from the "device" instance, remove the explicit field. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-stm.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 9f8a844..8f50484 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -110,7 +110,6 @@ struct channel_space { /** * struct stm_drvdata - specifics associated to an STM component * @base: memory mapped base address for this component. - * @dev: the device entity associated to this component. * @atclk: optional clock for the core parts of the STM. * @csdev: component vitals needed by the framework. * @spinlock: only one at a time pls. @@ -128,7 +127,6 @@ struct channel_space { */ struct stm_drvdata { void __iomem *base; - struct device *dev; struct clk *atclk; struct coresight_device *csdev; spinlock_t spinlock; @@ -205,13 +203,13 @@ static int stm_enable(struct coresight_device *csdev, if (val) return -EBUSY; - pm_runtime_get_sync(drvdata->dev); + pm_runtime_get_sync(csdev->dev.parent); spin_lock(&drvdata->spinlock); stm_enable_hw(drvdata); spin_unlock(&drvdata->spinlock); - dev_dbg(drvdata->dev, "STM tracing enabled\n"); + dev_dbg(&csdev->dev, "STM tracing enabled\n"); return 0; } @@ -271,10 +269,10 @@ static void stm_disable(struct coresight_device *csdev, /* Wait until the engine has completely stopped */ coresight_timeout(drvdata->base, STMTCSR, STMTCSR_BUSY_BIT, 0); - pm_runtime_put(drvdata->dev); + pm_runtime_put(csdev->dev.parent); local_set(&drvdata->mode, CS_MODE_DISABLED); - dev_dbg(drvdata->dev, "STM tracing disabled\n"); + dev_dbg(&csdev->dev, "STM tracing disabled\n"); } } @@ -763,9 +761,10 @@ static void stm_init_default_data(struct stm_drvdata *drvdata) bitmap_clear(drvdata->chs.guaranteed, 0, drvdata->numsp); } -static void stm_init_generic_data(struct stm_drvdata *drvdata) +static void stm_init_generic_data(struct stm_drvdata *drvdata, + const char *name) { - drvdata->stm.name = dev_name(drvdata->dev); + drvdata->stm.name = name; /* * MasterIDs are assigned at HW design phase. As such the core is @@ -807,7 +806,6 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) return -ENOMEM; - drvdata->dev = &adev->dev; drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); @@ -848,7 +846,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&drvdata->spinlock); stm_init_default_data(drvdata); - stm_init_generic_data(drvdata); + stm_init_generic_data(drvdata, dev_name(dev)); if (stm_register_device(dev, &drvdata->stm, THIS_MODULE)) { dev_info(dev, @@ -870,7 +868,8 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) pm_runtime_put(&adev->dev); - dev_info(dev, "%s initialized\n", (char *)coresight_get_uci_data(id)); + dev_info(&drvdata->csdev->dev, "%s initialized\n", + (char *)coresight_get_uci_data(id)); return 0; stm_unregister: From patchwork Mon Apr 15 16:03:55 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: 162234 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3108444jan; Mon, 15 Apr 2019 09:08:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRlEQVa/uoJ1P/Jb+8uNUVKBsK4f12dMT84+sgfleB0+u28VQquhVt8/P5HVxi4uEHANIm X-Received: by 2002:a17:902:407:: with SMTP id 7mr77438642ple.62.1555344519136; Mon, 15 Apr 2019 09:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344519; cv=none; d=google.com; s=arc-20160816; b=WQlsJw38iyS7jR1AcNmkVz3f6PFmfp7GQDgsYNZWCUVAX3IpFGvFs+Qqch3fw2ptaX HVFWX2gYi2U1Y1RzIZldRCX2sfor2VpszZdZPfO3OIycSxxJ6hA/abO9g7MfNuGF/IHp zLwdApZJooXL3t8xzgmvHTc96yb3kZZ8TsuiT6FugTfFvXm4DfNk0xtUcrZW134gYiD5 49AeMW/CENP0sFBCoki2S3g/nmUKWhza3NIs4zWoxXJNTtvh9rV+GnKSYM3PGULJUNvv iQYuTcNTxBJAY1svX0oQF1oOaVf5it6BCuOx39ogvZJD/bZTT0T7gB3EWtsUCvetCF6Y P9hw== 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=1mVJQYsQBHYALQSCbrXqltvVqzj2E2AkCD1WnPTc+c8=; b=L9DDlwUWIbnXtz8hMzelH+OfQGtsIamppPSwlRBFduYt276SGH9qSuhC4wq6FKjaLr uQqBphI0ZDXkFbTmlRJwOy+ERsrJS9bop/nWOCC0Eb2L3Rty3ijU0pUE3pefWBN++GQG 6ouOWo0KwYHf+GLHi0ksQnNU+lJR6rq5QdCi5EYtpFTJ+09Ga0JJiTuRhgp++DsrqgCw WWkj1be14iQQ9Zop55oi8TZ8+0+IpWLLG3LOgX4rCx9RVKAsYPsX/rhwn6xIwP3uf9XA prtw+mvghfgTQvg1BANOewkdShQpJ5RCrpoYvED3GII9HecUPoB1i+hMdjwJHtl5RJNY RULA== 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 e15si34002643pfj.60.2019.04.15.09.08.38; Mon, 15 Apr 2019 09:08:39 -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 S1728053AbfDOQIh (ORCPT + 30 others); Mon, 15 Apr 2019 12:08:37 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37798 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727904AbfDOQGG (ORCPT ); Mon, 15 Apr 2019 12:06:06 -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 E0815168F; Mon, 15 Apr 2019 09:06:05 -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 672CA3F721; Mon, 15 Apr 2019 09:06:04 -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 12/36] coresight: etm: Clean up device specific data Date: Mon, 15 Apr 2019 17:03:55 +0100 Message-Id: <1555344260-12375-13-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 Track the coresight device instead of the real device. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm.h | 6 ++---- .../hwtracing/coresight/coresight-etm3x-sysfs.c | 12 ++++++------ drivers/hwtracing/coresight/coresight-etm3x.c | 22 ++++++++++++---------- drivers/hwtracing/coresight/coresight-etm4x.c | 17 +++++++++-------- drivers/hwtracing/coresight/coresight-etm4x.h | 2 -- 5 files changed, 29 insertions(+), 30 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm.h b/drivers/hwtracing/coresight/coresight-etm.h index 79e1ad8..f3ab96e 100644 --- a/drivers/hwtracing/coresight/coresight-etm.h +++ b/drivers/hwtracing/coresight/coresight-etm.h @@ -208,7 +208,6 @@ struct etm_config { /** * struct etm_drvdata - specifics associated to an ETM component * @base: memory mapped base address for this component. - * @dev: the device entity associated to this component. * @atclk: optional clock for the core parts of the ETM. * @csdev: component vitals needed by the framework. * @spinlock: only one at a time pls. @@ -232,7 +231,6 @@ struct etm_config { */ struct etm_drvdata { void __iomem *base; - struct device *dev; struct clk *atclk; struct coresight_device *csdev; spinlock_t spinlock; @@ -260,7 +258,7 @@ static inline void etm_writel(struct etm_drvdata *drvdata, { if (drvdata->use_cp14) { if (etm_writel_cp14(off, val)) { - dev_err(drvdata->dev, + dev_err(&drvdata->csdev->dev, "invalid CP14 access to ETM reg: %#x", off); } } else { @@ -274,7 +272,7 @@ static inline unsigned int etm_readl(struct etm_drvdata *drvdata, u32 off) if (drvdata->use_cp14) { if (etm_readl_cp14(off, &val)) { - dev_err(drvdata->dev, + dev_err(&drvdata->csdev->dev, "invalid CP14 access to ETM reg: %#x", off); } } else { diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c index 75487b3..e8c7649 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c @@ -48,7 +48,7 @@ static ssize_t etmsr_show(struct device *dev, unsigned long flags, val; struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); - pm_runtime_get_sync(drvdata->dev); + pm_runtime_get_sync(dev->parent); spin_lock_irqsave(&drvdata->spinlock, flags); CS_UNLOCK(drvdata->base); @@ -56,7 +56,7 @@ static ssize_t etmsr_show(struct device *dev, CS_LOCK(drvdata->base); spin_unlock_irqrestore(&drvdata->spinlock, flags); - pm_runtime_put(drvdata->dev); + pm_runtime_put(dev->parent); return sprintf(buf, "%#lx\n", val); } @@ -131,7 +131,7 @@ static ssize_t mode_store(struct device *dev, if (config->mode & ETM_MODE_STALL) { if (!(drvdata->etmccr & ETMCCR_FIFOFULL)) { - dev_warn(drvdata->dev, "stall mode not supported\n"); + dev_warn(dev, "stall mode not supported\n"); ret = -EINVAL; goto err_unlock; } @@ -141,7 +141,7 @@ static ssize_t mode_store(struct device *dev, if (config->mode & ETM_MODE_TIMESTAMP) { if (!(drvdata->etmccer & ETMCCER_TIMESTAMP)) { - dev_warn(drvdata->dev, "timestamp not supported\n"); + dev_warn(dev, "timestamp not supported\n"); ret = -EINVAL; goto err_unlock; } @@ -945,7 +945,7 @@ static ssize_t seq_curr_state_show(struct device *dev, goto out; } - pm_runtime_get_sync(drvdata->dev); + pm_runtime_get_sync(dev->parent); spin_lock_irqsave(&drvdata->spinlock, flags); CS_UNLOCK(drvdata->base); @@ -953,7 +953,7 @@ static ssize_t seq_curr_state_show(struct device *dev, CS_LOCK(drvdata->base); spin_unlock_irqrestore(&drvdata->spinlock, flags); - pm_runtime_put(drvdata->dev); + pm_runtime_put(dev->parent); out: return sprintf(buf, "%#lx\n", val); } diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index be302ec..9c92491 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -165,7 +165,7 @@ static void etm_set_prog(struct etm_drvdata *drvdata) */ isb(); if (coresight_timeout_etm(drvdata, ETMSR, ETMSR_PROG_BIT, 1)) { - dev_err(drvdata->dev, + dev_err(&drvdata->csdev->dev, "%s: timeout observed when probing at offset %#x\n", __func__, ETMSR); } @@ -184,7 +184,7 @@ static void etm_clr_prog(struct etm_drvdata *drvdata) */ isb(); if (coresight_timeout_etm(drvdata, ETMSR, ETMSR_PROG_BIT, 0)) { - dev_err(drvdata->dev, + dev_err(&drvdata->csdev->dev, "%s: timeout observed when probing at offset %#x\n", __func__, ETMSR); } @@ -425,7 +425,7 @@ static int etm_enable_hw(struct etm_drvdata *drvdata) done: CS_LOCK(drvdata->base); - dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n", + dev_dbg(&drvdata->csdev->dev, "cpu: %d enable smp call done: %d\n", drvdata->cpu, rc); return rc; } @@ -455,6 +455,7 @@ int etm_get_trace_id(struct etm_drvdata *drvdata) { unsigned long flags; int trace_id = -1; + struct device *etm_dev = drvdata->csdev->dev.parent; if (!drvdata) goto out; @@ -462,7 +463,7 @@ int etm_get_trace_id(struct etm_drvdata *drvdata) if (!local_read(&drvdata->mode)) return drvdata->traceid; - pm_runtime_get_sync(drvdata->dev); + pm_runtime_get_sync(etm_dev); spin_lock_irqsave(&drvdata->spinlock, flags); @@ -471,7 +472,7 @@ int etm_get_trace_id(struct etm_drvdata *drvdata) CS_LOCK(drvdata->base); spin_unlock_irqrestore(&drvdata->spinlock, flags); - pm_runtime_put(drvdata->dev); + pm_runtime_put(etm_dev); out: return trace_id; @@ -526,7 +527,7 @@ static int etm_enable_sysfs(struct coresight_device *csdev) spin_unlock(&drvdata->spinlock); if (!ret) - dev_dbg(drvdata->dev, "ETM tracing enabled\n"); + dev_dbg(&csdev->dev, "ETM tracing enabled\n"); return ret; } @@ -581,7 +582,8 @@ static void etm_disable_hw(void *info) CS_LOCK(drvdata->base); - dev_dbg(drvdata->dev, "cpu: %d disable smp call done\n", drvdata->cpu); + dev_dbg(&drvdata->csdev->dev, + "cpu: %d disable smp call done\n", drvdata->cpu); } static void etm_disable_perf(struct coresight_device *csdev) @@ -628,7 +630,7 @@ static void etm_disable_sysfs(struct coresight_device *csdev) spin_unlock(&drvdata->spinlock); cpus_read_unlock(); - dev_dbg(drvdata->dev, "ETM tracing disabled\n"); + dev_dbg(&csdev->dev, "ETM tracing disabled\n"); } static void etm_disable(struct coresight_device *csdev, @@ -803,7 +805,6 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) drvdata->use_cp14 = of_property_read_bool(np, "arm,cp14"); } - drvdata->dev = &adev->dev; dev_set_drvdata(dev, drvdata); /* Validity for the resource is already checked by the AMBA core */ @@ -871,7 +872,8 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) } pm_runtime_put(&adev->dev); - dev_info(dev, "%s initialized\n", (char *)coresight_get_uci_data(id)); + dev_info(&drvdata->csdev->dev, + "%s initialized\n", (char *)coresight_get_uci_data(id)); if (boot_enable) { coresight_enable(drvdata->csdev); drvdata->boot_enable = true; diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 08ce37c..75b923f 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -88,6 +88,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) { int i, rc; struct etmv4_config *config = &drvdata->config; + struct device *etm_dev = &drvdata->csdev->dev; CS_UNLOCK(drvdata->base); @@ -102,7 +103,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) /* wait for TRCSTATR.IDLE to go up */ if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 1)) - dev_err(drvdata->dev, + dev_err(etm_dev, "timeout while waiting for Idle Trace Status\n"); writel_relaxed(config->pe_sel, drvdata->base + TRCPROCSELR); @@ -181,13 +182,13 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) /* wait for TRCSTATR.IDLE to go back down to '0' */ if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 0)) - dev_err(drvdata->dev, + dev_err(etm_dev, "timeout while waiting for Idle Trace Status\n"); done: CS_LOCK(drvdata->base); - dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n", + dev_dbg(etm_dev, "cpu: %d enable smp call done: %d\n", drvdata->cpu, rc); return rc; } @@ -292,7 +293,7 @@ static int etm4_enable_sysfs(struct coresight_device *csdev) spin_unlock(&drvdata->spinlock); if (!ret) - dev_dbg(drvdata->dev, "ETM tracing enabled\n"); + dev_dbg(&csdev->dev, "ETM tracing enabled\n"); return ret; } @@ -353,7 +354,8 @@ static void etm4_disable_hw(void *info) CS_LOCK(drvdata->base); - dev_dbg(drvdata->dev, "cpu: %d disable smp call done\n", drvdata->cpu); + dev_dbg(&drvdata->csdev->dev, + "cpu: %d disable smp call done\n", drvdata->cpu); } static int etm4_disable_perf(struct coresight_device *csdev, @@ -403,7 +405,7 @@ static void etm4_disable_sysfs(struct coresight_device *csdev) spin_unlock(&drvdata->spinlock); cpus_read_unlock(); - dev_dbg(drvdata->dev, "ETM tracing disabled\n"); + dev_dbg(&csdev->dev, "ETM tracing disabled\n"); } static void etm4_disable(struct coresight_device *csdev, @@ -987,7 +989,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) adev->dev.platform_data = pdata; } - drvdata->dev = &adev->dev; dev_set_drvdata(dev, drvdata); /* Validity for the resource is already checked by the AMBA core */ @@ -1049,7 +1050,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) } pm_runtime_put(&adev->dev); - dev_info(dev, "CPU%d: ETM v%d.%d initialized\n", + dev_info(&drvdata->csdev->dev, "CPU%d: ETM v%d.%d initialized\n", drvdata->cpu, drvdata->arch >> 4, drvdata->arch & 0xf); if (boot_enable) { diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 52786e9..4523f10 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -284,7 +284,6 @@ struct etmv4_config { /** * struct etm4_drvdata - specifics associated to an ETM component * @base: Memory mapped base address for this component. - * @dev: The device entity associated to this component. * @csdev: Component vitals needed by the framework. * @spinlock: Only one at a time pls. * @mode: This tracer's mode, i.e sysFS, Perf or disabled. @@ -340,7 +339,6 @@ struct etmv4_config { */ struct etmv4_drvdata { void __iomem *base; - struct device *dev; struct coresight_device *csdev; spinlock_t spinlock; local_t mode; From patchwork Mon Apr 15 16:03:56 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: 162208 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105336jan; Mon, 15 Apr 2019 09:06:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaAScEGCO8l99yd4eZJ/+CgwOBtkaZIe2JlGAgmc7imM3cxhpw+zKIqT10HkDuB7l6ih08 X-Received: by 2002:a63:f707:: with SMTP id x7mr71847461pgh.343.1555344373947; Mon, 15 Apr 2019 09:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344373; cv=none; d=google.com; s=arc-20160816; b=TTO0eIv3TsNiTc89jEQNKVCdQjwc7iaOMUJVAW6LwTroGxf/ShrZgeN+7WZZZ2EKbB OazsnJL/XTqDxZvJvyiT/XOw1fDtxiKdvdy1TFZijQhVVuvXrN7MeT9CDyFwvzxJqGAE sbxwd57axXLEP+ph4hmZRv+/hTxx1DWR8u/liivWNp4mIEXyPYDBIC5MtRYz774jibiZ 89TXCjefTWLtMkxB+5VYYZMHyoZw2w/bhOoeC2tFXhX5beQGsggGFa3EpSMubjwrGO+w 9eAHAoayBsGFSQGPIhd4KiJ6XyXw+iOFAtUsANGPtOgiRGjxUzfKQBfg1T2CPS+Mk+ek na/w== 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=sFstQoP9qH+rIt17Kaq706UFBzmZObZ2MAABdkYscQw=; b=IoFicfi+x6qLt9tIwd029HwxXnbZDMaglaVEuY1bS07sKzcVzyEsYqHHeDtvImFrqa SoyPF3R5jaPqd/dyvwKSYssqMfFX2AEAnk4DT1MpFtXg2bKtxSgsYUSKxY5eSKJeTSTX vKnGgq5bWB1ATpOhiALoKYF3+KeZFUaUs8OOFnkCSVROmHKeei3NFMBq3TpDEjqzTQbk ezm49wv1qmUHBj/xK1V7VyxdHM8pdM0scdHIsfdioxbWmqDmiK3F2XdlllZhfNIY/SZY hrGIkwbDe4Wobiwz0QD1jYuwycqGJB9QX7iFVK8PB1QTifgkin22uNF5gI+8zFBlBw/5 NW+g== 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 f2si22018404pgc.182.2019.04.15.09.06.13; Mon, 15 Apr 2019 09:06: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 S1727959AbfDOQGM (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:12 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37810 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727937AbfDOQGI (ORCPT ); Mon, 15 Apr 2019 12:06:08 -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 A28F21715; Mon, 15 Apr 2019 09:06:07 -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 293013F68F; Mon, 15 Apr 2019 09:06:06 -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 13/36] coresight: etb10: Clean up device specific data Date: Mon, 15 Apr 2019 17:03:56 +0100 Message-Id: <1555344260-12375-14-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 Track the coresight device instead of the real device. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etb10.c | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 13c0a60..6e6e9aa 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -65,7 +65,6 @@ /** * 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. * @atclk: optional clock for the core parts of the ETB. * @csdev: component vitals needed by the framework. * @miscdev: specifics to handle "/dev/xyz.etb" entry. @@ -78,7 +77,6 @@ */ struct etb_drvdata { void __iomem *base; - struct device *dev; struct clk *atclk; struct coresight_device *csdev; struct miscdevice miscdev; @@ -199,7 +197,6 @@ static int etb_enable_perf(struct coresight_device *csdev, void *data) static int etb_enable(struct coresight_device *csdev, u32 mode, void *data) { int ret; - struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); switch (mode) { case CS_MODE_SYSFS: @@ -216,13 +213,14 @@ static int etb_enable(struct coresight_device *csdev, u32 mode, void *data) if (ret) return ret; - dev_dbg(drvdata->dev, "ETB enabled\n"); + dev_dbg(&csdev->dev, "ETB enabled\n"); return 0; } static void __etb_disable_hw(struct etb_drvdata *drvdata) { u32 ffcr; + struct device *dev = &drvdata->csdev->dev; CS_UNLOCK(drvdata->base); @@ -235,7 +233,7 @@ static void __etb_disable_hw(struct etb_drvdata *drvdata) writel_relaxed(ffcr, drvdata->base + ETB_FFCR); if (coresight_timeout(drvdata->base, ETB_FFCR, ETB_FFCR_BIT, 0)) { - dev_err(drvdata->dev, + dev_err(dev, "timeout while waiting for completion of Manual Flush\n"); } @@ -243,7 +241,7 @@ static void __etb_disable_hw(struct etb_drvdata *drvdata) writel_relaxed(0x0, drvdata->base + ETB_CTL_REG); if (coresight_timeout(drvdata->base, ETB_FFSR, ETB_FFSR_BIT, 1)) { - dev_err(drvdata->dev, + dev_err(dev, "timeout while waiting for Formatter to Stop\n"); } @@ -258,6 +256,7 @@ static void etb_dump_hw(struct etb_drvdata *drvdata) u32 read_data, depth; u32 read_ptr, write_ptr; u32 frame_off, frame_endoff; + struct device *dev = &drvdata->csdev->dev; CS_UNLOCK(drvdata->base); @@ -267,10 +266,10 @@ static void etb_dump_hw(struct etb_drvdata *drvdata) frame_off = write_ptr % ETB_FRAME_SIZE_WORDS; frame_endoff = ETB_FRAME_SIZE_WORDS - frame_off; if (frame_off) { - dev_err(drvdata->dev, + dev_err(dev, "write_ptr: %lu not aligned to formatter frame size\n", (unsigned long)write_ptr); - dev_err(drvdata->dev, "frameoff: %lu, frame_endoff: %lu\n", + dev_err(dev, "frameoff: %lu, frame_endoff: %lu\n", (unsigned long)frame_off, (unsigned long)frame_endoff); write_ptr += frame_endoff; } @@ -331,7 +330,7 @@ static void etb_disable(struct coresight_device *csdev) } spin_unlock_irqrestore(&drvdata->spinlock, flags); - dev_dbg(drvdata->dev, "ETB disabled\n"); + dev_dbg(&csdev->dev, "ETB disabled\n"); } static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu, @@ -418,7 +417,7 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev, * chance to fix things. */ if (write_ptr % ETB_FRAME_SIZE_WORDS) { - dev_err(drvdata->dev, + dev_err(&csdev->dev, "write_ptr: %lu not aligned to formatter frame size\n", (unsigned long)write_ptr); @@ -543,7 +542,7 @@ static void etb_dump(struct etb_drvdata *drvdata) } spin_unlock_irqrestore(&drvdata->spinlock, flags); - dev_dbg(drvdata->dev, "ETB dumped\n"); + dev_dbg(&drvdata->csdev->dev, "ETB dumped\n"); } static int etb_open(struct inode *inode, struct file *file) @@ -554,7 +553,7 @@ static int etb_open(struct inode *inode, struct file *file) if (local_cmpxchg(&drvdata->reading, 0, 1)) return -EBUSY; - dev_dbg(drvdata->dev, "%s: successfully opened\n", __func__); + dev_dbg(&drvdata->csdev->dev, "%s: successfully opened\n", __func__); return 0; } @@ -564,6 +563,7 @@ static ssize_t etb_read(struct file *file, char __user *data, u32 depth; struct etb_drvdata *drvdata = container_of(file->private_data, struct etb_drvdata, miscdev); + struct device *dev = &drvdata->csdev->dev; etb_dump(drvdata); @@ -572,13 +572,14 @@ static ssize_t etb_read(struct file *file, char __user *data, len = depth * 4 - *ppos; if (copy_to_user(data, drvdata->buf + *ppos, len)) { - dev_dbg(drvdata->dev, "%s: copy_to_user failed\n", __func__); + dev_dbg(dev, + "%s: copy_to_user failed\n", __func__); return -EFAULT; } *ppos += len; - dev_dbg(drvdata->dev, "%s: %zu bytes copied, %d bytes left\n", + dev_dbg(dev, "%s: %zu bytes copied, %d bytes left\n", __func__, len, (int)(depth * 4 - *ppos)); return len; } @@ -589,7 +590,7 @@ static int etb_release(struct inode *inode, struct file *file) struct etb_drvdata, miscdev); local_set(&drvdata->reading, 0); - dev_dbg(drvdata->dev, "%s: released\n", __func__); + dev_dbg(&drvdata->csdev->dev, "%s: released\n", __func__); return 0; } @@ -693,7 +694,6 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) return -ENOMEM; - drvdata->dev = &adev->dev; drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); From patchwork Mon Apr 15 16:03:57 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: 162232 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3108265jan; Mon, 15 Apr 2019 09:08:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqytuyPHrpUULjKC7dyjq9MewDlgkRCQPS34ikp5vdJXbRtQHZMaPMcoFtWaAMxGeP+0mUiQ X-Received: by 2002:a63:cc0b:: with SMTP id x11mr54171849pgf.35.1555344510075; Mon, 15 Apr 2019 09:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344510; cv=none; d=google.com; s=arc-20160816; b=kM4ATl4oHo2y9YPYWhUPfT+jSe0LzI5xesg8i2C5lpfj0YfFpDDL6NocYg4a+hzwkr VPiIdGd20HQk6c9Sn4tXkzQXn27ZrxoQxmLKHpo3dA676vtggPzsMjOTSeZUUoppgePt XAUDYIyhSKM3/IpNUPb1rYaE3HLEnE5jAMtW136i2deF8234FVd6k8bOo2yqlT+Hr5NK SiNlpFxDnDJ0l8J5Zn1k+qJ+TfXeYigQ1GtPxZ/aoOGgz51KFmxnI3LLPUDrTZ+GppRD B6NiY+0YDq3oYRGYWhY5WsJE09bW+LdbsKqDpolciIRD/YjMI7qIMQeYUwtHAuYfVdIO swxQ== 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=R/qG7KUKxJ2zJrEzIBBzMirpSEeRFBq8evh5wYRe35E=; b=YlllSKvVQkrZ1LWnYEiwNrBR/JY0rmQ5KP9ZYi/ZyCHHX+03saJL80k5ksMYndkqLc bGGkX1+ZWIyJtFxSG5diyeYjkxaabWzmQtiBSF+Nm+TGyMK5tMwtEgGGl3hAK1FSrwLW 7/PD+oBrrE188l5sK4ZhYHKeXZXVY4mPTS8zjltMXaSe6T9S+xRcAvsQEq7cgS/2V3s1 55BWg0kl1pBnkEFZ1M3jgBLQgvZv4vAuBnsJKe9ItCFp8ESJ/ZGEFmA9cjkCKt5aIiv/ s3KveIBAJyrINuhDKTLEx+Xmm0wOuUWp8ZbdsRAAEEVnmXl2Ahaazo7MKFxX3HPPSUhb FYTA== 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 d2si42993352pgq.129.2019.04.15.09.08.29; Mon, 15 Apr 2019 09:08: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 S1727971AbfDOQGO (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:14 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37822 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727947AbfDOQGJ (ORCPT ); Mon, 15 Apr 2019 12:06:09 -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 651C280D; Mon, 15 Apr 2019 09:06:09 -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 DF5533F68F; Mon, 15 Apr 2019 09:06:07 -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 14/36] coresight: Rename of_coresight to coresight-platform Date: Mon, 15 Apr 2019 17:03:57 +0100 Message-Id: <1555344260-12375-15-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 Rename the firmware handling file to a more generic name, in preparation for adding ACPI support. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/Makefile | 3 +- drivers/hwtracing/coresight/coresight-platform.c | 298 +++++++++++++++++++++++ drivers/hwtracing/coresight/of_coresight.c | 297 ---------------------- 3 files changed, 299 insertions(+), 299 deletions(-) create mode 100644 drivers/hwtracing/coresight/coresight-platform.c delete mode 100644 drivers/hwtracing/coresight/of_coresight.c -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index 3b435aa..3c0ac42 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -2,8 +2,7 @@ # # Makefile for CoreSight drivers. # -obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o -obj-$(CONFIG_OF) += of_coresight.o +obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o coresight-platform.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o \ coresight-tmc-etf.o \ coresight-tmc-etr.o diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c new file mode 100644 index 0000000..514cc2b --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -0,0 +1,298 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_OF +static int of_dev_node_match(struct device *dev, void *data) +{ + return dev->of_node == data; +} + +static struct device * +of_coresight_get_endpoint_device(struct device_node *endpoint) +{ + struct device *dev = NULL; + + /* + * If we have a non-configurable replicator, it will be found on the + * platform bus. + */ + dev = bus_find_device(&platform_bus_type, NULL, + endpoint, of_dev_node_match); + if (dev) + return dev; + + /* + * We have a configurable component - circle through the AMBA bus + * looking for the device that matches the endpoint node. + */ + return bus_find_device(&amba_bustype, NULL, + endpoint, of_dev_node_match); +} + +static inline bool of_coresight_legacy_ep_is_input(struct device_node *ep) +{ + return of_property_read_bool(ep, "slave-mode"); +} + +static void of_coresight_get_ports_legacy(const struct device_node *node, + int *nr_inport, int *nr_outport) +{ + struct device_node *ep = NULL; + int in = 0, out = 0; + + do { + ep = of_graph_get_next_endpoint(node, ep); + if (!ep) + break; + + if (of_coresight_legacy_ep_is_input(ep)) + in++; + else + out++; + + } while (ep); + + *nr_inport = in; + *nr_outport = out; +} + +static struct device_node *of_coresight_get_port_parent(struct device_node *ep) +{ + struct device_node *parent = of_graph_get_port_parent(ep); + + /* + * Skip one-level up to the real device node, if we + * are using the new bindings. + */ + if (of_node_name_eq(parent, "in-ports") || + of_node_name_eq(parent, "out-ports")) + parent = of_get_next_parent(parent); + + return parent; +} + +static inline struct device_node * +of_coresight_get_input_ports_node(const struct device_node *node) +{ + return of_get_child_by_name(node, "in-ports"); +} + +static inline struct device_node * +of_coresight_get_output_ports_node(const struct device_node *node) +{ + return of_get_child_by_name(node, "out-ports"); +} + +static inline int +of_coresight_count_ports(struct device_node *port_parent) +{ + int i = 0; + struct device_node *ep = NULL; + + while ((ep = of_graph_get_next_endpoint(port_parent, ep))) + i++; + return i; +} + +static void of_coresight_get_ports(const struct device_node *node, + int *nr_inport, int *nr_outport) +{ + struct device_node *input_ports = NULL, *output_ports = NULL; + + input_ports = of_coresight_get_input_ports_node(node); + output_ports = of_coresight_get_output_ports_node(node); + + if (input_ports || output_ports) { + if (input_ports) { + *nr_inport = of_coresight_count_ports(input_ports); + of_node_put(input_ports); + } + if (output_ports) { + *nr_outport = of_coresight_count_ports(output_ports); + of_node_put(output_ports); + } + } else { + /* Fall back to legacy DT bindings parsing */ + of_coresight_get_ports_legacy(node, nr_inport, nr_outport); + } +} + +static int of_coresight_alloc_memory(struct device *dev, + struct coresight_platform_data *pdata) +{ + if (pdata->nr_outport) { + pdata->conns = devm_kzalloc(dev, pdata->nr_outport * + sizeof(*pdata->conns), + GFP_KERNEL); + if (!pdata->conns) + return -ENOMEM; + } + + return 0; +} + +int of_coresight_get_cpu(const struct device_node *node) +{ + int cpu; + struct device_node *dn; + + dn = of_parse_phandle(node, "cpu", 0); + /* Affinity defaults to CPU0 */ + if (!dn) + return 0; + cpu = of_cpu_node_to_id(dn); + of_node_put(dn); + + /* 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 + * and fill the connection information in @conn + * + * Parses the local port, remote device name and the remote port. + * + * Returns : + * 1 - If the parsing is successful and a connection record + * was created for an output connection. + * 0 - If the parsing completed without any fatal errors. + * -Errno - Fatal error, abort the scanning. + */ +static int of_coresight_parse_endpoint(struct device *dev, + struct device_node *ep, + struct coresight_connection *conn) +{ + int ret = 0; + struct of_endpoint endpoint, rendpoint; + struct device_node *rparent = NULL; + struct device_node *rep = NULL; + struct device *rdev = NULL; + + do { + /* Parse the local port details */ + if (of_graph_parse_endpoint(ep, &endpoint)) + break; + /* + * Get a handle on the remote endpoint and the device it is + * attached to. + */ + rep = of_graph_get_remote_endpoint(ep); + if (!rep) + break; + rparent = of_coresight_get_port_parent(rep); + if (!rparent) + break; + if (of_graph_parse_endpoint(rep, &rendpoint)) + break; + + /* If the remote device is not available, defer probing */ + rdev = of_coresight_get_endpoint_device(rparent); + if (!rdev) { + ret = -EPROBE_DEFER; + break; + } + + conn->outport = endpoint.port; + conn->child_name = devm_kstrdup(dev, + dev_name(rdev), + GFP_KERNEL); + conn->child_port = rendpoint.port; + /* Connection record updated */ + ret = 1; + } while (0); + + of_node_put(rparent); + of_node_put(rep); + put_device(rdev); + + return ret; +} + +struct coresight_platform_data * +of_get_coresight_platform_data(struct device *dev, + const struct device_node *node) +{ + int ret = 0; + struct coresight_platform_data *pdata; + struct coresight_connection *conn; + struct device_node *ep = NULL; + const struct device_node *parent = NULL; + bool legacy_binding = false; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + /* Use device name as sysfs handle */ + pdata->name = dev_name(dev); + 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); + + /* If there are no output connections, we are done */ + if (!pdata->nr_outport) + return pdata; + + ret = of_coresight_alloc_memory(dev, pdata); + if (ret) + return ERR_PTR(ret); + + parent = of_coresight_get_output_ports_node(node); + /* + * If the DT uses obsoleted bindings, the ports are listed + * under the device and we need to filter out the input + * ports. + */ + if (!parent) { + legacy_binding = true; + parent = node; + dev_warn_once(dev, "Uses obsolete Coresight DT bindings\n"); + } + + conn = pdata->conns; + + /* Iterate through each output port to discover topology */ + while ((ep = of_graph_get_next_endpoint(parent, ep))) { + /* + * Legacy binding mixes input/output ports under the + * same parent. So, skip the input ports if we are dealing + * with legacy binding, as they processed with their + * connected output ports. + */ + if (legacy_binding && of_coresight_legacy_ep_is_input(ep)) + continue; + + ret = of_coresight_parse_endpoint(dev, ep, conn); + switch (ret) { + case 1: + conn++; /* Fall through */ + case 0: + break; + default: + return ERR_PTR(ret); + } + } + + return pdata; +} +EXPORT_SYMBOL_GPL(of_get_coresight_platform_data); +#endif diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c deleted file mode 100644 index 7045930..0000000 --- a/drivers/hwtracing/coresight/of_coresight.c +++ /dev/null @@ -1,297 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012, The Linux Foundation. All rights reserved. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -static int of_dev_node_match(struct device *dev, void *data) -{ - return dev->of_node == data; -} - -static struct device * -of_coresight_get_endpoint_device(struct device_node *endpoint) -{ - struct device *dev = NULL; - - /* - * If we have a non-configurable replicator, it will be found on the - * platform bus. - */ - dev = bus_find_device(&platform_bus_type, NULL, - endpoint, of_dev_node_match); - if (dev) - return dev; - - /* - * We have a configurable component - circle through the AMBA bus - * looking for the device that matches the endpoint node. - */ - return bus_find_device(&amba_bustype, NULL, - endpoint, of_dev_node_match); -} - -static inline bool of_coresight_legacy_ep_is_input(struct device_node *ep) -{ - return of_property_read_bool(ep, "slave-mode"); -} - -static void of_coresight_get_ports_legacy(const struct device_node *node, - int *nr_inport, int *nr_outport) -{ - struct device_node *ep = NULL; - int in = 0, out = 0; - - do { - ep = of_graph_get_next_endpoint(node, ep); - if (!ep) - break; - - if (of_coresight_legacy_ep_is_input(ep)) - in++; - else - out++; - - } while (ep); - - *nr_inport = in; - *nr_outport = out; -} - -static struct device_node *of_coresight_get_port_parent(struct device_node *ep) -{ - struct device_node *parent = of_graph_get_port_parent(ep); - - /* - * Skip one-level up to the real device node, if we - * are using the new bindings. - */ - if (of_node_name_eq(parent, "in-ports") || - of_node_name_eq(parent, "out-ports")) - parent = of_get_next_parent(parent); - - return parent; -} - -static inline struct device_node * -of_coresight_get_input_ports_node(const struct device_node *node) -{ - return of_get_child_by_name(node, "in-ports"); -} - -static inline struct device_node * -of_coresight_get_output_ports_node(const struct device_node *node) -{ - return of_get_child_by_name(node, "out-ports"); -} - -static inline int -of_coresight_count_ports(struct device_node *port_parent) -{ - int i = 0; - struct device_node *ep = NULL; - - while ((ep = of_graph_get_next_endpoint(port_parent, ep))) - i++; - return i; -} - -static void of_coresight_get_ports(const struct device_node *node, - int *nr_inport, int *nr_outport) -{ - struct device_node *input_ports = NULL, *output_ports = NULL; - - input_ports = of_coresight_get_input_ports_node(node); - output_ports = of_coresight_get_output_ports_node(node); - - if (input_ports || output_ports) { - if (input_ports) { - *nr_inport = of_coresight_count_ports(input_ports); - of_node_put(input_ports); - } - if (output_ports) { - *nr_outport = of_coresight_count_ports(output_ports); - of_node_put(output_ports); - } - } else { - /* Fall back to legacy DT bindings parsing */ - of_coresight_get_ports_legacy(node, nr_inport, nr_outport); - } -} - -static int of_coresight_alloc_memory(struct device *dev, - struct coresight_platform_data *pdata) -{ - if (pdata->nr_outport) { - pdata->conns = devm_kzalloc(dev, pdata->nr_outport * - sizeof(*pdata->conns), - GFP_KERNEL); - if (!pdata->conns) - return -ENOMEM; - } - - return 0; -} - -int of_coresight_get_cpu(const struct device_node *node) -{ - int cpu; - struct device_node *dn; - - dn = of_parse_phandle(node, "cpu", 0); - /* Affinity defaults to CPU0 */ - if (!dn) - return 0; - cpu = of_cpu_node_to_id(dn); - of_node_put(dn); - - /* 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 - * and fill the connection information in @conn - * - * Parses the local port, remote device name and the remote port. - * - * Returns : - * 1 - If the parsing is successful and a connection record - * was created for an output connection. - * 0 - If the parsing completed without any fatal errors. - * -Errno - Fatal error, abort the scanning. - */ -static int of_coresight_parse_endpoint(struct device *dev, - struct device_node *ep, - struct coresight_connection *conn) -{ - int ret = 0; - struct of_endpoint endpoint, rendpoint; - struct device_node *rparent = NULL; - struct device_node *rep = NULL; - struct device *rdev = NULL; - - do { - /* Parse the local port details */ - if (of_graph_parse_endpoint(ep, &endpoint)) - break; - /* - * Get a handle on the remote endpoint and the device it is - * attached to. - */ - rep = of_graph_get_remote_endpoint(ep); - if (!rep) - break; - rparent = of_coresight_get_port_parent(rep); - if (!rparent) - break; - if (of_graph_parse_endpoint(rep, &rendpoint)) - break; - - /* If the remote device is not available, defer probing */ - rdev = of_coresight_get_endpoint_device(rparent); - if (!rdev) { - ret = -EPROBE_DEFER; - break; - } - - conn->outport = endpoint.port; - conn->child_name = devm_kstrdup(dev, - dev_name(rdev), - GFP_KERNEL); - conn->child_port = rendpoint.port; - /* Connection record updated */ - ret = 1; - } while (0); - - of_node_put(rparent); - of_node_put(rep); - put_device(rdev); - - return ret; -} - -struct coresight_platform_data * -of_get_coresight_platform_data(struct device *dev, - const struct device_node *node) -{ - int ret = 0; - struct coresight_platform_data *pdata; - struct coresight_connection *conn; - struct device_node *ep = NULL; - const struct device_node *parent = NULL; - bool legacy_binding = false; - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - - /* Use device name as sysfs handle */ - pdata->name = dev_name(dev); - 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); - - /* If there are no output connections, we are done */ - if (!pdata->nr_outport) - return pdata; - - ret = of_coresight_alloc_memory(dev, pdata); - if (ret) - return ERR_PTR(ret); - - parent = of_coresight_get_output_ports_node(node); - /* - * If the DT uses obsoleted bindings, the ports are listed - * under the device and we need to filter out the input - * ports. - */ - if (!parent) { - legacy_binding = true; - parent = node; - dev_warn_once(dev, "Uses obsolete Coresight DT bindings\n"); - } - - conn = pdata->conns; - - /* Iterate through each output port to discover topology */ - while ((ep = of_graph_get_next_endpoint(parent, ep))) { - /* - * Legacy binding mixes input/output ports under the - * same parent. So, skip the input ports if we are dealing - * with legacy binding, as they processed with their - * connected output ports. - */ - if (legacy_binding && of_coresight_legacy_ep_is_input(ep)) - continue; - - ret = of_coresight_parse_endpoint(dev, ep, conn); - switch (ret) { - case 1: - conn++; /* Fall through */ - case 0: - break; - default: - return ERR_PTR(ret); - } - } - - return pdata; -} -EXPORT_SYMBOL_GPL(of_get_coresight_platform_data); From patchwork Mon Apr 15 16:03:58 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: 162209 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105411jan; Mon, 15 Apr 2019 09:06:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJSPZ/ayRRSiezNOHpBYNOQkS0fNPrHlmh+kW+7TkybtKrXIITfig83A+OZxPTC+F4IPkP X-Received: by 2002:a63:7d03:: with SMTP id y3mr70646841pgc.8.1555344377252; Mon, 15 Apr 2019 09:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344377; cv=none; d=google.com; s=arc-20160816; b=n7vYuCNsMX4tS2f2MBbVflZL8nOTYQC9s1zeg5B1J7FLG+cERWGnWdLnOiT7BG9A7v bRoaL0IOmwCo8H8ZFHaR+UBGDCpDtnMSLCFiqBQcBk//NX6q4XvNXMktjqTT4U5MIECX ZKJSbnu9yecuHNLfUgYs7obTa+zRPLvOXko+bwdJE8dNUyzq1HbABexNu4drQmcphfXk HN/sfolVLWkx1fNuEfD0wmWnGuKTIEt7zwhotE7mSTS1kpLcurGSmsMmpo9QuxqTrXog 1dIrFWLYLU5tFi78gdkL+E2DQQra14d0U9SFVyuStpPqzhXWiTxYhHbjS+tOseRjr3Zr lR0Q== 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=RHstHalWmeyP8w90lwJAlqVnu3SqjScVnjdZBglBgI4=; b=NiPEctrWHdEIkrdSb2HjWc9lqV4IjZmzweG80oOfEDeDNBBGmz2fAKRnYLLxoXym+0 RD40LCvcrpdsfJRHnALfIvXSOxhLYmXTuw1WD47yAe4bj947BKAcr+gck5n4kGQNVjhP GRQWjA4GWj/GaZht7OPA2g8oBR1+C7k7Ke45VFktabi/kEOWoWRe80Gxmq2JiXWtBdDk LUifKSiGbPxhoc/zV3EdhsQbaMeRQYJpRO6F4BAlNwdu+RZF7PUHL1I5hi7/wf4xyC0F 9+ZtDECpIiZ/E7U9lnsUjtxzof9sFxzsZPjDKb5RCmBi5zkWx0ByxFlDta3cS5n6nRyL aYqg== 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 w3si44448747pgr.189.2019.04.15.09.06.16; Mon, 15 Apr 2019 09:06:17 -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 S1727983AbfDOQGP (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:15 -0400 Received: from foss.arm.com ([217.140.101.70]:37834 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727954AbfDOQGL (ORCPT ); Mon, 15 Apr 2019 12:06:11 -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 31847A78; Mon, 15 Apr 2019 09:06:11 -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 A1AF93F68F; Mon, 15 Apr 2019 09:06:09 -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 15/36] coresight: etm3x: Rearrange cp14 access detection Date: Mon, 15 Apr 2019 17:03:58 +0100 Message-Id: <1555344260-12375-16-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 As we are about to refactor the platform specific handling, move the DT property handling to generic helpers. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm3x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 9c92491..fa2f141 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -802,9 +802,9 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR(pdata); adev->dev.platform_data = pdata; - drvdata->use_cp14 = of_property_read_bool(np, "arm,cp14"); } + drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14"); dev_set_drvdata(dev, drvdata); /* Validity for the resource is already checked by the AMBA core */ From patchwork Mon Apr 15 16:03:59 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: 162210 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105493jan; Mon, 15 Apr 2019 09:06:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXj4Cccc6jegE1K3+VTZqEvSOhS5dAT3JWDqH3K5mDRrMHTyQQHg8tQ9uWSaGsB+PwkEcU X-Received: by 2002:a63:525f:: with SMTP id s31mr70679555pgl.172.1555344379906; Mon, 15 Apr 2019 09:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344379; cv=none; d=google.com; s=arc-20160816; b=NXyBONuPrPURpqdpKQvHfk2jno0vNsB98KusRPe4sXpPmRnR5o8R3Exs9y4rl4KHxi mwcOAuUF3oig9LZVUcuRHcb8Beg52uQyXKx5Ra9OJvn1B6DUh5cNmVrbmx2ee+YExhf4 kRChw5nerCNmnmNFFBOYgMpadzA4ddT81epRIiHcVHbz2mdqGHldqhmzidEe7g5wLJmi 4MlKFxDJpXy4rKcnbRYqxaQ5y85T9K3jTQMXSlwXW6/S0vlEcUrQ0i5Y/U2dSL1giN7Z hup/lVPrp+vuUb5VDmcn+fUEuCDQGyX8843G7DtWVIQEpo1Ajj9kevRa8GAql8gbLZBI ypig== 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=RbhWyPAxWOQYSqYn7EZ7Z5vXsr/ma8nI406Vuxe+3Lk=; b=akMNMDVcXOViTs1sAX0eC7CsbaM5hhL7p7zzrs88lD1bNlft/yHkG0thv3UITZwjfX O0wouwM8yd0wHzRgbbI1rzknz3EFEt/qyxrbvUouFMVj3m+hmT1ojZHonAClt5nXdO31 aI6VMVU81PoJubcw6bmiE5cd/LomWnqdrvGhjASBstgNAKouDidvFa6nTm2CUPbZbdE8 hhKjnQbjNTeUHA4IGaknuVKJ8MMFDPmK1UzwQS3JifBmToJlhMfQzECnVtz+jVbhfZ86 XnXw4CD9H5Qj3yoI8H9kqhf51J8wiBPNbUr8ZOfgtodDuKrP6XUC9qKs9bsYo2Kj61oP MFUg== 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 w3si44448747pgr.189.2019.04.15.09.06.19; Mon, 15 Apr 2019 09:06:19 -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 S1727995AbfDOQGR (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37848 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727963AbfDOQGN (ORCPT ); Mon, 15 Apr 2019 12:06:13 -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 E80611684; Mon, 15 Apr 2019 09:06:12 -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 6E47F3F68F; Mon, 15 Apr 2019 09:06:11 -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 16/36] coresight: stm: Rearrange probing the stimulus area Date: Mon, 15 Apr 2019 17:03:59 +0100 Message-Id: <1555344260-12375-17-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 As we are about to refactor the platform specific handling re-arrange some of the DT specific property handling. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-stm.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 8f50484..a0690be 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -683,14 +683,15 @@ static const struct attribute_group *coresight_stm_groups[] = { NULL, }; -static int stm_get_resource_byname(struct device_node *np, - char *ch_base, struct resource *res) +#ifdef CONFIG_OF +static int of_stm_get_stimulus_area(struct device *dev, struct resource *res) { const char *name = NULL; int index = 0, found = 0; + struct device_node *np = dev->of_node; while (!of_property_read_string_index(np, "reg-names", index, &name)) { - if (strcmp(ch_base, name)) { + if (strcmp("stm-stimulus-base", name)) { index++; continue; } @@ -705,6 +706,20 @@ static int stm_get_resource_byname(struct device_node *np, return of_address_to_resource(np, index, res); } +#else +static inline int of_stm_get_stimulus_area(struct device *dev, + struct resource *res) +{ + return -ENOENT; +} +#endif + +static int stm_get_stimulus_area(struct device *dev, struct resource *res) +{ + if (dev->of_node) + return of_stm_get_stimulus_area(dev, res); + return -ENOENT; +} static u32 stm_fundamental_data_size(struct stm_drvdata *drvdata) { @@ -819,7 +834,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR(base); drvdata->base = base; - ret = stm_get_resource_byname(np, "stm-stimulus-base", &ch_res); + ret = stm_get_stimulus_area(dev, &ch_res); if (ret) return ret; drvdata->chs.phys = ch_res.start; From patchwork Mon Apr 15 16:04:00 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: 162231 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3108180jan; Mon, 15 Apr 2019 09:08:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7dCRH5W33yeWNjkKymc7eCc1RqlwcCxRw1qLGtAK2sn7jv4unYWmDHTkOnjIdRdEQlwpy X-Received: by 2002:a63:7943:: with SMTP id u64mr70240801pgc.91.1555344504753; Mon, 15 Apr 2019 09:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344504; cv=none; d=google.com; s=arc-20160816; b=YOUy6PXKV/DwFCj9zFQShdvMfzmfZCUvxg1T2BgIuYVQM+6PHIQJSQIrPJ7yO4IobP plPRDp6GQwyzXveXDcbh+aNFcu1rY57unqc/UQ3I3AU53/43JMEMcrmGCsUNiypz04rl LPzv8TB2YaewI6cxQrxQLwb9GVMD5az7T4PG5x/kHJF1Roj3zsmX+zulOHnFL/2xIFfI j9IlGIaQ285g42Q893dhCLyNzUdQwlVu/mnP8VbG2+eHQon7dCCFJGe8TkaAQXkgz1D4 TErspzFDnr85yZioG2ETS0ldzuvTTxzn/ox6bUNykz1qyNKENXXwMJXYjUxFtNfJLcSk bclQ== 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=O03WAqB5753cZrcodrYNlgqDDr6nm/65cLjzBswv5C0=; b=FGZGDgjPNfwihs32ua1yWy1+Z5a/myfjE15sK2S+HhlW900QTf2iGR2QB2Cvc5PciF wdmJaMyJLWrsHPWeTt2ZujVxZDW9NWwPPJhflAnNuxQ6qwXoEs/E3odVBlFctJKt1qf5 CtfgQyCfxSd8XtfX07+UhkKJi7R86gbzjKTewobbWkR8UozP7s4kxzLUin8XUVMPnrKo Y0aOf33so7CIz53mIU3jcoln6RKhuc13FsNr0r2NahTCqbvF1w7u3lJwzS6FuucmKP/1 NdbArwXiyXwb9vFnSEUdden0RloaLXwU+5i6gk2YBD0xNwa9QLZL3UY545dCDZ6IbRx7 rIIg== 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.24; Mon, 15 Apr 2019 09:08:24 -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 S1728020AbfDOQIX (ORCPT + 30 others); Mon, 15 Apr 2019 12:08:23 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37866 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbfDOQGP (ORCPT ); Mon, 15 Apr 2019 12:06:15 -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 AB3CF1A25; Mon, 15 Apr 2019 09:06:14 -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 31BFD3F68F; Mon, 15 Apr 2019 09:06:13 -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 17/36] coresight: tmc-etr: Rearrange probing default buffer size Date: Mon, 15 Apr 2019 17:04:00 +0100 Message-Id: <1555344260-12375-18-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 As we are about to refactor the platform specific handling, make the default buffer size probing generic. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 819873a..c470b81 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -376,6 +376,15 @@ static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps) return rc; } +static u32 tmc_etr_get_default_buffer_size(struct device *dev) +{ + u32 size; + + if (fwnode_property_read_u32(dev->fwnode, "arm,buffer-size", &size)) + size = SZ_1M; + return size; +} + static int tmc_probe(struct amba_device *adev, const struct amba_id *id) { int ret = 0; @@ -419,16 +428,10 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) drvdata->config_type = BMVAL(devid, 6, 7); drvdata->memwidth = tmc_get_memwidth(devid); - if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) { - if (np) - ret = of_property_read_u32(np, - "arm,buffer-size", - &drvdata->size); - if (ret) - drvdata->size = SZ_1M; - } else { + if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) + drvdata->size = tmc_etr_get_default_buffer_size(dev); + else drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4; - } desc.pdata = pdata; desc.dev = dev; From patchwork Mon Apr 15 16:04:01 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: 162228 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3107802jan; Mon, 15 Apr 2019 09:08:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpCo8IIyJTE2TGT0SzAROL7a/k6VMwEWVoThnjtrQ3H3nf0U5YKgV8MsxTAvUL4V7Tfymg X-Received: by 2002:a65:4343:: with SMTP id k3mr70547173pgq.384.1555344487813; Mon, 15 Apr 2019 09:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344487; cv=none; d=google.com; s=arc-20160816; b=DKevKwYvwj/WZf1/3ttAAu5U4hlY+02+9rtSWBmPIpTUymH2B5lUfXd8c8ZC43j4Ek Q+Qt3Udud4Ag4uzKY1FjPq+LRr5ns3hpnVXALICm6sm1joT3x1YSLpLFOKI8wjh0gjbo E/0nJ7qPWCYv/sNoRIRzMqvK6Qeoo7EIaoTrVxXMGAtP9ods+w7i+3Ga/aqnkFt3JIW4 r9533uCubANlcOZN7f/lI143FePmNpRZVjro69RgVkHkG0GTe81CUYpOGHKQaMFC4t7k AwWWCv7ynksTZGb8U+Rl+GVZgiskK//fHJvAPNKaJLXryQA6JalHDRH8TLdy3dDT5fkr EAaQ== 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=XDRTMppfRnaUp3dHCTapRsTJIzJcZi1kV+zItlZEXlU=; b=w7EvfRF0HGmxSkMRIE0dxr9e+16/Gu9fX/o9NJ6UuyG5U7Z4PGKZmz80uMC/Dq/BhJ 3g1+esGG2PhsQ/IBRVDp8LnIcacOtFjXRaUc7x5dyGYDjkF+Lb3IgoRJmb+CC75Sa7RY FuuQ+jJ2BgdOSfqEKPu7WAfDm3GwDShd9OT2WjJMehluR2n582PAqZacE2PyAa0d85pi 8XKJrViLKXD97UtcPJUKOIYuqDUxNL66qzSU3xlwNeEd6/vuhnLpNBtBP00SSJBEkONe sLym0KWRl8t1dTsJ5+g0fpWU/R9N4AWApiyFSGhtyhVEKYjbkmr1foEVQk7hY2fI2FSW 9h4w== 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 s5si45214973plr.307.2019.04.15.09.08.07; Mon, 15 Apr 2019 09:08:07 -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 S1728011AbfDOQGW (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:22 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37880 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727991AbfDOQGQ (ORCPT ); Mon, 15 Apr 2019 12:06: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 6EFF31688; Mon, 15 Apr 2019 09:06:16 -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 E957C3F68F; Mon, 15 Apr 2019 09:06:14 -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 18/36] coresight: platform: Make memory allocation helper generic Date: Mon, 15 Apr 2019 17:04:01 +0100 Message-Id: <1555344260-12375-19-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 Rename the of_coresight_alloc_memory() => coresight_alloc_conns() as it is independent of the underlying firmware type. This is in preparation for the ACPI support. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-platform.c | 34 +++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 514cc2b..4c31299 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -17,6 +17,24 @@ #include #include +/* + * coresight_alloc_conns: Allocate connections record for each output + * port from the device. + */ +static int coresight_alloc_conns(struct device *dev, + struct coresight_platform_data *pdata) +{ + if (pdata->nr_outport) { + pdata->conns = devm_kzalloc(dev, pdata->nr_outport * + sizeof(*pdata->conns), + GFP_KERNEL); + if (!pdata->conns) + return -ENOMEM; + } + + return 0; +} + #ifdef CONFIG_OF static int of_dev_node_match(struct device *dev, void *data) { @@ -133,20 +151,6 @@ static void of_coresight_get_ports(const struct device_node *node, } } -static int of_coresight_alloc_memory(struct device *dev, - struct coresight_platform_data *pdata) -{ - if (pdata->nr_outport) { - pdata->conns = devm_kzalloc(dev, pdata->nr_outport * - sizeof(*pdata->conns), - GFP_KERNEL); - if (!pdata->conns) - return -ENOMEM; - } - - return 0; -} - int of_coresight_get_cpu(const struct device_node *node) { int cpu; @@ -252,7 +256,7 @@ of_get_coresight_platform_data(struct device *dev, if (!pdata->nr_outport) return pdata; - ret = of_coresight_alloc_memory(dev, pdata); + ret = coresight_alloc_conns(dev, pdata); if (ret) return ERR_PTR(ret); From patchwork Mon Apr 15 16:04:02 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: 162211 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105618jan; Mon, 15 Apr 2019 09:06:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnPo9Y0ssYtuLpFTAlzRbpgTvv5zBgB36qq9FkOF3xm8C8/GYgHEWvjdNGs1tRQFgYATsW X-Received: by 2002:a17:902:3e3:: with SMTP id d90mr76172554pld.271.1555344386129; Mon, 15 Apr 2019 09:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344386; cv=none; d=google.com; s=arc-20160816; b=LxtsQaTAImEBbNvcld0oR2Fw8AC7fyJzUzOWKvKk3E44CjHYPjiUcdmC8b8+alIXUN IhjF8SWeqPpfkSr18f7j/XTfl6Xvmiw9lENtPmE5aQlu3301g/EA1/JsOVbCrmVWLGoi +NNHWGZ+6994Z09QJmmM+YejrH+MbVxBcV/Zz59Y6DkwrnmOCKPuOjayAdgq28QvD8fa bo+BZKVjZRfdoSkSoR5yjduasUp+O2ooaUJvMh8uZosJHUL+CwCEt9ZQLFLw2lZ/AdG8 CaEio9xwRp6OaGygCmfBN2qP6BUGdJgri9PtbIQs39L6EoB9e9pE+NGfdrHr6rcP8tgz aNKw== 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=faDDdNIqq8uX49WRIGBNkUahVprC/uCdI13Y0CNjFq0=; b=SQDku2z73GGf5KFKKcgH4uGNamTfuMmxAnQTu6OSyBVV9fQcK5laob8fJ5iXUcjEq/ LqfgmBnPE2HKZouJ6YkmmdYr4IYAcijI0ILQmCYn3WlQiM3SA+O/JgpTat86VoX59Koj KwqrzgCs0pEGm+ZUMD56J981BfJ/+s7/gdL7jgfqKlZGxsCPiWqHMpjek/7M+Fql76Rc ZDKxKUigcbvA4/alxW0hOy8foBRS4hNvXsu96OiDrtLy7B6lAfIK+Utph+pbpIU9+sh9 sTgYC5BxTIokqYyepXD8xAu67x8qgLgKey+57y6a8vcFTeVIm02J2dBxcTYbT6kBtr7+ 3TNQ== 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 w3si44448747pgr.189.2019.04.15.09.06.25; Mon, 15 Apr 2019 09:06:26 -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 S1728027AbfDOQGY (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:24 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37892 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727963AbfDOQGS (ORCPT ); Mon, 15 Apr 2019 12:06:18 -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 3188F1684; Mon, 15 Apr 2019 09:06:18 -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 ABCB13F68F; Mon, 15 Apr 2019 09:06:16 -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 19/36] coresight: Introduce generic platform data helper Date: Mon, 15 Apr 2019 17:04:02 +0100 Message-Id: <1555344260-12375-20-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 So far we have hard coded the DT platform parsing code in every driver. Introduce generic helper to parse the information provided by the firmware in a platform agnostic manner, in preparation for the ACPI support. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-catu.c | 13 +++----- drivers/hwtracing/coresight/coresight-etb10.c | 11 +++---- drivers/hwtracing/coresight/coresight-etm3x.c | 12 +++----- drivers/hwtracing/coresight/coresight-etm4x.c | 11 +++---- drivers/hwtracing/coresight/coresight-funnel.c | 11 +++---- drivers/hwtracing/coresight/coresight-platform.c | 36 ++++++++++++++++------ drivers/hwtracing/coresight/coresight-replicator.c | 12 +++----- drivers/hwtracing/coresight/coresight-stm.c | 11 +++---- drivers/hwtracing/coresight/coresight-tmc.c | 13 +++----- drivers/hwtracing/coresight/coresight-tpiu.c | 11 +++---- include/linux/coresight.h | 7 ++--- 11 files changed, 66 insertions(+), 82 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index 14d1cf5..65b86ec 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -503,17 +503,14 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) struct coresight_desc catu_desc; struct coresight_platform_data *pdata = NULL; struct device *dev = &adev->dev; - struct device_node *np = dev->of_node; void __iomem *base; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) { - ret = PTR_ERR(pdata); - goto out; - } - dev->platform_data = pdata; + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) { + ret = PTR_ERR(pdata); + goto out; } + dev->platform_data = pdata; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) { diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 6e6e9aa..cd61b54 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -681,14 +681,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) struct etb_drvdata *drvdata; struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; - } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + adev->dev.platform_data = pdata; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index fa2f141..fa2164f 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -790,20 +790,16 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) struct etm_drvdata *drvdata; struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - - adev->dev.platform_data = pdata; - } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + adev->dev.platform_data = pdata; drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14"); dev_set_drvdata(dev, drvdata); diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 75b923f..998b9f3 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -976,18 +976,15 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) struct etmv4_drvdata *drvdata; struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; - } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + adev->dev.platform_data = pdata; dev_set_drvdata(dev, drvdata); diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 1085f31..2590744 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -185,14 +185,11 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) struct funnel_drvdata *drvdata; struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; - } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + adev->dev.platform_data = pdata; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 4c31299..25a1838 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -230,23 +230,17 @@ static int of_coresight_parse_endpoint(struct device *dev, return ret; } -struct coresight_platform_data * +static struct coresight_platform_data * of_get_coresight_platform_data(struct device *dev, - const struct device_node *node) + struct coresight_platform_data *pdata) { int ret = 0; - struct coresight_platform_data *pdata; struct coresight_connection *conn; struct device_node *ep = NULL; const struct device_node *parent = NULL; bool legacy_binding = false; + struct device_node *node = dev->of_node; - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - - /* Use device name as sysfs handle */ - pdata->name = dev_name(dev); pdata->cpu = of_coresight_get_cpu(node); /* Get the number of input and output port for this component */ @@ -298,5 +292,27 @@ of_get_coresight_platform_data(struct device *dev, return pdata; } -EXPORT_SYMBOL_GPL(of_get_coresight_platform_data); #endif + +struct coresight_platform_data * +coresight_get_platform_data(struct device *dev) +{ + struct coresight_platform_data *pdata; + struct fwnode_handle *fwnode = dev_fwnode(dev); + + if (IS_ERR_OR_NULL(fwnode)) + return NULL; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + /* Use device name as sysfs handle */ + pdata->name = dev_name(dev); + + if (is_of_node(fwnode)) + return of_get_coresight_platform_data(dev, pdata); + + return ERR_PTR(-ENOENT); +} +EXPORT_SYMBOL_GPL(coresight_get_platform_data); diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 8bbb008..7eb3bf7 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -177,15 +177,12 @@ static int replicator_probe(struct device *dev, struct resource *res) struct coresight_platform_data *pdata = NULL; struct replicator_drvdata *drvdata; struct coresight_desc desc = { 0 }; - struct device_node *np = dev->of_node; void __iomem *base; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - dev->platform_data = pdata; - } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + dev->platform_data = pdata; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) @@ -213,7 +210,6 @@ static int replicator_probe(struct device *dev, struct resource *res) } dev_set_drvdata(dev, drvdata); - desc.type = CORESIGHT_DEV_TYPE_LINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; desc.ops = &replicator_cs_ops; diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index a0690be..eae0094 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -809,14 +809,11 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) struct resource ch_res; size_t bitmap_size; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; - } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + adev->dev.platform_data = pdata; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index c470b81..7dbdf59 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -395,16 +395,13 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) struct tmc_drvdata *drvdata; struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) { - ret = PTR_ERR(pdata); - goto out; - } - adev->dev.platform_data = pdata; + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) { + ret = PTR_ERR(pdata); + goto out; } + adev->dev.platform_data = pdata; ret = -ENOMEM; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 96af7d5..eea7fd1 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -120,14 +120,11 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) struct tpiu_drvdata *drvdata; struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; - if (np) { - pdata = of_get_coresight_platform_data(dev, np); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; - } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + dev->platform_data = pdata; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 7b87965..5b29255 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -293,14 +293,11 @@ static inline void coresight_disclaim_device_unlocked(void __iomem *base) {} #ifdef CONFIG_OF extern int of_coresight_get_cpu(const struct device_node *node); -extern struct coresight_platform_data * -of_get_coresight_platform_data(struct device *dev, - const struct device_node *node); #else static inline int of_coresight_get_cpu(const struct device_node *node) { return 0; } -static inline struct coresight_platform_data *of_get_coresight_platform_data( - struct device *dev, const struct device_node *node) { return NULL; } #endif +struct coresight_platform_data *coresight_get_platform_data(struct device *dev); + #endif 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); From patchwork Mon Apr 15 16:04:04 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: 162229 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3107880jan; Mon, 15 Apr 2019 09:08:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy8YjQmwokNmtCMAmEgVsrgzIzxlGcMeUk4xoiE9F4tkjYjxwvCQulYtROl76Xd2S+3hiQ X-Received: by 2002:a17:902:2b81:: with SMTP id l1mr77096298plb.289.1555344491062; Mon, 15 Apr 2019 09:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344491; cv=none; d=google.com; s=arc-20160816; b=yHy+2bwF18U3SJaUsFVq7mCzuXLHUawZ7Fjd6kHUTp/Q5g/kA1mFp3cbo7sx6kZc1o /wBI9bYEJc0hqyOgcvXWOZL6OnCbgds7V4vFJ/VasoGki5rJsIIbMdqMUVzMSutrWv3t K/BYKfGf0tlplD6+1IBfFSER7WNmyvaUYEZtPOrkDmjv/r87Yu3twPd1tr+RrMntThjG aEwCgRH5cdkeys81yyzmKNskeGXJFEiVEuH13IG15eF9jBpuK4XThLWOwbEERwP95T8L FE1zWwT0NxEc5dpvPmfQCwmYsNGo+wiJPh7havdE0FiYKh+8Djji5uqDBuSo7XA2Pp4I uSOQ== 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=eanOL7O9qlnH+y8vlF7WvmtX7w9O13ThWVE7PSdkFno=; b=p4K9ppky1mnceprxm+vMcVgI5NOEN85xTc1vvJ63plCP7KFrkWu0jbVOtydf13y7Nr NOh3ts4mVSa/DsP0qMzjDu2enmsMmCIkppb+z/S/Szoju8iQPbwOPXkBzNXGwbFKHz2Y WsCOHBplU5SyCnr94FZOk0pV5jCTs00f8h9T48NYQTdDgvFvwzfYJyihL8+hAunnSG6o f5DCBHFM6Tya3oIqYu68+LC/yoTKi2DEYVHMsPlVtXxKtYBUvdKElK1+3CwOpCVIzFxp jNnnE73g1V2BpWL94XwodqlunEUaSFqO7SmkbWKRDP0KLQBMQp0sLKxRNE6qS+Yisv62 /y+w== 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 s5si45214973plr.307.2019.04.15.09.08.10; Mon, 15 Apr 2019 09:08:11 -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 S1727956AbfDOQIJ (ORCPT + 30 others); Mon, 15 Apr 2019 12:08:09 -0400 Received: from foss.arm.com ([217.140.101.70]:37916 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728009AbfDOQGW (ORCPT ); Mon, 15 Apr 2019 12:06:22 -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 AAFF11684; Mon, 15 Apr 2019 09:06:21 -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 314FD3F68F; Mon, 15 Apr 2019 09:06:20 -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 21/36] coresight: Remove cpu field from platform data Date: Mon, 15 Apr 2019 17:04:04 +0100 Message-Id: <1555344260-12375-22-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 CPU field is only used by ETMs and there is a separate API for fetching the same. So, let us use that instead of using the common platform probing helper. Also, remove it from the platform_data. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm3x.c | 2 +- drivers/hwtracing/coresight/coresight-etm4x.c | 2 +- drivers/hwtracing/coresight/coresight-platform.c | 1 - include/linux/coresight.h | 2 -- 4 files changed, 2 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index fa2164f..722fab96 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -819,7 +819,7 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) return ret; } - drvdata->cpu = pdata ? pdata->cpu : 0; + drvdata->cpu = coresight_get_cpu(dev); cpus_read_lock(); etmdrvdata[drvdata->cpu] = drvdata; diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 998b9f3..ced31d1 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -997,7 +997,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&drvdata->spinlock); - drvdata->cpu = pdata ? pdata->cpu : 0; + drvdata->cpu = coresight_get_cpu(dev); cpus_read_lock(); etmdrvdata[drvdata->cpu] = drvdata; diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 8a86ba3..f1ab1b5 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -316,7 +316,6 @@ 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 a48cd9b..bb7548f 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -91,14 +91,12 @@ union coresight_dev_subtype { /** * struct coresight_platform_data - data harvested from the DT specification - * @cpu: the CPU a source belongs to. Only applicable for ETM/PTMs. * @name: name of the component as shown under sysfs. * @nr_inport: number of input ports for this component. * @nr_outport: number of output ports for this component. * @conns: Array of nr_outport connections from this component */ struct coresight_platform_data { - int cpu; const char *name; int nr_inport; int nr_outport; From patchwork Mon Apr 15 16:04:05 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: 162212 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105697jan; Mon, 15 Apr 2019 09:06:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlMDWRROS4+HaTxB74p+ruJ/d8rfW1S4c7s7F7zF1YZk85DEXLaA/nxFjuXcmsGEiyUuwA X-Received: by 2002:aa7:82cb:: with SMTP id f11mr77380348pfn.0.1555344389564; Mon, 15 Apr 2019 09:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344389; cv=none; d=google.com; s=arc-20160816; b=pgXLS++WIHJnV/fTJsR4CjCOHBu8QbvfDVyu0tc4ynmowCqXSerqCOkvnIho/aqV1M rNUPXqckjD1T2LzZwl8+2DIpaAPB2q4q4vfuiBtddR7lNZV4pQnpni50yNfyk7Al51Hy LAws28o1P8OIukvEwj7Ak+kigFNyDfClotPbLny+XWo1fWVHAFfdrp+AqDAcc0kJu8Db M76u0AcZBXCPPSk5MnrXp6xlZPybv4RMYKpuYxI1lz6JiSswh7cSTEccXNNwLw6QAPNa PFNFaZfGGx+F6KE5gQrvDA0bkurJsZuFn4r629ZrH2Xo8pdzvOXJoF8ZwdQMXTbd7+UL vhpQ== 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=ehm+zKfrA4lO6v7pauXMB6X0IUotylfV3bayFyV0lDw=; b=WTDehy5wZKfYriyIt8i10lgR5+mF817ehTgbBJqbS2gtVdR20dDf5D1zZR3P4KoS+4 0XAKPFe8ToQ5aFvLEHhCxrpIagWgrTTji3lYScZNAfIB4nIHJ+iOhZx9byWpfNTIA9Gp Ak5kG3SFwq1/2odT11zpAvDZBzcPzWSl0c17HSpLUfKA0peO+kSaV6h9XRyqMgv0F8U8 ytpTtW42fOvyBDx9omhBHAxoQo1xDbNchef0UhLDV6l1daq0Q0vd6093y9Z7gj43ger1 cP4AavURzljDwYe2V9L6LVt+YK2LwKS06Ne7OXEshO85Av0vvulpM9aTjVfrmFayDQaI +dLg== 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 h63si27853496pge.558.2019.04.15.09.06.29; Mon, 15 Apr 2019 09:06:29 -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 S1728042AbfDOQG2 (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:28 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37924 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728021AbfDOQGY (ORCPT ); Mon, 15 Apr 2019 12:06:24 -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 717D61715; Mon, 15 Apr 2019 09:06:23 -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 E80113F68F; Mon, 15 Apr 2019 09:06:21 -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 22/36] coresight: Remove name from platform description Date: Mon, 15 Apr 2019 17:04:05 +0100 Message-Id: <1555344260-12375-23-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 We are about to use a name independent of the parent AMBA device name. As such, there is no need to have it in the platform description. Let us move this to coresight description instead. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-catu.c | 2 ++ drivers/hwtracing/coresight/coresight-etb10.c | 3 ++- drivers/hwtracing/coresight/coresight-etm3x.c | 1 + drivers/hwtracing/coresight/coresight-etm4x.c | 1 + drivers/hwtracing/coresight/coresight-funnel.c | 1 + drivers/hwtracing/coresight/coresight-platform.c | 3 --- drivers/hwtracing/coresight/coresight-replicator.c | 2 ++ drivers/hwtracing/coresight/coresight-stm.c | 1 + drivers/hwtracing/coresight/coresight-tmc.c | 5 +++-- drivers/hwtracing/coresight/coresight-tpiu.c | 1 + drivers/hwtracing/coresight/coresight.c | 2 +- include/linux/coresight.h | 8 ++++---- 12 files changed, 19 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index 65b86ec..03f5b95 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -551,6 +551,8 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) catu_desc.type = CORESIGHT_DEV_TYPE_HELPER; catu_desc.subtype.helper_subtype = CORESIGHT_DEV_SUBTYPE_HELPER_CATU; catu_desc.ops = &catu_ops; + catu_desc.name = dev_name(dev); + drvdata->csdev = coresight_register(&catu_desc); if (IS_ERR(drvdata->csdev)) ret = PTR_ERR(drvdata->csdev); diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index cd61b54..91a5d7a 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -723,12 +723,13 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &etb_cs_ops; desc.pdata = pdata; desc.dev = dev; + desc.name = dev_name(dev); desc.groups = coresight_etb_groups; drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) return PTR_ERR(drvdata->csdev); - drvdata->miscdev.name = pdata->name; + drvdata->miscdev.name = desc.name; drvdata->miscdev.minor = MISC_DYNAMIC_MINOR; drvdata->miscdev.fops = &etb_fops; ret = misc_register(&drvdata->miscdev); diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 722fab96..101fb01 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -854,6 +854,7 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &etm_cs_ops; desc.pdata = pdata; desc.dev = dev; + desc.name = dev_name(dev); desc.groups = coresight_etm_groups; drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index ced31d1..7ff0989 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -1034,6 +1034,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) desc.pdata = pdata; desc.dev = dev; desc.groups = coresight_etmv4_groups; + desc.name = dev_name(dev); drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { ret = PTR_ERR(drvdata->csdev); diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 2590744..61a9e01 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -216,6 +216,7 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &funnel_cs_ops; desc.pdata = pdata; desc.dev = dev; + desc.name = dev_name(dev); desc.groups = coresight_funnel_groups; drvdata->csdev = coresight_register(&desc); diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index f1ab1b5..0415fff 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -314,9 +314,6 @@ coresight_get_platform_data(struct device *dev) if (!pdata) return ERR_PTR(-ENOMEM); - /* Use device name as sysfs handle */ - pdata->name = dev_name(dev); - if (is_of_node(fwnode)) return of_get_coresight_platform_data(dev, pdata); diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 7eb3bf7..939f20d 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -215,6 +215,8 @@ static int replicator_probe(struct device *dev, struct resource *res) desc.ops = &replicator_cs_ops; desc.pdata = dev->platform_data; desc.dev = dev; + desc.name = dev_name(dev); + drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { ret = PTR_ERR(drvdata->csdev); diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index eae0094..734227f 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -871,6 +871,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &stm_cs_ops; desc.pdata = pdata; desc.dev = dev; + desc.name = dev_name(dev); desc.groups = coresight_stm_groups; drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 7dbdf59..02c5cb5 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -433,6 +433,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) desc.pdata = pdata; desc.dev = dev; desc.groups = coresight_tmc_groups; + desc.name = dev_name(dev); switch (drvdata->config_type) { case TMC_CONFIG_TYPE_ETB: @@ -455,7 +456,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &tmc_etf_cs_ops; break; default: - pr_err("%s: Unsupported TMC config\n", pdata->name); + pr_err("%s: Unsupported TMC config\n", desc.name); ret = -EINVAL; goto out; } @@ -466,7 +467,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) goto out; } - drvdata->miscdev.name = pdata->name; + drvdata->miscdev.name = desc.name; drvdata->miscdev.minor = MISC_DYNAMIC_MINOR; drvdata->miscdev.fops = &tmc_fops; ret = misc_register(&drvdata->miscdev); diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index eea7fd1..792f1d6 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -154,6 +154,7 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &tpiu_cs_ops; desc.pdata = pdata; desc.dev = dev; + desc.name = dev_name(dev); drvdata->csdev = coresight_register(&desc); if (!IS_ERR(drvdata->csdev)) { diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 55204dd..91c63cd 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1197,7 +1197,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) csdev->dev.parent = desc->dev; csdev->dev.release = coresight_device_release; csdev->dev.bus = &coresight_bustype; - dev_set_name(&csdev->dev, "%s", desc->pdata->name); + dev_set_name(&csdev->dev, "%s", desc->name); ret = device_register(&csdev->dev); if (ret) { diff --git a/include/linux/coresight.h b/include/linux/coresight.h index bb7548f..84a2137 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -91,13 +91,11 @@ union coresight_dev_subtype { /** * struct coresight_platform_data - data harvested from the DT specification - * @name: name of the component as shown under sysfs. * @nr_inport: number of input ports for this component. * @nr_outport: number of output ports for this component. * @conns: Array of nr_outport connections from this component */ struct coresight_platform_data { - const char *name; int nr_inport; int nr_outport; struct coresight_connection *conns; @@ -108,11 +106,12 @@ struct coresight_platform_data { * @type: as defined by @coresight_dev_type. * @subtype: as defined by @coresight_dev_subtype. * @ops: generic operations for this component, as defined - by @coresight_ops. + * by @coresight_ops. * @pdata: platform data collected from DT. * @dev: The device entity associated to this component. * @groups: operations specific to this component. These will end up - in the component's sysfs sub-directory. + * in the component's sysfs sub-directory. + * @name: name for the coresight device, also shown under sysfs. */ struct coresight_desc { enum coresight_dev_type type; @@ -121,6 +120,7 @@ struct coresight_desc { struct coresight_platform_data *pdata; struct device *dev; const struct attribute_group **groups; + const char *name; }; /** From patchwork Mon Apr 15 16:04:06 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: 162227 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3107469jan; Mon, 15 Apr 2019 09:07:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqytfX0nj7/LT/PB/tiivPtELPcqGX/4UbQf77pbPwDGcURHUj5cBzqNTtsjoBtw5w9wLQyX X-Received: by 2002:aa7:85cc:: with SMTP id z12mr76061705pfn.142.1555344470923; Mon, 15 Apr 2019 09:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344470; cv=none; d=google.com; s=arc-20160816; b=MC5RGRyvlfNkbvlTVGx8IU3r8dS9xMiIjKAlXkA98jqW4oPXZ4Wey6MHokXBPhMffn 877tDq0AwRlw3cjhimTQbQi0q/wDYywWRt9TKuj/+oWRVv6ertq/tpJKnbk/x77v8hPi NaE1/Ml7PvRj9ksDHXqwh4AiZT1RJeuVA3pNwBj9s6/vHreU6gogOb9SDkpjKvOirPPy BOCRJU+SGTf3m8w+06vsIPxclN2nJHzgVzMHm958r9cYWil49JNYfUBR1jkkPYh66qaV vzozkTpGu5/AnT64EJHldoreE98QbmXT+DPJXSXe6LhlpJ8GDlIODXYTYdjqQgvMsyaf Vymw== 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=A7QNmln8poZlbVc+qbMrbSEzPfmS2GxM0Wh6cJiPCIE=; b=XvtQsOYRAte9ll9XjU1849+xTxv2E7CPt6DxmhBeBEWIfKtCxlKSzERU1PilCD0JlR U1sngZxcb7nnKNs7hti5RlH3LN+jn+jGTwdRf4+aMT8cupv5OvDCfjH4VtOp7G0HvhUy IkugLoTObTBIFpkUad+g29G673kFED1PtZeKhfJVhCXIb8uK6b33zmcsejEZbEnLvksj hnCJEwRud2ZR+8ksy7tXvjs+z4pvDDV7JdQr1qqccC9B8F1LS621P06BZyYUU4fjko8e xo2QS+xypqI8rvpdM2VmVu27t76Kvw2JFWEQ7QzT4Yxg+ZaKKBpKHdsplwcXcY4aCUrq dCLw== 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 h13si47185811pgr.133.2019.04.15.09.07.50; Mon, 15 Apr 2019 09:07:50 -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 S1728047AbfDOQHt (ORCPT + 30 others); Mon, 15 Apr 2019 12:07:49 -0400 Received: from foss.arm.com ([217.140.101.70]:37944 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727963AbfDOQGZ (ORCPT ); Mon, 15 Apr 2019 12:06:25 -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 34B6F1A25; Mon, 15 Apr 2019 09:06:25 -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 AE3DC3F68F; Mon, 15 Apr 2019 09:06:23 -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 23/36] coresight: Cleanup coresight_remove_conns Date: Mon, 15 Apr 2019 17:04:06 +0100 Message-Id: <1555344260-12375-24-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 When a device is unregistered, we remove all connection references to it, by searching the connection records of all devices in the coresight bus, via coresight_remove_conns. We could avoid searching if this device doesn't have an input port (e.g, a source). Also document the purpose of the function. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 91c63cd..530ad69 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1094,10 +1094,21 @@ static int coresight_remove_match(struct device *dev, void *data) return 0; } +/* + * coresight_remove_conns - Remove references to this given devices + * from the connections of other devices. + */ static void coresight_remove_conns(struct coresight_device *csdev) { - bus_for_each_dev(&coresight_bustype, NULL, - csdev, coresight_remove_match); + /* + * Another device will point to this device only if there is + * an output port connected to this one. i.e, if the device + * doesn't have at least one input port, there is no point + * in searching all the devices. + */ + if (csdev->nr_inport) + bus_for_each_dev(&coresight_bustype, NULL, + csdev, coresight_remove_match); } /** From patchwork Mon Apr 15 16:04:07 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: 162225 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3107242jan; Mon, 15 Apr 2019 09:07:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzgGnNsTvdS+0d8KZNg+FaPSMlbyORuvOKt80h1qiOqxHL52qwaycF0LDHQKm+agJsJBOb X-Received: by 2002:a62:1c07:: with SMTP id c7mr76298311pfc.159.1555344459166; Mon, 15 Apr 2019 09:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344459; cv=none; d=google.com; s=arc-20160816; b=Q8W24nn6tqEK+WMRhfG2cVHYDzvX2WoxW0iiky6mlRPPiC5PIi/zDsopmXEm9KiGYf 70Vn1nA0eATvZm5uMLKfQmQ/CNGUph1LXuMI7LExSSsS0QyD4sNhG1DMcMypEGzwBZO6 7t6Aee4OaQKjlNWavHk20J0K3N8UmNXgKTU1/HPeWV20OL488kFhu2Dtk8GGiGVgSVJT O97og0BhU5sotTaAorXFjzpk0hJvSKvivAUJCEFu11+7/n9Yrx2lcYW1FRT5A012uJXr mrPqNFwyW4Ugo/ukhwR5CyiphsjEebTUMWVr/8TAXTou/XrvNP7J/4BM7/IhbvrG4YZu t4/g== 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=CZNI28MpFxDy7Wp7sUEXjogBay2OWyjp9wplfYRjhdY=; b=Xi+7/EwBh13kBLAs6vahyDBSTKY+odJ7E5EztCLww20w6lgp0zwbalJQebfTHJk6KY ghA8/wimeyEb6GDfwnHprgEE8WGhhCchzE1HdwkLaIb16ONKf2piO8OreVLoIVN1aSP9 PPoydggECiQhaSd7w7U5Hj8X52ZwTCPIchpl3kaQa5PNSHsxngE86osPxQC2mIT8Gaz0 PFzHlNNN+IsqC3VIaj5bJZ71d+GOCThP3iqEV2yVn9056ahopWLnLtQzyNzaYdl1CCIv DknW6ls7xLw8IgJtX2yRzthq78iEuUZa3wx+89mhFkLytXyrrN1cw22cpxWYbtZeX9b4 3Xqw== 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 s5si17623919pfm.234.2019.04.15.09.07.38; Mon, 15 Apr 2019 09:07:39 -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 S1727754AbfDOQGb (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:31 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37958 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728035AbfDOQG2 (ORCPT ); Mon, 15 Apr 2019 12:06:28 -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 EAEE61AC1; Mon, 15 Apr 2019 09:06:26 -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 712B73F68F; Mon, 15 Apr 2019 09:06:25 -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 24/36] coresight: Reuse platform data structure for connection tracking Date: Mon, 15 Apr 2019 17:04:07 +0100 Message-Id: <1555344260-12375-25-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 platform specific information describes the connections and the ports of a given coresigh device. This information is also recorded in the coresight device as separate fields. Let us reuse the original platform description to streamline the handling of the data. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 4 +-- drivers/hwtracing/coresight/coresight.c | 46 ++++++++++++------------- include/linux/coresight.h | 8 ++--- 3 files changed, 27 insertions(+), 31 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 0911f9c..d3ff2c7 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -747,8 +747,8 @@ tmc_etr_get_catu_device(struct tmc_drvdata *drvdata) if (!IS_ENABLED(CONFIG_CORESIGHT_CATU)) return NULL; - for (i = 0; i < etr->nr_outport; i++) { - tmp = etr->conns[i].child_dev; + for (i = 0; i < etr->pdata->nr_outport; i++) { + tmp = etr->pdata->conns[i].child_dev; if (tmp && coresight_is_catu_device(tmp)) return tmp; } diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 530ad69..f6c5244 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -100,8 +100,8 @@ static int coresight_find_link_inport(struct coresight_device *csdev, int i; struct coresight_connection *conn; - for (i = 0; i < parent->nr_outport; i++) { - conn = &parent->conns[i]; + for (i = 0; i < parent->pdata->nr_outport; i++) { + conn = &parent->pdata->conns[i]; if (conn->child_dev == csdev) return conn->child_port; } @@ -118,8 +118,8 @@ static int coresight_find_link_outport(struct coresight_device *csdev, int i; struct coresight_connection *conn; - for (i = 0; i < csdev->nr_outport; i++) { - conn = &csdev->conns[i]; + for (i = 0; i < csdev->pdata->nr_outport; i++) { + conn = &csdev->pdata->conns[i]; if (conn->child_dev == child) return conn->outport; } @@ -304,10 +304,10 @@ static void coresight_disable_link(struct coresight_device *csdev, if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) { refport = inport; - nr_conns = csdev->nr_inport; + nr_conns = csdev->pdata->nr_inport; } else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT) { refport = outport; - nr_conns = csdev->nr_outport; + nr_conns = csdev->pdata->nr_outport; } else { refport = 0; nr_conns = 1; @@ -593,9 +593,10 @@ static void coresight_grab_device(struct coresight_device *csdev) { int i; - for (i = 0; i < csdev->nr_outport; i++) { - struct coresight_device *child = csdev->conns[i].child_dev; + for (i = 0; i < csdev->pdata->nr_outport; i++) { + struct coresight_device *child; + child = csdev->pdata->conns[i].child_dev; if (child && child->type == CORESIGHT_DEV_TYPE_HELPER) pm_runtime_get_sync(child->dev.parent); } @@ -611,9 +612,10 @@ static void coresight_drop_device(struct coresight_device *csdev) int i; pm_runtime_put(csdev->dev.parent); - for (i = 0; i < csdev->nr_outport; i++) { - struct coresight_device *child = csdev->conns[i].child_dev; + for (i = 0; i < csdev->pdata->nr_outport; i++) { + struct coresight_device *child; + child = csdev->pdata->conns[i].child_dev; if (child && child->type == CORESIGHT_DEV_TYPE_HELPER) pm_runtime_put(child->dev.parent); } @@ -643,9 +645,10 @@ static int _coresight_build_path(struct coresight_device *csdev, goto out; /* Not a sink - recursively explore each port found on this element */ - for (i = 0; i < csdev->nr_outport; i++) { - struct coresight_device *child_dev = csdev->conns[i].child_dev; + for (i = 0; i < csdev->pdata->nr_outport; i++) { + struct coresight_device *child_dev; + child_dev = csdev->pdata->conns[i].child_dev; if (child_dev && _coresight_build_path(child_dev, sink, path) == 0) { found = true; @@ -998,8 +1001,8 @@ static int coresight_orphan_match(struct device *dev, void *data) * Circle throuch all the connection of that component. If we find * an orphan connection whose name matches @csdev, link it. */ - for (i = 0; i < i_csdev->nr_outport; i++) { - conn = &i_csdev->conns[i]; + for (i = 0; i < i_csdev->pdata->nr_outport; i++) { + conn = &i_csdev->pdata->conns[i]; /* We have found at least one orphan connection */ if (conn->child_dev == NULL) { @@ -1038,8 +1041,8 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev) { int i; - for (i = 0; i < csdev->nr_outport; i++) { - struct coresight_connection *conn = &csdev->conns[i]; + for (i = 0; i < csdev->pdata->nr_outport; i++) { + struct coresight_connection *conn = &csdev->pdata->conns[i]; struct device *dev = NULL; if (conn->child_name) @@ -1073,8 +1076,8 @@ static int coresight_remove_match(struct device *dev, void *data) * Circle throuch all the connection of that component. If we find * a connection whose name matches @csdev, remove it. */ - for (i = 0; i < iterator->nr_outport; i++) { - conn = &iterator->conns[i]; + for (i = 0; i < iterator->pdata->nr_outport; i++) { + conn = &iterator->pdata->conns[i]; if (conn->child_dev == NULL) continue; @@ -1106,7 +1109,7 @@ static void coresight_remove_conns(struct coresight_device *csdev) * doesn't have at least one input port, there is no point * in searching all the devices. */ - if (csdev->nr_inport) + if (csdev->pdata->nr_inport) bus_for_each_dev(&coresight_bustype, NULL, csdev, coresight_remove_match); } @@ -1193,10 +1196,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) csdev->refcnt = refcnts; - csdev->nr_inport = desc->pdata->nr_inport; - csdev->nr_outport = desc->pdata->nr_outport; - - csdev->conns = desc->pdata->conns; + csdev->pdata = desc->pdata; csdev->type = desc->type; csdev->subtype = desc->subtype; diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 84a2137..8c10def 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -140,9 +140,7 @@ struct coresight_connection { /** * struct coresight_device - representation of a device as used by the framework - * @conns: array of coresight_connections associated to this component. - * @nr_inport: number of input port associated to this component. - * @nr_outport: number of output port associated to this component. + * @pdata: Platform data with device connections associated to this device. * @type: as defined by @coresight_dev_type. * @subtype: as defined by @coresight_dev_subtype. * @ops: generic operations for this component, as defined @@ -157,9 +155,7 @@ struct coresight_connection { * @ea: Device attribute for sink representation under PMU directory. */ struct coresight_device { - struct coresight_connection *conns; - int nr_inport; - int nr_outport; + struct coresight_platform_data *pdata; enum coresight_dev_type type; union coresight_dev_subtype subtype; const struct coresight_ops *ops; From patchwork Mon Apr 15 16:04:08 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: 162213 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105781jan; Mon, 15 Apr 2019 09:06:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw931mEyF4qH27RB58Iaw7mcZI51mG1tlLc9Wdu7ufDcb0lRxglkcqAjhMDxxr/MOpPiVfx X-Received: by 2002:a62:5fc7:: with SMTP id t190mr28858677pfb.191.1555344393572; Mon, 15 Apr 2019 09:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344393; cv=none; d=google.com; s=arc-20160816; b=QHIKJOAuCMVeSOwKOg6a7BP2wLx3izjDxkACknp2mxvVpIWRrzz02J6EHL/a1KagP3 xP21qECre9eSHnf6Y0x3hS4EBq5NJ1C7lMriWXvq+hLcQqa9cv/hLy36QeTEJz60K9pH zqHhx0U9j/dbce+97GFLc4/cHyqmID4EaEYGPWioMTgZpcMCjCOjzrs+59RJU0vHqkpL C74yvAwwR21dtfXymfEj6FxZCWWUfg8hP7H3mm6e0SFHohmye1LWH1KfmwdRVcTjfGdv 5nBsCJMe1/y7QIAlvUmzqeBn63AtUHc+Lgt2v7CHq2qvY+nY8YplE/62hxkR3zJccCN6 lHog== 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=WzRP7qp0LldQLGFHfDGsfvzIbP/Ab65B+6JM1ceXnuI=; b=AswAyQIohgHpmZERAzg73HhaUWaxgJsp5kQZqom/JQYijd4LM0OogoKE3lalJTqTBo NZUg8GbQn8j2677qQUm2Ck6AuvqjRKcMGf7kCzo2LT+crAImGC3WSBEjtfleEjiM0Y6n PuqoSex/lGzBhN5zDeNTsRAxVfnS0tb86bs+uYFLt4udDzVCOzHp7FwfVI8MNYVMJ6gd R/W4UlMrXOjzEqJrz9h00KhOUCt/QsEt/9YmaeGuwc1NkAAClcLmFKj3h0IkEmR9Whb7 njQ+nzLtDZGsL+c2hd/pGzLjYxwSJNXhKkz3mk0rZkH/dF+jiB8CrmZF/xurJ+Q1vtyc FlcQ== 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 h63si27853496pge.558.2019.04.15.09.06.33; Mon, 15 Apr 2019 09:06:33 -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 S1728065AbfDOQGc (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:32 -0400 Received: from foss.arm.com ([217.140.101.70]:37976 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728021AbfDOQG3 (ORCPT ); Mon, 15 Apr 2019 12:06:29 -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 AD35F1BB2; Mon, 15 Apr 2019 09:06:28 -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 33A873F68F; Mon, 15 Apr 2019 09:06:27 -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 25/36] coresight: Rearrange platform data probing Date: Mon, 15 Apr 2019 17:04:08 +0100 Message-Id: <1555344260-12375-26-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 We are about to introduce methods to clean up the platform data as we switch to tracking the device reference from "name" to "fwnode handles" for device connections. This requires us to drop the fwnode handle references when the data is no longer required - i.e, when the device probe fails or the device gets unregistered. In order to consolidate the invocation of the cleanup, we delay the platform probing to the very last minute, possibly before invoking the coresight_register. Then, we leave the coresight core code to do the clean up. i.e, if the coresight_register fails, it takes care of freeing the data. Otherwise, coresight_unregister will do the necessary operations. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-catu.c | 14 +++++++------- drivers/hwtracing/coresight/coresight-etb10.c | 10 +++++----- drivers/hwtracing/coresight/coresight-etm3x.c | 12 +++++++----- drivers/hwtracing/coresight/coresight-etm4x.c | 10 +++++----- drivers/hwtracing/coresight/coresight-funnel.c | 10 +++++----- drivers/hwtracing/coresight/coresight-replicator.c | 12 +++++++----- drivers/hwtracing/coresight/coresight-stm.c | 11 +++++++---- drivers/hwtracing/coresight/coresight-tmc.c | 16 ++++++++-------- drivers/hwtracing/coresight/coresight-tpiu.c | 9 ++++----- 9 files changed, 55 insertions(+), 49 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index 03f5b95..f249be6 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -505,13 +505,6 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) struct device *dev = &adev->dev; void __iomem *base; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) { - ret = PTR_ERR(pdata); - goto out; - } - dev->platform_data = pdata; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) { ret = -ENOMEM; @@ -544,6 +537,13 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) if (ret) goto out; + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) { + ret = PTR_ERR(pdata); + goto out; + } + dev->platform_data = pdata; + drvdata->base = base; catu_desc.pdata = pdata; catu_desc.dev = dev; diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 91a5d7a..e5b46c7 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -682,11 +682,6 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -718,6 +713,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata->buf) return -ENOMEM; + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + adev->dev.platform_data = pdata; + desc.type = CORESIGHT_DEV_TYPE_SINK; desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; desc.ops = &etb_cs_ops; diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 101fb01..f2d4616 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -795,11 +795,6 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) return -ENOMEM; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - - adev->dev.platform_data = pdata; drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14"); dev_set_drvdata(dev, drvdata); @@ -849,6 +844,13 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) etm_init_trace_id(drvdata); etm_set_default(&drvdata->config); + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) { + ret = PTR_ERR(pdata); + goto err_arch_supported; + } + adev->dev.platform_data = pdata; + desc.type = CORESIGHT_DEV_TYPE_SOURCE; desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC; desc.ops = &etm_cs_ops; diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 7ff0989..7c53fb2 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -981,11 +981,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) return -ENOMEM; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; - dev_set_drvdata(dev, drvdata); /* Validity for the resource is already checked by the AMBA core */ @@ -1028,6 +1023,11 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) etm4_init_trace_id(drvdata); etm4_set_default(&drvdata->config); + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + adev->dev.platform_data = pdata; + desc.type = CORESIGHT_DEV_TYPE_SOURCE; desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC; desc.ops = &etm4_cs_ops; diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 61a9e01..38af045 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -186,11 +186,6 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -211,6 +206,11 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) drvdata->base = base; pm_runtime_put(&adev->dev); + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + adev->dev.platform_data = pdata; + desc.type = CORESIGHT_DEV_TYPE_LINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG; desc.ops = &funnel_cs_ops; diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 939f20d..8fbc028 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -179,11 +179,6 @@ static int replicator_probe(struct device *dev, struct resource *res) struct coresight_desc desc = { 0 }; void __iomem *base; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - dev->platform_data = pdata; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -209,6 +204,13 @@ static int replicator_probe(struct device *dev, struct resource *res) desc.groups = replicator_groups; } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) { + ret = PTR_ERR(pdata); + goto out_disable_clk; + } + dev->platform_data = pdata; + dev_set_drvdata(dev, drvdata); desc.type = CORESIGHT_DEV_TYPE_LINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 734227f..5c7fc4a 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -810,10 +810,6 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) size_t bitmap_size; struct coresight_desc desc = { 0 }; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - adev->dev.platform_data = pdata; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -866,6 +862,13 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) return -EPROBE_DEFER; } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) { + ret = PTR_ERR(pdata); + goto stm_unregister; + } + adev->dev.platform_data = pdata; + desc.type = CORESIGHT_DEV_TYPE_SOURCE; desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE; desc.ops = &stm_cs_ops; diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 02c5cb5..94d3ebf 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -396,13 +396,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) { - ret = PTR_ERR(pdata); - goto out; - } - adev->dev.platform_data = pdata; - ret = -ENOMEM; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) @@ -430,7 +423,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) else drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4; - desc.pdata = pdata; desc.dev = dev; desc.groups = coresight_tmc_groups; desc.name = dev_name(dev); @@ -461,6 +453,14 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) goto out; } + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) { + ret = PTR_ERR(pdata); + goto out; + } + adev->dev.platform_data = pdata; + desc.pdata = pdata; + drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { ret = PTR_ERR(drvdata->csdev); diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 792f1d6..39a509f 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -121,11 +121,6 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - dev->platform_data = pdata; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -148,6 +143,10 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) /* Disable tpiu to support older devices */ tpiu_disable_hw(drvdata); + pdata = coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + dev->platform_data = pdata; desc.type = CORESIGHT_DEV_TYPE_SINK; desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_PORT; From patchwork Mon Apr 15 16:04:09 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: 162226 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3107286jan; Mon, 15 Apr 2019 09:07:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjBIikLTGpC3CnYsaDne//YnmdMAdW8y1fZAsI9l0vYxWHYdGCcgVa5I4VY7KDIdkcrPxM X-Received: by 2002:aa7:8a92:: with SMTP id a18mr77356006pfc.218.1555344461787; Mon, 15 Apr 2019 09:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344461; cv=none; d=google.com; s=arc-20160816; b=D5xfSxtFP+SFego9YbBq3zhi2TcE7C62qiGwo+uOEazA/uznHl/mURTnGvYN3j9uES 9p0pZSQ5IvxmoRPM4IFRh2KfVnQlPflEKNC+XYF5VJA1Njd3Pzq49yq/65KCU7Zxk0gi ajkT3eMx/ao9SYht7CK93B214pBa3H+Mbvynm8lmJ/ZlG1yr3U1al9QV7R5qs30QJVKY HneDot/56P0/7GIysZtRUsLezUOjrbmM7O9me2jOC5Rzkon/wlUKOd7oNSwFA5ecA05G B5CFMa1+5qDJo0Sx+C8vIfXeUiupkG6X6CluW8TtGRblwip/RhmdRwpnzj1gu6KDiNAP kUcw== 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=414eQZsJ77Z2tzyFUkhQQCqxRqawI5Xu1zmqOoIbDBU=; b=Ft+nTl+K9EsLaffICI6joKmnAt45I+SKGJ/ZsuP2yYKCLp6nr/McPzjVpTjq6PaxF9 iKaf4AH7CXNLE8IhTLUN7FP1p9F1dcGZ2Uf3aW9GciLxnoxFcEcw2Sk6wT5/hLHH3E8L M5ZHZFM8AKh4PSUxsA3Apzg54MiVWxzYvou4GcOZsQOwMHMrpePrEpCfSQ6M2R1H6Pvl 86wOcrRjRKdL1nCTWgcNCeyYGE1Q2EEz1dTg6X8hMcGXspQe9J80wFOuFyjzpXvhwAqQ oO9AD0xwhPf+yW3vkemluA6ug9QINTlqMxJ/cHPQGhcdFlAGBhWWewHe6dnruBHKxLoR /Skg== 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 s5si17623919pfm.234.2019.04.15.09.07.41; Mon, 15 Apr 2019 09:07:41 -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 S1727877AbfDOQHk (ORCPT + 30 others); Mon, 15 Apr 2019 12:07:40 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37990 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728047AbfDOQGa (ORCPT ); Mon, 15 Apr 2019 12:06:30 -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 709461A25; Mon, 15 Apr 2019 09:06:30 -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 EA0573F68F; Mon, 15 Apr 2019 09:06:28 -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 26/36] coresight: Add support for releasing platform specific data Date: Mon, 15 Apr 2019 17:04:09 +0100 Message-Id: <1555344260-12375-27-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 Add a helper to clean up the platform specific data provided by the firmware. This will be later used for dropping the necessary references when we switch to the fwnode handles for tracking connections. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-platform.c | 12 +++++++++--- drivers/hwtracing/coresight/coresight-priv.h | 4 ++++ drivers/hwtracing/coresight/coresight.c | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 0415fff..a408b01 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -17,6 +17,7 @@ #include #include +#include "coresight-priv.h" /* * coresight_alloc_conns: Allocate connections record for each output * port from the device. @@ -304,7 +305,7 @@ EXPORT_SYMBOL_GPL(coresight_get_cpu); struct coresight_platform_data * coresight_get_platform_data(struct device *dev) { - struct coresight_platform_data *pdata; + struct coresight_platform_data *pdata, *ret = NULL; struct fwnode_handle *fwnode = dev_fwnode(dev); if (IS_ERR_OR_NULL(fwnode)) @@ -315,8 +316,13 @@ coresight_get_platform_data(struct device *dev) return ERR_PTR(-ENOMEM); if (is_of_node(fwnode)) - return of_get_coresight_platform_data(dev, pdata); + ret = of_get_coresight_platform_data(dev, pdata); - return ERR_PTR(-ENOENT); + if (!IS_ERR_OR_NULL(ret)) + return pdata; + + /* Cleanup the connection information */ + coresight_release_platform_data(pdata); + return ret; } EXPORT_SYMBOL_GPL(coresight_get_platform_data); diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index e0684d0..c216421 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -200,4 +200,8 @@ static inline void *coresight_get_uci_data(const struct amba_id *id) return 0; } +static inline void +coresight_release_platform_data(struct coresight_platform_data *pdata) +{} + #endif diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index f6c5244..82fb411 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1248,6 +1248,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) err_free_csdev: kfree(csdev); err_out: + /* Cleanup the connection information */ + coresight_release_platform_data(desc->pdata); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(coresight_register); @@ -1257,6 +1259,7 @@ void coresight_unregister(struct coresight_device *csdev) etm_perf_del_symlink_sink(csdev); /* Remove references of that device in the topology */ coresight_remove_conns(csdev); + coresight_release_platform_data(csdev->pdata); device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister); From patchwork Mon Apr 15 16:04:10 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: 162214 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105850jan; Mon, 15 Apr 2019 09:06:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLb67o15AGjF+7xJErgUn1YksfzqlxtrMCtt4OCN+iUhASPJYSe1a74zI4IWlrzgVeiXGp X-Received: by 2002:aa7:914d:: with SMTP id 13mr76791449pfi.149.1555344396377; Mon, 15 Apr 2019 09:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344396; cv=none; d=google.com; s=arc-20160816; b=V0sQtVHp0Vnz5KE+4aoGuWCWEF2JwMOSg00Hhhmb0jQq0BPpwozsvtZurqCiu1T8MY kZcnA/kTtenrR2rtqdtpdSOf9CBU94NUq50qCPDaFSvqklv6Hu9o/FBhWFTysvo+KmcB bQJxRjVHBJ5DKMg9ep4TH7qFS8imlktecWptrRP84XtD3arGgWl8rp98Kx4w6GyxydPI cDHU2/3mXmWu2ZP1d9Vu+JT3MLWj16/Si4Dg2EmgsNK0YiJ40tdaKjgq18IFLJLoz1yx wGxLw2Y1HHj9Bz9YxqTfYrOWNjpsf0afy/QbU3QcRUEO53mpvArWqfPvCwFuJC2TeKzz faBA== 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=l7ZbeE+7IXL/SrPJhpshOt18L87W8JQ783MAq+6fvt8=; b=S5B4kGge9wnfpBvuh6su8VhNlJI1ThiOW3I9DEsOGXu1Usq5QBViJ//5zIweSDdY7M RfxGkjApmobvPeS6SFkheFoYucotplrdk6q8owm5cHuLWlNeA4IT1l1GMoO33K+ujnIr FMYsmd54Pa8Xy0nujTx/bcZL+AyVLQjq1KYn/q64Jnr4mt6nL7Jr87w4HVGFmnFHn0b6 J4V2H7fj9JK6Bk0IONDXzqsTYB8t8g1MblZ6idODyV1Wl8W348t9zC+XDZBgAe1CPocT Mo4NIRI5NoyaVrLJQa85N9eH7V0kSbwN+mGjJ+RiOxDG981V/tQpziaErXrTQzFf8l46 YHgw== 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 b23si43326151pgm.517.2019.04.15.09.06.36; Mon, 15 Apr 2019 09:06:36 -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 S1728079AbfDOQGe (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:34 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728021AbfDOQGd (ORCPT ); Mon, 15 Apr 2019 12:06:33 -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 7A8541A25; Mon, 15 Apr 2019 09:06:32 -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 AD8F23F68F; Mon, 15 Apr 2019 09:06:30 -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 , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v2 27/36] drivers: Add a generic helper to match device by fwnode handle Date: Mon, 15 Apr 2019 17:04:10 +0100 Message-Id: <1555344260-12375-28-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 Make the device_fwnode_match() a generic helper to match device by fwnode handle for use with bus_find_device(). This will be also used by coresight. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/base/devcon.c | 5 ----- drivers/base/property.c | 6 ++++++ include/linux/property.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c index 04db9ae..f4a9e30 100644 --- a/drivers/base/devcon.c +++ b/drivers/base/devcon.c @@ -107,11 +107,6 @@ static struct bus_type *generic_match_buses[] = { NULL, }; -static int device_fwnode_match(struct device *dev, void *fwnode) -{ - return dev_fwnode(dev) == fwnode; -} - static void *device_connection_fwnode_match(struct device_connection *con) { struct bus_type *bus; diff --git a/drivers/base/property.c b/drivers/base/property.c index 8b91ab3..d10d923 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -25,6 +25,12 @@ struct fwnode_handle *dev_fwnode(struct device *dev) } EXPORT_SYMBOL_GPL(dev_fwnode); +int device_fwnode_match(struct device *dev, void *fwnode) +{ + return dev_fwnode(dev) == fwnode; +} +EXPORT_SYMBOL_GPL(device_fwnode_match); + /** * device_property_present - check if a property of a device is present * @dev: Device whose property is being checked diff --git a/include/linux/property.h b/include/linux/property.h index 65d3420..c8fd3d42 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -34,6 +34,7 @@ enum dev_dma_attr { }; struct fwnode_handle *dev_fwnode(struct device *dev); +int device_fwnode_match(struct device *dev, void *fwnode); bool device_property_present(struct device *dev, const char *propname); int device_property_read_u8_array(struct device *dev, const char *propname, From patchwork Mon Apr 15 16:04:11 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: 162215 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3105973jan; Mon, 15 Apr 2019 09:06:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5ogq7oJy4hHU/drbSDksEGo7HrfZZK6Y3LHxbz6mksoJwPA8TIFFSnj0+qwOEnUnrWNKc X-Received: by 2002:a17:902:469:: with SMTP id 96mr75081764ple.46.1555344402121; Mon, 15 Apr 2019 09:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344402; cv=none; d=google.com; s=arc-20160816; b=MmmZtX5KtP2mRf4kII7Q51lCzwBX174M5bk6xm9t8izeQJ+tN6StbR6qLJjqIXyNbq TWaSCKyOyLg19X4/gtJmhUK6EjViX1vUXPZPH7emeAeth4o7nzdAXpGcdMJHsWBIeZ32 dzQsUovm1vxgg7D+7u05+XwkZlRyQ493MXUbAqjsapXz0pfcRWkGYm0rMdBXNET5/lFE sOJxdURnIkm5NtLMkvBGvyjyQG0je9TNYqvRUbuTiZ+/hTtii97xgtb3FfnSgfDrQ0o/ A5yqPBGEtQM3I3a0EQC8k8E75o1e6fq1wW+Bmj3v8hze3xn13JsVWL9mEHZVL1sWuiGh EYzA== 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=CxfKgn5zqd9yiPaZOsyI4sX4t2LNHe9h+XDyYkySIno=; b=CAq4bp8UoTrU4geO48oFSq9WoFgLVvhWrq7fp0pKqlFSmNpSIEFfbvLBYPOfFh2dCn KklUyoUyZKHHivCYxa0ymI2zgm7umraEJka7GSmPSxyAjM86nle24nekkpFsFiAjT9x7 lM4/kXybHqDHx6AmJEg1HNDYw3lvJ0/FDJw26eFgrutjMjbRbn0G2idqy7L1Lyy4AAEb SccgpEmQTYtp24eAUtmMg3P9wbvETOJ1/0k4jnsL4/Sb9wHhwSn3RjMVa0VFgJav0AlH 805Xi10Robj0QhNq61+DFz0JDgRH4ACC1d1ecp5vPMjReWW7s2m0JM8yKCqfmQGTcRv6 i1Ig== 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 b23si43326151pgm.517.2019.04.15.09.06.41; Mon, 15 Apr 2019 09:06:42 -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 S1728098AbfDOQGk (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:40 -0400 Received: from foss.arm.com ([217.140.101.70]:38020 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728070AbfDOQGe (ORCPT ); Mon, 15 Apr 2019 12:06:34 -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 3D6211AC1; Mon, 15 Apr 2019 09:06:34 -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 B73993F68F; Mon, 15 Apr 2019 09:06:32 -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 28/36] coresight: platform: Use fwnode handle for device search Date: Mon, 15 Apr 2019 17:04:11 +0100 Message-Id: <1555344260-12375-29-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 We match of_node while searching for a device. Make this more generic in preparation for the ACPI support by using fwnode_handle. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-platform.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index a408b01..318a6ff 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -36,14 +36,8 @@ static int coresight_alloc_conns(struct device *dev, return 0; } -#ifdef CONFIG_OF -static int of_dev_node_match(struct device *dev, void *data) -{ - return dev->of_node == data; -} - static struct device * -of_coresight_get_endpoint_device(struct device_node *endpoint) +coresight_find_device_by_fwnode(struct fwnode_handle *fwnode) { struct device *dev = NULL; @@ -52,7 +46,7 @@ of_coresight_get_endpoint_device(struct device_node *endpoint) * platform bus. */ dev = bus_find_device(&platform_bus_type, NULL, - endpoint, of_dev_node_match); + fwnode, device_fwnode_match); if (dev) return dev; @@ -61,9 +55,10 @@ of_coresight_get_endpoint_device(struct device_node *endpoint) * looking for the device that matches the endpoint node. */ return bus_find_device(&amba_bustype, NULL, - endpoint, of_dev_node_match); + fwnode, device_fwnode_match); } +#ifdef CONFIG_OF static inline bool of_coresight_legacy_ep_is_input(struct device_node *ep) { return of_property_read_bool(ep, "slave-mode"); @@ -191,6 +186,7 @@ static int of_coresight_parse_endpoint(struct device *dev, struct device_node *rparent = NULL; struct device_node *rep = NULL; struct device *rdev = NULL; + struct fwnode_handle *rdev_fwnode; do { /* Parse the local port details */ @@ -209,8 +205,9 @@ static int of_coresight_parse_endpoint(struct device *dev, if (of_graph_parse_endpoint(rep, &rendpoint)) break; + rdev_fwnode = of_fwnode_handle(rparent); /* If the remote device is not available, defer probing */ - rdev = of_coresight_get_endpoint_device(rparent); + rdev = coresight_find_device_by_fwnode(rdev_fwnode); if (!rdev) { ret = -EPROBE_DEFER; break; From patchwork Mon Apr 15 16:04:12 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: 162223 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106968jan; Mon, 15 Apr 2019 09:07:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqylAthaCGbnKVEbeCFi9R127NqpGPhxSoJ7ziZjGcvVt7KhKEeH3zugOXy81gzG1mC8E/7x X-Received: by 2002:a17:902:2bc9:: with SMTP id l67mr59333390plb.237.1555344446788; Mon, 15 Apr 2019 09:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344446; cv=none; d=google.com; s=arc-20160816; b=Evwa/ldmklQt7gU3+ZLruV/BFWRa+0zVver9mTsAhjQdJEMXUduDjIhK9w26royNk1 qoDO/rxdW3QTiLUmiE+yIlo9ohwWRyoY6VpAA6utACqkTgSk0c2un/WqyHeGXG0x1Q14 p0fTQtrH0Y6FrrUxanZkG/pbdTHOnFj5A4d/4l9Isjrv+9hwVDIPz3TujZWMXJ8jE1iF 2Tz4d/eOdPtC+fQNe8tFig0tadQnZ5zC1c9dD+MIGYyzHCjmJsg6W5UJRKuj6S4pgCvi psaJC7egvpcBEwaLH+9DH4dE+/WSEogxPFFcVEpW0HkTWiSpxT3LKCGnYzZAOBCN9zvZ Sb9g== 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=N7UJ5/U3Qc6TQKdtlYq5UFT0iF+7WgxU86vP7uQ/uSM=; b=rqbHHV8CBcjSEE35Cowr47U0d93eWvPfLJExe12HkelFDZFTZ32WoVZL2VngKUGJKo 2m7K3CBJ862lHav0+yxIecEyUIk9qV9C78ncJVXOlSryStYg/PUoZ2IC6wME+8DVU32Y DusliP/b6tUDJY5EmF38htfuO4lx3K1NmF+tDDKfCW7pMWrrZ261HOUcMFpyWCO/ny9/ frdZrg5L5cvPwaxvmXVuPq4qkKcXQoRh2dEt43Z3gYDnsqkxgC+dXfn76IjhXhf9iM0/ zewB5iaqfJoSw7OAuznIQwKe8S9PCO/3l9VD+nGPFwtih03oxKa4B7oUXPZ33wt2/E6B q9FA== 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 i195si45006724pgd.521.2019.04.15.09.07.26; Mon, 15 Apr 2019 09:07:26 -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 S1728087AbfDOQGi (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:38 -0400 Received: from foss.arm.com ([217.140.101.70]:38036 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728069AbfDOQGg (ORCPT ); Mon, 15 Apr 2019 12:06:36 -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 F40F41AC1; Mon, 15 Apr 2019 09:06:35 -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 7A2693F68F; Mon, 15 Apr 2019 09:06:34 -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 29/36] coresight: Use fwnode handle instead of device names Date: Mon, 15 Apr 2019 17:04:12 +0100 Message-Id: <1555344260-12375-30-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 We rely on the device names to find a CoreSight device on the coresight bus. The device name however is obtained from the platform, which is bound to the real platform/amba device. As we are about to use different naming scheme for the coresight devices, we can't rely on the platform device name to find the corresponding coresight device. Instead we use the platform agnostic "fwnode handle" of the parent device to find the devices. We also reuse the same fwnode as the parent for the Coresight device we create. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-platform.c | 12 +++++-- drivers/hwtracing/coresight/coresight-priv.h | 4 +-- drivers/hwtracing/coresight/coresight.c | 42 +++++++++++++++++++----- include/linux/coresight.h | 4 +-- 4 files changed, 46 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 318a6ff..c9a59fb 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -214,9 +214,15 @@ static int of_coresight_parse_endpoint(struct device *dev, } conn->outport = endpoint.port; - conn->child_name = devm_kstrdup(dev, - dev_name(rdev), - GFP_KERNEL); + /* + * Hold the refcount to the target device. This could be + * released via: + * 1) coresight_release_platform_data() if the probe fails or + * this device is unregistered. + * 2) While removing the target device via + * coresight_remove_match() + */ + conn->child_fwnode = fwnode_handle_get(rdev_fwnode); conn->child_port = rendpoint.port; /* Connection record updated */ ret = 1; diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index c216421..61d7f9f 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -200,8 +200,6 @@ static inline void *coresight_get_uci_data(const struct amba_id *id) return 0; } -static inline void -coresight_release_platform_data(struct coresight_platform_data *pdata) -{} +void coresight_release_platform_data(struct coresight_platform_data *pdata); #endif diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 82fb411..5169ce1 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -976,6 +976,7 @@ static void coresight_device_release(struct device *dev) { struct coresight_device *csdev = to_coresight_device(dev); + fwnode_handle_put(csdev->dev.fwnode); kfree(csdev->refcnt); kfree(csdev); } @@ -1007,13 +1008,11 @@ static int coresight_orphan_match(struct device *dev, void *data) /* We have found at least one orphan connection */ if (conn->child_dev == NULL) { /* Does it match this newly added device? */ - if (conn->child_name && - !strcmp(dev_name(&csdev->dev), conn->child_name)) { + if (conn->child_fwnode == csdev->dev.fwnode) conn->child_dev = csdev; - } else { + else /* This component still has an orphan */ still_orphan = true; - } } } @@ -1045,9 +1044,9 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev) struct coresight_connection *conn = &csdev->pdata->conns[i]; struct device *dev = NULL; - if (conn->child_name) - dev = bus_find_device_by_name(&coresight_bustype, NULL, - conn->child_name); + dev = bus_find_device(&coresight_bustype, NULL, + (void *)conn->child_fwnode, + device_fwnode_match); if (dev) { conn->child_dev = to_coresight_device(dev); /* and put reference from 'bus_find_device()' */ @@ -1082,9 +1081,15 @@ static int coresight_remove_match(struct device *dev, void *data) if (conn->child_dev == NULL) continue; - if (!strcmp(dev_name(&csdev->dev), conn->child_name)) { + if (csdev->dev.fwnode == conn->child_fwnode) { iterator->orphan = true; conn->child_dev = NULL; + /* + * Drop the reference to the handle for the remote + * device acquired in parsing the connections from + * platform data. + */ + fwnode_handle_put(conn->child_fwnode); /* No need to continue */ break; } @@ -1164,6 +1169,22 @@ static int __init coresight_init(void) } postcore_initcall(coresight_init); +/* + * coresight_release_platform_data: Release references to the devices connected + * to the output port of this device. + */ +void coresight_release_platform_data(struct coresight_platform_data *pdata) +{ + int i; + + for (i = 0; i < pdata->nr_outport; i++) { + if (pdata->conns[i].child_fwnode) { + fwnode_handle_put(pdata->conns[i].child_fwnode); + pdata->conns[i].child_fwnode = 0; + } + } +} + struct coresight_device *coresight_register(struct coresight_desc *desc) { int ret; @@ -1208,6 +1229,11 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) csdev->dev.parent = desc->dev; csdev->dev.release = coresight_device_release; csdev->dev.bus = &coresight_bustype; + /* + * Hold the reference to our parent device. This will be + * dropped only in coresight_device_release(). + */ + csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev)); dev_set_name(&csdev->dev, "%s", desc->name); ret = device_register(&csdev->dev); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 8c10def..188e759 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -126,15 +126,15 @@ struct coresight_desc { /** * struct coresight_connection - representation of a single connection * @outport: a connection's output port number. - * @chid_name: remote component's name. * @child_port: remote component's port number @output is connected to. + * @chid_fwnode: remote component's fwnode handle. * @child_dev: a @coresight_device representation of the component connected to @outport. */ struct coresight_connection { int outport; - const char *child_name; int child_port; + struct fwnode_handle *child_fwnode; struct coresight_device *child_dev; }; From patchwork Mon Apr 15 16:04:13 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: 162224 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3107054jan; Mon, 15 Apr 2019 09:07:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXeAvRPB7GJjeHum1uzRtW8Hr+4lbZ064R/5ui5uaGuza51c1M07DMP+os/s1V0Ee+AP84 X-Received: by 2002:a63:f40d:: with SMTP id g13mr72537125pgi.345.1555344450683; Mon, 15 Apr 2019 09:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344450; cv=none; d=google.com; s=arc-20160816; b=JAqB+mXHe0wPEoAZiI4m51L4wA7aCwgTQSWCDWAblgjX9E+gXw23qfwDcXN8OGJunT iJnUAteLvJ4gXg518CbTIWR8aXFMhacX51zuwIdXNrTxyaZngR4340SshuAK9hzV0v6+ /gOrfqi/hB6fOfRU6K1KED3X9PdnmeETi6neAvf8i86u0iHoTcl6UQwzXH7y5LSQp/un x1FsZA8kOwCaKVYiupZ61xALnkHcL0VjTjhFWrd/pljITeJpoFB0ZMEbppox/EOHh7hQ x7IWS7PhQQtfVSBXtQ/uSLKbUAnswo005IZB931O1xyaUdejNXFyh/1AecWiEFqC3H9G FsJg== 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=1RWpDbcSfjHyj06WjQujCru+rrMgRqocs60U5TOsP8w=; b=wFmzK3/RkN3wN99RLH2n6Da7tNITYN70T0Mw9sOw0WgO4ruNaUDfhZie7vizYobnY4 iKv015AL6BnFX5TM6AUCEbQ/NX824GR/t0HlZOwBgyhFQa2uU579c61My6BL1jZalQDG LgPOU007Jnh4sjfpiyRGOoTZoMC1wuY/QAkRJKT5IK1PPjCKm8qMTayNorjgjtVEbtih +sVRvc7IO9sVMuVSC1w2fqYydG8GEzHBqtagO1wNTm+G3cMIdvVeZTj5/TxPyECx3U5L y3BOd+JnC0MGRWXm7ffhnG0sMWD581UxDrcfRcW3y+lt7bUP1cLJcTUEqAQvnQm7HuCH 4bZQ== 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 i195si45006724pgd.521.2019.04.15.09.07.30; Mon, 15 Apr 2019 09:07: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 S1727767AbfDOQH3 (ORCPT + 30 others); Mon, 15 Apr 2019 12:07:29 -0400 Received: from foss.arm.com ([217.140.101.70]:38046 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbfDOQGi (ORCPT ); Mon, 15 Apr 2019 12:06:38 -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 B69A01A25; Mon, 15 Apr 2019 09:06:37 -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 3CB383F68F; Mon, 15 Apr 2019 09:06:36 -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 30/36] coresight: Use platform agnostic names Date: Mon, 15 Apr 2019 17:04:13 +0100 Message-Id: <1555344260-12375-31-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 So far we have reused the name of the "platform" device for the CoreSight device. But this is not very intuitive when we move to ACPI. Also, the ACPI device names have ":" in them (e.g, ARMHC97C:01), which the perf tool doesn't like very much. This patch introduces a generic naming scheme, givin more intuitive names for the devices that appear on the CoreSight bus. The names follow the pattern "prefix" followed by "index" (e.g, etm5). We maintain a list of allocated devices per "prefix" to make sure we don't allocate a new name when it is reprobed (e.g, due to unsatisifed device dependencies). So, we maintain the list of "fwnodes" of the parent devices to allocate a consistent name. All devices except the ETMs get an index allocated in the order of probing. ETMs get an index based on the CPU they are attached to. TMC devices are named using "tmc_etf", "tmc_etb", and "tmc_etr" prefixes depending on the configuration of the device. The replicators are not classified as dynamic/static anymore. One could easily figure that out by checking the presence of "mgmt" registers under sysfs. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-catu.c | 7 ++- drivers/hwtracing/coresight/coresight-etb10.c | 7 ++- drivers/hwtracing/coresight/coresight-etm3x.c | 4 +- drivers/hwtracing/coresight/coresight-etm4x.c | 5 +- drivers/hwtracing/coresight/coresight-funnel.c | 7 ++- drivers/hwtracing/coresight/coresight-replicator.c | 7 ++- drivers/hwtracing/coresight/coresight-stm.c | 12 +++-- drivers/hwtracing/coresight/coresight-tmc.c | 15 +++++- drivers/hwtracing/coresight/coresight-tpiu.c | 7 ++- drivers/hwtracing/coresight/coresight.c | 58 ++++++++++++++++++++++ include/linux/coresight.h | 25 +++++++++- 11 files changed, 142 insertions(+), 12 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index f249be6..e0637fc 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -28,6 +28,8 @@ #define catu_dbg(x, ...) do {} while (0) #endif +DEFINE_CORESIGHT_DEVLIST(catu_devs, "catu"); + struct catu_etr_buf { struct tmc_sg_table *catu_table; dma_addr_t sladdr; @@ -505,6 +507,10 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) struct device *dev = &adev->dev; void __iomem *base; + catu_desc.name = coresight_alloc_device_name(&catu_devs, dev); + if (!catu_desc.name) + return -ENOMEM; + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) { ret = -ENOMEM; @@ -551,7 +557,6 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) catu_desc.type = CORESIGHT_DEV_TYPE_HELPER; catu_desc.subtype.helper_subtype = CORESIGHT_DEV_SUBTYPE_HELPER_CATU; catu_desc.ops = &catu_ops; - catu_desc.name = dev_name(dev); drvdata->csdev = coresight_register(&catu_desc); if (IS_ERR(drvdata->csdev)) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index e5b46c7..8361b91 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -62,6 +62,8 @@ #define ETB_FFSR_BIT 1 #define ETB_FRAME_SIZE_WORDS 4 +DEFINE_CORESIGHT_DEVLIST(etb_devs, "etb"); + /** * struct etb_drvdata - specifics associated to an ETB component * @base: memory mapped base address for this component. @@ -682,6 +684,10 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; + desc.name = coresight_alloc_device_name(&etb_devs, dev); + if (!desc.name) + return -ENOMEM; + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -723,7 +729,6 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &etb_cs_ops; desc.pdata = pdata; desc.dev = dev; - desc.name = dev_name(dev); desc.groups = coresight_etb_groups; drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index f2d4616..bed7291 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -815,6 +815,9 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) } drvdata->cpu = coresight_get_cpu(dev); + desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu); + if (!desc.name) + return -ENOMEM; cpus_read_lock(); etmdrvdata[drvdata->cpu] = drvdata; @@ -856,7 +859,6 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &etm_cs_ops; desc.pdata = pdata; desc.dev = dev; - desc.name = dev_name(dev); desc.groups = coresight_etm_groups; drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 7c53fb2..5c13a04 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -993,6 +993,10 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&drvdata->spinlock); drvdata->cpu = coresight_get_cpu(dev); + desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu); + if (!desc.name) + return -ENOMEM; + cpus_read_lock(); etmdrvdata[drvdata->cpu] = drvdata; @@ -1034,7 +1038,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) desc.pdata = pdata; desc.dev = dev; desc.groups = coresight_etmv4_groups; - desc.name = dev_name(dev); drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { ret = PTR_ERR(drvdata->csdev); diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 38af045..9b820b1 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -27,6 +27,8 @@ #define FUNNEL_HOLDTIME (0x7 << FUNNEL_HOLDTIME_SHFT) #define FUNNEL_ENSx_MASK 0xff +DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel"); + /** * struct funnel_drvdata - specifics associated to a funnel component * @base: memory mapped base address for this component. @@ -186,6 +188,10 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; + desc.name = coresight_alloc_device_name(&funnel_devs, dev); + if (!desc.name) + return -ENOMEM; + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -216,7 +222,6 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &funnel_cs_ops; desc.pdata = pdata; desc.dev = dev; - desc.name = dev_name(dev); desc.groups = coresight_funnel_groups; drvdata->csdev = coresight_register(&desc); diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 8fbc028..2eb489c 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -22,6 +22,8 @@ #define REPLICATOR_IDFILTER0 0x000 #define REPLICATOR_IDFILTER1 0x004 +DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); + /** * struct replicator_drvdata - specifics associated to a replicator component * @base: memory mapped base address for this component. Also indicates @@ -179,6 +181,10 @@ static int replicator_probe(struct device *dev, struct resource *res) struct coresight_desc desc = { 0 }; void __iomem *base; + desc.name = coresight_alloc_device_name(&replicator_devs, dev); + if (!desc.name) + return -ENOMEM; + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -217,7 +223,6 @@ static int replicator_probe(struct device *dev, struct resource *res) desc.ops = &replicator_cs_ops; desc.pdata = dev->platform_data; desc.dev = dev; - desc.name = dev_name(dev); drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 5c7fc4a..2d6ae00 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -107,6 +107,8 @@ struct channel_space { unsigned long *guaranteed; }; +DEFINE_CORESIGHT_DEVLIST(stm_devs, "stm"); + /** * struct stm_drvdata - specifics associated to an STM component * @base: memory mapped base address for this component. @@ -810,6 +812,10 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) size_t bitmap_size; struct coresight_desc desc = { 0 }; + desc.name = coresight_alloc_device_name(&stm_devs, dev); + if (!desc.name) + return -ENOMEM; + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -854,11 +860,12 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&drvdata->spinlock); stm_init_default_data(drvdata); - stm_init_generic_data(drvdata, dev_name(dev)); + stm_init_generic_data(drvdata, desc.name); if (stm_register_device(dev, &drvdata->stm, THIS_MODULE)) { dev_info(dev, - "stm_register_device failed, probing deferred\n"); + "%s : stm_register_device failed, probing deferred\n", + desc.name); return -EPROBE_DEFER; } @@ -874,7 +881,6 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &stm_cs_ops; desc.pdata = pdata; desc.dev = dev; - desc.name = dev_name(dev); desc.groups = coresight_stm_groups; drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 94d3ebf..8b7b5d0 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -25,6 +25,10 @@ #include "coresight-priv.h" #include "coresight-tmc.h" +DEFINE_CORESIGHT_DEVLIST(etb_devs, "tmc_etb"); +DEFINE_CORESIGHT_DEVLIST(etf_devs, "tmc_etf"); +DEFINE_CORESIGHT_DEVLIST(etr_devs, "tmc_etr"); + void tmc_wait_for_tmcready(struct tmc_drvdata *drvdata) { /* Ensure formatter, unformatter and hardware fifo are empty */ @@ -395,6 +399,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) struct tmc_drvdata *drvdata; struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; + struct coresight_dev_list *dev_list = NULL; ret = -ENOMEM; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); @@ -425,13 +430,13 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) desc.dev = dev; desc.groups = coresight_tmc_groups; - desc.name = dev_name(dev); switch (drvdata->config_type) { case TMC_CONFIG_TYPE_ETB: desc.type = CORESIGHT_DEV_TYPE_SINK; desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; desc.ops = &tmc_etb_cs_ops; + dev_list = &etb_devs; break; case TMC_CONFIG_TYPE_ETR: desc.type = CORESIGHT_DEV_TYPE_SINK; @@ -441,11 +446,13 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) coresight_get_uci_data(id)); if (ret) goto out; + dev_list = &etr_devs; break; case TMC_CONFIG_TYPE_ETF: desc.type = CORESIGHT_DEV_TYPE_LINKSINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO; desc.ops = &tmc_etf_cs_ops; + dev_list = &etf_devs; break; default: pr_err("%s: Unsupported TMC config\n", desc.name); @@ -453,6 +460,12 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) goto out; } + desc.name = coresight_alloc_device_name(dev_list, dev); + if (!desc.name) { + ret = -ENOMEM; + goto out; + } + pdata = coresight_get_platform_data(dev); if (IS_ERR(pdata)) { ret = PTR_ERR(pdata); diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 39a509f..0404434 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -46,6 +46,8 @@ #define FFCR_FON_MAN BIT(6) #define FFCR_STOP_FI BIT(12) +DEFINE_CORESIGHT_DEVLIST(tpiu_devs, "tpiu"); + /** * @base: memory mapped base address for this component. * @dev: the device entity associated to this component. @@ -121,6 +123,10 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; + desc.name = coresight_alloc_device_name(&tpiu_devs, dev); + if (!desc.name) + return -ENOMEM; + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -153,7 +159,6 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) desc.ops = &tpiu_cs_ops; desc.pdata = pdata; desc.dev = dev; - desc.name = dev_name(dev); drvdata->csdev = coresight_register(&desc); if (!IS_ERR(drvdata->csdev)) { diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 5169ce1..e3b9321 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1289,3 +1289,61 @@ void coresight_unregister(struct coresight_device *csdev) device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister); + + +/* + * coresight_search_device_idx - Search the fwnode handle of a device + * in the given dev_idx list. Must be called with the coresight_mutex held. + * + * Returns the index of the entry, when found. Otherwise, -ENOENT. + */ +static inline int coresight_search_device_idx(struct coresight_dev_list *dict, + struct fwnode_handle *fwnode) +{ + int i; + + for (i = 0; i < dict->nr_idx; i++) + if (dict->fwnode_list[i] == fwnode) + return i; + return -ENOENT; +} + +/* + * coresight_alloc_device_name - Get an index for a given device in the + * device index list specific to a driver. An index is allocated for a + * device and is tracked with the fwnode_handle to prevent allocating + * duplicate indices for the same device (e.g, if we defer probing of + * a device due to dependencies), in case the index is requested again. + */ +char *coresight_alloc_device_name(struct coresight_dev_list *dict, + struct device *dev) +{ + int idx; + char *name = NULL; + struct fwnode_handle **list; + + mutex_lock(&coresight_mutex); + + idx = coresight_search_device_idx(dict, dev_fwnode(dev)); + if (idx < 0) { + /* Make space for the new entry */ + idx = dict->nr_idx; + list = krealloc(dict->fwnode_list, + (idx + 1) * sizeof(*dict->fwnode_list), + GFP_KERNEL); + if (ZERO_OR_NULL_PTR(list)) { + idx = -ENOMEM; + goto done; + } + + list[idx] = dev_fwnode(dev); + dict->fwnode_list = list; + dict->nr_idx = idx + 1; + } + + name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx); +done: + mutex_unlock(&coresight_mutex); + return name; +} +EXPORT_SYMBOL_GPL(coresight_alloc_device_name); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 188e759..d6367a0 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -168,6 +168,28 @@ struct coresight_device { struct dev_ext_attribute *ea; }; +/* + * coresight_dev_list - Mapping for devices to "name" index for device + * names. + * + * @nr_idx: Number of entries already allocated. + * @pfx: Prefix pattern for device name. + * @fwnode_list: Array of fwnode_handles associated with each allocated + * index, upto nr_idx entries. + */ +struct coresight_dev_list { + int nr_idx; + const char *pfx; + struct fwnode_handle **fwnode_list; +}; + +#define DEFINE_CORESIGHT_DEVLIST(var, dev_pfx) \ +static struct coresight_dev_list (var) = { \ + .pfx = dev_pfx, \ + .nr_idx = 0, \ + .fwnode_list = NULL, \ +} + #define to_coresight_device(d) container_of(d, struct coresight_device, dev) #define source_ops(csdev) csdev->ops->source_ops @@ -260,7 +282,8 @@ extern int coresight_claim_device_unlocked(void __iomem *base); extern void coresight_disclaim_device(void __iomem *base); extern void coresight_disclaim_device_unlocked(void __iomem *base); - +extern char *coresight_alloc_device_name(struct coresight_dev_list *devs, + struct device *dev); #else static inline struct coresight_device * coresight_register(struct coresight_desc *desc) { return NULL; } From patchwork Mon Apr 15 16:04:14 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: 162221 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106779jan; Mon, 15 Apr 2019 09:07:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtS7WAW5rCCLm3Dy9iaRMW7hQ+GJkT3PcCepAhMVQaQUDxPIWYq73xls+hRk2WXmxEupuB X-Received: by 2002:a62:b418:: with SMTP id h24mr75998039pfn.145.1555344437135; Mon, 15 Apr 2019 09:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344437; cv=none; d=google.com; s=arc-20160816; b=H9VgD4NEzd4sTmn9gGpTjCRcwv116XPeoDaxp/DQoD0EAkYmijcX5L3nqa9RdKB5Cp aq3GsNLjF5J8vbzieTIVrHaHaQWuzqctWLpDOgFxdp1Ffsa2YPmLhwdPWDUSTCsLJquR dgASJxQE6D9tpdYM3+A+cb8NA3/E/F5llH5T/kBV5HYHL2sHrC1ii2DbmeKtGK7XK7pA HVuUloDLrdTw9epibrOW5WNVNwJFi+vh22YCxYtWDZ2PUqZwU8RxXfYAHLej3ArULw/N UJ00dNzwL915ShJwsqebRRspJQo6KreyDRcNiKjAbg+xV9aVu3Whg90AZGYd1u4u7np5 ajxw== 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=k9/IqUhzBEf1EbTGCam7SdG7m9maqbNvmh0adI5FB4M=; b=kGrdtZLUtaKnFXIQfWBKMwRtdFvwjC6mFnRKyK2n5OwOCrmtrjPXSzrwD5Wg2QLdZd AVxiqTncoqH1Fl8ePMIWT+mFmGfRSOU9ojLJ0ngBQBuW8ePiP7gzjZHstM5aYBM8jVfF a0/KR7NTQYlBZN5Wb368/Z7LWIf3H1orlgw8HGR0E408jPQsWHzshzbczcl2bPSozT0/ kX7K6pzf4aNlPp9E48ebRe92qUd1/7/6ZK/+Rpw34FoN5dJ1p7olWNme9irRdCRZKGv9 sh1BlPKf5Sy5sTHC3OPobq6Woy8Wa7FqA6E592YlDEXe6yDs0lTujfO3n2Rhq1P4VIm2 6U2A== 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 z2si43694144pgp.239.2019.04.15.09.07.16; Mon, 15 Apr 2019 09:07:17 -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 S1728121AbfDOQGo (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:44 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38056 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728092AbfDOQGj (ORCPT ); Mon, 15 Apr 2019 12:06:39 -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 792611AC1; Mon, 15 Apr 2019 09:06:39 -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 F37C43F68F; Mon, 15 Apr 2019 09:06:37 -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 31/36] coresight: stm: ACPI support for parsing stimulus base Date: Mon, 15 Apr 2019 17:04:14 +0100 Message-Id: <1555344260-12375-32-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 stimulus base for STM device must be listed as the second memory resource, followed by the programming base address as described in "Section 2.3 Resources" in ACPI for CoreSightTM 1.0 Platform Design documen (DEN0067). Add support for parsing the information for ACPI. Cc: Mathieu Poirier Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-stm.c | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 2d6ae00..7cf2fe4 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -16,6 +16,7 @@ * (C) 2015-2016 Chunyan Zhang */ #include +#include #include #include #include @@ -716,10 +717,52 @@ static inline int of_stm_get_stimulus_area(struct device *dev, } #endif +#ifdef CONFIG_ACPI +static int acpi_stm_get_stimulus_area(struct device *dev, struct resource *res) +{ + int rc; + bool found_base = false; + struct resource_entry *rent; + LIST_HEAD(res_list); + + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return -ENODEV; + rc = acpi_dev_get_resources(adev, &res_list, NULL, NULL); + if (rc < 0) + return rc; + + rc = -ENOENT; + list_for_each_entry(rent, &res_list, node) { + if (resource_type(rent->res) != IORESOURCE_MEM) + continue; + if (found_base) { + *res = *rent->res; + rc = 0; + break; + } + + found_base = true; + } + + acpi_dev_free_resource_list(&res_list); + return rc; +} +#else +static inline int acpi_stm_get_stimulus_area(struct device *dev, + struct resource *res) +{ + return -ENOENT; +} +#endif + static int stm_get_stimulus_area(struct device *dev, struct resource *res) { if (dev->of_node) return of_stm_get_stimulus_area(dev, res); + else if (is_acpi_node(dev->fwnode)) + return acpi_stm_get_stimulus_area(dev, res); return -ENOENT; } From patchwork Mon Apr 15 16:04:15 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: 162222 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106869jan; Mon, 15 Apr 2019 09:07:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOT9oefuAjXEgCGav4WD+qu5Wia0l6FXbsRBnOLRUNR03NI0g7zMvOpiI3I0h7op9XevMZ X-Received: by 2002:a62:cfc4:: with SMTP id b187mr75473864pfg.130.1555344441968; Mon, 15 Apr 2019 09:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344441; cv=none; d=google.com; s=arc-20160816; b=J30McYAJM4NuT1bvzAl1lUG1AGGsLPCXjpBba3uv8tYshaHVjRH71qPUR5x6b+lcVB 5Dr/pyI+it0wb5WFVF1PHoArIpCbMryzOwtOLN/BJSoeE4OmbsgUZWnAkPABxuKttlnO uNc2L+x2YIOoLSXPPS6ngrdA0tlhq6Z571MalgF5UDQJY5Rn3i9GhpkD8g34v6tFQeYp FzSjkaBp7sKeB1NhUHLEdIfWOoMtF7ppmkffBfDKEf/V0r/iAnKveu9jCTxUyVSDISvx Hok1S6nN5s+bzBZRy167fRlO2oE2Z377mr8lWqEYz1pybAugan2WgyxCrw8xHIl06B57 Xtug== 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=XBCbVw/4vklfWsS0kyH7RYO48gi/ywQYeEXjE6a83vQ=; b=WXbcDl16FZuNyQdEb1qv1AWklmyNIEI+yT1MKls0fnVD02NPXh14/j6zU3RBU8old1 xxUiy1Yc2yE/EIyLFNY9ab4xpAhig/WHC+e39q24UrXmmKwQzucW+KC9ixOglu3Rn/75 9aMCi95GRTvlnOPUFrzezMISrJAuJvpzdVi8njfwCeOme2YOvs701haMvvQypejMf0hd mpyp95Up0bPSnTddESW8lMG8U/vd6DS0llr6ptPusYR69o6CG3mR9VG2QF9qD12IcI/8 7XEfBiXS2D46Ulplb4/L9xE7UanAPBrMVKtlP/fiQ90UzuWSnzd6DgAbWC3XmxtoartL SkTw== 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 z2si43694144pgp.239.2019.04.15.09.07.21; Mon, 15 Apr 2019 09:07:21 -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 S1728109AbfDOQGo (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:44 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38068 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727762AbfDOQGl (ORCPT ); Mon, 15 Apr 2019 12:06:41 -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 3B8D11A25; Mon, 15 Apr 2019 09:06:41 -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 B60323F68F; Mon, 15 Apr 2019 09:06:39 -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 32/36] coresight: Support for ACPI bindings Date: Mon, 15 Apr 2019 17:04:15 +0100 Message-Id: <1555344260-12375-33-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 Add support for parsing the ACPI platform description for CoreSight. The connections are encoded in a DSD graph property with CoreSight specific variation of the property. The ETMs are listed as the children device of the respective CPU. Cc: "Rafael J. Wysocki" Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-platform.c | 409 +++++++++++++++++++++++ 1 file changed, 409 insertions(+) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index c9a59fb..224f698 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -3,6 +3,7 @@ * Copyright (c) 2012, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -297,10 +298,414 @@ of_get_coresight_platform_data(struct device *dev, } #endif +#ifdef CONFIG_ACPI + +#include +#include + +/* ACPI Graph _DSD UUID : "ab02a46b-74c7-45a2-bd68-f7d344ef2153" */ +static const guid_t acpi_graph_uuid = GUID_INIT(0xab02a46b, 0x74c7, 0x45a2, + 0xbd, 0x68, 0xf7, 0xd3, + 0x44, 0xef, 0x21, 0x53); +/* Coresight ACPI Graph UUID : "3ecbc8b6-1d0e-4fb3-8107-e627f805c6cd" */ +static const guid_t coresight_graph_uuid = GUID_INIT(0x3ecbc8b6, 0x1d0e, 0x4fb3, + 0x81, 0x07, 0xe6, 0x27, + 0xf8, 0x05, 0xc6, 0xcd); +#define ACPI_CORESIGHT_LINK_SLAVE 0 +#define ACPI_CORESIGHT_LINK_MASTER 1 + +static inline bool is_acpi_guid(const union acpi_object *obj) +{ + return (obj->type == ACPI_TYPE_BUFFER) && (obj->buffer.length == 16); +} + +/* + * acpi_guid_matches - Checks if the given object is a GUID object and + * that it matches the supplied the GUID. + */ +static inline bool acpi_guid_matches(const union acpi_object *obj, + const guid_t *guid) +{ + return is_acpi_guid(obj) && + guid_equal((guid_t *)obj->buffer.pointer, guid); +} + +static inline bool is_acpi_dsd_graph_guid(const union acpi_object *obj) +{ + return acpi_guid_matches(obj, &acpi_graph_uuid); +} + +static inline bool is_acpi_coresight_graph_guid(const union acpi_object *obj) +{ + return acpi_guid_matches(obj, &coresight_graph_uuid); +} + +static inline bool is_acpi_coresight_graph(const union acpi_object *obj) +{ + const union acpi_object *graphid, *guid, *links; + + if (obj->type != ACPI_TYPE_PACKAGE || + obj->package.count < 3) + return false; + + graphid = &obj->package.elements[0]; + guid = &obj->package.elements[1]; + links = &obj->package.elements[2]; + + if (graphid->type != ACPI_TYPE_INTEGER || + links->type != ACPI_TYPE_INTEGER) + return false; + + return is_acpi_coresight_graph_guid(guid); +} + +/* + * acpi_validate_dsd_graph - Make sure the given _DSD graph conforms + * to the ACPI _DSD Graph specification. + * + * ACPI Devices Graph property has the following format: + * Revision - Integer, must be 0 + * NumberOfGraphs - Integer, N indicating the following list. + * Graph[1], + * ... + * Graph[N] + * + * And each Graph entry has the following format: + * GraphID - Integer, identifying a graph the device belongs to. + * UUID - UUID identifying the specification that governs + * this graph. (e.g, see is_acpi_coresight_graph()) + * NumberOfLinks - Number "N" of connections on this node of the graph. + * Links[1] + * ... + * Links[N] + */ +static inline bool acpi_validate_dsd_graph(const union acpi_object *graph) +{ + int i, n; + const union acpi_object *rev, *nr_graphs; + + /* The graph must contain at least the Revision and Number of Graphs */ + if (graph->package.count < 2) + return false; + + rev = &graph->package.elements[0]; + nr_graphs = &graph->package.elements[1]; + + if (rev->type != ACPI_TYPE_INTEGER || + nr_graphs->type != ACPI_TYPE_INTEGER) + return false; + + /* We only support revision 0 */ + if (rev->integer.value != 0) + return false; + + n = nr_graphs->integer.value; + /* Make sure the package has right number of elements */ + if (graph->package.count != (n + 2)) + return false; + + /* Each entry must be a graph package with at least 3 members */ + for (i = 2; i < n + 2; i++) { + const union acpi_object *obj = &graph->package.elements[i]; + + if (obj->type != ACPI_TYPE_PACKAGE || + obj->package.count < 3) + return false; + } + + return true; +} + +/* acpi_get_dsd_graph - Find the _DSD Graph property for the given device. */ +const union acpi_object * +acpi_get_dsd_graph(struct acpi_device *adev) +{ + int i; + struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER }; + acpi_status status; + const union acpi_object *dsd; + + status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, + &buf, ACPI_TYPE_PACKAGE); + if (ACPI_FAILURE(status)) + return NULL; + + dsd = buf.pointer; + for (i = 0; i + 1 < dsd->package.count; i += 2) { + const union acpi_object *guid, *package; + + guid = &dsd->package.elements[i]; + package = &dsd->package.elements[i + 1]; + + /* All _DSD elements must have a UUID and a Package */ + if (!is_acpi_guid(guid) || package->type != ACPI_TYPE_PACKAGE) + break; + /* Skip the non-Graph _DSD packages */ + if (!is_acpi_dsd_graph_guid(guid)) + continue; + if (acpi_validate_dsd_graph(package)) + return package; + /* Invalid graph format, continue */ + dev_warn(&adev->dev, "Invalid Graph _DSD property\n"); + } + + return NULL; +} + +static inline bool +acpi_validate_coresight_graph(const union acpi_object *cs_graph) +{ + int nlinks; + + nlinks = cs_graph->package.elements[2].integer.value; + if (cs_graph->package.count != (nlinks + 3)) + return false; + /* The links are validated in acpi_coresight_parse_link() */ + return true; +} + +/* + * acpi_get_coresight_graph - Parse the device _DSD tables and find + * the Graph property matching the CoreSight Graphs. + * + * Returns the pointer to the CoreSight Graph Package when found. Otherwise + * returns NULL. + */ +const union acpi_object * +acpi_get_coresight_graph(struct acpi_device *adev) +{ + const union acpi_object *graph_list, *graph; + int i, nr_graphs; + + graph_list = acpi_get_dsd_graph(adev); + if (!graph_list) + return graph_list; + + nr_graphs = graph_list->package.elements[1].integer.value; + + for (i = 2; i < nr_graphs + 2; i++) { + graph = &graph_list->package.elements[i]; + if (!is_acpi_coresight_graph(graph)) + continue; + if (acpi_validate_coresight_graph(graph)) + return graph; + /* Invalid graph format */ + break; + } + + return NULL; +} + +/* + * acpi_coresight_parse_link - Parse the given Graph connection + * of the device and populate the coresight_connection for an output + * connection. + * + * CoreSight Graph specification mandates that the direction of the data + * flow must be specified in the link. i.e, + * + * SourcePortAddress, // Integer + * DestinationPortAddress, // Integer + * DestinationDeviceName, // Reference to another device + * DirectionOfFlow, // 1 for output(master), 0 for input(slave) + * + * Returns the direction of the data flow [ Input(slave) or Output(master) ] + * upon success. + * Returns an negative error number otherwise. + */ +static int acpi_coresight_parse_link(struct acpi_device *adev, + const union acpi_object *link, + struct coresight_connection *conn) +{ + int rc, dir; + const union acpi_object *fields; + struct acpi_device *r_adev; + struct device *rdev; + + if (link->type != ACPI_TYPE_PACKAGE || + link->package.count != 4) + return -EINVAL; + + fields = link->package.elements; + + if (fields[0].type != ACPI_TYPE_INTEGER || + fields[1].type != ACPI_TYPE_INTEGER || + fields[2].type != ACPI_TYPE_LOCAL_REFERENCE || + fields[3].type != ACPI_TYPE_INTEGER) + return -EINVAL; + + rc = acpi_bus_get_device(fields[2].reference.handle, &r_adev); + if (rc) + return rc; + + dir = fields[3].integer.value; + if (dir == ACPI_CORESIGHT_LINK_MASTER) { + conn->outport = fields[0].integer.value; + conn->child_port = fields[1].integer.value; + rdev = coresight_find_device_by_fwnode(&r_adev->fwnode); + if (!rdev) + return -EPROBE_DEFER; + /* + * Hold the refcount to the target device. This could be + * released via: + * 1) coresight_release_platform_data() if the probe fails or + * this device is unregistered. + * 2) While removing the target device via + * coresight_remove_match(). + */ + conn->child_fwnode = fwnode_handle_get(&r_adev->fwnode); + } + + return dir; +} + +/* + * acpi_coresight_parse_graph - Parse the _DSD CoreSight graph + * connection information and populate the supplied coresight_platform_data + * instance. + */ +static int acpi_coresight_parse_graph(struct acpi_device *adev, + struct coresight_platform_data *pdata) +{ + int rc, i, nlinks; + const union acpi_object *graph; + struct coresight_connection *conns, *ptr; + + pdata->nr_inport = pdata->nr_outport = 0; + graph = acpi_get_coresight_graph(adev); + if (!graph) + return -ENOENT; + + nlinks = graph->package.elements[2].integer.value; + if (!nlinks) + return 0; + + /* + * To avoid scanning the table twice (once for finding the number of + * output links and then later for parsing the output links), + * cache the links information in one go and then later copy + * it to the pdata. + */ + conns = devm_kcalloc(&adev->dev, nlinks, sizeof(*conns), GFP_KERNEL); + if (!conns) + return -ENOMEM; + ptr = conns; + for (i = 0; i < nlinks; i++) { + const union acpi_object *link = &graph->package.elements[3 + i]; + int dir; + + dir = acpi_coresight_parse_link(adev, link, ptr); + if (dir < 0) + return dir; + + if (dir == ACPI_CORESIGHT_LINK_MASTER) { + pdata->nr_outport++; + ptr++; + } else { + pdata->nr_inport++; + } + } + + rc = coresight_alloc_conns(&adev->dev, pdata); + if (rc) + return rc; + + /* Copy the connection information to the final location */ + for (i = 0; i < pdata->nr_outport; i++) + pdata->conns[i] = conns[i]; + + devm_kfree(&adev->dev, conns); + return 0; +} + +/* + * acpi_handle_to_logical_cpuid - Map a given acpi_handle to the + * logical CPU id of the corresponding CPU device. + * + * Returns the logical CPU id when found. Otherwise returns >= nr_cpus_id. + */ +static int +acpi_handle_to_logical_cpuid(acpi_handle handle) +{ + int i; + struct acpi_processor *pr; + + for_each_possible_cpu(i) { + pr = per_cpu(processors, i); + if (pr && pr->handle == handle) + break; + } + + return i; +} + +/* + * acpi_coresigh_get_cpu - Find the logical CPU id of the CPU associated + * with this coresight device. With ACPI bindings, the CoreSight components + * are listed as child device of the associated CPU. + * + * Returns the logical CPU id when found. Otherwise returns < 0. + */ +static int acpi_coresight_get_cpu(struct device *dev) +{ + int cpu; + acpi_handle cpu_handle; + acpi_status status; + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + status = acpi_get_parent(adev->handle, &cpu_handle); + if (ACPI_FAILURE(status)) + return 0; + + cpu = acpi_handle_to_logical_cpuid(cpu_handle); + if (cpu >= nr_cpu_ids) + return 0; + return cpu; +} + +static struct coresight_platform_data * +acpi_get_coresight_platform_data(struct device *dev, + struct coresight_platform_data *pdata) +{ + int rc = -EINVAL; + struct acpi_device *adev; + + adev = ACPI_COMPANION(dev); + if (!adev) + goto out; + + rc = acpi_coresight_parse_graph(adev, pdata); + if (rc) + goto out; +out: + if (rc) + return ERR_PTR(rc); + return pdata; +} + +#else + +static inline struct coresight_platform_data * +acpi_get_coresight_platform_data(struct device *dev, + struct coresight_platform_data *pdata) +{ + return NULL; +} + +static inline int acpi_coresight_get_cpu(struct device *dev) +{ + return 0; +} +#endif + int coresight_get_cpu(struct device *dev) { if (is_of_node(dev->fwnode)) return of_coresight_get_cpu(dev); + else if (is_acpi_device_node(dev->fwnode)) + return acpi_coresight_get_cpu(dev); return 0; } EXPORT_SYMBOL_GPL(coresight_get_cpu); @@ -320,6 +725,10 @@ coresight_get_platform_data(struct device *dev) if (is_of_node(fwnode)) ret = of_get_coresight_platform_data(dev, pdata); + else if (is_acpi_device_node(fwnode)) + ret = acpi_get_coresight_platform_data(dev, pdata); + else + return ERR_PTR(-ENOENT); if (!IS_ERR_OR_NULL(ret)) return pdata; From patchwork Mon Apr 15 16:04:16 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: 162216 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106079jan; Mon, 15 Apr 2019 09:06:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH05P1RNzIgpjvKbhJ9G/74UwAPz7SaOVUGYcAbvH/NKdXxNmFJ6R5Ni9x33Slj88Bzu5g X-Received: by 2002:a63:d304:: with SMTP id b4mr70963217pgg.300.1555344407193; Mon, 15 Apr 2019 09:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344407; cv=none; d=google.com; s=arc-20160816; b=zWRa7IvsKIEk6+uEdHcxIkdZoNroKJIv8/8kUMUZWpubP9/CosdeKprXXHW98PQsxk sqiCky4FVg+E3LY9C0TDQy1W2Z6JbJoBmeXvtPzEFlyVcBpMFcZOYCRUHxgFGty9jn7C AkZO5TJ3NBeOOdWrCPSMUr6UKrjII2tGGOR693GxbW37a2P0Enwxilc+3deb372Gj3+P 0QFsvtr7rFMmCvHhzSFv9URlgAluxJa5cIEk+0QJpVsB21pVgKAU+Ucmt1Hd3GCFzPaV QzcB8qziM7qmBd+kmVjhWKESuolGhic83cA+rrP1QnlDeavd9CfHoc9TdmwMlDzUzZB1 rO/Q== 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=eiyB8qqvQFxlkuEVtEOzNVi2Vvk5OItCGNPZKzvIivQ=; b=iVvq60lLVyGhPAUTZwe6Qbg4iqHfyh5VSmhZY2KkB6MN/mVeTg22tBRtgy8/R3YQBP Vp0f5c6+/fs00md6FKPllnD35DSfMOLjBE9E8B2ELNHkldb5qzPHUEYksQIN70KE7GO8 oJvZFi2HMLVVaxtR2YvqfBbRkbgLsOIlHpYanGiBYCMFiy1S9yR5rPnuULIsIzyg40wQ iDT9rkvogrw2GSCHZso+O4QNU+ssNlzKR1jgqK6ECbligQsRcMQCmOAUiqnL3JzRvA8h QEbZzwd1KC9NHpTBlNhz6byo4h91koVGWA7jPFLcyqv8xsossVLRCzZXsHoPQCqX7hqR OXuw== 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 l11si22057406plb.370.2019.04.15.09.06.46; Mon, 15 Apr 2019 09:06:47 -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 S1728133AbfDOQGp (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:45 -0400 Received: from foss.arm.com ([217.140.101.70]:38082 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728070AbfDOQGn (ORCPT ); Mon, 15 Apr 2019 12:06:43 -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 F21E51AC1; Mon, 15 Apr 2019 09:06:42 -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 785573F68F; Mon, 15 Apr 2019 09:06:41 -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 33/36] coresight: acpi: Support for components Date: Mon, 15 Apr 2019 17:04:16 +0100 Message-Id: <1555344260-12375-34-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 All AMBA devices are handled via ACPI AMBA scan notifier infrastructure. The platform devices get the ACPI id added to their driver. Cc: "Rafael J. Wysocki" Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/acpi/acpi_amba.c | 9 +++++++++ drivers/hwtracing/coresight/coresight-replicator.c | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c index 7f77c07..eef5a69 100644 --- a/drivers/acpi/acpi_amba.c +++ b/drivers/acpi/acpi_amba.c @@ -24,6 +24,15 @@ static const struct acpi_device_id amba_id_list[] = { {"ARMH0061", 0}, /* PL061 GPIO Device */ + {"ARMHC500", 0}, /* ARM CoreSight ETM4x */ + {"ARMHC501", 0}, /* ARM CoreSight ETR */ + {"ARMHC502", 0}, /* ARM CoreSight STM */ + {"ARMHC503", 0}, /* ARM CoreSight Debug */ + {"ARMHC979", 0}, /* ARM CoreSight TPIU */ + {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */ + {"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */ + {"ARMHC9CA", 0}, /* ARM CoreSight CATU */ + {"ARMHC9FF", 0}, /* ARM CoreSight Funnel */ {"", 0}, }; diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 2eb489c..a8f42df 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -5,6 +5,7 @@ * Description: CoreSight Replicator driver */ +#include #include #include #include @@ -290,11 +291,17 @@ static const struct of_device_id static_replicator_match[] = { {} }; +#ifdef CONFIG_ACPI +static const struct acpi_device_id static_replicator_acpi_ids[] = { + {"ARMHC985", 0}, /* ARM CoreSight Static Replicator */ +}; +#endif static struct platform_driver static_replicator_driver = { .probe = static_replicator_probe, .driver = { .name = "coresight-replicator", - .of_match_table = static_replicator_match, + .of_match_table = of_match_ptr(static_replicator_match), + .acpi_match_table = ACPI_PTR(static_replicator_acpi_ids), .pm = &replicator_dev_pm_ops, .suppress_bind_attrs = true, }, From patchwork Mon Apr 15 16:04:17 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: 162217 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106146jan; Mon, 15 Apr 2019 09:06:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPjucLNx+47pa5Wqhe9LzKYujG3msqYOXglo0odREYNFENWpgqufJb6Z0SelqH/EnDWXl5 X-Received: by 2002:a62:ee0a:: with SMTP id e10mr76413202pfi.6.1555344409677; Mon, 15 Apr 2019 09:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344409; cv=none; d=google.com; s=arc-20160816; b=qKzEUkM6bUCUvUBiFBSmkeY/bZq6Yf7HKAnsPI2Jt9v6SLHikV8gKDInRwcP5sufvE U99Rv8xOevYzkwk7+dygHgqna1MFVVIz3If3KFOF9bVAfMoGbp8HmglF7xFRdnPhQyfz 31EU/1aowWajPNh7QXVp+NydPC3rGyLdpWJqiwMfkaJsbRyWG1iAxIH/wBdgUcKS3a/a nbvVcAwwhPnfZ2dFAJ8dmnwoQDaAFf3NL1N446D9sY66GY1pgStaE+zYh52A5RquH6YM oi5kshgInXBYM83RiD+P2iL8yzjz0UuVDITycxB2PsDKd1nV/r6cQeg58u5rW7r2hNs9 Lqug== 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=MK89BfFuVrE+LPq36m4frmy3UmyjKRB0ojhczMQ6vSI=; b=MWkpj7tT8YlrbzH6AmxE6WWQYYizNl4q2LR1/kd5TcDsCN6PbVOavc8J9y9/Mts2Cb AnydeyywRA43QwLXYPSiV5eo8cp2hD6x6cNj8lISuWTa+0bzCHB2F9K5pxszfcJO8DZx Re0NElYNQC+Q7/wlGkRytsO8YkUjfZJ8IXO1PUZA01Ml9BkJAYSca8EFTBgxF/aDmvKy 53hrXg7z9DX0YPvSnY1B+wWrj9DM9bgooFo5fLsQ2SlJbzzwjcC+kqD/CECV+tHMdk1d qNPuGYH542nRXttdIo2klS193yl3jMrNGvGBU/ahtDAaGfjk7feUhXo0IcRqXQwzLtgD mhMg== 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 l11si22057406plb.370.2019.04.15.09.06.49; Mon, 15 Apr 2019 09:06:49 -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 S1728145AbfDOQGs (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:48 -0400 Received: from foss.arm.com ([217.140.101.70]:38092 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728115AbfDOQGp (ORCPT ); Mon, 15 Apr 2019 12:06:45 -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 B46BF80D; Mon, 15 Apr 2019 09:06:44 -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 3AA223F68F; Mon, 15 Apr 2019 09:06:43 -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 34/36] [RFC] coresight: Pass coresight_device for coresight_release_platform_data Date: Mon, 15 Apr 2019 17:04:17 +0100 Message-Id: <1555344260-12375-35-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 As we prepare to expose the links between the devices in sysfs, pass the coresight_device instance to the coresight_release_platform_data in order to free up the connections when the device is removed. No functional changes as such in this patch. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-platform.c | 2 +- drivers/hwtracing/coresight/coresight-priv.h | 3 ++- drivers/hwtracing/coresight/coresight.c | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 224f698..6559c49 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -734,7 +734,7 @@ coresight_get_platform_data(struct device *dev) return pdata; /* Cleanup the connection information */ - coresight_release_platform_data(pdata); + coresight_release_platform_data(NULL, pdata); return ret; } EXPORT_SYMBOL_GPL(coresight_get_platform_data); diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 61d7f9f..bf28ca9 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -200,6 +200,7 @@ static inline void *coresight_get_uci_data(const struct amba_id *id) return 0; } -void coresight_release_platform_data(struct coresight_platform_data *pdata); +void coresight_release_platform_data(struct coresight_device *csdev, + struct coresight_platform_data *pdata); #endif diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index e3b9321..010bc86 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1173,7 +1173,8 @@ postcore_initcall(coresight_init); * coresight_release_platform_data: Release references to the devices connected * to the output port of this device. */ -void coresight_release_platform_data(struct coresight_platform_data *pdata) +void coresight_release_platform_data(struct coresight_device *csdev, + struct coresight_platform_data *pdata) { int i; @@ -1275,7 +1276,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) kfree(csdev); err_out: /* Cleanup the connection information */ - coresight_release_platform_data(desc->pdata); + coresight_release_platform_data(NULL, desc->pdata); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(coresight_register); @@ -1285,7 +1286,7 @@ void coresight_unregister(struct coresight_device *csdev) etm_perf_del_symlink_sink(csdev); /* Remove references of that device in the topology */ coresight_remove_conns(csdev); - coresight_release_platform_data(csdev->pdata); + coresight_release_platform_data(csdev, csdev->pdata); device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister); From patchwork Mon Apr 15 16:04:18 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: 162220 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106508jan; Mon, 15 Apr 2019 09:07:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMkiCC3ix78bTQf/87AiXTMdAqKZq5tozTsH0wqbiHiAHxFqrN2YI8dR9G2Pi4UAgT7SZ7 X-Received: by 2002:a63:c45:: with SMTP id 5mr71650953pgm.385.1555344424082; Mon, 15 Apr 2019 09:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344424; cv=none; d=google.com; s=arc-20160816; b=dvedG7KeWnwQpNzWX9tG08HqISZaIRqMnQeHG1LFRulpB3nt3W7j/CwNSUt/Hu+OfD CtozsW3ODw7i+8pQhK2afeeAuS/tACXHzapvgqzxc+A5IGYB2TLJFnxXMpOBQKUpVWRV emejqQq8FS1S6UipO0jnkPp24eYRweoVqacxE9Iv9OwrJP7rLkF4njgXgAkFdp4XD82e UfLanvKwcXBQUjsX58Ngv/kjSpLTa7UrutAMEDxFsib/R4aTOPhf67EbLh8UYyMLgB2S Z1MmwCwcSqZ6HW+K4hiB4NJib1UEsqm1ZP6xHvjJSwvF3KEIj2Mz7UbkLZP8bqN/srZe HhLA== 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=JWBOasr8D+53EuLJhCrCPJtNqGy1fkR8v29V/b26zwk=; b=swQiMVpXoRgFKdbkHrJlb3E/KIIusfzH7yRJ/XY1YsYhiANgrm3r+o9KfrStvPUXBv z6eyQ7H54UkKY5RlvdfYHdp5HNLcMg0iU8+H1xqy52KI8iWXDNOFe9EtrVJ9Euz6n/Kn 91TJK0k4ei1Rm09xFcr5xlG/ZMpHGMCMkusr5X52WgO8UpFgpb/W2PwwPG4MKWN3UlEs Iwlm4rF9vhjsnLFQARow3QBu00uBcx4yzjRMZfvosZ7AgiqkV0WOzHfXS9wvke2m4ml+ ig+4VGWh/BpyOJCwg0cAEkjj9mc3jjy5q76uOsTAC2fUrdgzk/4hr2zFhM3aUYZAazj3 0jdg== 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 t70si27014464pgd.386.2019.04.15.09.07.03; Mon, 15 Apr 2019 09:07:04 -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 S1728166AbfDOQHC (ORCPT + 30 others); Mon, 15 Apr 2019 12:07:02 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38104 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbfDOQGq (ORCPT ); Mon, 15 Apr 2019 12:06:46 -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 76AFD1A25; Mon, 15 Apr 2019 09:06:46 -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 F11763F68F; Mon, 15 Apr 2019 09:06:44 -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 35/36] [RFC] coresight: add return value for fixup connections Date: Mon, 15 Apr 2019 17:04:18 +0100 Message-Id: <1555344260-12375-36-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 Handle failures in fixing up connections for a newly registered device. This will be useful to handle cases where we fail to expose the links via sysfs for the connections. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 010bc86..4d63063 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1025,18 +1025,18 @@ static int coresight_orphan_match(struct device *dev, void *data) return 0; } -static void coresight_fixup_orphan_conns(struct coresight_device *csdev) +static int coresight_fixup_orphan_conns(struct coresight_device *csdev) { /* * No need to check for a return value as orphan connection(s) * are hooked-up with each newly added component. */ - bus_for_each_dev(&coresight_bustype, NULL, + return bus_for_each_dev(&coresight_bustype, NULL, csdev, coresight_orphan_match); } -static void coresight_fixup_device_conns(struct coresight_device *csdev) +static int coresight_fixup_device_conns(struct coresight_device *csdev) { int i; @@ -1056,6 +1056,8 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev) conn->child_dev = NULL; } } + + return 0; } static int coresight_remove_match(struct device *dev, void *data) @@ -1265,10 +1267,15 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) mutex_lock(&coresight_mutex); - coresight_fixup_device_conns(csdev); - coresight_fixup_orphan_conns(csdev); + ret = coresight_fixup_device_conns(csdev); + if (!ret) + ret = coresight_fixup_orphan_conns(csdev); mutex_unlock(&coresight_mutex); + if (ret) { + coresight_unregister(csdev); + return ERR_PTR(ret); + } return csdev; From patchwork Mon Apr 15 16:04:19 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: 162218 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106192jan; Mon, 15 Apr 2019 09:06:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZYKs0IFwzl5dT/2UpnY+TTFTf0oL6AjEpn97IqS4c5UPNCpJLV476Ta3H9seMYd19di1i X-Received: by 2002:a62:6e05:: with SMTP id j5mr74029867pfc.5.1555344412082; Mon, 15 Apr 2019 09:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344412; cv=none; d=google.com; s=arc-20160816; b=L9ks2IaQWY0HvECt3qJyIxMGFGLgsrRdrdEVHIITjXw5ICJA1wgj790kswEB4uEdjl ps7ntKE+zhF/zVLvGWXX+M9ghHDdnjJINnxTKCQDRwkdJ4lq5nv39rCqM+uK8Wqo5KDE rRV/+2TTRgju2LpoURLZJ74kJO8tt5FmXUSGYF5DKwg0O2Zkd34nO7Qjq2fiFZVX0KCa ofLSRy976wCkifWqcG/IvXdA9xeEOSjiwBytaenAyMKUSQ63ODh8XZ22+eXauqQKNqde F8l8RU6IUOhGkniHF7XbeujzIEDWpWUMEADSOJdqFiWo6c+D28igUrS4fGuCk9O3P9Mh kYGw== 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=7guntLSdYHrxwDXiY7Iwh3IBB++GOO9lgopk8y+dqWY=; b=i+0N3vlrniScww1ozbMg1yrnEa1ynBpLMICriSNXzikp/5eWwhIwNnba3pfTiMSVPb 4DfYe/frhBaQFfHCoocZA07KXryIyuObCr5HsQIghr3/QyVajE0IEs8u8TllV1Mhx8u/ 1GIYT6azzeaImJg8Fy0IzVWobh/S9iaiC/z7C+V5NhwqLozic2zntBCA18IxvcVQOXbT cDerrUFE6v21yMRxnanbLnKghR3tB1V4q8m4QwaWN4UueZCmVSGMZpBWY0ASkUX9dtvm 1NrPEqwVcZMRAeivImYC/MRyTPq1sH/hmFSvdMTfL8Abw4ZbfH/J94H5BTYdp62Pprgw 0J0w== 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 k8si37245465plt.354.2019.04.15.09.06.51; Mon, 15 Apr 2019 09:06:52 -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 S1728156AbfDOQGu (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:50 -0400 Received: from foss.arm.com ([217.140.101.70]:38114 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728144AbfDOQGs (ORCPT ); Mon, 15 Apr 2019 12:06:48 -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 3D64F80D; Mon, 15 Apr 2019 09:06:48 -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 B54793F68F; Mon, 15 Apr 2019 09:06:46 -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 36/36] [RFC] coresight: Expose device connections via sysfs Date: Mon, 15 Apr 2019 17:04:19 +0100 Message-Id: <1555344260-12375-37-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 Coresight device connections are a bit complicated and is not exposed currently to the user. One has to look at the platform descriptions (DT bindings or ACPI bindings) to make an understanding. Given the new naming scheme, it will be helpful to have this information to choose the appropriate devices for tracing. This patch exposes the device connections via links in the sysfs directories. e.g, for a connection devA[OutputPort_X] -> devB[InputPort_Y] is represented as two symlinks: /sys/bus/coresight/.../devA/out:X -> /sys/bus/coresight/.../devB /sys/bus/coresight/.../devB/in:Y -> /sys/bus/coresight/.../devA We could have segregated the links to separate directories aka attribute_groups, for input_ports and output_ports. But the sysfs won't let you create empty attribute_groups and thus it becomes complicated to dynamically create the attribute_groups. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight.c | 120 +++++++++++++++++++++++++++++--- include/linux/coresight.h | 4 ++ 2 files changed, 113 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 4d63063..50a1f29 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -981,9 +981,92 @@ static void coresight_device_release(struct device *dev) kfree(csdev); } + +/* + * coresight_make_links: Make a link for a connection from a @orig + * device to @target, represented by @conn. + * + * e.g, for devOrig[output_X] -> devTarget[input_Y] is represented + * as two symbolic links : + * + * /sys/.../devOrig/out:X -> /sys/.../devTarget/ + * /sys/.../devTarget/in:Y -> /sys/.../devOrig/ + * + * The link names are allocated for a device where it appears. i.e, the + * "out" link on the master and "in" link on the slave device. + * The link names are stored in the connection record for avoiding + * the reconstruction of names for removal. + */ +static int coresight_make_links(struct coresight_device *orig, + struct coresight_connection *conn, + struct coresight_device *target) +{ + int ret = -ENOMEM; + char *outs = NULL, *ins = NULL; + + do { + outs = devm_kasprintf(&orig->dev, GFP_KERNEL, + "out:%d", conn->outport); + if (!outs) + break; + ins = devm_kasprintf(&target->dev, GFP_KERNEL, + "in:%d", conn->child_port); + if (!ins) + break; + ret = sysfs_create_link(&orig->dev.kobj, + &target->dev.kobj, outs); + if (ret) + break; + + ret = sysfs_create_link(&target->dev.kobj, + &orig->dev.kobj, ins); + if (ret) { + sysfs_remove_link(&orig->dev.kobj, outs); + break; + } + + conn->inlink_name = ins; + conn->outlink_name = outs; + /* + * Install the device connection. This also indicates that + * the links are operational on both ends. + */ + conn->child_dev = target; + return 0; + } while (0); + + if (outs) + devm_kfree(&orig->dev, outs); + if (ins) + devm_kfree(&target->dev, ins); + return ret; +} + +/* + * coresight_remove_links: Remove the sysfs links for a given connection @conn, + * from @orig device to @target device. See coresight_make_links() for more + * details. + */ +static void coresight_remove_links(struct coresight_device *orig, + struct coresight_connection *conn) +{ + struct coresight_device *target = conn->child_dev; + + if (!orig || !target) + return; + + sysfs_remove_link(&orig->dev.kobj, conn->outlink_name); + sysfs_remove_link(&target->dev.kobj, conn->inlink_name); + + devm_kfree(&target->dev, conn->inlink_name); + devm_kfree(&orig->dev, conn->outlink_name); + conn->inlink_name = conn->outlink_name = NULL; + conn->child_dev = NULL; +} + static int coresight_orphan_match(struct device *dev, void *data) { - int i; + int i, ret = 0; bool still_orphan = false; struct coresight_device *csdev, *i_csdev; struct coresight_connection *conn; @@ -1008,19 +1091,23 @@ static int coresight_orphan_match(struct device *dev, void *data) /* We have found at least one orphan connection */ if (conn->child_dev == NULL) { /* Does it match this newly added device? */ - if (conn->child_fwnode == csdev->dev.fwnode) - conn->child_dev = csdev; - else + if (conn->child_fwnode == csdev->dev.fwnode) { + ret = coresight_make_links(i_csdev, + conn, csdev); + if (ret) + return ret; + } else { /* This component still has an orphan */ still_orphan = true; + } } } i_csdev->orphan = still_orphan; /* - * Returning '0' ensures that all known component on the - * bus will be checked. + * Returning '0' in case we didn't encounter any error, + * ensures that all known component on the bus will be checked. */ return 0; } @@ -1038,7 +1125,7 @@ static int coresight_fixup_orphan_conns(struct coresight_device *csdev) static int coresight_fixup_device_conns(struct coresight_device *csdev) { - int i; + int i, ret = 0; for (i = 0; i < csdev->pdata->nr_outport; i++) { struct coresight_connection *conn = &csdev->pdata->conns[i]; @@ -1048,9 +1135,12 @@ static int coresight_fixup_device_conns(struct coresight_device *csdev) (void *)conn->child_fwnode, device_fwnode_match); if (dev) { - conn->child_dev = to_coresight_device(dev); + ret = coresight_make_links(csdev, conn, + to_coresight_device(dev)); /* and put reference from 'bus_find_device()' */ put_device(dev); + if (ret) + break; } else { csdev->orphan = true; conn->child_dev = NULL; @@ -1085,7 +1175,7 @@ static int coresight_remove_match(struct device *dev, void *data) if (csdev->dev.fwnode == conn->child_fwnode) { iterator->orphan = true; - conn->child_dev = NULL; + coresight_remove_links(iterator, conn); /* * Drop the reference to the handle for the remote * device acquired in parsing the connections from @@ -1179,10 +1269,18 @@ void coresight_release_platform_data(struct coresight_device *csdev, struct coresight_platform_data *pdata) { int i; + struct coresight_connection *conns = pdata->conns; for (i = 0; i < pdata->nr_outport; i++) { - if (pdata->conns[i].child_fwnode) { - fwnode_handle_put(pdata->conns[i].child_fwnode); + /* If we have made the links, remove them now */ + if (csdev && conns[i].child_dev) + coresight_remove_links(csdev, &conns[i]); + /* + * Drop the refcount and clear the handle as this device + * is going away + */ + if (conns[i].child_fwnode) { + fwnode_handle_put(conns[i].child_fwnode); pdata->conns[i].child_fwnode = 0; } } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index d6367a0..284d783 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -130,12 +130,16 @@ struct coresight_desc { * @chid_fwnode: remote component's fwnode handle. * @child_dev: a @coresight_device representation of the component connected to @outport. + * @inlink_name: Name for the "input" link + * @outlink_name: Name for the "output" link */ struct coresight_connection { int outport; int child_port; struct fwnode_handle *child_fwnode; struct coresight_device *child_dev; + const char *inlink_name; + const char *outlink_name; }; /** From patchwork Mon Apr 15 16:04:20 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: 162219 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106258jan; Mon, 15 Apr 2019 09:06:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBcSK15Kvf4vocK27nUoGiz2WeTD3D6f5erdkvWR1escCttlaRbeqN4SoduT9H/9Wij7xU X-Received: by 2002:a17:902:2bc9:: with SMTP id l67mr59330205plb.237.1555344414613; Mon, 15 Apr 2019 09:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344414; cv=none; d=google.com; s=arc-20160816; b=o/7/mw7hAFSDC4vB9UR4JVcSOVmdFfFfcd+vE94c7bXFcoWtGcnH2S7tTpSX15O9wk 2wIEDVrtDNaEYhDPe2EW5vVkU6iXv12lCDAV19O52HFLuI+LYdEQccGey64X6/fvvKgI YlAq2KHdFZgpuvZA85yUSy4uYeDvhyQoVJM7NeN1AWyRp2QOTmSgEGRqjx1j8if8Y33f /mIWVCO8Xd/3IUQ3mb9+ixi0Om3SncI81DTgUPK8o6VG1nC9naqZ92409jhs/NdXLS/k ReFBWnjPHw3f0Suup69TSUgzpyzNOM5Unbyyi+QDWFkIXExndBc44Q0pgFYuWgUEHN3x Lhqw== 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=VYrdyVdXitr0IukJNDx1qYS4TusT1Vc6l7Tt7/OvRJU=; b=iFyHM+5Ys6Ivaq09KdNQ8kvNfZywat1N1UwvDw+FXgkeLZS9yQygdaS1zUHCBt44Ef 8GccRxhtBaf03wg6lhX01Jc34a8SUlxfz0ADLtaThtWs3i76cDx6vALOoOcdluCJVOxN /2koqlHRXXCZfYG0DYOc7P0tzc7ajpPh+rX4DpyKHuYPkQ3n5/L4y9Uyh5Hl+MORbjLF KkrxGXE5AKsze+PoyaP5GMT4FDT7wLhfm7RMtM9PPZDl1MVMAywJQvobfrhVtohZnqpm 6DGW6nDdcHfIXZyz6fnkkT3MvBzjda4qfCnb4NF7TZhq1X5h/gZ2xY15V68kHLobpbUe Y7MQ== 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 k8si37245465plt.354.2019.04.15.09.06.54; Mon, 15 Apr 2019 09:06:54 -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 S1727790AbfDOQGx (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:53 -0400 Received: from foss.arm.com ([217.140.101.70]:38126 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbfDOQGu (ORCPT ); Mon, 15 Apr 2019 12:06:50 -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 F3F67A78; Mon, 15 Apr 2019 09:06:49 -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 7A3703F68F; Mon, 15 Apr 2019 09:06:48 -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: [TEST PATCH 37/36][EDK2] edk2-platform: juno: Update ACPI CoreSight Bindings Date: Mon, 15 Apr 2019 17:04:20 +0100 Message-Id: <1555344260-12375-38-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 ACPI bindings for CoreSight components on the Juno-r0 board. Please note that the bindings apply only for the juno-r0. The layout on r1 and r2 are slightly different and will need dynamic ACPI table support to be able to use a single UEFI image. Signed-off-by: Suzuki K Poulose --- Platform/ARM/JunoPkg/AcpiTables/Dsdt.asl | 241 +++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) -- 2.7.4 diff --git a/Platform/ARM/JunoPkg/AcpiTables/Dsdt.asl b/Platform/ARM/JunoPkg/AcpiTables/Dsdt.asl index 702b057..c70e8ac 100644 --- a/Platform/ARM/JunoPkg/AcpiTables/Dsdt.asl +++ b/Platform/ARM/JunoPkg/AcpiTables/Dsdt.asl @@ -14,6 +14,51 @@ #include "ArmPlatform.h" +#define ACPI_GRAPH_REV 0 +#define ACPI_GRAPH_UUID "ab02a46b-74c7-45a2-bd68-f7d344ef2153" + +#define CORESIGHT_GRAPH_UUID "3ecbc8b6-1d0e-4fb3-8107-e627f805c6cd" + +#define CS_LINK_MASTER 1 +#define CS_LINK_SLAVE 0 + + +#define DSD_CS_GRAPH_BEGIN(_nports) \ + Package () { \ + 1, // GraphID \ + ToUUID(CORESIGHT_GRAPH_UUID), \ + _nports, + +#define DSD_CS_GRAPH_END \ + } + +#define DSD_GRAPH_BEGIN(_nports) \ + ToUUID(ACPI_GRAPH_UUID), \ + Package() { \ + ACPI_GRAPH_REV, \ + 1, \ + DSD_CS_GRAPH_BEGIN(_nports) + +#define DSD_GRAPH_END \ + DSD_CS_GRAPH_END \ + } + +#define DSD_PORTS_BEGIN(_nports) \ + Name (_DSD, Package () { \ + DSD_GRAPH_BEGIN(_nports) + +#define DSD_PORTS_END \ + DSD_GRAPH_END \ + }) + +#define CS_PORT(_port, _rport, _rphandle, _dir) \ + Package () { _port, _rport, _rphandle, _dir} + +#define CS_INPUT_PORT(_port, _rport, _rphandle) \ + CS_PORT(_port, _rport, _rphandle, CS_LINK_SLAVE) +#define CS_OUTPUT_PORT(_port, _rport, _rphandle) \ + CS_PORT(_port, _rport, _rphandle, CS_LINK_MASTER) + DefinitionBlock("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARM-JUNO", EFI_ACPI_ARM_OEM_REVISION) { Scope(_SB) { // @@ -122,15 +167,56 @@ DefinitionBlock("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARM-JUNO", EFI_ACPI_ARM_O Method (_LPI, 0, NotSerialized) { return(PLPI) } + + Device(ETM0) { // ETM on Cluster0 CPU0 + Name (_HID, "ARMHC500") + Name (_CID, "ARMHC500") + Name (_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x22040000, 0x1000) + }) + + DSD_PORTS_BEGIN(1) + CS_OUTPUT_PORT(0, 0, \_SB_.CLU0.FUN0) + DSD_PORTS_END + + } // ETM0 } + Device(CPU1) { // A57-1: Cluster 0, Cpu 1 Name(_HID, "ACPI0007") Name(_UID, 5) Method (_LPI, 0, NotSerialized) { return(PLPI) } + Device(ETM1) { // ETM on Cluster0 CPU1 + Name (_HID, "ARMHC500") + Name (_CID, "ARMHC500") + Name (_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x22140000, 0x1000) + }) + + DSD_PORTS_BEGIN(1) + CS_OUTPUT_PORT(0, 1, \_SB_.CLU0.FUN0) + DSD_PORTS_END + + } // ETM1 } + + Device(FUN0) { + Name(_HID, "ARMHC9FF") + Name(_CID, "ARMHC9FF") + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x220c0000, 0x1000) + }) + + DSD_PORTS_BEGIN(3) + CS_OUTPUT_PORT(0, 0, \_SB_.MFUN), + CS_INPUT_PORT(0, 0, \_SB_.CLU0.CPU0.ETM0), + CS_INPUT_PORT(1, 0, \_SB_.CLU0.CPU1.ETM1) + DSD_PORTS_END + } // CL0.FUN0 } + Device (CLU1) { // Cluster1 state Name(_HID, "ACPI0010") Name(_UID, 2) @@ -208,19 +294,45 @@ DefinitionBlock("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARM-JUNO", EFI_ACPI_ARM_O "CorePwrDn" }, }) + Device(CPU2) { // A53-0: Cluster 1, Cpu 0 Name(_HID, "ACPI0007") Name(_UID, 0) Method (_LPI, 0, NotSerialized) { return(PLPI) } + Device(ETM2) { // ETM on Cluster1, CPU0 + Name (_HID, "ARMHC500") + Name (_CID, "ARMHC500") + Name (_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x23040000, 0x1000) + }) + + DSD_PORTS_BEGIN(1) + CS_OUTPUT_PORT(0, 0, \_SB_.CLU1.FUN1) + DSD_PORTS_END + + } // ETM2 } + Device(CPU3) { // A53-1: Cluster 1, Cpu 1 Name(_HID, "ACPI0007") Name(_UID, 1) Method (_LPI, 0, NotSerialized) { return(PLPI) } + Device(ETM3) { // ETM on Cluster1, CPU1 + Name (_HID, "ARMHC500") + Name (_CID, "ARMHC500") + Name (_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x23140000, 0x1000) + }) + + DSD_PORTS_BEGIN(1) + CS_OUTPUT_PORT(0, 1, \_SB_.CLU1.FUN1) + DSD_PORTS_END + + } // ETM3 } Device(CPU4) { // A53-2: Cluster 1, Cpu 2 Name(_HID, "ACPI0007") @@ -228,6 +340,18 @@ DefinitionBlock("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARM-JUNO", EFI_ACPI_ARM_O Method (_LPI, 0, NotSerialized) { return(PLPI) } + Device(ETM4) { // ETM on Cluster1, CPU2 + Name (_HID, "ARMHC500") // ETM + Name (_CID, "ARMHC500") // ETM + Name (_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x23240000, 0x1000) + }) + + DSD_PORTS_BEGIN(1) + CS_OUTPUT_PORT(0, 2, \_SB_.CLU1.FUN1) + DSD_PORTS_END + + } // ETM4 } Device(CPU5) { // A53-3: Cluster 1, Cpu 3 Name(_HID, "ACPI0007") @@ -235,9 +359,126 @@ DefinitionBlock("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARM-JUNO", EFI_ACPI_ARM_O Method (_LPI, 0, NotSerialized) { return(PLPI) } + Device(ETM5) { // ETM on Cluster1, CPU3 + Name (_HID, "ARMHC500") // ETM + Name (_CID, "ARMHC500") // ETM + Name (_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x23340000, 0x1000) + }) + + DSD_PORTS_BEGIN(1) + CS_OUTPUT_PORT(0, 3, \_SB_.CLU1.FUN1) + DSD_PORTS_END + } // ETM5 } + Device(FUN1) { + Name(_HID, "ARMHC9FF") + Name(_CID, "ARMHC9FF") + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x230c0000, 0x1000) + }) + + DSD_PORTS_BEGIN(5) + CS_OUTPUT_PORT(0, 1, \_SB_.MFUN), + CS_INPUT_PORT(0, 0, \_SB_.CLU1.CPU2.ETM2), + CS_INPUT_PORT(1, 0, \_SB_.CLU1.CPU3.ETM3), + CS_INPUT_PORT(2, 0, \_SB_.CLU1.CPU4.ETM4), + CS_INPUT_PORT(3, 0, \_SB_.CLU1.CPU5.ETM5) + DSD_PORTS_END + } // CL1.FUN1 } + Device(STM0) { + Name(_HID, "ARMHC502") // STM + Name(_CID, "ARMHC502") + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x20100000, 0x1000) + Memory32Fixed(ReadWrite, 0x28000000, 0x1000000) + }) + DSD_PORTS_BEGIN(1) + CS_OUTPUT_PORT(0, 2, \_SB_.MFUN) + DSD_PORTS_END + } + + Device(MFUN) { + Name(_HID, "ARMHC9FF") // Funnel + Name(_CID, "ARMHC9FF") // Funnel + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x20040000, 0x1000) + }) + + DSD_PORTS_BEGIN(4) + CS_OUTPUT_PORT(0, 0, \_SB_.ETF0), + CS_INPUT_PORT(0, 0, \_SB_.CLU0.FUN0), + CS_INPUT_PORT(1, 0, \_SB_.CLU1.FUN1), + CS_INPUT_PORT(2, 0, \_SB_.STM0) + DSD_PORTS_END + + } // MFUN-nel + + Device(ETF0) { + Name(_HID, "ARMHC97C") // TMC + Name(_CID, "ARMHC97C") // TMC + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x20010000, 0x1000) + }) + + DSD_PORTS_BEGIN(2) + CS_OUTPUT_PORT(0, 1, \_SB_.RPL), + CS_INPUT_PORT(0, 0, \_SB_.MFUN) + DSD_PORTS_END + + } // ETF0 + + Device(RPL) { + Name(_HID, "ARMHC98D") // Replicator + Name(_CID, "ARMHC98D") // Replicator + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x20120000, 0x1000) + }) + + DSD_PORTS_BEGIN(3) + CS_OUTPUT_PORT(0, 0, \_SB_.TPIU), + CS_OUTPUT_PORT(1, 0, \_SB_.ETR), + CS_INPUT_PORT(0, 0, \_SB_.ETF0) + DSD_PORTS_END + + } // RPL + + Device(ETR) { + Name(_HID, "ARMHC97C") // TMC + Name(_CID, "ARMHC97C") // TMC + Name(_CCA, 0) // The ETR on this platform is not coherent + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x20070000, 0x1000) + }) + + Name(_DSD, Package() { + DSD_GRAPH_BEGIN(1) + CS_INPUT_PORT(0, 1, \_SB_.RPL) + DSD_GRAPH_END, + + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package() { + Package(2) {"arm,scatter-gather", 1} + } + }) + + } // ETR + + Device(TPIU) { + Name(_HID, "ARMHC979") // TPIU + Name(_CID, "ARMHC979") // TPIU + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, 0x20030000, 0x1000) + }) + + DSD_PORTS_BEGIN(1) + CS_INPUT_PORT(0, 0, \_SB_.RPL) + DSD_PORTS_END + + } // TPIU + // // Keyboard and Mouse //