Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp270661pxu; Thu, 7 Jan 2021 04:45:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjd6ejxU4V2EUtHKP/clSD3AIs0KUn38U/mYscqcpD5qRx8yB9HsQx75o1tuF54DmB98St X-Received: by 2002:a50:8a90:: with SMTP id j16mr1512018edj.334.1610023506988; Thu, 07 Jan 2021 04:45:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610023506; cv=none; d=google.com; s=arc-20160816; b=putmXo34RCvMv+4sdvow/BNMjKCUS96dU439/RDauzMTgMwD7quBNiiAk4YolD4L+y MdoCIdACoqkUaNIcXdx/v7rPVSdibranji3NZYArA1Uflc134OvnNlJomhU/nXBMJ9BF C0n7kp/WLOzwIIteHGw0LcQJrB9PZfR5HoDbW3a7NvcjM/RGdr2bJY+pT2j1TOIYF3M0 e8dEzED42TlhvzaqA/20BAuNc+gHVZGZ75dl8GbzPVzmmsllF+4qGgiwQx6H8/LAbBWO fjmqp0jTONVNDO4d+6+tjU6iajbdbk5zyGZ907QBvrfBHtvLV6ayyU5rLoazQYYjKTQW 5dWA== 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=sqfLH/YPEGRpJ86ZpMUZiM7Y6JIjToJ6gcBm5xij+ok=; b=kNlnS2LsLgxDZBFzus8d/OwsX6bfQD3bn0mGBF6s0rWUjcwppERv3CfRl7sE6khztm PxxGepgwabpg3dQXERRLXPoOMg//eX4KfRcaGPxTcDEQgYe6bohO7tZsc5kK2lI8f2Kb HvHjw4KOcSm83CTeV4sVQbvmZ/aK5QIshSHHmuEwCY784nk2Gl40hCApNVnSKewRhQyl SG7Qz1h8N883jjpROmOnvQAY9cRQW7N2ssuTdXAlzx9wco4BmGkKdEvCTaSq2b+bPUyW 6bu1DmJtmanEmTXxRld0/s2fqbELsqpO1qpYKk6oNkrJGGtsZarRPpphtORAp9JH03yF MVtg== 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 30si2239805edv.385.2021.01.07.04.44.43; Thu, 07 Jan 2021 04:45:06 -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 S1728538AbhAGMlf (ORCPT + 99 others); Thu, 7 Jan 2021 07:41:35 -0500 Received: from foss.arm.com ([217.140.110.172]:59980 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728520AbhAGMld (ORCPT ); Thu, 7 Jan 2021 07:41:33 -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 7E67614FF; Thu, 7 Jan 2021 04:39:37 -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 63EAE3F719; Thu, 7 Jan 2021 04:39:36 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org, leo.yan@linaro.org, mike.leach@linaro.org, anshuman.khandual@arm.com, Suzuki K Poulose Subject: [PATCH v6 17/26] coresight: etm4x: Use TRCDEVARCH for component discovery Date: Thu, 7 Jan 2021 12:38:50 +0000 Message-Id: <20210107123859.674252-18-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210107123859.674252-1-suzuki.poulose@arm.com> References: <20210107123859.674252-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 We have been using TRCIDR1 for detecting the ETM version. This is in preparation for the future IP support. Cc: Mike Leach Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- .../coresight/coresight-etm4x-core.c | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index a97870ac0d08..84af2c7b7f86 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -153,18 +153,6 @@ static void etm4_cs_unlock(struct etmv4_drvdata *drvdata, CS_UNLOCK(csa->base); } -static bool etm4_arch_supported(u8 arch) -{ - /* Mask out the minor version number */ - switch (arch & 0xf0) { - case ETM_ARCH_V4: - break; - default: - return false; - } - return true; -} - static int etm4_cpu_id(struct coresight_device *csdev) { struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); @@ -784,6 +772,26 @@ static const struct coresight_ops etm4_cs_ops = { static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata, struct csdev_access *csa) { + u32 devarch = readl_relaxed(drvdata->base + TRCDEVARCH); + u32 idr1 = readl_relaxed(drvdata->base + TRCIDR1); + + /* + * All ETMs must implement TRCDEVARCH to indicate that + * the component is an ETMv4. To support any broken + * implementations we fall back to TRCIDR1 check, which + * is not really reliable. + */ + if ((devarch & ETM_DEVARCH_ID_MASK) == ETM_DEVARCH_ETMv4x_ARCH) { + drvdata->arch = etm_devarch_to_arch(devarch); + } else { + pr_warn("CPU%d: ETM4x incompatible TRCDEVARCH: %x, falling back to TRCIDR1\n", + smp_processor_id(), devarch); + + if (ETM_TRCIDR1_ARCH_MAJOR(idr1) != ETM_TRCIDR1_ARCH_ETMv4) + return false; + drvdata->arch = etm_trcidr_to_arch(idr1); + } + *csa = CSDEV_ACCESS_IOMEM(drvdata->base); return true; } @@ -800,7 +808,6 @@ static bool etm4_init_csdev_access(struct etmv4_drvdata *drvdata, static void etm4_init_arch_data(void *info) { u32 etmidr0; - u32 etmidr1; u32 etmidr2; u32 etmidr3; u32 etmidr4; @@ -865,14 +872,6 @@ static void etm4_init_arch_data(void *info) /* TSSIZE, bits[28:24] Global timestamp size field */ drvdata->ts_size = BMVAL(etmidr0, 24, 28); - /* base architecture of trace unit */ - etmidr1 = etm4x_relaxed_read32(csa, TRCIDR1); - /* - * TRCARCHMIN, bits[7:4] architecture the minor version number - * TRCARCHMAJ, bits[11:8] architecture major versin number - */ - drvdata->arch = BMVAL(etmidr1, 4, 11); - /* maximum size of resources */ etmidr2 = etm4x_relaxed_read32(csa, TRCIDR2); /* CIDSIZE, bits[9:5] Indicates the Context ID size */ @@ -1712,7 +1711,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) etm4_init_arch_data, &init_arg, 1)) dev_err(dev, "ETM arch init failed\n"); - if (etm4_arch_supported(drvdata->arch) == false) + if (!drvdata->arch) return -EINVAL; etm4_init_trace_id(drvdata); @@ -1744,7 +1743,8 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) pm_runtime_put(&adev->dev); dev_info(&drvdata->csdev->dev, "CPU%d: ETM v%d.%d initialized\n", - drvdata->cpu, drvdata->arch >> 4, drvdata->arch & 0xf); + drvdata->cpu, ETM_ARCH_MAJOR_VERSION(drvdata->arch), + ETM_ARCH_MINOR_VERSION(drvdata->arch)); if (boot_enable) { coresight_enable(drvdata->csdev); -- 2.24.1