Skip to content

Commit

Permalink
remoteproc: qcom: Add sysfs entry to detect device shutdown
Browse files Browse the repository at this point in the history
This change adds a sysfs entry which indicates whether the device is being
shutdown to the qcom remoteproc drivers. This is going to be used in the
following patches.

Signed-off-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
  • Loading branch information
Gokul krishna Krishnakumar authored and intel-lab-lkp committed Sep 19, 2022
1 parent 729c163 commit dcf1afc
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
58 changes: 58 additions & 0 deletions drivers/remoteproc/qcom_common.c
Expand Up @@ -87,9 +87,32 @@ struct qcom_ssr_subsystem {
struct list_head list;
};

static struct kobject *sysfs_kobject;
bool qcom_device_shutdown_in_progress;
EXPORT_SYMBOL(qcom_device_shutdown_in_progress);

static LIST_HEAD(qcom_ssr_subsystem_list);
static DEFINE_MUTEX(qcom_ssr_subsys_lock);

static const char * const ssr_timeout_msg = "srcu notifier chain for %s:%s taking too long";

static ssize_t qcom_rproc_shutdown_request_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
bool val;
int ret;

ret = kstrtobool(buf, &val);
if (ret)
return ret;

qcom_device_shutdown_in_progress = val;
pr_info("qcom rproc: Device shutdown requested: %s\n", val ? "true" : "false");
return count;
}
static struct kobj_attribute shutdown_requested_attr = __ATTR(shutdown_in_progress, 0220, NULL,
qcom_rproc_shutdown_request_store);

static void qcom_minidump_cleanup(struct rproc *rproc)
{
struct rproc_dump_segment *entry, *tmp;
Expand Down Expand Up @@ -505,5 +528,40 @@ void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr)
}
EXPORT_SYMBOL_GPL(qcom_remove_ssr_subdev);

static int __init qcom_common_init(void)
{
int ret = 0;

qcom_device_shutdown_in_progress = false;

sysfs_kobject = kobject_create_and_add("qcom_rproc", kernel_kobj);
if (!sysfs_kobject) {
pr_err("qcom rproc: failed to create sysfs kobject\n");
return -EINVAL;
}

ret = sysfs_create_file(sysfs_kobject, &shutdown_requested_attr.attr);
if (ret) {
pr_err("qcom rproc: failed to create sysfs file\n");
goto remove_kobject;
}

return 0;

sysfs_remove_file(sysfs_kobject, &shutdown_requested_attr.attr);
remove_kobject:
kobject_put(sysfs_kobject);
return ret;

}
module_init(qcom_common_init);

static void __exit qcom_common_exit(void)
{
sysfs_remove_file(sysfs_kobject, &shutdown_requested_attr.attr);
kobject_put(sysfs_kobject);
}
module_exit(qcom_common_exit);

MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver");
MODULE_LICENSE("GPL v2");
1 change: 1 addition & 0 deletions drivers/remoteproc/qcom_common.h
Expand Up @@ -34,6 +34,7 @@ struct qcom_rproc_ssr {
};

void qcom_minidump(struct rproc *rproc, unsigned int minidump_id);
extern bool qcom_device_shutdown_in_progress;

void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink,
const char *ssr_name);
Expand Down

0 comments on commit dcf1afc

Please sign in to comment.