Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1879527pxb; Sun, 10 Jan 2021 14:54:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDnOItwLX0LPxRZTCgWr0YvCf4Y1hf3e/l+XnxUp3NoUdJPDvkqmyW+v0ZgdMB4pSjrAQv X-Received: by 2002:a05:6402:168f:: with SMTP id a15mr12783098edv.376.1610319264579; Sun, 10 Jan 2021 14:54:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610319264; cv=none; d=google.com; s=arc-20160816; b=YF36CM/ZzIcDDN71ubA4oCxGvDBTuqFobKpn3RagTVWUrwAYyZOOaK8xoUg+vWuXck Pu8DWfENdEC7ycgB+nu4YxkOwznXuIXnS0sHFQijWhqNaMclx8MOmQhbpxEYFIbtL5zU VNfql6GHWbTJ8E/vVE74qZyZAgXI+6FoceQp+laX0jeXouQW43qKadlVNnJZLJ+HrPdu JSWfm4pQNMSl3aBBOnIkhpX4uyFYRkLpsgUqo5/d2dNw3c4n7OZc1Y9TYPCISw+N2x1l rNE1zSzw3lsXf3T5WWdqCHUIZZAnBsWPHKgiWdx5B3Rjw5e2hD5zC16sZR+YacyViooJ cL7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7WUQBzrAwvdTdEl7h6DgROS0UOaEDNN1DaHQaDVpvvw=; b=oE9c7jFt2n9QnAAz70nMbpz2zF/BGdUUBT3IF7WhxO7DQrw2qDOR/fyFx3/Io0MYHE rHEsmIHW0B8zRB6JPXxkN11MUszyNZZxU9xkSO4cqm7wCEk06xCTf3SvxRJtmm/GTju8 LZyxonvbkA2VCQ8wd4YpcC6UkPiYEIja0kMR0oV5EIqqYcCgomBeabk5MiZdqrLtDvwX RFYO1sJt7O01oLMLcVNU8FGJrkYxMgC12sX5FIgn44aJXK/t5K5TyrJQxT5+Hxfk2Ixs 3imIbFCReWUpjRSiTR2XDB6wACFtUXQvW7eHW9FSug+8WFFBEwOXzKIXSRzDsfRBx34j nzxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s30si6276110edi.465.2021.01.10.14.54.01; Sun, 10 Jan 2021 14:54:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727543AbhAJWvr (ORCPT + 99 others); Sun, 10 Jan 2021 17:51:47 -0500 Received: from foss.arm.com ([217.140.110.172]:39102 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727415AbhAJWvV (ORCPT ); Sun, 10 Jan 2021 17:51:21 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 65FBA150C; Sun, 10 Jan 2021 14:49:30 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 160313F719; Sun, 10 Jan 2021 14:49:28 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: coresight@lists.linaro.org, mathieu.poirier@linaro.org, anshuman.khandual@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, jonathan.zhouwen@huawei.com, catalin.marinas@arm.com, Suzuki K Poulose Subject: [PATCH v7 18/28] coresight: etm4x: Detect access early on the target CPU Date: Sun, 10 Jan 2021 22:48:40 +0000 Message-Id: <20210110224850.1880240-19-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210110224850.1880240-1-suzuki.poulose@arm.com> References: <20210110224850.1880240-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to detect the support for system instruction support, move the detection of the device access to the target CPU. Cc: Mike Leach Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- Changes since v3 - Name constructs etm4_xx instead of etm_** (Mathieu) --- .../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 862b424aef26..7adc9bd03eb5 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) -- 2.24.1