From patchwork Mon Feb 1 18:13:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12059675 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=ham 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 B781FC433E6 for ; Mon, 1 Feb 2021 18:18:38 +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 5420A64E50 for ; Mon, 1 Feb 2021 18:18:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5420A64E50 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=kLn7Frnb3KXBIVI15eI1F4oY4Cfd8CLAhQLuyIpXh2w=; b=UytIvmO2voaTT5jKokJbi1i9n 6cgONezr+vd/grrk7ImKqCR3Bwiz1XiOHo47vr//zY/6z83+D5yoPq2JWB6lW4maMubgDETjtqWTh IlYheyIlLHR9nX8gW75zoGsQp+Fe4jP/H63afRNI+4pQ0fE7pmviTpqGCJKlmi/u/RSXaU0ILDJhy 5vG7nJ0fDtwxVYgUUQLknJjsHvaTvjZ7GJCcTDYOSOiVbakEAmYNcm5rcts/QJ4+nY/gT2HtCU6Rn TFVEH8toXsWX42i3Z5JAfjy4X4/NJ+43yuAugRnkItw9p3P/OB+qnVQCDLEwkj/SIXwy7oYLgH8jY tzfU47M9A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6dkd-0004KB-2c; Mon, 01 Feb 2021 18:16:39 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6diX-0003CL-MK for linux-arm-kernel@merlin.infradead.org; Mon, 01 Feb 2021 18:14:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=PBNis2Le7mMZDVQZFpE5Weqxv7IPb4FFDDpAkRZVBuo=; b=Nfk9idLLEFqgcTYAFvc3s9F2Lj sA7N8dKzKvcUMr6CX/7vWA1rycIsNiqtbGYHBW5PWui8Em2b4OIbWVlW+GeQYHioXYyjEKXNhTfn5 XuVKyD16DB42AF73gfRBRupZaswST/sPh9X/ft+3arhhgduVNW8o3b7+sPV5a545EINpm94SmoVa7 WTxnx8TawtEKukjHD+79kxDfhNfoArFr80d+pDSNoY+libGM0GV4v+19HaX8//JrSsJQkwT9FDHQt iQsEHPNrI3bkzV853flzocLtIEyWFBNlOiR7G/RS37qO0C1NC56VSYKT40xiWBOLqCQPt5I7FKbX4 PpScQHkQ==; Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1l6diS-00E8DH-4L for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 18:14:26 +0000 Received: by mail-pj1-x1034.google.com with SMTP id lw17so326566pjb.0 for ; Mon, 01 Feb 2021 10:14:22 -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=PBNis2Le7mMZDVQZFpE5Weqxv7IPb4FFDDpAkRZVBuo=; b=oGJdf3twifKKOxzMWTxbHs26h/jfYISQ7r0dqOxkpJHd2XrT3wAyyea0/RKuT7ghdA RPcqX24YF6x69/+aMYjktfs4dwXDXgswZPfMFPNvgFlYeIM/LCZaZ/peMYll/Z+Wxz3H rHhKDeLLs3voRJdSjeytXDcFPoZbniDG1bywZMcp2h7/HJfR5ekwiiPYjW+JH16zyw1l Vv1BxiUt0iV66TLE8arp+7EFntLwckLCpuNlod7H807liZGiT9AatoWXoQL18k/Rhhu4 xR58q4OkUXRqdlZwNk8PIhduapiX/CKV5vJPMqdolTYmm7Nxft9xIuUsFM/9mwXfO4Zj R32w== 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=PBNis2Le7mMZDVQZFpE5Weqxv7IPb4FFDDpAkRZVBuo=; b=ab/wnSiuIcFqRyzYvqtXQZKHE3tga/ZY0GNNUr4v9MBMmAANSCthitqXZXgn3tBFX+ 7kMKwPlTIqJA5S1bbTkBBm5Tzuf4JTSyk+jWyHt8RUt4F8GVnX1TJs2YlVMKyA8kTwzC 9eCBi9dgbynNJdNo4HRnyBbUF9vyopUzWyiqGzbRhwzcPXEISyWv9sjR1hh+cmXQ11/I lBRp6oWInXGN/V4a93Y8YHVI8SAhSY3EOsz6OQ+VsrNiRq6TlyY3mbPb822lG2hXQWRn nB6B71OzpDIb2ne75X8JV0g+rrBdPZCea8E/ZRQhoayecsTyFYeXkz8GqcPW3/BUlrcj uVAg== X-Gm-Message-State: AOAM5334pDGOf2HNeZNiPq7FVFujkOqQIAp1sBm/la8h3X9j/zSH+p5B A11F+RjUPN9WONJy15UOZSlPTQ== X-Google-Smtp-Source: ABdhPJypa4yLATjeTzQd8p2ebrRP6WZKQ97kLu31Gwa7amDvHqhCSbOxnwQ6dXzcieuiqVBhDe0Odw== X-Received: by 2002:a17:90a:df15:: with SMTP id gp21mr118981pjb.63.1612203260425; Mon, 01 Feb 2021 10:14:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 10:14:19 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 25/31] coresight: etm4x: Refactor probing routine Date: Mon, 1 Feb 2021 11:13:45 -0700 Message-Id: <20210201181351.1475223-26-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_181426_789972_D5E98054 X-CRM114-Status: GOOD ( 19.11 ) 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 CoreSight ETM with system register access may not have a memory mapped i/o access. Refactor the ETM specific probing into a common routine to allow reusing the code for such ETMs. Cc: Mike Leach Signed-off-by: Suzuki K Poulose Link: https://lore.kernel.org/r/20210110224850.1880240-24-suzuki.poulose@arm.com Signed-off-by: Mathieu Poirier --- .../coresight/coresight-etm4x-core.c | 62 ++++++++++++------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 48d8e99e31eb..c3e458af618a 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -1708,14 +1708,11 @@ static void etm4_pm_clear(void) } } -static int etm4_probe(struct amba_device *adev, const struct amba_id *id) +static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid) { int ret; - void __iomem *base; - struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; struct etmv4_drvdata *drvdata; - struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; struct etm4_init_arg init_arg = { 0 }; @@ -1739,11 +1736,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up")) drvdata->skip_power_up = true; - /* 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); - drvdata->base = base; spin_lock_init(&drvdata->spinlock); @@ -1773,7 +1765,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) if (IS_ERR(pdata)) return PTR_ERR(pdata); - adev->dev.platform_data = pdata; + dev->platform_data = pdata; desc.type = CORESIGHT_DEV_TYPE_SOURCE; desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC; @@ -1793,7 +1785,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) etmdrvdata[drvdata->cpu] = drvdata; - pm_runtime_put(&adev->dev); dev_info(&drvdata->csdev->dev, "CPU%d: ETM v%d.%d initialized\n", drvdata->cpu, ETM_ARCH_MAJOR_VERSION(drvdata->arch), ETM_ARCH_MINOR_VERSION(drvdata->arch)); @@ -1803,11 +1794,30 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) drvdata->boot_enable = true; } - etm4_check_arch_features(drvdata, id->id); + etm4_check_arch_features(drvdata, etm_pid); return 0; } +static int etm4_probe_amba(struct amba_device *adev, const struct amba_id *id) +{ + void __iomem *base; + struct device *dev = &adev->dev; + struct resource *res = &adev->res; + int ret; + + /* 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); + + ret = etm4_probe(dev, base, id->id); + if (!ret) + pm_runtime_put(&adev->dev); + + return ret; +} + static struct amba_cs_uci_id uci_id_etm4[] = { { /* ETMv4 UCI data */ @@ -1824,15 +1834,12 @@ static void clear_etmdrvdata(void *info) etmdrvdata[cpu] = NULL; } -static int etm4_remove(struct amba_device *adev) +static int __exit etm4_remove_dev(struct etmv4_drvdata *drvdata) { - struct etmv4_drvdata *drvdata = dev_get_drvdata(&adev->dev); - etm_perf_symlink(drvdata->csdev, false); - /* - * Taking hotplug lock here to avoid racing between etm4_remove and - * CPU hotplug call backs. + * Taking hotplug lock here to avoid racing between etm4_remove_dev() + * and CPU hotplug call backs. */ cpus_read_lock(); /* @@ -1851,6 +1858,15 @@ static int etm4_remove(struct amba_device *adev) return 0; } +static int __exit etm4_remove_amba(struct amba_device *adev) +{ + struct etmv4_drvdata *drvdata = dev_get_drvdata(&adev->dev); + + if (drvdata) + return etm4_remove_dev(drvdata); + return 0; +} + static const struct amba_id etm4_ids[] = { CS_AMBA_ID(0x000bb95d), /* Cortex-A53 */ CS_AMBA_ID(0x000bb95e), /* Cortex-A57 */ @@ -1874,14 +1890,14 @@ static const struct amba_id etm4_ids[] = { MODULE_DEVICE_TABLE(amba, etm4_ids); -static struct amba_driver etm4x_driver = { +static struct amba_driver etm4x_amba_driver = { .drv = { .name = "coresight-etm4x", .owner = THIS_MODULE, .suppress_bind_attrs = true, }, - .probe = etm4_probe, - .remove = etm4_remove, + .probe = etm4_probe_amba, + .remove = etm4_remove_amba, .id_table = etm4_ids, }; @@ -1895,7 +1911,7 @@ static int __init etm4x_init(void) if (ret) return ret; - ret = amba_driver_register(&etm4x_driver); + ret = amba_driver_register(&etm4x_amba_driver); if (ret) { pr_err("Error registering etm4x driver\n"); etm4_pm_clear(); @@ -1906,7 +1922,7 @@ static int __init etm4x_init(void) static void __exit etm4x_exit(void) { - amba_driver_unregister(&etm4x_driver); + amba_driver_unregister(&etm4x_amba_driver); etm4_pm_clear(); }