From patchwork Mon Feb 1 18:13:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12060261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A414C433DB for ; Mon, 1 Feb 2021 23:59:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D34DF64EDC for ; Mon, 1 Feb 2021 23:59:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D34DF64EDC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fgT3ABOHYsWChIvmaAUB4ph8ConWQwIv6hAwVd1JUjM=; b=h/8Dj6iBprR6FSU7ZJyCisPlc 9rk98YaSeTJwYQG7bK+SkJ3sdBnuEn18Qcy1kq4zfB8DNEL8xDhxpSgSI2Yor09B+rzVGAoL7Qrtj VH94y/Keli0B+bZELsfmKmvGex46arq1JBTCbFNzkfLP6Pc/p4VD7EJsPhrD5OI7FV0Z8uQWeJ+Hy GPrZdOd6e7yqp9otzHeJKZhCwW51qoBYuL757FFWA/wbb8ccCC+9wWowbLugc5P/lz0iNO6eoNoUE rk2+9djcZqvo5iIrDflyDW/C5kFCoiduYLlzy0myVA1I9VRFo3TrDiJrHJ+nDFrzIc9gRcKldS1Wf qxfaKBldA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6dqW-0007DD-5I; Mon, 01 Feb 2021 18:22:45 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6diS-0003A0-Ef for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 18:14:37 +0000 Received: by mail-pj1-x102d.google.com with SMTP id l18so81298pji.3 for ; Mon, 01 Feb 2021 10:14:24 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=r6MZF2I+EtOQE1SlYRYLpgst5vG63s12bYpfROsNq20=; b=IjBy6Xq2lMnYRbP3Ejtc/LmkvMh2Sa8jSyuaoWtu9fcSvCcqKm0qp7nk2bcNawnQrz T/U70s2x+j51GKG54IsMh2yzO2gRYDGWJS+qyns0vvMTVT9BrpJl7eDSSCCr74PEiAfr swpE1OdZgudfL26fV0tOp32pzdvXqBHiCjlSCSP3Jc29tYdAlSmNG4ErxaBqmqjDxg8P m7csedHcUOe3oVM1h9g8nAEHgPv2StUwXklYGMLkZn0jntYzDqD/j7gy/EvRp4ZpEAMk RdJwLHKezgqvIhwE3K4KAWQhAJDXN9PpcgnT3Gs0CFIQqWhi6k5lYJLNFohgjUMFKK7X vMGA== 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:mime-version:content-transfer-encoding; bh=r6MZF2I+EtOQE1SlYRYLpgst5vG63s12bYpfROsNq20=; b=Fx5w9GLURbRiPfHKtFN4fOKOANtTncyHyvUxmZmiHjso5bp92ebABuOIS5XXsk4pGF JXflOGCXDG/nDU24wB7UXvXIOdTpY00URTFdz8WWDcq7M3KWm3g6cc54xxZJTAWyv8Qw hBIYK/zOI2oUMlQ9c8hWZq24r4HzAhqjOimuf5DossQyGqeQLoPgIh88uIX9z8pEQPNF J3TPKGIjYr/PQZV+FG7gLkgnFXgFZIx5BnnyE5n6UiaSHkSu8STVnN3twAB2O+zIZpd7 JqCdk+O8QaehkVC9yQZqvCr8K53P0u5Ew9JHLuCh7o+6pAkqePYFeC3vcVRnyG7yYIam kjeQ== X-Gm-Message-State: AOAM5313aEaV1CQR7HuUs5E/pytQQxjSPQXYSVRkl3F3cIBDv3z3veP3 HOdZjsxztH7SALSiM9AetQIavw== X-Google-Smtp-Source: ABdhPJyQScyV4qottp3h9tV17KkDMs4Qrdf8uhR12hijrNHwEevNIqNPuBNvQ5MmIR4bXeMzIcrg9w== X-Received: by 2002:a17:90a:5c81:: with SMTP id r1mr109235pji.175.1612203262477; Mon, 01 Feb 2021 10:14:22 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id e12sm75784pjj.23.2021.02.01.10.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 10:14:21 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 27/31] coresight: etm4x: Add support for sysreg only devices Date: Mon, 1 Feb 2021 11:13:47 -0700 Message-Id: <20210201181351.1475223-28-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210201181351.1475223-1-mathieu.poirier@linaro.org> References: <20210201181351.1475223-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210201_131424_680056_1B014866 X-CRM114-Status: GOOD ( 23.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Suzuki K Poulose Add support for devices with system instruction access only. They don't have a memory mapped interface and thus are not AMBA devices. System register access is not permitted to TRCPDCR and thus skip access to them. Cc: Mike Leach Signed-off-by: Suzuki K Poulose Link: https://lore.kernel.org/r/20210110224850.1880240-26-suzuki.poulose@arm.com Signed-off-by: Mathieu Poirier --- .../coresight/coresight-etm4x-core.c | 68 +++++++++++++++++-- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index fc26ecbc2d87..c6238e208685 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -1736,9 +1737,6 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid) return -ENOMEM; } - if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up")) - drvdata->skip_power_up = true; - drvdata->base = base; spin_lock_init(&drvdata->spinlock); @@ -1762,6 +1760,11 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid) if (!drvdata->arch) return -EINVAL; + /* TRCPDCR is not accessible with system instructions. */ + if (!desc.access.io_mem || + fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up")) + drvdata->skip_power_up = true; + etm4_init_trace_id(drvdata); etm4_set_default(&drvdata->config); @@ -1820,6 +1823,25 @@ static int etm4_probe_amba(struct amba_device *adev, const struct amba_id *id) return ret; } +static int etm4_probe_platform_dev(struct platform_device *pdev) +{ + int ret; + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + /* + * System register based devices could match the + * HW by reading appropriate registers on the HW + * and thus we could skip the PID. + */ + ret = etm4_probe(&pdev->dev, NULL, 0); + + pm_runtime_put(&pdev->dev); + return ret; +} + static struct amba_cs_uci_id uci_id_etm4[] = { { /* ETMv4 UCI data */ @@ -1869,6 +1891,17 @@ static int __exit etm4_remove_amba(struct amba_device *adev) return 0; } +static int __exit etm4_remove_platform_dev(struct platform_device *pdev) +{ + int ret = 0; + struct etmv4_drvdata *drvdata = dev_get_drvdata(&pdev->dev); + + if (drvdata) + ret = etm4_remove_dev(drvdata); + pm_runtime_disable(&pdev->dev); + return ret; +} + static const struct amba_id etm4_ids[] = { CS_AMBA_ID(0x000bb95d), /* Cortex-A53 */ CS_AMBA_ID(0x000bb95e), /* Cortex-A57 */ @@ -1903,6 +1936,21 @@ static struct amba_driver etm4x_amba_driver = { .id_table = etm4_ids, }; +static const struct of_device_id etm4_sysreg_match[] = { + { .compatible = "arm,coresight-etm4x-sysreg" }, + {} +}; + +static struct platform_driver etm4_platform_driver = { + .probe = etm4_probe_platform_dev, + .remove = etm4_remove_platform_dev, + .driver = { + .name = "coresight-etm4x", + .of_match_table = etm4_sysreg_match, + .suppress_bind_attrs = true, + }, +}; + static int __init etm4x_init(void) { int ret; @@ -1915,16 +1963,26 @@ static int __init etm4x_init(void) ret = amba_driver_register(&etm4x_amba_driver); if (ret) { - pr_err("Error registering etm4x driver\n"); - etm4_pm_clear(); + pr_err("Error registering etm4x AMBA driver\n"); + goto clear_pm; } + ret = platform_driver_register(&etm4_platform_driver); + if (!ret) + return 0; + + pr_err("Error registering etm4x platform driver\n"); + amba_driver_unregister(&etm4x_amba_driver); + +clear_pm: + etm4_pm_clear(); return ret; } static void __exit etm4x_exit(void) { amba_driver_unregister(&etm4x_amba_driver); + platform_driver_unregister(&etm4_platform_driver); etm4_pm_clear(); }