Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1879416pxb; Sun, 10 Jan 2021 14:54:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXVeI+82adTMpqmAateAKGTmglzyJjOCL9xbIIm3syUOSVfQBuPyxDmI/G8uUoLU7k6qVG X-Received: by 2002:a50:e84d:: with SMTP id k13mr11963501edn.154.1610319239950; Sun, 10 Jan 2021 14:53:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610319239; cv=none; d=google.com; s=arc-20160816; b=vjglac6Ou93mNKpCmON6zWQrKx/blBwgcQ5YMNBuqJ5b8R5hdTXogesmKB/0BsrKbq a7jlakRS0qpIZe8JFyzi3tFVk/nW5CPudMWG9MVEgWIiG5/4nXv/OC4xRwkM7C7dIxJ/ uoAypqRT57j1zld/GXIK9v7pZ+dXmiybpy2I7hCrf7n4F9YXX8RackjGi2/Zsp0Jympn tqNPYRs3DmTbkDMl8j8/E1yJt7RCXre53rkDiLao0lVhifTIZwLHJRtDCFPYIugtvnc+ ynuXAUXt0yHquZG+jN6sUEXIEJ7xrNRuLLhGO1y3+hlJ5Dw0hN0Hpij68g6BdvNW1t6q 1WDg== 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=KThfToTgQIfoBqQ0O2Sbon/Or4qzM4+21q6fPeATz8g=; b=gB2zeVP+78obLWmY9acFVffbhHKtZFmV1HmRA8yFSohh3zoYoWJaa1K9eFvtfd6aK6 Vqzvzi7ON4lVWDwzqvu1/nTO1X1kLVKavEfEFh0V9t2AGkzWDoeE4GxShJWGfjShYpBn NCfJGJlzr/HTzRXUbLGA2SoUSnYPXGDLvsAvcEkeDOQ4XaoXajOg6gJzQTVC0EQ7VpWJ ShRxdIv0THYoWwYUSpOdAmJmkN008Lk2Bh0eYD1eZupXqlG4pKir/zpEuybc72Y2EHJZ tAD7h5zwxvpguo8IwCMKENRof+K3KE0mI9KSMg9OWVfggdpKqQ6f+3HHs68JbWWgEKy4 QTHQ== 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 d19si6363616eds.173.2021.01.10.14.53.36; Sun, 10 Jan 2021 14:53:59 -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 S1727322AbhAJWu5 (ORCPT + 99 others); Sun, 10 Jan 2021 17:50:57 -0500 Received: from foss.arm.com ([217.140.110.172]:39072 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727311AbhAJWu4 (ORCPT ); Sun, 10 Jan 2021 17:50:56 -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 E79401529; Sun, 10 Jan 2021 14:49:31 -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 98BB73F719; Sun, 10 Jan 2021 14:49:30 -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 19/28] coresight: etm4x: Use TRCDEVARCH for component discovery Date: Sun, 10 Jan 2021 22:48:41 +0000 Message-Id: <20210110224850.1880240-20-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 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 7adc9bd03eb5..5d3041eccc14 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