Merge "coresight: Add result check of pm_runtime_get_sync"

This commit is contained in:
qctecmdr 2022-12-20 20:44:27 -08:00 committed by Gerrit - the friendly Code Review server
commit b49626251e
7 changed files with 61 additions and 12 deletions

View File

@ -916,13 +916,19 @@ struct coresight_device *coresight_get_sink_by_id(u32 id)
static inline bool coresight_get_ref(struct coresight_device *csdev)
{
struct device *dev = csdev->dev.parent;
int ret;
/* Make sure the driver can't be removed */
if (!try_module_get(dev->driver->owner))
return false;
/* Make sure the device can't go away */
get_device(dev);
pm_runtime_get_sync(dev);
ret = pm_runtime_get_sync(dev);
if (ret < 0) {
pm_runtime_put_noidle(dev);
return false;
}
return true;
}

View File

@ -179,8 +179,13 @@ static ssize_t coresight_cti_reg_show(struct device *dev,
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct cs_off_attribute *cti_attr = container_of(attr, struct cs_off_attribute, attr);
u32 val = 0;
int ret;
pm_runtime_get_sync(dev->parent);
ret = pm_runtime_get_sync(dev->parent);
if (ret < 0) {
pm_runtime_put_noidle(dev->parent);
return ret;
}
spin_lock(&drvdata->spinlock);
if (drvdata->config.hw_powered)
val = readl_relaxed(drvdata->base + cti_attr->off);
@ -197,11 +202,16 @@ static __maybe_unused ssize_t coresight_cti_reg_store(struct device *dev,
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct cs_off_attribute *cti_attr = container_of(attr, struct cs_off_attribute, attr);
unsigned long val = 0;
int ret;
if (kstrtoul(buf, 0, &val))
return -EINVAL;
pm_runtime_get_sync(dev->parent);
ret = pm_runtime_get_sync(dev->parent);
if (ret < 0) {
pm_runtime_put_noidle(dev->parent);
return ret;
}
spin_lock(&drvdata->spinlock);
if (drvdata->config.hw_powered)
cti_write_single_reg(drvdata, cti_attr->off, val);

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
* Copyright (c) 2011-2012, 2021, The Linux Foundation. All rights reserved.
*
* Description: CoreSight Program Flow Trace driver
*/
@ -459,6 +459,7 @@ int etm_get_trace_id(struct etm_drvdata *drvdata)
unsigned long flags;
int trace_id = -1;
struct device *etm_dev;
int ret;
if (!drvdata)
goto out;
@ -467,7 +468,11 @@ int etm_get_trace_id(struct etm_drvdata *drvdata)
if (!local_read(&drvdata->mode))
return drvdata->traceid;
pm_runtime_get_sync(etm_dev);
ret = pm_runtime_get_sync(etm_dev);
if (ret < 0) {
pm_runtime_put_noidle(etm_dev);
return ret;
}
spin_lock_irqsave(&drvdata->spinlock, flags);

View File

@ -47,8 +47,14 @@ static ssize_t etmsr_show(struct device *dev,
{
unsigned long flags, val;
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
int ret;
ret = pm_runtime_get_sync(dev->parent);
if (ret < 0) {
pm_runtime_put_noidle(dev->parent);
return ret;
}
pm_runtime_get_sync(dev->parent);
spin_lock_irqsave(&drvdata->spinlock, flags);
CS_UNLOCK(drvdata->base);
@ -939,13 +945,19 @@ static ssize_t seq_curr_state_show(struct device *dev,
unsigned long val, flags;
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct etm_config *config = &drvdata->config;
int ret;
if (!local_read(&drvdata->mode)) {
val = config->seq_curr_state;
goto out;
}
pm_runtime_get_sync(dev->parent);
ret = pm_runtime_get_sync(dev->parent);
if (ret < 0) {
pm_runtime_put_noidle(dev->parent);
return ret;
}
spin_lock_irqsave(&drvdata->spinlock, flags);
CS_UNLOCK(drvdata->base);

View File

@ -2434,10 +2434,16 @@ static ssize_t coresight_etm4x_reg_show(struct device *dev,
{
u32 val, offset;
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
int ret;
offset = coresight_etm4x_attr_to_offset(d_attr);
pm_runtime_get_sync(dev->parent);
ret = pm_runtime_get_sync(dev->parent);
if (ret < 0) {
pm_runtime_put_noidle(dev->parent);
return ret;
}
val = etmv4_cross_read(drvdata, offset);
pm_runtime_put_sync(dev->parent);

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2011-2012, 2017, The Linux Foundation. All rights reserved.
* Copyright (c) 2011-2012, 2017, 2021, The Linux Foundation. All rights reserved.
*
* Description: CoreSight Funnel driver
*/
@ -188,8 +188,13 @@ static ssize_t funnel_ctrl_show(struct device *dev,
{
u32 val;
struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent);
int ret;
pm_runtime_get_sync(dev->parent);
ret = pm_runtime_get_sync(dev->parent);
if (ret < 0) {
pm_runtime_put_noidle(dev->parent);
return ret;
}
val = get_funnel_ctrl_hw(drvdata);

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2015-2016, 2021, The Linux Foundation. All rights reserved.
*
* Description: CoreSight System Trace Macrocell driver
*
@ -196,6 +196,7 @@ static int stm_enable(struct coresight_device *csdev,
{
u32 val;
struct stm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
int ret;
if (mode != CS_MODE_SYSFS)
return -EINVAL;
@ -206,7 +207,11 @@ static int stm_enable(struct coresight_device *csdev,
if (val)
return -EBUSY;
pm_runtime_get_sync(csdev->dev.parent);
ret = pm_runtime_get_sync(csdev->dev.parent);
if (ret < 0) {
pm_runtime_put_noidle(csdev->dev.parent);
return ret;
}
spin_lock(&drvdata->spinlock);
stm_enable_hw(drvdata);