From patchwork Mon Feb 1 18:13:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12059685 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=-14.3 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, UNWANTED_LANGUAGE_BODY,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 72CF4C433E0 for ; Mon, 1 Feb 2021 18:20:48 +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 C702E64DE1 for ; Mon, 1 Feb 2021 18:20:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C702E64DE1 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=hGbNZjOcIY6+gpawv8LE84uvakXTZI8iDPGuYVn5PQE=; b=XYesS3vwzwyMgTD2DbKBOKB0b jACKcUdXclMpEaOslmQCIo7lMKBnc9dG9uwkFzPWw0l/4/7NedrP0sYP4wMvU1QeRRomNdcNpPu4L bTCwTceg31eqCTbchhl57WYuzhhC8+W08oXmEPGHE9pY/kyNQABDYrzblCoTUBd5GlNHxm3M9/o1p gmBHsucT7ypWQpIWVOQ4RyoMzgJcKSuFzcCMNhlQLIFo+eWafuKnMEbBovtnOC0Bs9OiHcNg2figg /JzK0NgLqDS9WPkU5J2XdddQeaUBDSdzsySzEq/C8uqUpCBKdUm0B1A6y5NA4PtoSwY2Y0pQM2pGj PnVS4JUYQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6dmM-0005KF-91; Mon, 01 Feb 2021 18:18:27 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6diL-00036I-4X for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 18:14:32 +0000 Received: by mail-pj1-x1035.google.com with SMTP id z9so72660pjl.5 for ; Mon, 01 Feb 2021 10:14:16 -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=MZ0qc4FQm15rLxsjsyvmy33IGQ5QIQNw22305IvB1H4=; b=OF9Ql11LG+gDLcy/2U6/rozE5uggjn0RcpCYJSBEDxPryxGcJJEYj5JifZQb530/dv tzlLLR8ZXbU5vcJDK9k+o4XwJjsbq+5orcGSH/CbeXB0lb9MNY/q2ashSbGlC0RjvT8N 5PeFWqDHabeMVfPiZjeWDNB8rBaWJSzulFMIxwVOkOuEQqOv9Wa20EOE7nJNW06nWcN1 dCcoSCGh7sfbG8Yo53wUBf82d3PCJli0743wnekcgdiJLqas3uXARkoRGiX/9UfJMK+Z cHY9rgdYFcw32iyrjXHce5HpxS3MlMSi+97MVpj4X+85gFgRlrfquTiTsoW0LxYtF95W CxFw== 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=MZ0qc4FQm15rLxsjsyvmy33IGQ5QIQNw22305IvB1H4=; b=EPQLk9wMgwHdvDtxt4YZZSkErWUWvhzVOyH88wOdba50r0KN33GYa7FfeONoBBd2o5 SmGDCOFZefMN5EuXP1XH8zabcyMIRrHrrcQIe+J2Tu51Hyz+ysSRdygL0bwxqHQH4yJl WhZZgO0vvfD9uJvM370iyLiOfIXal9LMkM5j0me2m/Wed/34UhfYOiw7V5OnUuoL1LNn j6v0426Hoieo69DG07X6Rb+n0V6MAC9RKO6KmbWMvqa5AJAaAS9RsVt9gnFMlHUpJ3/n 0xAo0lOswIszWHXqEmo9a1w/Swk9NBjJun8sfWE/OxwgHHVp6w74d8IKfh84XT+D7IS5 BxjA== X-Gm-Message-State: AOAM532jntEwYm2WpjQZs+FT9RiIzpAqX6ln7sVQ3l0VaXMQAjNawr+z ISzp47sXHr1fhXjevSWDUxxcNw== X-Google-Smtp-Source: ABdhPJydriz8XQSVP4xtpVuwejzTBocd5o9fD1om/EzM/gOK3gKA30RbAcaNlT4sdox1xT/COCfh8w== X-Received: by 2002:a17:90a:d912:: with SMTP id c18mr151485pjv.102.1612203255251; Mon, 01 Feb 2021 10:14:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 10:14:14 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 20/31] coresight: etm4x: Detect access early on the target CPU Date: Mon, 1 Feb 2021 11:13:40 -0700 Message-Id: <20210201181351.1475223-21-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_131418_081528_909F8E72 X-CRM114-Status: GOOD ( 18.60 ) 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 In preparation to detect the support for system instruction support, move the detection of the device access to the target CPU. Cc: Mike Leach Signed-off-by: Suzuki K Poulose Link: https://lore.kernel.org/r/20210110224850.1880240-19-suzuki.poulose@arm.com Signed-off-by: Mathieu Poirier --- .../coresight/coresight-etm4x-core.c | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 59da9efae9c2..bfe3b8224d9a 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -59,6 +59,11 @@ static u64 etm4_get_access_type(struct etmv4_config *config); static enum cpuhp_state hp_online; +struct etm4_init_arg { + struct etmv4_drvdata *drvdata; + struct csdev_access *csa; +}; + /* * Check if TRCSSPCICRn(i) is implemented for a given instance. * @@ -776,6 +781,22 @@ static const struct coresight_ops etm4_cs_ops = { .source_ops = &etm4_source_ops, }; +static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata, + struct csdev_access *csa) +{ + *csa = CSDEV_ACCESS_IOMEM(drvdata->base); + return true; +} + +static bool etm4_init_csdev_access(struct etmv4_drvdata *drvdata, + struct csdev_access *csa) +{ + if (drvdata->base) + return etm4_init_iomem_access(drvdata, csa); + + return false; +} + static void etm4_init_arch_data(void *info) { u32 etmidr0; @@ -784,11 +805,22 @@ static void etm4_init_arch_data(void *info) u32 etmidr3; u32 etmidr4; u32 etmidr5; - struct etmv4_drvdata *drvdata = info; - struct csdev_access tmp_csa = CSDEV_ACCESS_IOMEM(drvdata->base); - struct csdev_access *csa = &tmp_csa; + struct etm4_init_arg *init_arg = info; + struct etmv4_drvdata *drvdata; + struct csdev_access *csa; int i; + drvdata = init_arg->drvdata; + csa = init_arg->csa; + + /* + * If we are unable to detect the access mechanism, + * or unable to detect the trace unit type, fail + * early. + */ + if (!etm4_init_csdev_access(drvdata, csa)) + return; + /* Make sure all registers are accessible */ etm4_os_unlock_csa(drvdata, csa); etm4_cs_unlock(drvdata, csa); @@ -1634,6 +1666,7 @@ 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 etm4_init_arg init_arg = { 0 }; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) @@ -1661,7 +1694,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR(base); drvdata->base = base; - desc.access = CSDEV_ACCESS_IOMEM(base); spin_lock_init(&drvdata->spinlock); @@ -1673,8 +1705,11 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) if (!desc.name) return -ENOMEM; + init_arg.drvdata = drvdata; + init_arg.csa = &desc.access; + if (smp_call_function_single(drvdata->cpu, - etm4_init_arch_data, drvdata, 1)) + etm4_init_arch_data, &init_arg, 1)) dev_err(dev, "ETM arch init failed\n"); if (etm4_arch_supported(drvdata->arch) == false)