Commit 08e9fa5f authored by James Clark's avatar James Clark Committed by Mathieu Poirier

coresight: Re-use same function for similar sysfs register accessors

Currently each accessor macro creates an identical function which wastes
space in the text area and pollutes the ftrace function names. Change it
so that the same function is used, but the register to access is passed
in as parameter rather than baked into each function.
Signed-off-by: default avatarJames Clark <james.clark@arm.com>
Reviewed-by: default avatarMike Leach <mike.leach@linaro.org>
Link: https://lore.kernel.org/r/20220830172614.340962-4-james.clark@arm.comSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
parent b6df1cbb
...@@ -365,24 +365,15 @@ static const struct etr_buf_operations etr_catu_buf_ops = { ...@@ -365,24 +365,15 @@ static const struct etr_buf_operations etr_catu_buf_ops = {
.get_data = catu_get_data_etr_buf, .get_data = catu_get_data_etr_buf,
}; };
coresight_simple_reg32(devid, CORESIGHT_DEVID);
coresight_simple_reg32(control, CATU_CONTROL);
coresight_simple_reg32(status, CATU_STATUS);
coresight_simple_reg32(mode, CATU_MODE);
coresight_simple_reg32(axictrl, CATU_AXICTRL);
coresight_simple_reg32(irqen, CATU_IRQEN);
coresight_simple_reg64(sladdr, CATU_SLADDRLO, CATU_SLADDRHI);
coresight_simple_reg64(inaddr, CATU_INADDRLO, CATU_INADDRHI);
static struct attribute *catu_mgmt_attrs[] = { static struct attribute *catu_mgmt_attrs[] = {
&dev_attr_devid.attr, coresight_simple_reg32(devid, CORESIGHT_DEVID),
&dev_attr_control.attr, coresight_simple_reg32(control, CATU_CONTROL),
&dev_attr_status.attr, coresight_simple_reg32(status, CATU_STATUS),
&dev_attr_mode.attr, coresight_simple_reg32(mode, CATU_MODE),
&dev_attr_axictrl.attr, coresight_simple_reg32(axictrl, CATU_AXICTRL),
&dev_attr_irqen.attr, coresight_simple_reg32(irqen, CATU_IRQEN),
&dev_attr_sladdr.attr, coresight_simple_reg64(sladdr, CATU_SLADDRLO, CATU_SLADDRHI),
&dev_attr_inaddr.attr, coresight_simple_reg64(inaddr, CATU_INADDRLO, CATU_INADDRHI),
NULL, NULL,
}; };
......
...@@ -60,6 +60,20 @@ EXPORT_SYMBOL_GPL(coresight_barrier_pkt); ...@@ -60,6 +60,20 @@ EXPORT_SYMBOL_GPL(coresight_barrier_pkt);
static const struct cti_assoc_op *cti_assoc_ops; static const struct cti_assoc_op *cti_assoc_ops;
ssize_t coresight_simple_show(struct device *_dev,
struct device_attribute *attr, char *buf)
{
struct coresight_device *csdev = container_of(_dev, struct coresight_device, dev);
struct cs_pair_attribute *cs_attr = container_of(attr, struct cs_pair_attribute, attr);
u64 val;
pm_runtime_get_sync(_dev->parent);
val = csdev_access_relaxed_read_pair(&csdev->access, cs_attr->lo_off, cs_attr->hi_off);
pm_runtime_put_sync(_dev->parent);
return sysfs_emit(buf, "0x%llx\n", val);
}
EXPORT_SYMBOL_GPL(coresight_simple_show);
void coresight_set_cti_ops(const struct cti_assoc_op *cti_op) void coresight_set_cti_ops(const struct cti_assoc_op *cti_op)
{ {
cti_assoc_ops = cti_op; cti_assoc_ops = cti_op;
......
...@@ -655,24 +655,15 @@ static const struct file_operations etb_fops = { ...@@ -655,24 +655,15 @@ static const struct file_operations etb_fops = {
.llseek = no_llseek, .llseek = no_llseek,
}; };
coresight_simple_reg32(rdp, ETB_RAM_DEPTH_REG);
coresight_simple_reg32(sts, ETB_STATUS_REG);
coresight_simple_reg32(rrp, ETB_RAM_READ_POINTER);
coresight_simple_reg32(rwp, ETB_RAM_WRITE_POINTER);
coresight_simple_reg32(trg, ETB_TRG);
coresight_simple_reg32(ctl, ETB_CTL_REG);
coresight_simple_reg32(ffsr, ETB_FFSR);
coresight_simple_reg32(ffcr, ETB_FFCR);
static struct attribute *coresight_etb_mgmt_attrs[] = { static struct attribute *coresight_etb_mgmt_attrs[] = {
&dev_attr_rdp.attr, coresight_simple_reg32(rdp, ETB_RAM_DEPTH_REG),
&dev_attr_sts.attr, coresight_simple_reg32(sts, ETB_STATUS_REG),
&dev_attr_rrp.attr, coresight_simple_reg32(rrp, ETB_RAM_READ_POINTER),
&dev_attr_rwp.attr, coresight_simple_reg32(rwp, ETB_RAM_WRITE_POINTER),
&dev_attr_trg.attr, coresight_simple_reg32(trg, ETB_TRG),
&dev_attr_ctl.attr, coresight_simple_reg32(ctl, ETB_CTL_REG),
&dev_attr_ffsr.attr, coresight_simple_reg32(ffsr, ETB_FFSR),
&dev_attr_ffcr.attr, coresight_simple_reg32(ffcr, ETB_FFCR),
NULL, NULL,
}; };
......
...@@ -1252,28 +1252,17 @@ static struct attribute *coresight_etm_attrs[] = { ...@@ -1252,28 +1252,17 @@ static struct attribute *coresight_etm_attrs[] = {
NULL, NULL,
}; };
coresight_simple_reg32(etmccr, ETMCCR);
coresight_simple_reg32(etmccer, ETMCCER);
coresight_simple_reg32(etmscr, ETMSCR);
coresight_simple_reg32(etmidr, ETMIDR);
coresight_simple_reg32(etmcr, ETMCR);
coresight_simple_reg32(etmtraceidr, ETMTRACEIDR);
coresight_simple_reg32(etmteevr, ETMTEEVR);
coresight_simple_reg32(etmtssvr, ETMTSSCR);
coresight_simple_reg32(etmtecr1, ETMTECR1);
coresight_simple_reg32(etmtecr2, ETMTECR2);
static struct attribute *coresight_etm_mgmt_attrs[] = { static struct attribute *coresight_etm_mgmt_attrs[] = {
&dev_attr_etmccr.attr, coresight_simple_reg32(etmccr, ETMCCR),
&dev_attr_etmccer.attr, coresight_simple_reg32(etmccer, ETMCCER),
&dev_attr_etmscr.attr, coresight_simple_reg32(etmscr, ETMSCR),
&dev_attr_etmidr.attr, coresight_simple_reg32(etmidr, ETMIDR),
&dev_attr_etmcr.attr, coresight_simple_reg32(etmcr, ETMCR),
&dev_attr_etmtraceidr.attr, coresight_simple_reg32(etmtraceidr, ETMTRACEIDR),
&dev_attr_etmteevr.attr, coresight_simple_reg32(etmteevr, ETMTEEVR),
&dev_attr_etmtssvr.attr, coresight_simple_reg32(etmtssvr, ETMTSSCR),
&dev_attr_etmtecr1.attr, coresight_simple_reg32(etmtecr1, ETMTECR1),
&dev_attr_etmtecr2.attr, coresight_simple_reg32(etmtecr2, ETMTECR2),
NULL, NULL,
}; };
......
...@@ -39,24 +39,30 @@ ...@@ -39,24 +39,30 @@
#define ETM_MODE_EXCL_KERN BIT(30) #define ETM_MODE_EXCL_KERN BIT(30)
#define ETM_MODE_EXCL_USER BIT(31) #define ETM_MODE_EXCL_USER BIT(31)
struct cs_pair_attribute {
struct device_attribute attr;
s32 lo_off;
s32 hi_off;
};
#define __coresight_simple_show(name, lo_off, hi_off) \ extern ssize_t coresight_simple_show(struct device *_dev,
static ssize_t name##_show(struct device *_dev, \ struct device_attribute *attr, char *buf);
struct device_attribute *attr, char *buf) \
{ \ #define coresight_simple_reg32(name, offset) \
struct coresight_device *csdev = container_of(_dev, struct coresight_device, dev); \ (&((struct cs_pair_attribute[]) { \
u64 val; \ { \
pm_runtime_get_sync(_dev->parent); \ __ATTR(name, 0444, coresight_simple_show, NULL), \
val = csdev_access_relaxed_read_pair(&csdev->access, lo_off, hi_off); \ offset, -1 \
pm_runtime_put_sync(_dev->parent); \ } \
return scnprintf(buf, PAGE_SIZE, "0x%llx\n", val); \ })[0].attr.attr)
} \
static DEVICE_ATTR_RO(name) #define coresight_simple_reg64(name, lo_off, hi_off) \
(&((struct cs_pair_attribute[]) { \
#define coresight_simple_reg32(name, offset) \ { \
__coresight_simple_show(name, offset, -1) __ATTR(name, 0444, coresight_simple_show, NULL), \
#define coresight_simple_reg64(name, lo_off, hi_off) \ lo_off, hi_off \
__coresight_simple_show(name, lo_off, hi_off) } \
})[0].attr.attr)
extern const u32 coresight_barrier_pkt[4]; extern const u32 coresight_barrier_pkt[4];
#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(coresight_barrier_pkt)) #define CORESIGHT_BARRIER_PKT_SIZE (sizeof(coresight_barrier_pkt))
......
...@@ -196,12 +196,9 @@ static const struct coresight_ops replicator_cs_ops = { ...@@ -196,12 +196,9 @@ static const struct coresight_ops replicator_cs_ops = {
.link_ops = &replicator_link_ops, .link_ops = &replicator_link_ops,
}; };
coresight_simple_reg32(idfilter0, REPLICATOR_IDFILTER0);
coresight_simple_reg32(idfilter1, REPLICATOR_IDFILTER1);
static struct attribute *replicator_mgmt_attrs[] = { static struct attribute *replicator_mgmt_attrs[] = {
&dev_attr_idfilter0.attr, coresight_simple_reg32(idfilter0, REPLICATOR_IDFILTER0),
&dev_attr_idfilter1.attr, coresight_simple_reg32(idfilter1, REPLICATOR_IDFILTER1),
NULL, NULL,
}; };
......
...@@ -634,19 +634,6 @@ static ssize_t traceid_store(struct device *dev, ...@@ -634,19 +634,6 @@ static ssize_t traceid_store(struct device *dev,
} }
static DEVICE_ATTR_RW(traceid); static DEVICE_ATTR_RW(traceid);
coresight_simple_reg32(tcsr, STMTCSR);
coresight_simple_reg32(tsfreqr, STMTSFREQR);
coresight_simple_reg32(syncr, STMSYNCR);
coresight_simple_reg32(sper, STMSPER);
coresight_simple_reg32(spter, STMSPTER);
coresight_simple_reg32(privmaskr, STMPRIVMASKR);
coresight_simple_reg32(spscr, STMSPSCR);
coresight_simple_reg32(spmscr, STMSPMSCR);
coresight_simple_reg32(spfeat1r, STMSPFEAT1R);
coresight_simple_reg32(spfeat2r, STMSPFEAT2R);
coresight_simple_reg32(spfeat3r, STMSPFEAT3R);
coresight_simple_reg32(devid, CORESIGHT_DEVID);
static struct attribute *coresight_stm_attrs[] = { static struct attribute *coresight_stm_attrs[] = {
&dev_attr_hwevent_enable.attr, &dev_attr_hwevent_enable.attr,
&dev_attr_hwevent_select.attr, &dev_attr_hwevent_select.attr,
...@@ -657,18 +644,18 @@ static struct attribute *coresight_stm_attrs[] = { ...@@ -657,18 +644,18 @@ static struct attribute *coresight_stm_attrs[] = {
}; };
static struct attribute *coresight_stm_mgmt_attrs[] = { static struct attribute *coresight_stm_mgmt_attrs[] = {
&dev_attr_tcsr.attr, coresight_simple_reg32(tcsr, STMTCSR),
&dev_attr_tsfreqr.attr, coresight_simple_reg32(tsfreqr, STMTSFREQR),
&dev_attr_syncr.attr, coresight_simple_reg32(syncr, STMSYNCR),
&dev_attr_sper.attr, coresight_simple_reg32(sper, STMSPER),
&dev_attr_spter.attr, coresight_simple_reg32(spter, STMSPTER),
&dev_attr_privmaskr.attr, coresight_simple_reg32(privmaskr, STMPRIVMASKR),
&dev_attr_spscr.attr, coresight_simple_reg32(spscr, STMSPSCR),
&dev_attr_spmscr.attr, coresight_simple_reg32(spmscr, STMSPMSCR),
&dev_attr_spfeat1r.attr, coresight_simple_reg32(spfeat1r, STMSPFEAT1R),
&dev_attr_spfeat2r.attr, coresight_simple_reg32(spfeat2r, STMSPFEAT2R),
&dev_attr_spfeat3r.attr, coresight_simple_reg32(spfeat3r, STMSPFEAT3R),
&dev_attr_devid.attr, coresight_simple_reg32(devid, CORESIGHT_DEVID),
NULL, NULL,
}; };
......
...@@ -251,36 +251,21 @@ static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid) ...@@ -251,36 +251,21 @@ static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid)
return memwidth; return memwidth;
} }
coresight_simple_reg32(rsz, TMC_RSZ);
coresight_simple_reg32(sts, TMC_STS);
coresight_simple_reg32(trg, TMC_TRG);
coresight_simple_reg32(ctl, TMC_CTL);
coresight_simple_reg32(ffsr, TMC_FFSR);
coresight_simple_reg32(ffcr, TMC_FFCR);
coresight_simple_reg32(mode, TMC_MODE);
coresight_simple_reg32(pscr, TMC_PSCR);
coresight_simple_reg32(axictl, TMC_AXICTL);
coresight_simple_reg32(authstatus, TMC_AUTHSTATUS);
coresight_simple_reg32(devid, CORESIGHT_DEVID);
coresight_simple_reg64(rrp, TMC_RRP, TMC_RRPHI);
coresight_simple_reg64(rwp, TMC_RWP, TMC_RWPHI);
coresight_simple_reg64(dba, TMC_DBALO, TMC_DBAHI);
static struct attribute *coresight_tmc_mgmt_attrs[] = { static struct attribute *coresight_tmc_mgmt_attrs[] = {
&dev_attr_rsz.attr, coresight_simple_reg32(rsz, TMC_RSZ),
&dev_attr_sts.attr, coresight_simple_reg32(sts, TMC_STS),
&dev_attr_rrp.attr, coresight_simple_reg64(rrp, TMC_RRP, TMC_RRPHI),
&dev_attr_rwp.attr, coresight_simple_reg64(rwp, TMC_RWP, TMC_RWPHI),
&dev_attr_trg.attr, coresight_simple_reg32(trg, TMC_TRG),
&dev_attr_ctl.attr, coresight_simple_reg32(ctl, TMC_CTL),
&dev_attr_ffsr.attr, coresight_simple_reg32(ffsr, TMC_FFSR),
&dev_attr_ffcr.attr, coresight_simple_reg32(ffcr, TMC_FFCR),
&dev_attr_mode.attr, coresight_simple_reg32(mode, TMC_MODE),
&dev_attr_pscr.attr, coresight_simple_reg32(pscr, TMC_PSCR),
&dev_attr_devid.attr, coresight_simple_reg32(devid, CORESIGHT_DEVID),
&dev_attr_dba.attr, coresight_simple_reg64(dba, TMC_DBALO, TMC_DBAHI),
&dev_attr_axictl.attr, coresight_simple_reg32(axictl, TMC_AXICTL),
&dev_attr_authstatus.attr, coresight_simple_reg32(authstatus, TMC_AUTHSTATUS),
NULL, NULL,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment