History

Merge tag 'coresight-next-v5.19' of gitolite.kernel.org:pub/scm/linux/kernel/git/coresight/linux into char-misc-next

Mathieu writes: Coresight changes for v5.19 This pull request includes: - Work to uniformise access to the ETMv4 registers, making it easier to look for and change register accesses. - A correction to a probing failure when looking for links between devices. - The replacement of a call to mutex_lock() with a mutex_trylock() in the panic notifier of the cpu-debug infrastructure to avoid a possible deadlock. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> * tag 'coresight-next-v5.19' of gitolite.kernel.org:pub/scm/linux/kernel/git/coresight/linux: coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier coresight: core: Fix coresight device probe failure issue coresight: etm4x: Cleanup TRCRSCTLRn register accesses coresight: etm4x: Cleanup TRCBBCTLR register accesses coresight: etm4x: Cleanup TRCSSPCICRn register accesses coresight: etm4x: Cleanup TRCSSCCRn and TRCSSCSRn register accesses coresight: etm4x: Cleanup TRCACATRn register accesses coresight: etm3x: Cleanup ETMTECR1 register accesses coresight: etm4x: Cleanup TRCVICTLR register accesses coresight: etm4x: Cleanup TRCSTALLCTLR register accesses coresight: etm4x: Cleanup TRCEVENTCTL1R register accesses coresight: etm4x: Cleanup TRCCONFIGR register accesses coresight: etm4x: Cleanup TRCIDR5 register accesses coresight: etm4x: Cleanup TRCIDR4 register accesses coresight: etm4x: Cleanup TRCIDR3 register accesses coresight: etm4x: Cleanup TRCIDR2 register accesses coresight: etm4x: Cleanup TRCIDR0 register accesses

Greg Kroah-Hartman committed 4 years ago

Commit 9c518db2 parents e727efe 1adff547 files · +268 −212Browse files

Unified · Split

7 files
  1. drivers/hwtracing/coresight/coresight-core.c +22 −11
  2. drivers/hwtracing/coresight/coresight-cpu-debug.c +4 −3
  3. drivers/hwtracing/coresight/coresight-etm3x-core.c +1 −1
  4. drivers/hwtracing/coresight/coresight-etm3x-sysfs.c +1 −1
  5. drivers/hwtracing/coresight/coresight-etm4x-core.c +44 −92
  6. drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +94 −86
  7. drivers/hwtracing/coresight/coresight-etm4x.h +102 −18
drivers/hwtracing/coresight/coresight-core.c+22−11
@@ -1379,7 +1379,7 @@ static int coresight_fixup_device_conns(struct coresight_device *csdev) · 1378 unmodified lines
13791379 continue;
13801380 conn->child_dev =
13811381 coresight_find_csdev_by_fwnode(conn->child_fwnode);
1382− if (conn->child_dev) {
1382+ if (conn->child_dev && conn->child_dev->has_conns_grp) {
13831383 ret = coresight_make_links(csdev, conn,
13841384 conn->child_dev);
13851385 if (ret)
@@ -1571,6 +1571,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) · 185 unmodified lines
15711571 int nr_refcnts = 1;
15721572 atomic_t *refcnts = NULL;
15731573 struct coresight_device *csdev;
1574+ bool registered = false;
15741575
15751576 csdev = kzalloc(sizeof(*csdev), GFP_KERNEL);
15761577 if (!csdev) {
@@ -1591,7 +1592,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) · 14 unmodified lines
15911592 refcnts = kcalloc(nr_refcnts, sizeof(*refcnts), GFP_KERNEL);
15921593 if (!refcnts) {
15931594 ret = -ENOMEM;
1594− goto err_free_csdev;
1595+ kfree(csdev);
1596+ goto err_out;
15951597 }
15961598
15971599 csdev->refcnt = refcnts;
@@ -1616,6 +1618,13 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) · 18 unmodified lines
16161618 csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev));
16171619 dev_set_name(&csdev->dev, "%s", desc->name);
16181620
1621+ /*
1622+ * Make sure the device registration and the connection fixup
1623+ * are synchronised, so that we don't see uninitialised devices
1624+ * on the coresight bus while trying to resolve the connections.
1625+ */
1626+ mutex_lock(&coresight_mutex);
1627+
16191628 ret = device_register(&csdev->dev);
16201629 if (ret) {
16211630 put_device(&csdev->dev);
@@ -1623,7 +1632,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) · 1 unmodified line
16231632 * All resources are free'd explicitly via
16241633 * coresight_device_release(), triggered from put_device().
16251634 */
1626− goto err_out;
1635+ goto out_unlock;
16271636 }
16281637
16291638 if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
@@ -1638,11 +1647,11 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) · 8 unmodified lines
16381647 * from put_device(), which is in turn called from
16391648 * function device_unregister().
16401649 */
1641− goto err_out;
1650+ goto out_unlock;
16421651 }
16431652 }
1644−
1645− mutex_lock(&coresight_mutex);
1653+ /* Device is now registered */
1654+ registered = true;
16461655
16471656 ret = coresight_create_conns_sysfs_group(csdev);
16481657 if (!ret)
@@ -1652,16 +1661,18 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) · 3 unmodified lines
16521661 if (!ret && cti_assoc_ops && cti_assoc_ops->add)
16531662 cti_assoc_ops->add(csdev);
16541663
1664+out_unlock:
16551665 mutex_unlock(&coresight_mutex);
1656− if (ret) {
1666+ /* Success */
1667+ if (!ret)
1668+ return csdev;
1669+
1670+ /* Unregister the device if needed */
1671+ if (registered) {
16571672 coresight_unregister(csdev);
16581673 return ERR_PTR(ret);
16591674 }
16601675
1661− return csdev;
1662−
1663−err_free_csdev:
1664− kfree(csdev);
16651676 err_out:
16661677 /* Cleanup the connection information */
16671678 coresight_release_platform_data(NULL, desc->pdata);
drivers/hwtracing/coresight/coresight-cpu-debug.c+4−3
@@ -380,9 +380,10 @@ static int debug_notifier_call(struct notifier_block *self, · 379 unmodified lines
380380 int cpu;
381381 struct debug_drvdata *drvdata;
382382
383− mutex_lock(&debug_lock);
383+ /* Bail out if we can't acquire the mutex or the functionality is off */
384+ if (!mutex_trylock(&debug_lock))
385+ return NOTIFY_DONE;
384386
385− /* Bail out if the functionality is disabled */
386387 if (!debug_enable)
387388 goto skip_dump;
388389
@@ -401,7 +402,7 @@ static int debug_notifier_call(struct notifier_block *self, · 12 unmodified lines
401402
402403 skip_dump:
403404 mutex_unlock(&debug_lock);
404− return 0;
405+ return NOTIFY_DONE;
405406 }
406407
407408 static struct notifier_block debug_notifier = {
drivers/hwtracing/coresight/coresight-etm3x-core.c+1−1
@@ -204,7 +204,7 @@ void etm_set_default(struct etm_config *config) · 203 unmodified lines
204204 * set all bits in register 0x007, the ETMTECR2, to 0
205205 * set register 0x008, the ETMTEEVR, to 0x6F (TRUE).
206206 */
207− config->enable_ctrl1 = BIT(24);
207+ config->enable_ctrl1 = ETMTECR1_INC_EXC;
208208 config->enable_ctrl2 = 0x0;
209209 config->enable_event = ETM_HARD_WIRE_RES_A;
210210
drivers/hwtracing/coresight/coresight-etm3x-sysfs.c+1−1
@@ -474,7 +474,7 @@ static ssize_t addr_start_store(struct device *dev, · 473 unmodified lines
474474 config->addr_val[idx] = val;
475475 config->addr_type[idx] = ETM_ADDR_TYPE_START;
476476 config->startstop_ctrl |= (1 << idx);
477− config->enable_ctrl1 |= BIT(25);
477+ config->enable_ctrl1 |= ETMTECR1_START_STOP;
478478 spin_unlock(&drvdata->spinlock);
479479
480480 return size;
drivers/hwtracing/coresight/coresight-etm4x-core.c+44−92
@@ -443,7 +443,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) · 442 unmodified lines
443443 for (i = 0; i < drvdata->nr_ss_cmp; i++) {
444444 /* always clear status bit on restart if using single-shot */
445445 if (config->ss_ctrl[i] || config->ss_pe_cmp[i])
446− config->ss_status[i] &= ~BIT(31);
446+ config->ss_status[i] &= ~TRCSSCSRn_STATUS;
447447 etm4x_relaxed_write32(csa, config->ss_ctrl[i], TRCSSCCRn(i));
448448 etm4x_relaxed_write32(csa, config->ss_status[i], TRCSSCSRn(i));
449449 if (etm4x_sspcicrn_present(drvdata, i))
@@ -633,7 +633,7 @@ static int etm4_parse_event_config(struct coresight_device *csdev, · 183 unmodified lines
633633
634634 /* Go from generic option to ETMv4 specifics */
635635 if (attr->config & BIT(ETM_OPT_CYCACC)) {
636− config->cfg |= BIT(4);
636+ config->cfg |= TRCCONFIGR_CCI;
637637 /* TRM: Must program this for cycacc to work */
638638 config->ccctlr = ETM_CYC_THRESHOLD_DEFAULT;
639639 }
@@ -653,14 +653,14 @@ static int etm4_parse_event_config(struct coresight_device *csdev, · 13 unmodified lines
653653 goto out;
654654
655655 /* bit[11], Global timestamp tracing bit */
656− config->cfg |= BIT(11);
656+ config->cfg |= TRCCONFIGR_TS;
657657 }
658658
659659 /* Only trace contextID when runs in root PID namespace */
660660 if ((attr->config & BIT(ETM_OPT_CTXTID)) &&
661661 task_is_in_init_pid_ns(current))
662662 /* bit[6], Context ID tracing bit */
663− config->cfg |= BIT(ETM4_CFG_BIT_CTXTID);
663+ config->cfg |= TRCCONFIGR_CID;
664664
665665 /*
666666 * If set bit ETM_OPT_CTXTID2 in perf config, this asks to trace VMID
@@ -672,17 +672,15 @@ static int etm4_parse_event_config(struct coresight_device *csdev, · 5 unmodified lines
672672 ret = -EINVAL;
673673 goto out;
674674 }
675−
676675 /* Only trace virtual contextID when runs in root PID namespace */
677676 if (task_is_in_init_pid_ns(current))
678− config->cfg |= BIT(ETM4_CFG_BIT_VMID) |
679− BIT(ETM4_CFG_BIT_VMID_OPT);
677+ config->cfg |= TRCCONFIGR_VMID | TRCCONFIGR_VMIDOPT;
680678 }
681679
682680 /* return stack - enable if selected and supported */
683681 if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack)
684682 /* bit[12], Return stack enable bit */
685− config->cfg |= BIT(12);
683+ config->cfg |= TRCCONFIGR_RS;
686684
687685 /*
688686 * Set any selected configuration and preset.
@@ -1097,107 +1095,67 @@ static void etm4_init_arch_data(void *info) · 408 unmodified lines
10971095 etmidr0 = etm4x_relaxed_read32(csa, TRCIDR0);
10981096
10991097 /* INSTP0, bits[2:1] P0 tracing support field */
1100− if (BMVAL(etmidr0, 1, 2) == 0b11)
1101− drvdata->instrp0 = true;
1102− else
1103− drvdata->instrp0 = false;
1104−
1098+ drvdata->instrp0 = !!(FIELD_GET(TRCIDR0_INSTP0_MASK, etmidr0) == 0b11);
11051099 /* TRCBB, bit[5] Branch broadcast tracing support bit */
1106− if (BMVAL(etmidr0, 5, 5))
1107− drvdata->trcbb = true;
1108− else
1109− drvdata->trcbb = false;
1110−
1100+ drvdata->trcbb = !!(etmidr0 & TRCIDR0_TRCBB);
11111101 /* TRCCOND, bit[6] Conditional instruction tracing support bit */
1112− if (BMVAL(etmidr0, 6, 6))
1113− drvdata->trccond = true;
1114− else
1115− drvdata->trccond = false;
1116−
1102+ drvdata->trccond = !!(etmidr0 & TRCIDR0_TRCCOND);
11171103 /* TRCCCI, bit[7] Cycle counting instruction bit */
1118− if (BMVAL(etmidr0, 7, 7))
1119− drvdata->trccci = true;
1120− else
1121− drvdata->trccci = false;
1122−
1104+ drvdata->trccci = !!(etmidr0 & TRCIDR0_TRCCCI);
11231105 /* RETSTACK, bit[9] Return stack bit */
1124− if (BMVAL(etmidr0, 9, 9))
1125− drvdata->retstack = true;
1126− else
1127− drvdata->retstack = false;
1128−
1106+ drvdata->retstack = !!(etmidr0 & TRCIDR0_RETSTACK);
11291107 /* NUMEVENT, bits[11:10] Number of events field */
1130− drvdata->nr_event = BMVAL(etmidr0, 10, 11);
1108+ drvdata->nr_event = FIELD_GET(TRCIDR0_NUMEVENT_MASK, etmidr0);
11311109 /* QSUPP, bits[16:15] Q element support field */
1132− drvdata->q_support = BMVAL(etmidr0, 15, 16);
1110+ drvdata->q_support = FIELD_GET(TRCIDR0_QSUPP_MASK, etmidr0);
11331111 /* TSSIZE, bits[28:24] Global timestamp size field */
1134− drvdata->ts_size = BMVAL(etmidr0, 24, 28);
1112+ drvdata->ts_size = FIELD_GET(TRCIDR0_TSSIZE_MASK, etmidr0);
11351113
11361114 /* maximum size of resources */
11371115 etmidr2 = etm4x_relaxed_read32(csa, TRCIDR2);
11381116 /* CIDSIZE, bits[9:5] Indicates the Context ID size */
1139− drvdata->ctxid_size = BMVAL(etmidr2, 5, 9);
1117+ drvdata->ctxid_size = FIELD_GET(TRCIDR2_CIDSIZE_MASK, etmidr2);
11401118 /* VMIDSIZE, bits[14:10] Indicates the VMID size */
1141− drvdata->vmid_size = BMVAL(etmidr2, 10, 14);
1119+ drvdata->vmid_size = FIELD_GET(TRCIDR2_VMIDSIZE_MASK, etmidr2);
11421120 /* CCSIZE, bits[28:25] size of the cycle counter in bits minus 12 */
1143− drvdata->ccsize = BMVAL(etmidr2, 25, 28);
1121+ drvdata->ccsize = FIELD_GET(TRCIDR2_CCSIZE_MASK, etmidr2);
11441122
11451123 etmidr3 = etm4x_relaxed_read32(csa, TRCIDR3);
11461124 /* CCITMIN, bits[11:0] minimum threshold value that can be programmed */
1147− drvdata->ccitmin = BMVAL(etmidr3, 0, 11);
1125+ drvdata->ccitmin = FIELD_GET(TRCIDR3_CCITMIN_MASK, etmidr3);
11481126 /* EXLEVEL_S, bits[19:16] Secure state instruction tracing */
1149− drvdata->s_ex_level = BMVAL(etmidr3, 16, 19);
1127+ drvdata->s_ex_level = FIELD_GET(TRCIDR3_EXLEVEL_S_MASK, etmidr3);
11501128 drvdata->config.s_ex_level = drvdata->s_ex_level;
11511129 /* EXLEVEL_NS, bits[23:20] Non-secure state instruction tracing */
1152− drvdata->ns_ex_level = BMVAL(etmidr3, 20, 23);
1153−
1130+ drvdata->ns_ex_level = FIELD_GET(TRCIDR3_EXLEVEL_NS_MASK, etmidr3);
11541131 /*
11551132 * TRCERR, bit[24] whether a trace unit can trace a
11561133 * system error exception.
11571134 */
1158− if (BMVAL(etmidr3, 24, 24))
1159− drvdata->trc_error = true;
1160− else
1161− drvdata->trc_error = false;
1162−
1135+ drvdata->trc_error = !!(etmidr3 & TRCIDR3_TRCERR);
11631136 /* SYNCPR, bit[25] implementation has a fixed synchronization period? */
1164− if (BMVAL(etmidr3, 25, 25))
1165− drvdata->syncpr = true;
1166− else
1167− drvdata->syncpr = false;
1168−
1137+ drvdata->syncpr = !!(etmidr3 & TRCIDR3_SYNCPR);
11691138 /* STALLCTL, bit[26] is stall control implemented? */
1170− if (BMVAL(etmidr3, 26, 26))
1171− drvdata->stallctl = true;
1172− else
1173− drvdata->stallctl = false;
1174−
1139+ drvdata->stallctl = !!(etmidr3 & TRCIDR3_STALLCTL);
11751140 /* SYSSTALL, bit[27] implementation can support stall control? */
1176− if (BMVAL(etmidr3, 27, 27))
1177− drvdata->sysstall = true;
1178− else
1179− drvdata->sysstall = false;
1180−
1141+ drvdata->sysstall = !!(etmidr3 & TRCIDR3_SYSSTALL);
11811142 /*
11821143 * NUMPROC - the number of PEs available for tracing, 5bits
11831144 * = TRCIDR3.bits[13:12]bits[30:28]
11841145 * bits[4:3] = TRCIDR3.bits[13:12] (since etm-v4.2, otherwise RES0)
11851146 * bits[3:0] = TRCIDR3.bits[30:28]
11861147 */
1187− drvdata->nr_pe = (BMVAL(etmidr3, 12, 13) << 3) | BMVAL(etmidr3, 28, 30);
1188−
1148+ drvdata->nr_pe = (FIELD_GET(TRCIDR3_NUMPROC_HI_MASK, etmidr3) << 3) |
1149+ FIELD_GET(TRCIDR3_NUMPROC_LO_MASK, etmidr3);
11891150 /* NOOVERFLOW, bit[31] is trace overflow prevention supported */
1190− if (BMVAL(etmidr3, 31, 31))
1191− drvdata->nooverflow = true;
1192− else
1193− drvdata->nooverflow = false;
1151+ drvdata->nooverflow = !!(etmidr3 & TRCIDR3_NOOVERFLOW);
11941152
11951153 /* number of resources trace unit supports */
11961154 etmidr4 = etm4x_relaxed_read32(csa, TRCIDR4);
11971155 /* NUMACPAIRS, bits[0:3] number of addr comparator pairs for tracing */
1198− drvdata->nr_addr_cmp = BMVAL(etmidr4, 0, 3);
1156+ drvdata->nr_addr_cmp = FIELD_GET(TRCIDR4_NUMACPAIRS_MASK, etmidr4);
11991157 /* NUMPC, bits[15:12] number of PE comparator inputs for tracing */
1200− drvdata->nr_pe_cmp = BMVAL(etmidr4, 12, 15);
1158+ drvdata->nr_pe_cmp = FIELD_GET(TRCIDR4_NUMPC_MASK, etmidr4);
12011159 /*
12021160 * NUMRSPAIR, bits[19:16]
12031161 * The number of resource pairs conveyed by the HW starts at 0, i.e a
@@ -1208,7 +1166,7 @@ static void etm4_init_arch_data(void *info) · 4 unmodified lines
12081166 * the default TRUE and FALSE resource selectors are omitted.
12091167 * Otherwise for values 0x1 and above the number is N + 1 as per v4.2.
12101168 */
1211− drvdata->nr_resource = BMVAL(etmidr4, 16, 19);
1169+ drvdata->nr_resource = FIELD_GET(TRCIDR4_NUMRSPAIR_MASK, etmidr4);
12121170 if ((drvdata->arch < ETM_ARCH_V4_3) || (drvdata->nr_resource > 0))
12131171 drvdata->nr_resource += 1;
12141172 /*
@@ -1216,45 +1174,39 @@ static void etm4_init_arch_data(void *info) · 1 unmodified line
12161174 * comparator control for tracing. Read any status regs as these
12171175 * also contain RO capability data.
12181176 */
1219− drvdata->nr_ss_cmp = BMVAL(etmidr4, 20, 23);
1177+ drvdata->nr_ss_cmp = FIELD_GET(TRCIDR4_NUMSSCC_MASK, etmidr4);
12201178 for (i = 0; i < drvdata->nr_ss_cmp; i++) {
12211179 drvdata->config.ss_status[i] =
12221180 etm4x_relaxed_read32(csa, TRCSSCSRn(i));
12231181 }
12241182 /* NUMCIDC, bits[27:24] number of Context ID comparators for tracing */
1225− drvdata->numcidc = BMVAL(etmidr4, 24, 27);
1183+ drvdata->numcidc = FIELD_GET(TRCIDR4_NUMCIDC_MASK, etmidr4);
12261184 /* NUMVMIDC, bits[31:28] number of VMID comparators for tracing */
1227− drvdata->numvmidc = BMVAL(etmidr4, 28, 31);
1185+ drvdata->numvmidc = FIELD_GET(TRCIDR4_NUMVMIDC_MASK, etmidr4);
12281186
12291187 etmidr5 = etm4x_relaxed_read32(csa, TRCIDR5);
12301188 /* NUMEXTIN, bits[8:0] number of external inputs implemented */
1231− drvdata->nr_ext_inp = BMVAL(etmidr5, 0, 8);
1189+ drvdata->nr_ext_inp = FIELD_GET(TRCIDR5_NUMEXTIN_MASK, etmidr5);
12321190 /* TRACEIDSIZE, bits[21:16] indicates the trace ID width */
1233− drvdata->trcid_size = BMVAL(etmidr5, 16, 21);
1191+ drvdata->trcid_size = FIELD_GET(TRCIDR5_TRACEIDSIZE_MASK, etmidr5);
12341192 /* ATBTRIG, bit[22] implementation can support ATB triggers? */
1235− if (BMVAL(etmidr5, 22, 22))
1236− drvdata->atbtrig = true;
1237− else
1238− drvdata->atbtrig = false;
1193+ drvdata->atbtrig = !!(etmidr5 & TRCIDR5_ATBTRIG);
12391194 /*
12401195 * LPOVERRIDE, bit[23] implementation supports
12411196 * low-power state override
12421197 */
1243− if (BMVAL(etmidr5, 23, 23) && (!drvdata->skip_power_up))
1244− drvdata->lpoverride = true;
1245− else
1246− drvdata->lpoverride = false;
1198+ drvdata->lpoverride = (etmidr5 & TRCIDR5_LPOVERRIDE) && (!drvdata->skip_power_up);
12471199 /* NUMSEQSTATE, bits[27:25] number of sequencer states implemented */
1248− drvdata->nrseqstate = BMVAL(etmidr5, 25, 27);
1200+ drvdata->nrseqstate = FIELD_GET(TRCIDR5_NUMSEQSTATE_MASK, etmidr5);
12491201 /* NUMCNTR, bits[30:28] number of counters available for tracing */
1250− drvdata->nr_cntr = BMVAL(etmidr5, 28, 30);
1202+ drvdata->nr_cntr = FIELD_GET(TRCIDR5_NUMCNTR_MASK, etmidr5);
12511203 etm4_cs_lock(drvdata, csa);
12521204 cpu_detect_trace_filtering(drvdata);
12531205 }
12541206
12551207 static inline u32 etm4_get_victlr_access_type(struct etmv4_config *config)
12561208 {
1257− return etm4_get_access_type(config) << TRCVICTLR_EXLEVEL_SHIFT;
1209+ return etm4_get_access_type(config) << __bf_shf(TRCVICTLR_EXLEVEL_MASK);
12581210 }
12591211
12601212 /* Set ELx trace filter access in the TRCVICTLR register */
@@ -1280,7 +1232,7 @@ static void etm4_set_default_config(struct etmv4_config *config) · 19 unmodified lines
12801232 config->ts_ctrl = 0x0;
12811233
12821234 /* TRCVICTLR::EVENT = 0x01, select the always on logic */
1283− config->vinst_ctrl = BIT(0);
1235+ config->vinst_ctrl = FIELD_PREP(TRCVICTLR_EVENT_MASK, 0x01);
12841236
12851237 /* TRCVICTLR::EXLEVEL_NS:EXLEVELS: Set kernel / user filtering */
12861238 etm4_set_victlr_access(config);
@@ -1389,7 +1341,7 @@ static void etm4_set_default_filter(struct etmv4_config *config) · 102 unmodified lines
13891341 * TRCVICTLR::SSSTATUS == 1, the start-stop logic is
13901342 * in the started state
13911343 */
1392− config->vinst_ctrl |= BIT(9);
1344+ config->vinst_ctrl |= TRCVICTLR_SSSTATUS;
13931345 config->mode |= ETM_MODE_VIEWINST_STARTSTOP;
13941346
13951347 /* No start-stop filtering for ViewInst */
@@ -1493,7 +1445,7 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata, · 97 unmodified lines
14931445 * TRCVICTLR::SSSTATUS == 1, the start-stop logic is
14941446 * in the started state
14951447 */
1496− config->vinst_ctrl |= BIT(9);
1448+ config->vinst_ctrl |= TRCVICTLR_SSSTATUS;
14971449
14981450 /* No start-stop filtering for ViewInst */
14991451 config->vissctlr = 0x0;
@@ -1521,7 +1473,7 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata, · 21 unmodified lines
15211473 * etm4_disable_perf().
15221474 */
15231475 if (filters->ssstatus)
1524− config->vinst_ctrl |= BIT(9);
1476+ config->vinst_ctrl |= TRCVICTLR_SSSTATUS;
15251477
15261478 /* No include/exclude filtering for ViewInst */
15271479 config->viiectlr = 0x0;
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c+94−86
@@ -22,7 +22,7 @@ static int etm4_set_mode_exclude(struct etmv4_drvdata *drvdata, bool exclude) · 21 unmodified lines
2222 * TRCACATRn.TYPE bit[1:0]: type of comparison
2323 * the trace unit performs
2424 */
25− if (BMVAL(config->addr_acc[idx], 0, 1) == ETM_INSTR_ADDR) {
25+ if (FIELD_GET(TRCACATRn_TYPE_MASK, config->addr_acc[idx]) == TRCACATRn_TYPE_ADDR) {
2626 if (idx % 2 != 0)
2727 return -EINVAL;
2828
@@ -180,12 +180,12 @@ static ssize_t reset_store(struct device *dev, · 151 unmodified lines
180180
181181 /* Disable data tracing: do not trace load and store data transfers */
182182 config->mode &= ~(ETM_MODE_LOAD | ETM_MODE_STORE);
183− config->cfg &= ~(BIT(1) | BIT(2));
183+ config->cfg &= ~(TRCCONFIGR_INSTP0_LOAD | TRCCONFIGR_INSTP0_STORE);
184184
185185 /* Disable data value and data address tracing */
186186 config->mode &= ~(ETM_MODE_DATA_TRACE_ADDR |
187187 ETM_MODE_DATA_TRACE_VAL);
188− config->cfg &= ~(BIT(16) | BIT(17));
188+ config->cfg &= ~(TRCCONFIGR_DA | TRCCONFIGR_DV);
189189
190190 /* Disable all events tracing */
191191 config->eventctrl0 = 0x0;
@@ -206,11 +206,11 @@ static ssize_t reset_store(struct device *dev, · 14 unmodified lines
206206 * started state. ARM recommends start-stop logic is set before
207207 * each trace run.
208208 */
209− config->vinst_ctrl = BIT(0);
209+ config->vinst_ctrl = FIELD_PREP(TRCVICTLR_EVENT_MASK, 0x01);
210210 if (drvdata->nr_addr_cmp > 0) {
211211 config->mode |= ETM_MODE_VIEWINST_STARTSTOP;
212212 /* SSSTATUS, bit[9] */
213− config->vinst_ctrl |= BIT(9);
213+ config->vinst_ctrl |= TRCVICTLR_SSSTATUS;
214214 }
215215
216216 /* No address range filtering for ViewInst */
@@ -304,134 +304,134 @@ static ssize_t mode_store(struct device *dev, · 87 unmodified lines
304304
305305 if (drvdata->instrp0 == true) {
306306 /* start by clearing instruction P0 field */
307− config->cfg &= ~(BIT(1) | BIT(2));
307+ config->cfg &= ~TRCCONFIGR_INSTP0_LOAD_STORE;
308308 if (config->mode & ETM_MODE_LOAD)
309309 /* 0b01 Trace load instructions as P0 instructions */
310− config->cfg |= BIT(1);
310+ config->cfg |= TRCCONFIGR_INSTP0_LOAD;
311311 if (config->mode & ETM_MODE_STORE)
312312 /* 0b10 Trace store instructions as P0 instructions */
313− config->cfg |= BIT(2);
313+ config->cfg |= TRCCONFIGR_INSTP0_STORE;
314314 if (config->mode & ETM_MODE_LOAD_STORE)
315315 /*
316316 * 0b11 Trace load and store instructions
317317 * as P0 instructions
318318 */
319− config->cfg |= BIT(1) | BIT(2);
319+ config->cfg |= TRCCONFIGR_INSTP0_LOAD_STORE;
320320 }
321321
322322 /* bit[3], Branch broadcast mode */
323323 if ((config->mode & ETM_MODE_BB) && (drvdata->trcbb == true))
324− config->cfg |= BIT(3);
324+ config->cfg |= TRCCONFIGR_BB;
325325 else
326− config->cfg &= ~BIT(3);
326+ config->cfg &= ~TRCCONFIGR_BB;
327327
328328 /* bit[4], Cycle counting instruction trace bit */
329329 if ((config->mode & ETMv4_MODE_CYCACC) &&
330330 (drvdata->trccci == true))
331− config->cfg |= BIT(4);
331+ config->cfg |= TRCCONFIGR_CCI;
332332 else
333− config->cfg &= ~BIT(4);
333+ config->cfg &= ~TRCCONFIGR_CCI;
334334
335335 /* bit[6], Context ID tracing bit */
336336 if ((config->mode & ETMv4_MODE_CTXID) && (drvdata->ctxid_size))
337− config->cfg |= BIT(6);
337+ config->cfg |= TRCCONFIGR_CID;
338338 else
339− config->cfg &= ~BIT(6);
339+ config->cfg &= ~TRCCONFIGR_CID;
340340
341341 if ((config->mode & ETM_MODE_VMID) && (drvdata->vmid_size))
342− config->cfg |= BIT(7);
342+ config->cfg |= TRCCONFIGR_VMID;
343343 else
344− config->cfg &= ~BIT(7);
344+ config->cfg &= ~TRCCONFIGR_VMID;
345345
346346 /* bits[10:8], Conditional instruction tracing bit */
347347 mode = ETM_MODE_COND(config->mode);
348348 if (drvdata->trccond == true) {
349− config->cfg &= ~(BIT(8) | BIT(9) | BIT(10));
350− config->cfg |= mode << 8;
349+ config->cfg &= ~TRCCONFIGR_COND_MASK;
350+ config->cfg |= mode << __bf_shf(TRCCONFIGR_COND_MASK);
351351 }
352352
353353 /* bit[11], Global timestamp tracing bit */
354354 if ((config->mode & ETMv4_MODE_TIMESTAMP) && (drvdata->ts_size))
355− config->cfg |= BIT(11);
355+ config->cfg |= TRCCONFIGR_TS;
356356 else
357− config->cfg &= ~BIT(11);
357+ config->cfg &= ~TRCCONFIGR_TS;
358358
359359 /* bit[12], Return stack enable bit */
360360 if ((config->mode & ETM_MODE_RETURNSTACK) &&
361361 (drvdata->retstack == true))
362− config->cfg |= BIT(12);
362+ config->cfg |= TRCCONFIGR_RS;
363363 else
364− config->cfg &= ~BIT(12);
364+ config->cfg &= ~TRCCONFIGR_RS;
365365
366366 /* bits[14:13], Q element enable field */
367367 mode = ETM_MODE_QELEM(config->mode);
368368 /* start by clearing QE bits */
369− config->cfg &= ~(BIT(13) | BIT(14));
369+ config->cfg &= ~(TRCCONFIGR_QE_W_COUNTS | TRCCONFIGR_QE_WO_COUNTS);
370370 /*
371371 * if supported, Q elements with instruction counts are enabled.
372372 * Always set the low bit for any requested mode. Valid combos are
373373 * 0b00, 0b01 and 0b11.
374374 */
375375 if (mode && drvdata->q_support)
376− config->cfg |= BIT(13);
376+ config->cfg |= TRCCONFIGR_QE_W_COUNTS;
377377 /*
378378 * if supported, Q elements with and without instruction
379379 * counts are enabled
380380 */
381381 if ((mode & BIT(1)) && (drvdata->q_support & BIT(1)))
382− config->cfg |= BIT(14);
382+ config->cfg |= TRCCONFIGR_QE_WO_COUNTS;
383383
384384 /* bit[11], AMBA Trace Bus (ATB) trigger enable bit */
385385 if ((config->mode & ETM_MODE_ATB_TRIGGER) &&
386386 (drvdata->atbtrig == true))
387− config->eventctrl1 |= BIT(11);
387+ config->eventctrl1 |= TRCEVENTCTL1R_ATB;
388388 else
389− config->eventctrl1 &= ~BIT(11);
389+ config->eventctrl1 &= ~TRCEVENTCTL1R_ATB;
390390
391391 /* bit[12], Low-power state behavior override bit */
392392 if ((config->mode & ETM_MODE_LPOVERRIDE) &&
393393 (drvdata->lpoverride == true))
394− config->eventctrl1 |= BIT(12);
394+ config->eventctrl1 |= TRCEVENTCTL1R_LPOVERRIDE;
395395 else
396− config->eventctrl1 &= ~BIT(12);
396+ config->eventctrl1 &= ~TRCEVENTCTL1R_LPOVERRIDE;
397397
398398 /* bit[8], Instruction stall bit */
399399 if ((config->mode & ETM_MODE_ISTALL_EN) && (drvdata->stallctl == true))
400− config->stall_ctrl |= BIT(8);
400+ config->stall_ctrl |= TRCSTALLCTLR_ISTALL;
401401 else
402− config->stall_ctrl &= ~BIT(8);
402+ config->stall_ctrl &= ~TRCSTALLCTLR_ISTALL;
403403
404404 /* bit[10], Prioritize instruction trace bit */
405405 if (config->mode & ETM_MODE_INSTPRIO)
406− config->stall_ctrl |= BIT(10);
406+ config->stall_ctrl |= TRCSTALLCTLR_INSTPRIORITY;
407407 else
408− config->stall_ctrl &= ~BIT(10);
408+ config->stall_ctrl &= ~TRCSTALLCTLR_INSTPRIORITY;
409409
410410 /* bit[13], Trace overflow prevention bit */
411411 if ((config->mode & ETM_MODE_NOOVERFLOW) &&
412412 (drvdata->nooverflow == true))
413− config->stall_ctrl |= BIT(13);
413+ config->stall_ctrl |= TRCSTALLCTLR_NOOVERFLOW;
414414 else
415− config->stall_ctrl &= ~BIT(13);
415+ config->stall_ctrl &= ~TRCSTALLCTLR_NOOVERFLOW;
416416
417417 /* bit[9] Start/stop logic control bit */
418418 if (config->mode & ETM_MODE_VIEWINST_STARTSTOP)
419− config->vinst_ctrl |= BIT(9);
419+ config->vinst_ctrl |= TRCVICTLR_SSSTATUS;
420420 else
421− config->vinst_ctrl &= ~BIT(9);
421+ config->vinst_ctrl &= ~TRCVICTLR_SSSTATUS;
422422
423423 /* bit[10], Whether a trace unit must trace a Reset exception */
424424 if (config->mode & ETM_MODE_TRACE_RESET)
425− config->vinst_ctrl |= BIT(10);
425+ config->vinst_ctrl |= TRCVICTLR_TRCRESET;
426426 else
427− config->vinst_ctrl &= ~BIT(10);
427+ config->vinst_ctrl &= ~TRCVICTLR_TRCRESET;
428428
429429 /* bit[11], Whether a trace unit must trace a system error exception */
430430 if ((config->mode & ETM_MODE_TRACE_ERR) &&
431431 (drvdata->trc_error == true))
432− config->vinst_ctrl |= BIT(11);
432+ config->vinst_ctrl |= TRCVICTLR_TRCERR;
433433 else
434− config->vinst_ctrl &= ~BIT(11);
434+ config->vinst_ctrl &= ~TRCVICTLR_TRCERR;
435435
436436 if (config->mode & (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER))
437437 etm4_config_trace_mode(config);
@@ -534,7 +534,7 @@ static ssize_t event_instren_show(struct device *dev, · 96 unmodified lines
534534 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
535535 struct etmv4_config *config = &drvdata->config;
536536
537− val = BMVAL(config->eventctrl1, 0, 3);
537+ val = FIELD_GET(TRCEVENTCTL1R_INSTEN_MASK, config->eventctrl1);
538538 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
539539 }
540540
@@ -551,23 +551,28 @@ static ssize_t event_instren_store(struct device *dev, · 10 unmodified lines
551551
552552 spin_lock(&drvdata->spinlock);
553553 /* start by clearing all instruction event enable bits */
554− config->eventctrl1 &= ~(BIT(0) | BIT(1) | BIT(2) | BIT(3));
554+ config->eventctrl1 &= ~TRCEVENTCTL1R_INSTEN_MASK;
555555 switch (drvdata->nr_event) {
556556 case 0x0:
557557 /* generate Event element for event 1 */
558− config->eventctrl1 |= val & BIT(1);
558+ config->eventctrl1 |= val & TRCEVENTCTL1R_INSTEN_1;
559559 break;
560560 case 0x1:
561561 /* generate Event element for event 1 and 2 */
562− config->eventctrl1 |= val & (BIT(0) | BIT(1));
562+ config->eventctrl1 |= val & (TRCEVENTCTL1R_INSTEN_0 | TRCEVENTCTL1R_INSTEN_1);
563563 break;
564564 case 0x2:
565565 /* generate Event element for event 1, 2 and 3 */
566− config->eventctrl1 |= val & (BIT(0) | BIT(1) | BIT(2));
566+ config->eventctrl1 |= val & (TRCEVENTCTL1R_INSTEN_0 |
567+ TRCEVENTCTL1R_INSTEN_1 |
568+ TRCEVENTCTL1R_INSTEN_2);
567569 break;
568570 case 0x3:
569571 /* generate Event element for all 4 events */
570− config->eventctrl1 |= val & 0xF;
572+ config->eventctrl1 |= val & (TRCEVENTCTL1R_INSTEN_0 |
573+ TRCEVENTCTL1R_INSTEN_1 |
574+ TRCEVENTCTL1R_INSTEN_2 |
575+ TRCEVENTCTL1R_INSTEN_3);
571576 break;
572577 default:
573578 break;
@@ -702,10 +707,10 @@ static ssize_t bb_ctrl_store(struct device *dev, · 128 unmodified lines
702707 * individual range comparators. If include then at least 1
703708 * range must be selected.
704709 */
705− if ((val & BIT(8)) && (BMVAL(val, 0, 7) == 0))
710+ if ((val & TRCBBCTLR_MODE) && (FIELD_GET(TRCBBCTLR_RANGE_MASK, val) == 0))
706711 return -EINVAL;
707712
708− config->bb_ctrl = val & GENMASK(8, 0);
713+ config->bb_ctrl = val & (TRCBBCTLR_MODE | TRCBBCTLR_RANGE_MASK);
709714 return size;
710715 }
711716 static DEVICE_ATTR_RW(bb_ctrl);
@@ -718,7 +723,7 @@ static ssize_t event_vinst_show(struct device *dev, · 6 unmodified lines
718723 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
719724 struct etmv4_config *config = &drvdata->config;
720725
721− val = config->vinst_ctrl & ETMv4_EVENT_MASK;
726+ val = FIELD_GET(TRCVICTLR_EVENT_MASK, config->vinst_ctrl);
722727 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
723728 }
724729
@@ -734,9 +739,9 @@ static ssize_t event_vinst_store(struct device *dev, · 9 unmodified lines
734739 return -EINVAL;
735740
736741 spin_lock(&drvdata->spinlock);
737− val &= ETMv4_EVENT_MASK;
738− config->vinst_ctrl &= ~ETMv4_EVENT_MASK;
739− config->vinst_ctrl |= val;
742+ val &= TRCVICTLR_EVENT_MASK >> __bf_shf(TRCVICTLR_EVENT_MASK);
743+ config->vinst_ctrl &= ~TRCVICTLR_EVENT_MASK;
744+ config->vinst_ctrl |= FIELD_PREP(TRCVICTLR_EVENT_MASK, val);
740745 spin_unlock(&drvdata->spinlock);
741746 return size;
742747 }
@@ -750,7 +755,7 @@ static ssize_t s_exlevel_vinst_show(struct device *dev, · 7 unmodified lines
750755 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
751756 struct etmv4_config *config = &drvdata->config;
752757
753− val = (config->vinst_ctrl & TRCVICTLR_EXLEVEL_S_MASK) >> TRCVICTLR_EXLEVEL_S_SHIFT;
758+ val = FIELD_GET(TRCVICTLR_EXLEVEL_S_MASK, config->vinst_ctrl);
754759 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
755760 }
756761
@@ -767,10 +772,10 @@ static ssize_t s_exlevel_vinst_store(struct device *dev, · 10 unmodified lines
767772
768773 spin_lock(&drvdata->spinlock);
769774 /* clear all EXLEVEL_S bits */
770− config->vinst_ctrl &= ~(TRCVICTLR_EXLEVEL_S_MASK);
775+ config->vinst_ctrl &= ~TRCVICTLR_EXLEVEL_S_MASK;
771776 /* enable instruction tracing for corresponding exception level */
772777 val &= drvdata->s_ex_level;
773− config->vinst_ctrl |= (val << TRCVICTLR_EXLEVEL_S_SHIFT);
778+ config->vinst_ctrl |= val << __bf_shf(TRCVICTLR_EXLEVEL_S_MASK);
774779 spin_unlock(&drvdata->spinlock);
775780 return size;
776781 }
@@ -785,7 +790,7 @@ static ssize_t ns_exlevel_vinst_show(struct device *dev, · 8 unmodified lines
785790 struct etmv4_config *config = &drvdata->config;
786791
787792 /* EXLEVEL_NS, bits[23:20] */
788− val = (config->vinst_ctrl & TRCVICTLR_EXLEVEL_NS_MASK) >> TRCVICTLR_EXLEVEL_NS_SHIFT;
793+ val = FIELD_GET(TRCVICTLR_EXLEVEL_NS_MASK, config->vinst_ctrl);
789794 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
790795 }
791796
@@ -802,10 +807,10 @@ static ssize_t ns_exlevel_vinst_store(struct device *dev, · 10 unmodified lines
802807
803808 spin_lock(&drvdata->spinlock);
804809 /* clear EXLEVEL_NS bits */
805− config->vinst_ctrl &= ~(TRCVICTLR_EXLEVEL_NS_MASK);
810+ config->vinst_ctrl &= ~TRCVICTLR_EXLEVEL_NS_MASK;
806811 /* enable instruction tracing for corresponding exception level */
807812 val &= drvdata->ns_ex_level;
808− config->vinst_ctrl |= (val << TRCVICTLR_EXLEVEL_NS_SHIFT);
813+ config->vinst_ctrl |= val << __bf_shf(TRCVICTLR_EXLEVEL_NS_MASK);
809814 spin_unlock(&drvdata->spinlock);
810815 return size;
811816 }
@@ -858,11 +863,11 @@ static ssize_t addr_instdatatype_show(struct device *dev, · 46 unmodified lines
858863
859864 spin_lock(&drvdata->spinlock);
860865 idx = config->addr_idx;
861− val = BMVAL(config->addr_acc[idx], 0, 1);
866+ val = FIELD_GET(TRCACATRn_TYPE_MASK, config->addr_acc[idx]);
862867 len = scnprintf(buf, PAGE_SIZE, "%s\n",
863− val == ETM_INSTR_ADDR ? "instr" :
864− (val == ETM_DATA_LOAD_ADDR ? "data_load" :
865− (val == ETM_DATA_STORE_ADDR ? "data_store" :
868+ val == TRCACATRn_TYPE_ADDR ? "instr" :
869+ (val == TRCACATRn_TYPE_DATA_LOAD_ADDR ? "data_load" :
870+ (val == TRCACATRn_TYPE_DATA_STORE_ADDR ? "data_store" :
866871 "data_load_store")));
867872 spin_unlock(&drvdata->spinlock);
868873 return len;
@@ -886,7 +891,7 @@ static ssize_t addr_instdatatype_store(struct device *dev, · 17 unmodified lines
886891 idx = config->addr_idx;
887892 if (!strcmp(str, "instr"))
888893 /* TYPE, bits[1:0] */
889− config->addr_acc[idx] &= ~(BIT(0) | BIT(1));
894+ config->addr_acc[idx] &= ~TRCACATRn_TYPE_MASK;
890895
891896 spin_unlock(&drvdata->spinlock);
892897 return size;
@@ -1144,7 +1149,7 @@ static ssize_t addr_ctxtype_show(struct device *dev, · 251 unmodified lines
11441149 spin_lock(&drvdata->spinlock);
11451150 idx = config->addr_idx;
11461151 /* CONTEXTTYPE, bits[3:2] */
1147− val = BMVAL(config->addr_acc[idx], 2, 3);
1152+ val = FIELD_GET(TRCACATRn_CONTEXTTYPE_MASK, config->addr_acc[idx]);
11481153 len = scnprintf(buf, PAGE_SIZE, "%s\n", val == ETM_CTX_NONE ? "none" :
11491154 (val == ETM_CTX_CTXID ? "ctxid" :
11501155 (val == ETM_CTX_VMID ? "vmid" : "all")));
@@ -1170,18 +1175,18 @@ static ssize_t addr_ctxtype_store(struct device *dev, · 19 unmodified lines
11701175 idx = config->addr_idx;
11711176 if (!strcmp(str, "none"))
11721177 /* start by clearing context type bits */
1173− config->addr_acc[idx] &= ~(BIT(2) | BIT(3));
1178+ config->addr_acc[idx] &= ~TRCACATRn_CONTEXTTYPE_MASK;
11741179 else if (!strcmp(str, "ctxid")) {
11751180 /* 0b01 The trace unit performs a Context ID */
11761181 if (drvdata->numcidc) {
1177− config->addr_acc[idx] |= BIT(2);
1178− config->addr_acc[idx] &= ~BIT(3);
1182+ config->addr_acc[idx] |= TRCACATRn_CONTEXTTYPE_CTXID;
1183+ config->addr_acc[idx] &= ~TRCACATRn_CONTEXTTYPE_VMID;
11791184 }
11801185 } else if (!strcmp(str, "vmid")) {
11811186 /* 0b10 The trace unit performs a VMID */
11821187 if (drvdata->numvmidc) {
1183− config->addr_acc[idx] &= ~BIT(2);
1184− config->addr_acc[idx] |= BIT(3);
1188+ config->addr_acc[idx] &= ~TRCACATRn_CONTEXTTYPE_CTXID;
1189+ config->addr_acc[idx] |= TRCACATRn_CONTEXTTYPE_VMID;
11851190 }
11861191 } else if (!strcmp(str, "all")) {
11871192 /*
@@ -1189,9 +1194,9 @@ static ssize_t addr_ctxtype_store(struct device *dev, · 1 unmodified line
11891194 * comparison and a VMID
11901195 */
11911196 if (drvdata->numcidc)
1192− config->addr_acc[idx] |= BIT(2);
1197+ config->addr_acc[idx] |= TRCACATRn_CONTEXTTYPE_CTXID;
11931198 if (drvdata->numvmidc)
1194− config->addr_acc[idx] |= BIT(3);
1199+ config->addr_acc[idx] |= TRCACATRn_CONTEXTTYPE_VMID;
11951200 }
11961201 spin_unlock(&drvdata->spinlock);
11971202 return size;
@@ -1210,7 +1215,7 @@ static ssize_t addr_context_show(struct device *dev, · 12 unmodified lines
12101215 spin_lock(&drvdata->spinlock);
12111216 idx = config->addr_idx;
12121217 /* context ID comparator bits[6:4] */
1213− val = BMVAL(config->addr_acc[idx], 4, 6);
1218+ val = FIELD_GET(TRCACATRn_CONTEXT_MASK, config->addr_acc[idx]);
12141219 spin_unlock(&drvdata->spinlock);
12151220 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
12161221 }
@@ -1235,8 +1240,8 @@ static ssize_t addr_context_store(struct device *dev, · 18 unmodified lines
12351240 spin_lock(&drvdata->spinlock);
12361241 idx = config->addr_idx;
12371242 /* clear context ID comparator bits[6:4] */
1238− config->addr_acc[idx] &= ~(BIT(4) | BIT(5) | BIT(6));
1239− config->addr_acc[idx] |= (val << 4);
1243+ config->addr_acc[idx] &= ~TRCACATRn_CONTEXT_MASK;
1244+ config->addr_acc[idx] |= val << __bf_shf(TRCACATRn_CONTEXT_MASK);
12401245 spin_unlock(&drvdata->spinlock);
12411246 return size;
12421247 }
@@ -1253,7 +1258,7 @@ static ssize_t addr_exlevel_s_ns_show(struct device *dev, · 10 unmodified lines
12531258
12541259 spin_lock(&drvdata->spinlock);
12551260 idx = config->addr_idx;
1256− val = BMVAL(config->addr_acc[idx], 8, 14);
1261+ val = FIELD_GET(TRCACATRn_EXLEVEL_MASK, config->addr_acc[idx]);
12571262 spin_unlock(&drvdata->spinlock);
12581263 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
12591264 }
@@ -1270,14 +1275,14 @@ static ssize_t addr_exlevel_s_ns_store(struct device *dev, · 10 unmodified lines
12701275 if (kstrtoul(buf, 0, &val))
12711276 return -EINVAL;
12721277
1273− if (val & ~((GENMASK(14, 8) >> 8)))
1278+ if (val & ~(TRCACATRn_EXLEVEL_MASK >> __bf_shf(TRCACATRn_EXLEVEL_MASK)))
12741279 return -EINVAL;
12751280
12761281 spin_lock(&drvdata->spinlock);
12771282 idx = config->addr_idx;
12781283 /* clear Exlevel_ns & Exlevel_s bits[14:12, 11:8], bit[15] is res0 */
1279− config->addr_acc[idx] &= ~(GENMASK(14, 8));
1280− config->addr_acc[idx] |= (val << 8);
1284+ config->addr_acc[idx] &= ~TRCACATRn_EXLEVEL_MASK;
1285+ config->addr_acc[idx] |= val << __bf_shf(TRCACATRn_EXLEVEL_MASK);
12811286 spin_unlock(&drvdata->spinlock);
12821287 return size;
12831288 }
@@ -1721,8 +1726,11 @@ static ssize_t res_ctrl_store(struct device *dev, · 437 unmodified lines
17211726 /* For odd idx pair inversal bit is RES0 */
17221727 if (idx % 2 != 0)
17231728 /* PAIRINV, bit[21] */
1724− val &= ~BIT(21);
1725− config->res_ctrl[idx] = val & GENMASK(21, 0);
1729+ val &= ~TRCRSCTLRn_PAIRINV;
1730+ config->res_ctrl[idx] = val & (TRCRSCTLRn_PAIRINV |
1731+ TRCRSCTLRn_INV |
1732+ TRCRSCTLRn_GROUP_MASK |
1733+ TRCRSCTLRn_SELECT_MASK);
17261734 spin_unlock(&drvdata->spinlock);
17271735 return size;
17281736 }
@@ -1787,9 +1795,9 @@ static ssize_t sshot_ctrl_store(struct device *dev, · 58 unmodified lines
17871795
17881796 spin_lock(&drvdata->spinlock);
17891797 idx = config->ss_idx;
1790− config->ss_ctrl[idx] = val & GENMASK(24, 0);
1798+ config->ss_ctrl[idx] = FIELD_PREP(TRCSSCCRn_SAC_ARC_RST_MASK, val);
17911799 /* must clear bit 31 in related status register on programming */
1792− config->ss_status[idx] &= ~BIT(31);
1800+ config->ss_status[idx] &= ~TRCSSCSRn_STATUS;
17931801 spin_unlock(&drvdata->spinlock);
17941802 return size;
17951803 }
@@ -1837,9 +1845,9 @@ static ssize_t sshot_pe_ctrl_store(struct device *dev, · 41 unmodified lines
18371845
18381846 spin_lock(&drvdata->spinlock);
18391847 idx = config->ss_idx;
1840− config->ss_pe_cmp[idx] = val & GENMASK(7, 0);
1848+ config->ss_pe_cmp[idx] = FIELD_PREP(TRCSSPCICRn_PC_MASK, val);
18411849 /* must clear bit 31 in related status register on programming */
1842− config->ss_status[idx] &= ~BIT(31);
1850+ config->ss_status[idx] &= ~TRCSSCSRn_STATUS;
18431851 spin_unlock(&drvdata->spinlock);
18441852 return size;
18451853 }
drivers/hwtracing/coresight/coresight-etm4x.h+102−18
@@ -130,6 +130,104 @@ · 129 unmodified lines
130130
131131 #define TRCRSR_TA BIT(12)
132132
133+/*
134+ * Bit positions of registers that are defined above, in the sysreg.h style
135+ * of _MASK for multi bit fields and BIT() for single bits.
136+ */
137+#define TRCIDR0_INSTP0_MASK GENMASK(2, 1)
138+#define TRCIDR0_TRCBB BIT(5)
139+#define TRCIDR0_TRCCOND BIT(6)
140+#define TRCIDR0_TRCCCI BIT(7)
141+#define TRCIDR0_RETSTACK BIT(9)
142+#define TRCIDR0_NUMEVENT_MASK GENMASK(11, 10)
143+#define TRCIDR0_QSUPP_MASK GENMASK(16, 15)
144+#define TRCIDR0_TSSIZE_MASK GENMASK(28, 24)
145+
146+#define TRCIDR2_CIDSIZE_MASK GENMASK(9, 5)
147+#define TRCIDR2_VMIDSIZE_MASK GENMASK(14, 10)
148+#define TRCIDR2_CCSIZE_MASK GENMASK(28, 25)
149+
150+#define TRCIDR3_CCITMIN_MASK GENMASK(11, 0)
151+#define TRCIDR3_EXLEVEL_S_MASK GENMASK(19, 16)
152+#define TRCIDR3_EXLEVEL_NS_MASK GENMASK(23, 20)
153+#define TRCIDR3_TRCERR BIT(24)
154+#define TRCIDR3_SYNCPR BIT(25)
155+#define TRCIDR3_STALLCTL BIT(26)
156+#define TRCIDR3_SYSSTALL BIT(27)
157+#define TRCIDR3_NUMPROC_LO_MASK GENMASK(30, 28)
158+#define TRCIDR3_NUMPROC_HI_MASK GENMASK(13, 12)
159+#define TRCIDR3_NOOVERFLOW BIT(31)
160+
161+#define TRCIDR4_NUMACPAIRS_MASK GENMASK(3, 0)
162+#define TRCIDR4_NUMPC_MASK GENMASK(15, 12)
163+#define TRCIDR4_NUMRSPAIR_MASK GENMASK(19, 16)
164+#define TRCIDR4_NUMSSCC_MASK GENMASK(23, 20)
165+#define TRCIDR4_NUMCIDC_MASK GENMASK(27, 24)
166+#define TRCIDR4_NUMVMIDC_MASK GENMASK(31, 28)
167+
168+#define TRCIDR5_NUMEXTIN_MASK GENMASK(8, 0)
169+#define TRCIDR5_TRACEIDSIZE_MASK GENMASK(21, 16)
170+#define TRCIDR5_ATBTRIG BIT(22)
171+#define TRCIDR5_LPOVERRIDE BIT(23)
172+#define TRCIDR5_NUMSEQSTATE_MASK GENMASK(27, 25)
173+#define TRCIDR5_NUMCNTR_MASK GENMASK(30, 28)
174+
175+#define TRCCONFIGR_INSTP0_LOAD BIT(1)
176+#define TRCCONFIGR_INSTP0_STORE BIT(2)
177+#define TRCCONFIGR_INSTP0_LOAD_STORE (TRCCONFIGR_INSTP0_LOAD | TRCCONFIGR_INSTP0_STORE)
178+#define TRCCONFIGR_BB BIT(3)
179+#define TRCCONFIGR_CCI BIT(4)
180+#define TRCCONFIGR_CID BIT(6)
181+#define TRCCONFIGR_VMID BIT(7)
182+#define TRCCONFIGR_COND_MASK GENMASK(10, 8)
183+#define TRCCONFIGR_TS BIT(11)
184+#define TRCCONFIGR_RS BIT(12)
185+#define TRCCONFIGR_QE_W_COUNTS BIT(13)
186+#define TRCCONFIGR_QE_WO_COUNTS BIT(14)
187+#define TRCCONFIGR_VMIDOPT BIT(15)
188+#define TRCCONFIGR_DA BIT(16)
189+#define TRCCONFIGR_DV BIT(17)
190+
191+#define TRCEVENTCTL1R_INSTEN_MASK GENMASK(3, 0)
192+#define TRCEVENTCTL1R_INSTEN_0 BIT(0)
193+#define TRCEVENTCTL1R_INSTEN_1 BIT(1)
194+#define TRCEVENTCTL1R_INSTEN_2 BIT(2)
195+#define TRCEVENTCTL1R_INSTEN_3 BIT(3)
196+#define TRCEVENTCTL1R_ATB BIT(11)
197+#define TRCEVENTCTL1R_LPOVERRIDE BIT(12)
198+
199+#define TRCSTALLCTLR_ISTALL BIT(8)
200+#define TRCSTALLCTLR_INSTPRIORITY BIT(10)
201+#define TRCSTALLCTLR_NOOVERFLOW BIT(13)
202+
203+#define TRCVICTLR_EVENT_MASK GENMASK(7, 0)
204+#define TRCVICTLR_SSSTATUS BIT(9)
205+#define TRCVICTLR_TRCRESET BIT(10)
206+#define TRCVICTLR_TRCERR BIT(11)
207+#define TRCVICTLR_EXLEVEL_MASK GENMASK(22, 16)
208+#define TRCVICTLR_EXLEVEL_S_MASK GENMASK(19, 16)
209+#define TRCVICTLR_EXLEVEL_NS_MASK GENMASK(22, 20)
210+
211+#define TRCACATRn_TYPE_MASK GENMASK(1, 0)
212+#define TRCACATRn_CONTEXTTYPE_MASK GENMASK(3, 2)
213+#define TRCACATRn_CONTEXTTYPE_CTXID BIT(2)
214+#define TRCACATRn_CONTEXTTYPE_VMID BIT(3)
215+#define TRCACATRn_CONTEXT_MASK GENMASK(6, 4)
216+#define TRCACATRn_EXLEVEL_MASK GENMASK(14, 8)
217+
218+#define TRCSSCSRn_STATUS BIT(31)
219+#define TRCSSCCRn_SAC_ARC_RST_MASK GENMASK(24, 0)
220+
221+#define TRCSSPCICRn_PC_MASK GENMASK(7, 0)
222+
223+#define TRCBBCTLR_MODE BIT(8)
224+#define TRCBBCTLR_RANGE_MASK GENMASK(7, 0)
225+
226+#define TRCRSCTLRn_PAIRINV BIT(21)
227+#define TRCRSCTLRn_INV BIT(20)
228+#define TRCRSCTLRn_GROUP_MASK GENMASK(19, 16)
229+#define TRCRSCTLRn_SELECT_MASK GENMASK(15, 0)
230+
133231 /*
134232 * System instructions to access ETM registers.
135233 * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions
@@ -630,23 +728,9 @@ · 494 unmodified lines
630728 #define ETM_EXLEVEL_NS_OS BIT(5) /* NonSecure EL1 */
631729 #define ETM_EXLEVEL_NS_HYP BIT(6) /* NonSecure EL2 */
632730
633−#define ETM_EXLEVEL_MASK (GENMASK(6, 0))
634−#define ETM_EXLEVEL_S_MASK (GENMASK(3, 0))
635−#define ETM_EXLEVEL_NS_MASK (GENMASK(6, 4))
636−
637731 /* access level controls in TRCACATRn */
638732 #define TRCACATR_EXLEVEL_SHIFT 8
639733
640−/* access level control in TRCVICTLR */
641−#define TRCVICTLR_EXLEVEL_SHIFT 16
642−#define TRCVICTLR_EXLEVEL_S_SHIFT 16
643−#define TRCVICTLR_EXLEVEL_NS_SHIFT 20
644−
645−/* secure / non secure masks - TRCVICTLR, IDR3 */
646−#define TRCVICTLR_EXLEVEL_MASK (ETM_EXLEVEL_MASK << TRCVICTLR_EXLEVEL_SHIFT)
647−#define TRCVICTLR_EXLEVEL_S_MASK (ETM_EXLEVEL_S_MASK << TRCVICTLR_EXLEVEL_SHIFT)
648−#define TRCVICTLR_EXLEVEL_NS_MASK (ETM_EXLEVEL_NS_MASK << TRCVICTLR_EXLEVEL_SHIFT)
649−
650734 #define ETM_TRCIDR1_ARCH_MAJOR_SHIFT 8
651735 #define ETM_TRCIDR1_ARCH_MAJOR_MASK (0xfU << ETM_TRCIDR1_ARCH_MAJOR_SHIFT)
652736 #define ETM_TRCIDR1_ARCH_MAJOR(x) \
@@ -986,10 +1070,10 @@ struct etmv4_drvdata { · 333 unmodified lines
9861070
9871071 /* Address comparator access types */
9881072 enum etm_addr_acctype {
989− ETM_INSTR_ADDR,
990− ETM_DATA_LOAD_ADDR,
991− ETM_DATA_STORE_ADDR,
992− ETM_DATA_LOAD_STORE_ADDR,
1073+ TRCACATRn_TYPE_ADDR,
1074+ TRCACATRn_TYPE_DATA_LOAD_ADDR,
1075+ TRCACATRn_TYPE_DATA_STORE_ADDR,
1076+ TRCACATRn_TYPE_DATA_LOAD_STORE_ADDR,
9931077 };
9941078
9951079 /* Address comparator context types */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t