summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthuang <matthuang@google.com>2022-05-06 23:54:42 +0800
committerTreeHugger Robot <treehugger-gerrit@google.com>2022-07-07 01:37:58 +0000
commit56aaf871edeeb1fbce691719e8f57200ea1952d1 (patch)
tree1c0586438c076493763c8f7acf68d2c1ff9e0bc2
parent81a5b0ecfa0b18b7c0fa7a690081b38ba18df6ad (diff)
downloadaoc-56aaf871edeeb1fbce691719e8f57200ea1952d1.tar.gz
aoc_chan: Add non wake up channel.
Bug: 195077076 Test: libusf read events from non wake up channel. Signed-off-by: matthuang <matthuang@google.com> Change-Id: I0aa87a2d4a410d5f231fa2f7fad4112168d362ba
-rw-r--r--aoc_channel_dev.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/aoc_channel_dev.c b/aoc_channel_dev.c
index d09d6f6..47b1f5e 100644
--- a/aoc_channel_dev.c
+++ b/aoc_channel_dev.c
@@ -38,6 +38,7 @@ module_param(sent_msg_count, long, S_IRUGO);
struct chan_prvdata {
struct wakeup_source *queue_wakelock;
struct wakeup_source *user_wakelock;
+ struct task_struct *demux_task;
};
struct aocc_device_entry {
@@ -66,6 +67,7 @@ static int aocc_remove(struct aoc_service_dev *dev);
static const char * const channel_service_names[] = {
"com.google.usf",
+ "com.google.usf.non_wake_up",
"usf_sh_mem_doorbell",
NULL,
};
@@ -134,7 +136,6 @@ struct file_prvdata {
/* Globals */
/* TODO(b/141396548): Move these to drv_data. */
static LIST_HEAD(s_open_files);
-static struct task_struct *s_demux_task;
/* Shared memory transport doorbell globals. */
/* TODO (b/184637825): Use mailbox device for AoC shared memory transport. */
@@ -152,7 +153,7 @@ static int aocc_demux_kthread(void *data)
struct aoc_service_dev *service = (struct aoc_service_dev *)data;
struct chan_prvdata *service_prvdata = service->prvdata;
- pr_info("Demux handler started!");
+ dev_info(&(service->dev), "Demux handler started!");
while (!kthread_should_stop()) {
int handler_found = 0;
@@ -440,7 +441,7 @@ static int aocc_open(struct inode *inode, struct file *file)
/* Allocate a unique index to represent this open file. */
prvdata->channel_index = atomic_inc_return(&channel_index_counter);
- pr_info("New client with channel ID %d", prvdata->channel_index);
+ dev_info(&(entry->service->dev), "New client with channel ID %d", prvdata->channel_index);
/* Start a new empty message list for this channel's message queue. */
INIT_LIST_HEAD(&prvdata->pending_aoc_messages);
@@ -774,19 +775,16 @@ static int aocc_probe(struct aoc_service_dev *dev)
return -ENOMEM;
if (strcmp(dev_name(&dev->dev), "usf_sh_mem_doorbell") != 0) {
+ ret = create_character_device(dev);
+ if (ret)
+ return ret;
prvdata->user_wakelock = wakeup_source_register(&dev->dev, dev_name(&dev->dev));
prvdata->queue_wakelock = wakeup_source_register(&dev->dev, "usf_queue");
dev->prvdata = prvdata;
-
- ret = create_character_device(dev);
-
- s_demux_task = kthread_run(&aocc_demux_kthread, dev,
- "aocc_demux");
-
- sched_setscheduler(s_demux_task, SCHED_FIFO, &param);
-
- if (IS_ERR(s_demux_task))
- ret = PTR_ERR(s_demux_task);
+ prvdata->demux_task = kthread_run(&aocc_demux_kthread, dev, dev_name(&dev->dev));
+ sched_setscheduler(prvdata->demux_task, SCHED_FIFO, &param);
+ if (IS_ERR(prvdata->demux_task))
+ ret = PTR_ERR(prvdata->demux_task);
}
aocc_sh_mem_doorbell_probe(dev);
@@ -800,16 +798,13 @@ static int aocc_remove(struct aoc_service_dev *dev)
struct aocc_device_entry *tmp;
struct chan_prvdata *prvdata;
- if (dev != sh_mem_doorbell_service_dev) {
- kthread_stop(s_demux_task);
- }
-
/* Uninstall the shared memory doorbell service. */
if (dev == sh_mem_doorbell_service_dev) {
sh_mem_doorbell_service_dev->handler = NULL;
sh_mem_doorbell_service_dev = NULL;
} else {
prvdata = dev->prvdata;
+ kthread_stop(prvdata->demux_task);
if (prvdata->queue_wakelock) {
wakeup_source_unregister(prvdata->queue_wakelock);
prvdata->queue_wakelock = NULL;