Commit 6582fe69 authored by Leo Yan's avatar Leo Yan Committed by Suzuki K Poulose
Browse files

coresight: cti: Fix register reads



Introduce cti_read_single_reg() as an interface for reading registers
with unlocking the CS lock.  Consolidate register read in sysfs
interfaces using this new helper.

Fixes: b5213376 ("coresight: cti: Add sysfs access to program function registers")
Fixes: 1a556ca6 ("coresight: cti: Add sysfs coresight mgmt register access")
Reviewed-by: default avatarMike Leach <mike.leach@arm.com>
Signed-off-by: default avatarLeo Yan <leo.yan@arm.com>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260226-arm_coresight_cti_refactor_v1-v2-2-b30fada3cfec@arm.com
parent ef7d4aaf
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -156,6 +156,17 @@ static int cti_disable_hw(struct cti_drvdata *drvdata)
	return 0;
}

u32 cti_read_single_reg(struct cti_drvdata *drvdata, int offset)
{
	int val;

	CS_UNLOCK(drvdata->base);
	val = readl_relaxed(drvdata->base + offset);
	CS_LOCK(drvdata->base);

	return val;
}

void cti_write_single_reg(struct cti_drvdata *drvdata, int offset, u32 value)
{
	CS_UNLOCK(drvdata->base);
+2 −4
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ static ssize_t coresight_cti_reg_show(struct device *dev,

	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
		if (drvdata->config.hw_powered)
			val = readl_relaxed(drvdata->base + cti_attr->off);
			val = cti_read_single_reg(drvdata, cti_attr->off);
	}

	pm_runtime_put_sync(dev->parent);
@@ -269,11 +269,9 @@ static ssize_t cti_reg32_show(struct device *dev, char *buf,

	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
		if ((reg_offset >= 0) && cti_active(config)) {
			CS_UNLOCK(drvdata->base);
			val = readl_relaxed(drvdata->base + reg_offset);
			val = cti_read_single_reg(drvdata, reg_offset);
			if (pcached_val)
				*pcached_val = val;
			CS_LOCK(drvdata->base);
		} else if (pcached_val) {
			val = *pcached_val;
		}
+1 −0
Original line number Diff line number Diff line
@@ -220,6 +220,7 @@ int cti_disable(struct coresight_device *csdev, struct coresight_path *path);
void cti_write_all_hw_regs(struct cti_drvdata *drvdata);
void cti_write_intack(struct device *dev, u32 ackval);
void cti_write_single_reg(struct cti_drvdata *drvdata, int offset, u32 value);
u32 cti_read_single_reg(struct cti_drvdata *drvdata, int offset);
int cti_channel_trig_op(struct device *dev, enum cti_chan_op op,
			enum cti_trig_dir direction, u32 channel_idx,
			u32 trigger_idx);