Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1879461pxb; Sun, 10 Jan 2021 14:54:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxj2gdIhtRVYj1yMuLst0hUnguGbdePf4QgQTJB3dc2jQ833/e9qa2Aae0lISeSFqECGiqq X-Received: by 2002:a50:fd18:: with SMTP id i24mr12659638eds.146.1610319247569; Sun, 10 Jan 2021 14:54:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610319247; cv=none; d=google.com; s=arc-20160816; b=Y4ayI3eecwx3G0a60jsSgHhFAc3FhhpZdbGcNrkTGCM3ULMG2X70t/GQg8fYQxRQrO 01DqsOirT1gBKGpkjlxr3fbhso0bSrxyxFl4S+fhMYRvSG3qn/iT+wfPEofk+6GN6a4t qrr8aYiFlK7qv+91X/TpVoM59eYIIUcwAvfh0ZOMxjUvsutQK3q+bqSTvTXgqD13fJqx bdiEq0jXVQeM6qxPlSNcmZKacCVRrdrkrgds6PnPVnnPR6hUjCMA+h4RWszNTczIPYVr V3EHrXPCrIYffkw1OREOfKQwVLw5T+KdxF4oPB9vsbYxFRQjGwNTltomeFY6GjGa6veN SntA== 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=uhD1GOJFEmPh65j7V1kMYea+IjLrH1DzDxuUE4bHsOk=; b=UYEFzmc219pgq/4OHKjxugqFSJnfvpkuGDu7ySx1wl5sRuw2vXLIfLiuKZ8N707S2T WS2NkMX94Ae573Q8JjPFipE9Bk+FhPNf6+PiZAEVG0KbcNKJuzukUwqRb6kS/A6FxZ1x Ow4yFRoBSUfTRi0GSVmdWOeICaaTLPTMWCrXuGkBqhnnFJTd2QKAeOVpbT2zUF9/O90M BRQzTigCm9Jfo2cd9RsY2Sosvutu14pT2HXJj/d/9kfm4uwv9PCT6OXBBhgy+p5iEN5v SoFyJwUepIbM+xgUgUvwxS2ptP2vl9kK1d9OzBN+R1MbUJ22fhs3O8L2wUU03M19uINA Rr1Q== 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 eb10si5830073ejc.405.2021.01.10.14.53.44; Sun, 10 Jan 2021 14:54:07 -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 S1727398AbhAJWvM (ORCPT + 99 others); Sun, 10 Jan 2021 17:51:12 -0500 Received: from foss.arm.com ([217.140.110.172]:39074 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727309AbhAJWu5 (ORCPT ); Sun, 10 Jan 2021 17:50:57 -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 83C8C152F; Sun, 10 Jan 2021 14:49:36 -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 34D733F719; Sun, 10 Jan 2021 14:49:35 -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 22/28] coresight: etm4x: Detect system instructions support Date: Sun, 10 Jan 2021 22:48:44 +0000 Message-Id: <20210110224850.1880240-23-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 ETM v4.4 onwards adds support for system instruction access to the ETM. Detect the support on an ETM and switch to using the mode when available. Cc: Mike Leach Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- .../coresight/coresight-etm4x-core.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 3b17feb86d8a..6cbc6e0c0819 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -782,6 +782,37 @@ static const struct coresight_ops etm4_cs_ops = { .source_ops = &etm4_source_ops, }; +static inline bool cpu_supports_sysreg_trace(void) +{ + u64 dfr0 = read_sysreg_s(SYS_ID_AA64DFR0_EL1); + + return ((dfr0 >> ID_AA64DFR0_TRACEVER_SHIFT) & 0xfUL) > 0; +} + +static bool etm4_init_sysreg_access(struct etmv4_drvdata *drvdata, + struct csdev_access *csa) +{ + u32 devarch; + + if (!cpu_supports_sysreg_trace()) + return false; + + /* + * ETMs implementing sysreg access must implement TRCDEVARCH. + */ + devarch = read_etm4x_sysreg_const_offset(TRCDEVARCH); + if ((devarch & ETM_DEVARCH_ID_MASK) != ETM_DEVARCH_ETMv4x_ARCH) + return false; + *csa = (struct csdev_access) { + .io_mem = false, + .read = etm4x_sysreg_read, + .write = etm4x_sysreg_write, + }; + + drvdata->arch = etm_devarch_to_arch(devarch); + return true; +} + static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata, struct csdev_access *csa) { @@ -812,9 +843,17 @@ static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata, static bool etm4_init_csdev_access(struct etmv4_drvdata *drvdata, struct csdev_access *csa) { + /* + * Always choose the memory mapped io, if there is + * a memory map to prevent sysreg access on broken + * systems. + */ if (drvdata->base) return etm4_init_iomem_access(drvdata, csa); + if (etm4_init_sysreg_access(drvdata, csa)) + return true; + return false; } -- 2.24.1