Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1031936pxb; Tue, 8 Feb 2022 07:51:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQiVIVIz47GL0tfJspfDnOKtd7OVDYNyqUnF92f+nMrg8mIMTNxHm7I/0R4a7fnTJsqz0B X-Received: by 2002:a17:902:e84a:: with SMTP id t10mr4936761plg.25.1644335470228; Tue, 08 Feb 2022 07:51:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644335470; cv=none; d=google.com; s=arc-20160816; b=fUHT7EzlTFKPpedCcbtVDsXZXZipgyX/lrn33RwXtblXYDNDBqfCnWvUIvip8YL1ML RROussG25gZd+2+Nltc6vCJcGHTHtUv+XKts7PfBEtCQD+9htmN4x+lPQcmsbBXD8rjE kmf4q0hQN3xXhn91OMBf9QYwq3oT38yDyo+7lOCPTBc6WYnSHkam85CAazCTm7DBQ76d bquBAiY9Cayv0BaqUqMYN+wYLu1z+oMJoEynte901gtDuokLRpzkaPlLPLZisVPQU9ns nlscIB2co75OE2S7B5RI9Y8Pw9P64XcdziBB7bD2qR8YR2bcM6vegsunwoJxsbf0cvlm G2SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=kDmHxeBQUl+rZZAJ7g87tKDbqFdO7hParR4cnT5r2tY=; b=SjSLv14w5duVTjTFQG1KFQvDQ9FxMzzhYTz/H/R30WovudflaDNei7x8gZWv8aJwCR 152qcEqdjCBoUWR54P/1DvHqf7WvpxqnsmJll76lm2EFeMod2M9lvd7K49abgbV7iBD9 jjBBhHCU6hj/fosXdvgLrx/lMH63JIi+r29Jj+jW3324OoJDH/WgM2qMvogeALdolTTM i2/RV2ADbzBrSBdd7jFaSZkF46DNw9p9rCQg9bqly6bqnbpLnMKFXvfd4e826Wr5ApQv aAtA6qZAyUgobcIf3+7ImeZoUZ0yJsElqqPig3LfdcQVqDjNCVC9HCKxYssatFSI9nbm Je8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A7diG2DU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 82si14027633pgb.538.2022.02.08.07.50.57; Tue, 08 Feb 2022 07:51:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A7diG2DU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1355836AbiBHLtH (ORCPT + 99 others); Tue, 8 Feb 2022 06:49:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349305AbiBHLsv (ORCPT ); Tue, 8 Feb 2022 06:48:51 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B6CDC03C18C for ; Tue, 8 Feb 2022 03:37:02 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id d27so1884593wrc.6 for ; Tue, 08 Feb 2022 03:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kDmHxeBQUl+rZZAJ7g87tKDbqFdO7hParR4cnT5r2tY=; b=A7diG2DUiuxIOiAMuIE0aXaK5zh5HEg1Jg0KbudixlINuC+lFA9k1zxiz1wx9gyhbP MEYzc+X2DW/YmcFVPKHFFHWIKUrpC774nYFFTPRtWt147MGroD0RAzmS5CYZFs4Hy7x4 pXkNHn+vkAd/seKhCSwbowiGN0miw85lPmlZJI5UX6gKmoo8xWkq1Ti2aRnEwfcdG7Fx 3ZIWttONlELcZTfq3sj9iHSIExOBxvpVbWlXMr12M7t/FiOQh3rz1nxFtIueCMS+7gtv bMzLp0dQTr3J8wqW4UApxgpog7U2n2kafLb8kSV8w8R/gZvY/HUS9DOgIPU1x5PJr+Z/ ersw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kDmHxeBQUl+rZZAJ7g87tKDbqFdO7hParR4cnT5r2tY=; b=Hpmk6Cv/uGtZtSadvkMzwP1u+SAZa2jEFzNlckwciw/i9r/ZloX1sSquQYtt9dK6C5 L9GlnNmrCUUylXj6/9lnYWOQCWJ/Jl6G4Ri0DeW4Ip3r+zkdS0cWY2P9ZcdZ1L3kX3s2 xPgducOccDle0NuOhvYA2MrwGxKKqYanIKckZSgqhH2OxpFNMEO2I9vXHqSuqMbCiNM+ Gs/cJ6jERjJ6Ek479RL9zIZSrAF77vkzSTL5Q2hh1bg+QFoqha+76mkmJrd0QEHrfkNP qQ/zKim0kkbhyXojlhj34sRNtnVEz3dV07UCaZm6UUazPFjwAiPcBu9GQp1ldQrgpLZq 52rg== X-Gm-Message-State: AOAM53082VTUg9/a5dCO/adRuK3XubTa/Pp4RO31OQITI7TMiANVyZKq AbUdQsPC/VmQMkk9kxLkJmxQikBQKFgK6z/t/6H+9RjSvr5nog== X-Received: by 2002:adf:e710:: with SMTP id c16mr3276778wrm.699.1644320220607; Tue, 08 Feb 2022 03:37:00 -0800 (PST) MIME-Version: 1.0 References: <20220203120604.128396-1-james.clark@arm.com> <20220203120604.128396-2-james.clark@arm.com> In-Reply-To: <20220203120604.128396-2-james.clark@arm.com> From: Mike Leach Date: Tue, 8 Feb 2022 11:36:49 +0000 Message-ID: Subject: Re: [PATCH v2 01/15] coresight: Make ETM4x TRCIDR0 register accesses consistent with sysreg.h To: James Clark Cc: suzuki.poulose@arm.com, mathieu.poirier@linaro.org, coresight@lists.linaro.org, leo.yan@linaro.com, Leo Yan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi James, On Thu, 3 Feb 2022 at 12:06, James Clark wrote: > > This is a no-op change for style and consistency and has no effect on the > binary produced by gcc-11. > > Signed-off-by: James Clark > --- > .../coresight/coresight-etm4x-core.c | 36 +++++-------------- > drivers/hwtracing/coresight/coresight-etm4x.h | 17 +++++++++ > drivers/hwtracing/coresight/coresight-priv.h | 5 +++ > 3 files changed, 30 insertions(+), 28 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index e2eebd865241..107e81948f76 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -1091,41 +1091,21 @@ static void etm4_init_arch_data(void *info) > etmidr0 = etm4x_relaxed_read32(csa, TRCIDR0); > > /* INSTP0, bits[2:1] P0 tracing support field */ > - if (BMVAL(etmidr0, 1, 2) == 0b11) > - drvdata->instrp0 = true; > - else > - drvdata->instrp0 = false; > - > + drvdata->instrp0 = !!(REG_VAL(etmidr0, TRCIDR0_INSTP0) == 0b11); > /* TRCBB, bit[5] Branch broadcast tracing support bit */ > - if (BMVAL(etmidr0, 5, 5)) > - drvdata->trcbb = true; > - else > - drvdata->trcbb = false; > - > + drvdata->trcbb = !!(etmidr0 & TRCIDR0_TRCBB); > /* TRCCOND, bit[6] Conditional instruction tracing support bit */ > - if (BMVAL(etmidr0, 6, 6)) > - drvdata->trccond = true; > - else > - drvdata->trccond = false; > - > + drvdata->trccond = !!(etmidr0 & TRCIDR0_TRCCOND); > /* TRCCCI, bit[7] Cycle counting instruction bit */ > - if (BMVAL(etmidr0, 7, 7)) > - drvdata->trccci = true; > - else > - drvdata->trccci = false; > - > + drvdata->trccci = !!(etmidr0 & TRCIDR0_TRCCCI); > /* RETSTACK, bit[9] Return stack bit */ > - if (BMVAL(etmidr0, 9, 9)) > - drvdata->retstack = true; > - else > - drvdata->retstack = false; > - > + drvdata->retstack = !!(etmidr0 & TRCIDR0_RETSTACK); > /* NUMEVENT, bits[11:10] Number of events field */ > - drvdata->nr_event = BMVAL(etmidr0, 10, 11); > + drvdata->nr_event = REG_VAL(etmidr0, TRCIDR0_NUMEVENT); > /* QSUPP, bits[16:15] Q element support field */ > - drvdata->q_support = BMVAL(etmidr0, 15, 16); > + drvdata->q_support = REG_VAL(etmidr0, TRCIDR0_QSUPP); > /* TSSIZE, bits[28:24] Global timestamp size field */ > - drvdata->ts_size = BMVAL(etmidr0, 24, 28); > + drvdata->ts_size = REG_VAL(etmidr0, TRCIDR0_TSSIZE); > > /* maximum size of resources */ > etmidr2 = etm4x_relaxed_read32(csa, TRCIDR2); > diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h > index 3c4d69b096ca..2bd8ad953b8e 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x.h > +++ b/drivers/hwtracing/coresight/coresight-etm4x.h > @@ -130,6 +130,23 @@ > > #define TRCRSR_TA BIT(12) > > +/* > + * Bit positions of registers that are defined above, in the sysreg.h style > + * of _MASK, _SHIFT and BIT(). > + */ > +#define TRCIDR0_INSTP0_SHIFT 1 > +#define TRCIDR0_INSTP0_MASK GENMASK(1, 0) > +#define TRCIDR0_TRCBB BIT(5) > +#define TRCIDR0_TRCCOND BIT(6) > +#define TRCIDR0_TRCCCI BIT(7) > +#define TRCIDR0_RETSTACK BIT(9) > +#define TRCIDR0_NUMEVENT_SHIFT 10 > +#define TRCIDR0_NUMEVENT_MASK GENMASK(1, 0) > +#define TRCIDR0_QSUPP_SHIFT 15 > +#define TRCIDR0_QSUPP_MASK GENMASK(1, 0) > +#define TRCIDR0_TSSIZE_SHIFT 24 > +#define TRCIDR0_TSSIZE_MASK GENMASK(4, 0) > + > /* > * System instructions to access ETM registers. > * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions > diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h > index ff1dd2092ac5..1452c6038421 100644 > --- a/drivers/hwtracing/coresight/coresight-priv.h > +++ b/drivers/hwtracing/coresight/coresight-priv.h > @@ -36,6 +36,11 @@ > > #define TIMEOUT_US 100 > #define BMVAL(val, lsb, msb) ((val & GENMASK(msb, lsb)) >> lsb) > +/* > + * Extract a field from a register where field is #defined in the form > + * __MASK and __SHIFT > + */ > +#define REG_VAL(val, field) ((val & (field##_MASK << field##_SHIFT)) >> field##_SHIFT) > The only v minor comment I would have is that this macro could be REG_FIELD() or REG_FIELD_VAL(), which in my view would make more natural and obvious reading in the source files where it appears. e.g. drvdata->nr_event = REG_FIELD(etmidr0, TRCIDR0_NUMEVENT); However it ends up, it certainly needs to stay in a common header for possible use in other drivers (not just ETMv3). Regards Mike > #define ETM_MODE_EXCL_KERN BIT(30) > #define ETM_MODE_EXCL_USER BIT(31) > -- > 2.28.0 > -- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK