From patchwork Thu May 2 16:54:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 163273 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp5963143ill; Thu, 2 May 2019 09:54:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEy+6UvD0jEPwTEawgMV+5PmKyuxhyp07U8m2UxjrPED1fnPvqHbJsTPx6GbH4ozjWs34X X-Received: by 2002:a17:902:581:: with SMTP id f1mr4881451plf.304.1556816057095; Thu, 02 May 2019 09:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556816057; cv=none; d=google.com; s=arc-20160816; b=bBKSirIVvpLfxTkWRiaIv10PqccyNUnVOsK4tFhir2XYiwNH9P5Rn7Rrr2AsPeSP2n q9c9+9X1oAePLN3Wn6LZMK3PHsWhwoGB29qTpZYoQ1bK9CDSF6oOB1+zsjAbwGMH7QUr 8s7PTN+wezndBbuwNsNx8MdMHwUdFfTjAmHGANYB0bJvrwS2CKrj5OeZWqAXz/bd2mdf 1XlE1hOu5XXyCIZGC2YzgHLWvOxJuf8NudbuSZEXO30VpKlult3FMv7DDPDBVrf6hq70 SDu6C0QhWhHi9wpyJ84Ry0MzjQTVj0j/teMc53BUwD25RkpOFRo8iuVjlDNd4Y9gRsfX ca6g== 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:dkim-signature; bh=QrkjN2tlb0+q0lMYNdu1T28xei8lTxBSs279cdRR46c=; b=vsDwrq3irfE1uiNJPwyuJDkxxXNMeCgSjOxcPRKd4HX+xVBoDqAmd1iNsPPAd6TARE UfyZ4ajr3ovLpFQOezxbQIsnHgiOpjQhuZg19Vud8sBsHLeyp8ce/A7Lwd9NTZ7GfgZO DTH3s9tfZduNdWqeF5GCfq6kB7pjWotgHOQCRA5b3ltPUoiXTHoyk0AIOK5PqqpQYPUc 6uAlg4k99x3nbwKkSw/zbhdLY7y1sMaIb55pJw4MrIW8N+K0qBdgxMOdkW54x+uhhCkH Zg8ODyJ4W+qJHH820pF/Tx4ko/V66rj7aBLHbUxojIc7EcRAoPwZHg3fOTWLClSEDzFR /TNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hQ2/20Wl"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si24151037pgs.232.2019.05.02.09.54.16; Thu, 02 May 2019 09:54: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; dkim=pass header.i=@linaro.org header.s=google header.b="hQ2/20Wl"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbfEBQyP (ORCPT + 30 others); Thu, 2 May 2019 12:54:15 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34804 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbfEBQyN (ORCPT ); Thu, 2 May 2019 12:54:13 -0400 Received: by mail-pg1-f194.google.com with SMTP id c13so1339254pgt.1 for ; Thu, 02 May 2019 09:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QrkjN2tlb0+q0lMYNdu1T28xei8lTxBSs279cdRR46c=; b=hQ2/20WlvXmaLiPR466EjcP4wNnUJnwClir6hGSLn1LeC8HAFfuFsavJQtf1F3Xc9Q fAF6HkANU6E7+6D5+4JNnY1cguq1/FZVZC891QzNIZTF71IWWfuditDUronyL+fyb6bt M8VJwMnEgzi9h1jYS4xtZ+spLnZRRVWReimQwrR5NNWLtAygSBxM6i4prhZEkJ6dm0Mo sMhzWFknNuEs/f8ETF3Ce2LJ1cqp5RxzHilUdGgxHSbVQi9nf32nWNdmE1gWQ3A8wqyQ b49s/InI9jSlOB6xAbbvUtkZ4VhaL/JfjW+o/rH8+n21rPaqnBe80Puq4rOlvoa1bZx8 ZVtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QrkjN2tlb0+q0lMYNdu1T28xei8lTxBSs279cdRR46c=; b=aB/0CPSBLWzDzRiNUW+xd5WQvrDimSy5hU8QAGQCuz4ZXRSQPv76Ngv59rPoFSsrU4 AQJEFGuuanIzD6Fc+5pdDYFqodapIc90ek0sug7TY3JTvr6CiCAoeQHvHP8HwmD5UlQk wSx6PUe0BVlwN4CQziNua3/+X0jhDhQx4XfhSo5dYbSMVAphuQaZeT42Uu6mPTBNqr+l AFBTkInv+ziHbc7aiLSwS2MJ3XDuJgI0grVIULIunETtPe94VZHF3JhAlYI460VF04oX FeMakb/5/R4/RDjxxL5zsKBkPYF3xB96eyM0OCkBYiXr/X73WhNIdHBJsArnfyaHB+zb ex9Q== X-Gm-Message-State: APjAAAUC+KmX+Qi+ezzdrdMJ+PZGbC06F3TsqkegoVVshcxht0ii46ZF ZTlqRXpoIvKFG5tqkBR+QDUFz4vWjdg= X-Received: by 2002:a63:8dc9:: with SMTP id z192mr5007952pgd.6.1556816052459; Thu, 02 May 2019 09:54:12 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j2sm69949pff.77.2019.05.02.09.54.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 09:54:11 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] coresight: funnel: Support static funnel Date: Thu, 2 May 2019 10:54:05 -0600 Message-Id: <20190502165405.31573-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190502165405.31573-1-mathieu.poirier@linaro.org> References: <20190502165405.31573-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan Since CoreSight hardware topology can use a 'hidden' funnel in the trace data path, this kind funnel doesn't have register for accessing and is used by default from hardware design perspective. Below is an example for related hardware topology: +------+ +------+ | cpu0 |->| ETM |-\ +------+ +------+ \-> +--------+ +-----+ ...... | Funnel |->| ETF |-\ Hidden funnel +------+ +------+ /-> +--------+ +-----+ \ | | cpu3 |->| ETM |-/ \ V +------+ +------+ \-> +--------+ | Funnel |-> ... +------+ +------+ /-> +--------+ | cpu4 |->| ETM |-\ / +------+ +------+ \-> +--------+ +-----+ / ...... | Funnel |->| ETF |-/ +------+ +------+ /-> +--------+ +-----+ | cpu7 |->| ETM |-/ +------+ +------+ The CoreSight funnel driver only supports dynamic funnel with registration register resource, thus it cannot support for the static funnel case and it's impossible to create trace data path for this case. This patch is to extend CoreSight funnel driver to support both for static funnel and dynamic funnel. For the dynamic funnel it reuses the code existed in the driver, for static funnel the driver will support device probe if without providing register resource and the driver skips registers accessing when detect the register base is NULL. Cc: Mathieu Poirier Cc: Suzuki K Poulose Cc: Wanglai Shi Suggested-by: Suzuki K Poulose Signed-off-by: Leo Yan Reviewed-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- .../hwtracing/coresight/coresight-funnel.c | 116 ++++++++++++++---- 1 file changed, 89 insertions(+), 27 deletions(-) -- 2.17.1 diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 927925151509..16b0c0e1e43a 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -43,7 +45,7 @@ struct funnel_drvdata { unsigned long priority; }; -static int funnel_enable_hw(struct funnel_drvdata *drvdata, int port) +static int dynamic_funnel_enable_hw(struct funnel_drvdata *drvdata, int port) { u32 functl; int rc = 0; @@ -71,17 +73,19 @@ static int funnel_enable_hw(struct funnel_drvdata *drvdata, int port) static int funnel_enable(struct coresight_device *csdev, int inport, int outport) { - int rc; + int rc = 0; struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - rc = funnel_enable_hw(drvdata, inport); + if (drvdata->base) + rc = dynamic_funnel_enable_hw(drvdata, inport); if (!rc) dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport); return rc; } -static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport) +static void dynamic_funnel_disable_hw(struct funnel_drvdata *drvdata, + int inport) { u32 functl; @@ -103,7 +107,8 @@ static void funnel_disable(struct coresight_device *csdev, int inport, { struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - funnel_disable_hw(drvdata, inport); + if (drvdata->base) + dynamic_funnel_disable_hw(drvdata, inport); dev_dbg(drvdata->dev, "FUNNEL inport %d disabled\n", inport); } @@ -177,54 +182,70 @@ static struct attribute *coresight_funnel_attrs[] = { }; ATTRIBUTE_GROUPS(coresight_funnel); -static int funnel_probe(struct amba_device *adev, const struct amba_id *id) +static int funnel_probe(struct device *dev, struct resource *res) { int ret; void __iomem *base; - struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; struct funnel_drvdata *drvdata; - struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; + struct device_node *np = 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; + dev->platform_data = pdata; } + if (of_device_is_compatible(np, "arm,coresight-funnel")) + pr_warn_once("Uses OBSOLETE CoreSight funnel binding\n"); + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; - drvdata->dev = &adev->dev; - drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ + drvdata->dev = dev; + drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); if (ret) return ret; } - dev_set_drvdata(dev, drvdata); - /* Validity for the resource is already checked by the AMBA core */ - base = devm_ioremap_resource(dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + /* + * Map the device base for dynamic-funnel, which has been + * validated by AMBA core. + */ + if (res) { + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) { + ret = PTR_ERR(base); + goto out_disable_clk; + } + drvdata->base = base; + desc.groups = coresight_funnel_groups; + } - drvdata->base = base; - pm_runtime_put(&adev->dev); + dev_set_drvdata(dev, drvdata); desc.type = CORESIGHT_DEV_TYPE_LINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG; desc.ops = &funnel_cs_ops; desc.pdata = pdata; desc.dev = dev; - desc.groups = coresight_funnel_groups; drvdata->csdev = coresight_register(&desc); + if (IS_ERR(drvdata->csdev)) { + ret = PTR_ERR(drvdata->csdev); + goto out_disable_clk; + } + + pm_runtime_put(dev); - return PTR_ERR_OR_ZERO(drvdata->csdev); +out_disable_clk: + if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) + clk_disable_unprepare(drvdata->atclk); + return ret; } #ifdef CONFIG_PM @@ -253,7 +274,48 @@ static const struct dev_pm_ops funnel_dev_pm_ops = { SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL) }; -static const struct amba_id funnel_ids[] = { +static int static_funnel_probe(struct platform_device *pdev) +{ + int ret; + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + /* Static funnel do not have programming base */ + ret = funnel_probe(&pdev->dev, NULL); + + if (ret) { + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + + return ret; +} + +static const struct of_device_id static_funnel_match[] = { + {.compatible = "arm,coresight-static-funnel"}, + {} +}; + +static struct platform_driver static_funnel_driver = { + .probe = static_funnel_probe, + .driver = { + .name = "coresight-static-funnel", + .of_match_table = static_funnel_match, + .pm = &funnel_dev_pm_ops, + .suppress_bind_attrs = true, + }, +}; +builtin_platform_driver(static_funnel_driver); + +static int dynamic_funnel_probe(struct amba_device *adev, + const struct amba_id *id) +{ + return funnel_probe(&adev->dev, &adev->res); +} + +static const struct amba_id dynamic_funnel_ids[] = { { .id = 0x000bb908, .mask = 0x000fffff, @@ -266,14 +328,14 @@ static const struct amba_id funnel_ids[] = { { 0, 0}, }; -static struct amba_driver funnel_driver = { +static struct amba_driver dynamic_funnel_driver = { .drv = { - .name = "coresight-funnel", + .name = "coresight-dynamic-funnel", .owner = THIS_MODULE, .pm = &funnel_dev_pm_ops, .suppress_bind_attrs = true, }, - .probe = funnel_probe, - .id_table = funnel_ids, + .probe = dynamic_funnel_probe, + .id_table = dynamic_funnel_ids, }; -builtin_amba_driver(funnel_driver); +builtin_amba_driver(dynamic_funnel_driver);