Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4038786pxb; Mon, 1 Feb 2021 10:45:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0l0nz0UfqVKGdPH/620Y6wRzXveyU1VTQ7Kam8GZ2TWFIj5+luY1X417ZDXGGrz8ZE894 X-Received: by 2002:a17:906:3649:: with SMTP id r9mr7526341ejb.202.1612205102762; Mon, 01 Feb 2021 10:45:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612205102; cv=none; d=google.com; s=arc-20160816; b=gciQFeQLa0phutt6noYWrnYL8ZJSak+ssF9arjmZ5+0vwuH8MyyizAJktWuHt3MAPg UIhe+esUV6CkimcwvT+uo9fg1r02+o7cuyA3gurutMJWxla0/XfjY5JAY4wSrLaDaKjY VJpikYxy8/r3fH+hy+eg4eSqfzLhUxWpBuvAyvKYrRxifsVZQjtL8ZZzZGxWbd8VOfZ6 Q+u0kchxgxyC2ew45LafmijUPFb5zO+xXW9oDCnpMSeAw6mZSIwcPEY4/qxxcx/fw5ii 50Yw/v841DlpcaoqOqpnzqTLHxtpEE5+7QDpg65soJLt7TRgflDP79+yjFIGDVJ+TYLu uf8w== 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 :dkim-signature; bh=rMKTiBBzzA6qqd/h2MGcj7qPjB9ZbPsUF9hLa2otpO8=; b=PS1MeXyRl6uo2MO/pEZESonu+tfaLWLPyZepfFYkr2SzVKfc4i2PKQ5krOxgSh09TV q2QMa4CE8IUKH1R3uh++nhz0JzRmFjwmA0lb8hmKT3TpO/BcuPNJZ7a3UpqI1Pg87PDC G6GZ6lYmVqfMrdMPcHX9tVlh27LIhTIWeyZ01+xcgHDuEoB8MwgajYveZ8qbvsuXFm82 p78kCGfxyA/4M9yOIAxOCqEzC590PKOXSLfpJ/TDsYHObCO/aUakTsAPJrzpNDGDfND2 +836JgCzjwm4H3pGq2QXHgrc/Eit7ExkLTnK9mp4QKMydSr4HV4NXXf9PGI/vXammIVs 0ZxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mr3uuV5h; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hj12si4924325ejb.577.2021.02.01.10.44.37; Mon, 01 Feb 2021 10:45:02 -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; dkim=pass header.i=@linaro.org header.s=google header.b=mr3uuV5h; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232447AbhBASl7 (ORCPT + 99 others); Mon, 1 Feb 2021 13:41:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbhBASPM (ORCPT ); Mon, 1 Feb 2021 13:15:12 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8292FC06121C for ; Mon, 1 Feb 2021 10:14:14 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id e19so12129992pfh.6 for ; Mon, 01 Feb 2021 10:14:14 -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=rMKTiBBzzA6qqd/h2MGcj7qPjB9ZbPsUF9hLa2otpO8=; b=mr3uuV5hq02GXn/RPIeayLViAvbTjtyxGnZZ/uAvii+zw7bOaztYkzXjVLHUAp2JmA queFWoAtMlomRlZdDFh1RMeYdgSgf/iv7fY2tZx7Pmb9GYW16+ErcAkk3JklVKKlYXsM tcJtp+YGuxPYtwYHgU8IlmtrAo5hSGZ2puppL43mtLUKI6VbM4Sf5InRyuJWqB76rWR2 EZvlTMuFrPgSrvn+hux3V13Heug9PG9U6Xl4pmf+MFm7qp3T8PMUYjBZVhJfX2yQPlPz rWvDDQyxo4U5MvxbpBREmEwVSonuiNKapJVByaPZ8BkdqDpOcoB8gGw7fDyq3V+L4Z3C 8frQ== 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=rMKTiBBzzA6qqd/h2MGcj7qPjB9ZbPsUF9hLa2otpO8=; b=B7EpvXJCBT5pt/UgqL1x1uWZPtbbI0FQyDm/rxxUgV5DrIHBeHquwIkzukEaFpELC+ jkObgECuqq3AnMogopkTMdv6ITq9BfZSjrYNYMXv6jUD1q4kK5tth3IGWYbxi63FVNWw Hlt4HWTeKQTtdSZHZMSgUbmVx18NMUvqgxXNpkk06+nXOVwj914MtckDJQmF0zNvf48X hKG6iyxOr4mYGSxBrHLBhsmWX0AnvrvvVc06ggDiWBWo2ASXeQxuY1qLMMtWG024la3u MD2CGAhpV3luAo3WBWLID1n/HQE9ukFQRAT2rYzTItlj0O70kbVzvX1+uwxeJgoZGQ/h 8/Cw== X-Gm-Message-State: AOAM530O+O9srNGIwp/tjkzUpMHtzq5TrsA2PXXqF4A7CsyDFRIazL2d 2swG1NiMaQp5yFs+u/Q7fAZKaP0Mzkr3yQ== X-Received: by 2002:a62:75c1:0:b029:1b6:b71a:a369 with SMTP id q184-20020a6275c10000b02901b6b71aa369mr17568835pfc.27.1612203254038; Mon, 01 Feb 2021 10:14:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 10:14:13 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/31] coresight: etm4x: Handle ETM architecture version Date: Mon, 1 Feb 2021 11:13:39 -0700 Message-Id: <20210201181351.1475223-20-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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose We are about to rely on TRCDEVARCH for detecting the ETM and its architecture version, falling back to TRCIDR1 if the former is not implemented (in older broken implementations). Also, we use the architecture version information to make some decisions. Streamline the architecture version handling by adding helpers. Signed-off-by: Suzuki K Poulose Link: https://lore.kernel.org/r/20210110224850.1880240-18-suzuki.poulose@arm.com Signed-off-by: Mathieu Poirier --- .../coresight/coresight-etm4x-core.c | 2 +- drivers/hwtracing/coresight/coresight-etm4x.h | 60 ++++++++++++++++++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index c9fcb17968a0..59da9efae9c2 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -917,7 +917,7 @@ static void etm4_init_arch_data(void *info) * Otherwise for values 0x1 and above the number is N + 1 as per v4.2. */ drvdata->nr_resource = BMVAL(etmidr4, 16, 19); - if ((drvdata->arch < ETM4X_ARCH_4V3) || (drvdata->nr_resource > 0)) + if ((drvdata->arch < ETM_ARCH_V4_3) || (drvdata->nr_resource > 0)) drvdata->nr_resource += 1; /* * NUMSSCC, bits[23:20] the number of single-shot diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 91b82002e260..0af60571aa23 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -468,7 +468,6 @@ #define ETM_MAX_RES_SEL 32 #define ETM_MAX_SS_CMP 8 -#define ETM_ARCH_V4 0x40 #define ETMv4_SYNC_MASK 0x1F #define ETM_CYC_THRESHOLD_MASK 0xFFF #define ETM_CYC_THRESHOLD_DEFAULT 0x100 @@ -593,8 +592,63 @@ #define TRCVICTLR_EXLEVEL_S_MASK (ETM_EXLEVEL_S_MASK << TRCVICTLR_EXLEVEL_SHIFT) #define TRCVICTLR_EXLEVEL_NS_MASK (ETM_EXLEVEL_NS_MASK << TRCVICTLR_EXLEVEL_SHIFT) +#define ETM_TRCIDR1_ARCH_MAJOR_SHIFT 8 +#define ETM_TRCIDR1_ARCH_MAJOR_MASK (0xfU << ETM_TRCIDR1_ARCH_MAJOR_SHIFT) +#define ETM_TRCIDR1_ARCH_MAJOR(x) \ + (((x) & ETM_TRCIDR1_ARCH_MAJOR_MASK) >> ETM_TRCIDR1_ARCH_MAJOR_SHIFT) +#define ETM_TRCIDR1_ARCH_MINOR_SHIFT 4 +#define ETM_TRCIDR1_ARCH_MINOR_MASK (0xfU << ETM_TRCIDR1_ARCH_MINOR_SHIFT) +#define ETM_TRCIDR1_ARCH_MINOR(x) \ + (((x) & ETM_TRCIDR1_ARCH_MINOR_MASK) >> ETM_TRCIDR1_ARCH_MINOR_SHIFT) +#define ETM_TRCIDR1_ARCH_SHIFT ETM_TRCIDR1_ARCH_MINOR_SHIFT +#define ETM_TRCIDR1_ARCH_MASK \ + (ETM_TRCIDR1_ARCH_MAJOR_MASK | ETM_TRCIDR1_ARCH_MINOR_MASK) + +#define ETM_TRCIDR1_ARCH_ETMv4 0x4 + +/* + * Driver representation of the ETM architecture. + * The version of an ETM component can be detected from + * + * TRCDEVARCH - CoreSight architected register + * - Bits[15:12] - Major version + * - Bits[19:16] - Minor version + * TRCIDR1 - ETM architected register + * - Bits[11:8] - Major version + * - Bits[7:4] - Minor version + * We must rely on TRCDEVARCH for the version information, + * however we don't want to break the support for potential + * old implementations which might not implement it. Thus + * we fall back to TRCIDR1 if TRCDEVARCH is not implemented + * for memory mapped components. + * Now to make certain decisions easier based on the version + * we use an internal representation of the version in the + * driver, as follows : + * + * ETM_ARCH_VERSION[7:0], where : + * Bits[7:4] - Major version + * Bits[3:0] - Minro version + */ +#define ETM_ARCH_VERSION(major, minor) \ + ((((major) & 0xfU) << 4) | (((minor) & 0xfU))) +#define ETM_ARCH_MAJOR_VERSION(arch) (((arch) >> 4) & 0xfU) +#define ETM_ARCH_MINOR_VERSION(arch) ((arch) & 0xfU) + +#define ETM_ARCH_V4 ETM_ARCH_VERSION(4, 0) /* Interpretation of resource numbers change at ETM v4.3 architecture */ -#define ETM4X_ARCH_4V3 0x43 +#define ETM_ARCH_V4_3 ETM_ARCH_VERSION(4, 3) + +static inline u8 etm_devarch_to_arch(u32 devarch) +{ + return ETM_ARCH_VERSION(ETM_DEVARCH_ARCHID_ARCH_VER(devarch), + ETM_DEVARCH_REVISION(devarch)); +} + +static inline u8 etm_trcidr_to_arch(u32 trcidr1) +{ + return ETM_ARCH_VERSION(ETM_TRCIDR1_ARCH_MAJOR(trcidr1), + ETM_TRCIDR1_ARCH_MINOR(trcidr1)); +} enum etm_impdef_type { ETM4_IMPDEF_HISI_CORE_COMMIT, @@ -761,7 +815,7 @@ struct etmv4_save_state { * @spinlock: Only one at a time pls. * @mode: This tracer's mode, i.e sysFS, Perf or disabled. * @cpu: The cpu this component is affined to. - * @arch: ETM version number. + * @arch: ETM architecture version. * @nr_pe: The number of processing entity available for tracing. * @nr_pe_cmp: The number of processing entity comparator inputs that are * available for tracing. -- 2.25.1