Commit c95c2733 authored by James Clark's avatar James Clark Committed by Suzuki K Poulose

coresight: Add a helper for getting csdev->mode

Now that mode is in struct coresight_device accesses can be wrapped.
Signed-off-by: default avatarJames Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20240129154050.569566-12-james.clark@arm.comSigned-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
parent d724f652
...@@ -148,12 +148,12 @@ static int etb_enable_sysfs(struct coresight_device *csdev) ...@@ -148,12 +148,12 @@ static int etb_enable_sysfs(struct coresight_device *csdev)
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
/* Don't messup with perf sessions. */ /* Don't messup with perf sessions. */
if (local_read(&csdev->mode) == CS_MODE_PERF) { if (coresight_get_mode(csdev) == CS_MODE_PERF) {
ret = -EBUSY; ret = -EBUSY;
goto out; goto out;
} }
if (local_read(&csdev->mode) == CS_MODE_DISABLED) { if (coresight_get_mode(csdev) == CS_MODE_DISABLED) {
ret = etb_enable_hw(drvdata); ret = etb_enable_hw(drvdata);
if (ret) if (ret)
goto out; goto out;
...@@ -179,7 +179,7 @@ static int etb_enable_perf(struct coresight_device *csdev, void *data) ...@@ -179,7 +179,7 @@ static int etb_enable_perf(struct coresight_device *csdev, void *data)
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
/* No need to continue if the component is already in used by sysFS. */ /* No need to continue if the component is already in used by sysFS. */
if (local_read(&drvdata->csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS) {
ret = -EBUSY; ret = -EBUSY;
goto out; goto out;
} }
...@@ -361,7 +361,7 @@ static int etb_disable(struct coresight_device *csdev) ...@@ -361,7 +361,7 @@ static int etb_disable(struct coresight_device *csdev)
} }
/* Complain if we (somehow) got out of sync */ /* Complain if we (somehow) got out of sync */
WARN_ON_ONCE(local_read(&csdev->mode) == CS_MODE_DISABLED); WARN_ON_ONCE(coresight_get_mode(csdev) == CS_MODE_DISABLED);
etb_disable_hw(drvdata); etb_disable_hw(drvdata);
/* Dissociate from monitored process. */ /* Dissociate from monitored process. */
drvdata->pid = -1; drvdata->pid = -1;
...@@ -588,7 +588,7 @@ static void etb_dump(struct etb_drvdata *drvdata) ...@@ -588,7 +588,7 @@ static void etb_dump(struct etb_drvdata *drvdata)
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
if (local_read(&drvdata->csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS) {
__etb_disable_hw(drvdata); __etb_disable_hw(drvdata);
etb_dump_hw(drvdata); etb_dump_hw(drvdata);
__etb_enable_hw(drvdata); __etb_enable_hw(drvdata);
......
...@@ -676,7 +676,7 @@ static void etm_disable(struct coresight_device *csdev, ...@@ -676,7 +676,7 @@ static void etm_disable(struct coresight_device *csdev,
* change its status. As such we can read the status here without * change its status. As such we can read the status here without
* fearing it will change under us. * fearing it will change under us.
*/ */
mode = local_read(&csdev->mode); mode = coresight_get_mode(csdev);
switch (mode) { switch (mode) {
case CS_MODE_DISABLED: case CS_MODE_DISABLED:
...@@ -727,7 +727,7 @@ static int etm_starting_cpu(unsigned int cpu) ...@@ -727,7 +727,7 @@ static int etm_starting_cpu(unsigned int cpu)
etmdrvdata[cpu]->os_unlock = true; etmdrvdata[cpu]->os_unlock = true;
} }
if (local_read(&etmdrvdata[cpu]->csdev->mode)) if (coresight_get_mode(etmdrvdata[cpu]->csdev))
etm_enable_hw(etmdrvdata[cpu]); etm_enable_hw(etmdrvdata[cpu]);
spin_unlock(&etmdrvdata[cpu]->spinlock); spin_unlock(&etmdrvdata[cpu]->spinlock);
return 0; return 0;
...@@ -739,7 +739,7 @@ static int etm_dying_cpu(unsigned int cpu) ...@@ -739,7 +739,7 @@ static int etm_dying_cpu(unsigned int cpu)
return 0; return 0;
spin_lock(&etmdrvdata[cpu]->spinlock); spin_lock(&etmdrvdata[cpu]->spinlock);
if (local_read(&etmdrvdata[cpu]->csdev->mode)) if (coresight_get_mode(etmdrvdata[cpu]->csdev))
etm_disable_hw(etmdrvdata[cpu]); etm_disable_hw(etmdrvdata[cpu]);
spin_unlock(&etmdrvdata[cpu]->spinlock); spin_unlock(&etmdrvdata[cpu]->spinlock);
return 0; return 0;
......
...@@ -722,7 +722,7 @@ static ssize_t cntr_val_show(struct device *dev, ...@@ -722,7 +722,7 @@ static ssize_t cntr_val_show(struct device *dev,
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct etm_config *config = &drvdata->config; struct etm_config *config = &drvdata->config;
if (!local_read(&drvdata->csdev->mode)) { if (!coresight_get_mode(drvdata->csdev)) {
spin_lock(&drvdata->spinlock); spin_lock(&drvdata->spinlock);
for (i = 0; i < drvdata->nr_cntr; i++) for (i = 0; i < drvdata->nr_cntr; i++)
ret += sprintf(buf, "counter %d: %x\n", ret += sprintf(buf, "counter %d: %x\n",
...@@ -941,7 +941,7 @@ static ssize_t seq_curr_state_show(struct device *dev, ...@@ -941,7 +941,7 @@ static ssize_t seq_curr_state_show(struct device *dev,
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct etm_config *config = &drvdata->config; struct etm_config *config = &drvdata->config;
if (!local_read(&drvdata->csdev->mode)) { if (!coresight_get_mode(drvdata->csdev)) {
val = config->seq_curr_state; val = config->seq_curr_state;
goto out; goto out;
} }
......
...@@ -1007,7 +1007,7 @@ static void etm4_disable(struct coresight_device *csdev, ...@@ -1007,7 +1007,7 @@ static void etm4_disable(struct coresight_device *csdev,
* change its status. As such we can read the status here without * change its status. As such we can read the status here without
* fearing it will change under us. * fearing it will change under us.
*/ */
mode = local_read(&csdev->mode); mode = coresight_get_mode(csdev);
switch (mode) { switch (mode) {
case CS_MODE_DISABLED: case CS_MODE_DISABLED:
...@@ -1659,7 +1659,7 @@ static int etm4_starting_cpu(unsigned int cpu) ...@@ -1659,7 +1659,7 @@ static int etm4_starting_cpu(unsigned int cpu)
if (!etmdrvdata[cpu]->os_unlock) if (!etmdrvdata[cpu]->os_unlock)
etm4_os_unlock(etmdrvdata[cpu]); etm4_os_unlock(etmdrvdata[cpu]);
if (local_read(&etmdrvdata[cpu]->csdev->mode)) if (coresight_get_mode(etmdrvdata[cpu]->csdev))
etm4_enable_hw(etmdrvdata[cpu]); etm4_enable_hw(etmdrvdata[cpu]);
spin_unlock(&etmdrvdata[cpu]->spinlock); spin_unlock(&etmdrvdata[cpu]->spinlock);
return 0; return 0;
...@@ -1671,7 +1671,7 @@ static int etm4_dying_cpu(unsigned int cpu) ...@@ -1671,7 +1671,7 @@ static int etm4_dying_cpu(unsigned int cpu)
return 0; return 0;
spin_lock(&etmdrvdata[cpu]->spinlock); spin_lock(&etmdrvdata[cpu]->spinlock);
if (local_read(&etmdrvdata[cpu]->csdev->mode)) if (coresight_get_mode(etmdrvdata[cpu]->csdev))
etm4_disable_hw(etmdrvdata[cpu]); etm4_disable_hw(etmdrvdata[cpu]);
spin_unlock(&etmdrvdata[cpu]->spinlock); spin_unlock(&etmdrvdata[cpu]->spinlock);
return 0; return 0;
...@@ -1829,7 +1829,7 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) ...@@ -1829,7 +1829,7 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata)
* Save and restore the ETM Trace registers only if * Save and restore the ETM Trace registers only if
* the ETM is active. * the ETM is active.
*/ */
if (local_read(&drvdata->csdev->mode) && drvdata->save_state) if (coresight_get_mode(drvdata->csdev) && drvdata->save_state)
ret = __etm4_cpu_save(drvdata); ret = __etm4_cpu_save(drvdata);
return ret; return ret;
} }
......
...@@ -262,7 +262,7 @@ static void stm_disable(struct coresight_device *csdev, ...@@ -262,7 +262,7 @@ static void stm_disable(struct coresight_device *csdev,
* change its status. As such we can read the status here without * change its status. As such we can read the status here without
* fearing it will change under us. * fearing it will change under us.
*/ */
if (local_read(&csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(csdev) == CS_MODE_SYSFS) {
spin_lock(&drvdata->spinlock); spin_lock(&drvdata->spinlock);
stm_disable_hw(drvdata); stm_disable_hw(drvdata);
spin_unlock(&drvdata->spinlock); spin_unlock(&drvdata->spinlock);
...@@ -369,7 +369,7 @@ static long stm_generic_set_options(struct stm_data *stm_data, ...@@ -369,7 +369,7 @@ static long stm_generic_set_options(struct stm_data *stm_data,
{ {
struct stm_drvdata *drvdata = container_of(stm_data, struct stm_drvdata *drvdata = container_of(stm_data,
struct stm_drvdata, stm); struct stm_drvdata, stm);
if (!(drvdata && local_read(&drvdata->csdev->mode))) if (!(drvdata && coresight_get_mode(drvdata->csdev)))
return -EINVAL; return -EINVAL;
if (channel >= drvdata->numsp) if (channel >= drvdata->numsp)
...@@ -404,7 +404,7 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data, ...@@ -404,7 +404,7 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
struct stm_drvdata, stm); struct stm_drvdata, stm);
unsigned int stm_flags; unsigned int stm_flags;
if (!(drvdata && local_read(&drvdata->csdev->mode))) if (!(drvdata && coresight_get_mode(drvdata->csdev)))
return -EACCES; return -EACCES;
if (channel >= drvdata->numsp) if (channel >= drvdata->numsp)
...@@ -511,7 +511,7 @@ static ssize_t port_select_show(struct device *dev, ...@@ -511,7 +511,7 @@ static ssize_t port_select_show(struct device *dev,
struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent);
unsigned long val; unsigned long val;
if (!local_read(&drvdata->csdev->mode)) { if (!coresight_get_mode(drvdata->csdev)) {
val = drvdata->stmspscr; val = drvdata->stmspscr;
} else { } else {
spin_lock(&drvdata->spinlock); spin_lock(&drvdata->spinlock);
...@@ -537,7 +537,7 @@ static ssize_t port_select_store(struct device *dev, ...@@ -537,7 +537,7 @@ static ssize_t port_select_store(struct device *dev,
spin_lock(&drvdata->spinlock); spin_lock(&drvdata->spinlock);
drvdata->stmspscr = val; drvdata->stmspscr = val;
if (local_read(&drvdata->csdev->mode)) { if (coresight_get_mode(drvdata->csdev)) {
CS_UNLOCK(drvdata->base); CS_UNLOCK(drvdata->base);
/* Process as per ARM's TRM recommendation */ /* Process as per ARM's TRM recommendation */
stmsper = readl_relaxed(drvdata->base + STMSPER); stmsper = readl_relaxed(drvdata->base + STMSPER);
...@@ -558,7 +558,7 @@ static ssize_t port_enable_show(struct device *dev, ...@@ -558,7 +558,7 @@ static ssize_t port_enable_show(struct device *dev,
struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent);
unsigned long val; unsigned long val;
if (!local_read(&drvdata->csdev->mode)) { if (!coresight_get_mode(drvdata->csdev)) {
val = drvdata->stmsper; val = drvdata->stmsper;
} else { } else {
spin_lock(&drvdata->spinlock); spin_lock(&drvdata->spinlock);
...@@ -584,7 +584,7 @@ static ssize_t port_enable_store(struct device *dev, ...@@ -584,7 +584,7 @@ static ssize_t port_enable_store(struct device *dev,
spin_lock(&drvdata->spinlock); spin_lock(&drvdata->spinlock);
drvdata->stmsper = val; drvdata->stmsper = val;
if (local_read(&drvdata->csdev->mode)) { if (coresight_get_mode(drvdata->csdev)) {
CS_UNLOCK(drvdata->base); CS_UNLOCK(drvdata->base);
writel_relaxed(drvdata->stmsper, drvdata->base + STMSPER); writel_relaxed(drvdata->stmsper, drvdata->base + STMSPER);
CS_LOCK(drvdata->base); CS_LOCK(drvdata->base);
......
...@@ -62,7 +62,7 @@ static int coresight_enable_source_sysfs(struct coresight_device *csdev, ...@@ -62,7 +62,7 @@ static int coresight_enable_source_sysfs(struct coresight_device *csdev,
* change with coresight_mutex held, which we already have here. * change with coresight_mutex held, which we already have here.
*/ */
lockdep_assert_held(&coresight_mutex); lockdep_assert_held(&coresight_mutex);
if (local_read(&csdev->mode) != CS_MODE_SYSFS) { if (coresight_get_mode(csdev) != CS_MODE_SYSFS) {
ret = source_ops(csdev)->enable(csdev, data, mode); ret = source_ops(csdev)->enable(csdev, data, mode);
if (ret) if (ret)
return ret; return ret;
...@@ -87,7 +87,7 @@ static bool coresight_disable_source_sysfs(struct coresight_device *csdev, ...@@ -87,7 +87,7 @@ static bool coresight_disable_source_sysfs(struct coresight_device *csdev,
void *data) void *data)
{ {
lockdep_assert_held(&coresight_mutex); lockdep_assert_held(&coresight_mutex);
if (local_read(&csdev->mode) != CS_MODE_SYSFS) if (coresight_get_mode(csdev) != CS_MODE_SYSFS)
return false; return false;
csdev->refcnt--; csdev->refcnt--;
...@@ -184,7 +184,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev) ...@@ -184,7 +184,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
* coresight_enable_source() so can still race with Perf mode which * coresight_enable_source() so can still race with Perf mode which
* doesn't hold coresight_mutex. * doesn't hold coresight_mutex.
*/ */
if (local_read(&csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(csdev) == CS_MODE_SYSFS) {
/* /*
* There could be multiple applications driving the software * There could be multiple applications driving the software
* source. So keep the refcount for each such user when the * source. So keep the refcount for each such user when the
...@@ -338,7 +338,7 @@ static ssize_t enable_source_show(struct device *dev, ...@@ -338,7 +338,7 @@ static ssize_t enable_source_show(struct device *dev,
guard(mutex)(&coresight_mutex); guard(mutex)(&coresight_mutex);
return scnprintf(buf, PAGE_SIZE, "%u\n", return scnprintf(buf, PAGE_SIZE, "%u\n",
local_read(&csdev->mode) == CS_MODE_SYSFS); coresight_get_mode(csdev) == CS_MODE_SYSFS);
} }
static ssize_t enable_source_store(struct device *dev, static ssize_t enable_source_store(struct device *dev,
......
...@@ -558,7 +558,7 @@ static void tmc_shutdown(struct amba_device *adev) ...@@ -558,7 +558,7 @@ static void tmc_shutdown(struct amba_device *adev)
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
if (local_read(&drvdata->csdev->mode) == CS_MODE_DISABLED) if (coresight_get_mode(drvdata->csdev) == CS_MODE_DISABLED)
goto out; goto out;
if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) if (drvdata->config_type == TMC_CONFIG_TYPE_ETR)
......
...@@ -89,7 +89,7 @@ static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata) ...@@ -89,7 +89,7 @@ static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
* When operating in sysFS mode the content of the buffer needs to be * When operating in sysFS mode the content of the buffer needs to be
* read before the TMC is disabled. * read before the TMC is disabled.
*/ */
if (local_read(&drvdata->csdev->mode) == CS_MODE_SYSFS) if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS)
tmc_etb_dump_hw(drvdata); tmc_etb_dump_hw(drvdata);
tmc_disable_hw(drvdata); tmc_disable_hw(drvdata);
...@@ -205,7 +205,7 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev) ...@@ -205,7 +205,7 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev)
* sink is already enabled no memory is needed and the HW need not be * sink is already enabled no memory is needed and the HW need not be
* touched. * touched.
*/ */
if (local_read(&csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(csdev) == CS_MODE_SYSFS) {
csdev->refcnt++; csdev->refcnt++;
goto out; goto out;
} }
...@@ -262,7 +262,7 @@ static int tmc_enable_etf_sink_perf(struct coresight_device *csdev, void *data) ...@@ -262,7 +262,7 @@ static int tmc_enable_etf_sink_perf(struct coresight_device *csdev, void *data)
* No need to continue if the ETB/ETF is already operated * No need to continue if the ETB/ETF is already operated
* from sysFS. * from sysFS.
*/ */
if (local_read(&csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(csdev) == CS_MODE_SYSFS) {
ret = -EBUSY; ret = -EBUSY;
break; break;
} }
...@@ -345,7 +345,7 @@ static int tmc_disable_etf_sink(struct coresight_device *csdev) ...@@ -345,7 +345,7 @@ static int tmc_disable_etf_sink(struct coresight_device *csdev)
} }
/* Complain if we (somehow) got out of sync */ /* Complain if we (somehow) got out of sync */
WARN_ON_ONCE(local_read(&csdev->mode) == CS_MODE_DISABLED); WARN_ON_ONCE(coresight_get_mode(csdev) == CS_MODE_DISABLED);
tmc_etb_disable_hw(drvdata); tmc_etb_disable_hw(drvdata);
/* Dissociate from monitored process. */ /* Dissociate from monitored process. */
drvdata->pid = -1; drvdata->pid = -1;
...@@ -485,7 +485,7 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, ...@@ -485,7 +485,7 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,
return 0; return 0;
/* This shouldn't happen */ /* This shouldn't happen */
if (WARN_ON_ONCE(local_read(&csdev->mode) != CS_MODE_PERF)) if (WARN_ON_ONCE(coresight_get_mode(csdev) != CS_MODE_PERF))
return 0; return 0;
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
...@@ -631,7 +631,7 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata) ...@@ -631,7 +631,7 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata)
} }
/* Don't interfere if operated from Perf */ /* Don't interfere if operated from Perf */
if (local_read(&drvdata->csdev->mode) == CS_MODE_PERF) { if (coresight_get_mode(drvdata->csdev) == CS_MODE_PERF) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -643,7 +643,7 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata) ...@@ -643,7 +643,7 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata)
} }
/* Disable the TMC if need be */ /* Disable the TMC if need be */
if (local_read(&drvdata->csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS) {
/* There is no point in reading a TMC in HW FIFO mode */ /* There is no point in reading a TMC in HW FIFO mode */
mode = readl_relaxed(drvdata->base + TMC_MODE); mode = readl_relaxed(drvdata->base + TMC_MODE);
if (mode != TMC_MODE_CIRCULAR_BUFFER) { if (mode != TMC_MODE_CIRCULAR_BUFFER) {
...@@ -675,7 +675,7 @@ int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata) ...@@ -675,7 +675,7 @@ int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata)
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
/* Re-enable the TMC if need be */ /* Re-enable the TMC if need be */
if (local_read(&drvdata->csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS) {
/* There is no point in reading a TMC in HW FIFO mode */ /* There is no point in reading a TMC in HW FIFO mode */
mode = readl_relaxed(drvdata->base + TMC_MODE); mode = readl_relaxed(drvdata->base + TMC_MODE);
if (mode != TMC_MODE_CIRCULAR_BUFFER) { if (mode != TMC_MODE_CIRCULAR_BUFFER) {
......
...@@ -1143,7 +1143,7 @@ static void __tmc_etr_disable_hw(struct tmc_drvdata *drvdata) ...@@ -1143,7 +1143,7 @@ static void __tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
* When operating in sysFS mode the content of the buffer needs to be * When operating in sysFS mode the content of the buffer needs to be
* read before the TMC is disabled. * read before the TMC is disabled.
*/ */
if (local_read(&drvdata->csdev->mode) == CS_MODE_SYSFS) if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS)
tmc_etr_sync_sysfs_buf(drvdata); tmc_etr_sync_sysfs_buf(drvdata);
tmc_disable_hw(drvdata); tmc_disable_hw(drvdata);
...@@ -1189,7 +1189,7 @@ static struct etr_buf *tmc_etr_get_sysfs_buffer(struct coresight_device *csdev) ...@@ -1189,7 +1189,7 @@ static struct etr_buf *tmc_etr_get_sysfs_buffer(struct coresight_device *csdev)
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
} }
if (drvdata->reading || local_read(&csdev->mode) == CS_MODE_PERF) { if (drvdata->reading || coresight_get_mode(csdev) == CS_MODE_PERF) {
ret = -EBUSY; ret = -EBUSY;
goto out; goto out;
} }
...@@ -1230,7 +1230,7 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev) ...@@ -1230,7 +1230,7 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
* sink is already enabled no memory is needed and the HW need not be * sink is already enabled no memory is needed and the HW need not be
* touched, even if the buffer size has changed. * touched, even if the buffer size has changed.
*/ */
if (local_read(&csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(csdev) == CS_MODE_SYSFS) {
csdev->refcnt++; csdev->refcnt++;
goto out; goto out;
} }
...@@ -1652,7 +1652,7 @@ static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, void *data) ...@@ -1652,7 +1652,7 @@ static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, void *data)
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
/* Don't use this sink if it is already claimed by sysFS */ /* Don't use this sink if it is already claimed by sysFS */
if (local_read(&csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(csdev) == CS_MODE_SYSFS) {
rc = -EBUSY; rc = -EBUSY;
goto unlock_out; goto unlock_out;
} }
...@@ -1726,7 +1726,7 @@ static int tmc_disable_etr_sink(struct coresight_device *csdev) ...@@ -1726,7 +1726,7 @@ static int tmc_disable_etr_sink(struct coresight_device *csdev)
} }
/* Complain if we (somehow) got out of sync */ /* Complain if we (somehow) got out of sync */
WARN_ON_ONCE(local_read(&csdev->mode) == CS_MODE_DISABLED); WARN_ON_ONCE(coresight_get_mode(csdev) == CS_MODE_DISABLED);
tmc_etr_disable_hw(drvdata); tmc_etr_disable_hw(drvdata);
/* Dissociate from monitored process. */ /* Dissociate from monitored process. */
drvdata->pid = -1; drvdata->pid = -1;
...@@ -1778,7 +1778,7 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata) ...@@ -1778,7 +1778,7 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata)
} }
/* Disable the TMC if we are trying to read from a running session. */ /* Disable the TMC if we are trying to read from a running session. */
if (local_read(&drvdata->csdev->mode) == CS_MODE_SYSFS) if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS)
__tmc_etr_disable_hw(drvdata); __tmc_etr_disable_hw(drvdata);
drvdata->reading = true; drvdata->reading = true;
...@@ -1800,7 +1800,7 @@ int tmc_read_unprepare_etr(struct tmc_drvdata *drvdata) ...@@ -1800,7 +1800,7 @@ int tmc_read_unprepare_etr(struct tmc_drvdata *drvdata)
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
/* RE-enable the TMC if need be */ /* RE-enable the TMC if need be */
if (local_read(&drvdata->csdev->mode) == CS_MODE_SYSFS) { if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS) {
/* /*
* The trace run will continue with the same allocated trace * The trace run will continue with the same allocated trace
* buffer. Since the tracer is still enabled drvdata::buf can't * buffer. Since the tracer is still enabled drvdata::buf can't
......
...@@ -207,7 +207,7 @@ static void smb_enable_sysfs(struct coresight_device *csdev) ...@@ -207,7 +207,7 @@ static void smb_enable_sysfs(struct coresight_device *csdev)
{ {
struct smb_drv_data *drvdata = dev_get_drvdata(csdev->dev.parent); struct smb_drv_data *drvdata = dev_get_drvdata(csdev->dev.parent);
if (local_read(&csdev->mode) != CS_MODE_DISABLED) if (coresight_get_mode(csdev) != CS_MODE_DISABLED)
return; return;
smb_enable_hw(drvdata); smb_enable_hw(drvdata);
...@@ -253,8 +253,8 @@ static int smb_enable(struct coresight_device *csdev, enum cs_mode mode, ...@@ -253,8 +253,8 @@ static int smb_enable(struct coresight_device *csdev, enum cs_mode mode,
return -EBUSY; return -EBUSY;
/* Do nothing, the SMB is already enabled as other mode */ /* Do nothing, the SMB is already enabled as other mode */
if (local_read(&csdev->mode) != CS_MODE_DISABLED && if (coresight_get_mode(csdev) != CS_MODE_DISABLED &&
local_read(&csdev->mode) != mode) coresight_get_mode(csdev) != mode)
return -EBUSY; return -EBUSY;
switch (mode) { switch (mode) {
...@@ -291,7 +291,7 @@ static int smb_disable(struct coresight_device *csdev) ...@@ -291,7 +291,7 @@ static int smb_disable(struct coresight_device *csdev)
return -EBUSY; return -EBUSY;
/* Complain if we (somehow) got out of sync */ /* Complain if we (somehow) got out of sync */
WARN_ON_ONCE(local_read(&csdev->mode) == CS_MODE_DISABLED); WARN_ON_ONCE(coresight_get_mode(csdev) == CS_MODE_DISABLED);
smb_disable_hw(drvdata); smb_disable_hw(drvdata);
......
...@@ -591,6 +591,11 @@ static inline bool coresight_take_mode(struct coresight_device *csdev, ...@@ -591,6 +591,11 @@ static inline bool coresight_take_mode(struct coresight_device *csdev,
CS_MODE_DISABLED; CS_MODE_DISABLED;
} }
static inline enum cs_mode coresight_get_mode(struct coresight_device *csdev)
{
return local_read(&csdev->mode);
}
extern struct coresight_device * extern struct coresight_device *
coresight_register(struct coresight_desc *desc); coresight_register(struct coresight_desc *desc);
extern void coresight_unregister(struct coresight_device *csdev); extern void coresight_unregister(struct coresight_device *csdev);
......
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