From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, bjorn.andersson@linaro.org, broonie@kernel.org, robh@kernel.org Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, lgirdwood@gmail.com, tiwai@suse.de, plai@codeaurora.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 06/16] ASoC: qcom: audioreach: add q6apm support Date: Wed, 14 Jul 2021 11:40:21 -0500 [thread overview] Message-ID: <77b9d17d-33b6-8a7a-bb1d-e32543d9da79@linux.intel.com> (raw) In-Reply-To: <20210714153039.28373-7-srinivas.kandagatla@linaro.org> > /* SubGraph Config */ > @@ -32,7 +33,7 @@ struct apm_sub_graph_params { > /* container config */ > struct apm_container_obj { > struct apm_container_cfg container_cfg; > - /* Capablity ID list */ > + /* Capability ID list */ squash in wrong patch, this should have been included in the previous patch. > struct apm_prop_data cap_data; > uint32_t num_capablity_id; and this is still wrong... > uint32_t capability_id; > @@ -270,3 +271,308 @@ void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, > APM_MODULE_INSTANCE_ID, > true); > } > + > +static void apm_populate_container_config( > + struct apm_container_obj *cfg, > + struct audioreach_container *cont) > +{ > + > + /* Container Config */ > + cfg->container_cfg.container_id = cont->container_id; > + cfg->container_cfg.num_prop = 4; > + > + /* Capablity list */ Man, again ... > + cfg->cap_data.prop_id = APM_CONTAINER_PROP_ID_CAPABILITY_LIST; > + cfg->cap_data.prop_size = APM_CONTAINER_PROP_ID_CAPABILITY_SIZE; > + cfg->num_capablity_id = 1; > + cfg->capability_id = cont->capability_id; > + > + /* Graph Position */ > + cfg->pos_data.prop_id = APM_CONTAINER_PROP_ID_GRAPH_POS; > + cfg->pos_data.prop_size = sizeof(struct apm_cont_prop_id_graph_pos); > + cfg->pos.graph_pos = cont->graph_pos; > + > + /* Stack size */ > + cfg->stack_data.prop_id = APM_CONTAINER_PROP_ID_STACK_SIZE; > + cfg->stack_data.prop_size = sizeof(struct > + apm_cont_prop_id_stack_size); > + cfg->stack.stack_size = cont->stack_size; > + > + /* Proc domain */ > + cfg->domain_data.prop_id = APM_CONTAINER_PROP_ID_PROC_DOMAIN; > + cfg->domain_data.prop_size = sizeof(struct > + apm_cont_prop_id_domain); > + cfg->domain.proc_domain = cont->proc_domain; > +} > +static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, > + uint32_t graph_id) > +{ > + struct audioreach_graph *graph = NULL; useless init > + struct audioreach_graph_info *info; > + unsigned long flags; > + > + spin_lock_irqsave(&apm->lock, flags); > + graph = idr_find(&apm->graph_idr, graph_id); > + spin_unlock_irqrestore(&apm->lock, flags); > + > + if (graph) { > + kref_get(&graph->refcount); > + return graph; > + } > + > + info = idr_find(&apm->graph_info_idr, graph_id); > + > + if (!info) > + return ERR_PTR(-ENODEV); > + > + graph = kzalloc(sizeof(*graph), GFP_KERNEL); > + if (!graph) > + return ERR_PTR(-ENOMEM); > + > + graph->apm = apm; > + graph->info = info; > + graph->id = graph_id; > + > + /* Assuming Linear Graphs only for now! */ > + graph->graph = audioreach_alloc_graph_pkt(apm, &info->sg_list, graph_id); > + if (IS_ERR(graph->graph)) > + return ERR_PTR(-ENOMEM); > + > + spin_lock(&apm->lock); > + idr_alloc(&apm->graph_idr, graph, graph_id, > + graph_id + 1, GFP_ATOMIC); ATOMIC? > + spin_unlock(&apm->lock); > + > + kref_init(&graph->refcount); > + > + q6apm_send_cmd_sync(apm, graph->graph, 0); > + > + return graph; > +} > + > +static int audioreach_graph_mgmt_cmd(struct audioreach_graph *graph, > + uint32_t opcode) > +{ > + struct gpr_pkt *pkt; > + void *p; > + int i = 0, rc, payload_size; > + struct q6apm *apm = graph->apm; > + struct audioreach_graph_info *info = graph->info; > + int num_sub_graphs = info->num_sub_graphs; > + struct apm_graph_mgmt_cmd *mgmt_cmd; > + struct apm_module_param_data *param_data; > + struct audioreach_sub_graph *sg; > + > + payload_size = APM_GRAPH_MGMT_PSIZE(num_sub_graphs); > + > + p = audioreach_alloc_apm_cmd_pkt(payload_size, opcode, 0); > + if (IS_ERR(p)) > + return -ENOMEM; > + > + pkt = p; > + p = p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; > + > + mgmt_cmd = p; > + mgmt_cmd->num_sub_graphs = num_sub_graphs; > + > + param_data = &mgmt_cmd->param_data; > + param_data->module_instance_id = APM_MODULE_INSTANCE_ID; > + param_data->param_id = APM_PARAM_ID_SUB_GRAPH_LIST; > + param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE; > + > + list_for_each_entry(sg, &info->sg_list, node) { > + mgmt_cmd->sub_graph_id_list[i++] = sg->sub_graph_id; > + } > + > + rc = q6apm_send_cmd_sync(apm, pkt, 0); > + > + kfree(pkt); > + > + return rc; > +} > + > +static void q6apm_put_audioreach_graph(struct kref *ref) > +{ > + struct audioreach_graph *graph; > + struct q6apm *apm; > + unsigned long flags; > + > + graph = container_of(ref, struct audioreach_graph, refcount); > + apm = graph->apm; > + > + audioreach_graph_mgmt_cmd(graph, APM_CMD_GRAPH_CLOSE); > + > + spin_lock_irqsave(&apm->lock, flags); > + graph = idr_remove(&apm->graph_idr, graph->id); > + spin_unlock_irqrestore(&apm->lock, flags); > + > + kfree(graph->graph); > + kfree(graph); earlier in the _get routine, you had a kref_get(&graph->refcount) is it intentional that there's kref_put? adding a comment on the refcounts might be useful...
WARNING: multiple messages have this Message-ID (diff)
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, bjorn.andersson@linaro.org, broonie@kernel.org, robh@kernel.org Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, tiwai@suse.de, plai@codeaurora.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 06/16] ASoC: qcom: audioreach: add q6apm support Date: Wed, 14 Jul 2021 11:40:21 -0500 [thread overview] Message-ID: <77b9d17d-33b6-8a7a-bb1d-e32543d9da79@linux.intel.com> (raw) In-Reply-To: <20210714153039.28373-7-srinivas.kandagatla@linaro.org> > /* SubGraph Config */ > @@ -32,7 +33,7 @@ struct apm_sub_graph_params { > /* container config */ > struct apm_container_obj { > struct apm_container_cfg container_cfg; > - /* Capablity ID list */ > + /* Capability ID list */ squash in wrong patch, this should have been included in the previous patch. > struct apm_prop_data cap_data; > uint32_t num_capablity_id; and this is still wrong... > uint32_t capability_id; > @@ -270,3 +271,308 @@ void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, > APM_MODULE_INSTANCE_ID, > true); > } > + > +static void apm_populate_container_config( > + struct apm_container_obj *cfg, > + struct audioreach_container *cont) > +{ > + > + /* Container Config */ > + cfg->container_cfg.container_id = cont->container_id; > + cfg->container_cfg.num_prop = 4; > + > + /* Capablity list */ Man, again ... > + cfg->cap_data.prop_id = APM_CONTAINER_PROP_ID_CAPABILITY_LIST; > + cfg->cap_data.prop_size = APM_CONTAINER_PROP_ID_CAPABILITY_SIZE; > + cfg->num_capablity_id = 1; > + cfg->capability_id = cont->capability_id; > + > + /* Graph Position */ > + cfg->pos_data.prop_id = APM_CONTAINER_PROP_ID_GRAPH_POS; > + cfg->pos_data.prop_size = sizeof(struct apm_cont_prop_id_graph_pos); > + cfg->pos.graph_pos = cont->graph_pos; > + > + /* Stack size */ > + cfg->stack_data.prop_id = APM_CONTAINER_PROP_ID_STACK_SIZE; > + cfg->stack_data.prop_size = sizeof(struct > + apm_cont_prop_id_stack_size); > + cfg->stack.stack_size = cont->stack_size; > + > + /* Proc domain */ > + cfg->domain_data.prop_id = APM_CONTAINER_PROP_ID_PROC_DOMAIN; > + cfg->domain_data.prop_size = sizeof(struct > + apm_cont_prop_id_domain); > + cfg->domain.proc_domain = cont->proc_domain; > +} > +static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, > + uint32_t graph_id) > +{ > + struct audioreach_graph *graph = NULL; useless init > + struct audioreach_graph_info *info; > + unsigned long flags; > + > + spin_lock_irqsave(&apm->lock, flags); > + graph = idr_find(&apm->graph_idr, graph_id); > + spin_unlock_irqrestore(&apm->lock, flags); > + > + if (graph) { > + kref_get(&graph->refcount); > + return graph; > + } > + > + info = idr_find(&apm->graph_info_idr, graph_id); > + > + if (!info) > + return ERR_PTR(-ENODEV); > + > + graph = kzalloc(sizeof(*graph), GFP_KERNEL); > + if (!graph) > + return ERR_PTR(-ENOMEM); > + > + graph->apm = apm; > + graph->info = info; > + graph->id = graph_id; > + > + /* Assuming Linear Graphs only for now! */ > + graph->graph = audioreach_alloc_graph_pkt(apm, &info->sg_list, graph_id); > + if (IS_ERR(graph->graph)) > + return ERR_PTR(-ENOMEM); > + > + spin_lock(&apm->lock); > + idr_alloc(&apm->graph_idr, graph, graph_id, > + graph_id + 1, GFP_ATOMIC); ATOMIC? > + spin_unlock(&apm->lock); > + > + kref_init(&graph->refcount); > + > + q6apm_send_cmd_sync(apm, graph->graph, 0); > + > + return graph; > +} > + > +static int audioreach_graph_mgmt_cmd(struct audioreach_graph *graph, > + uint32_t opcode) > +{ > + struct gpr_pkt *pkt; > + void *p; > + int i = 0, rc, payload_size; > + struct q6apm *apm = graph->apm; > + struct audioreach_graph_info *info = graph->info; > + int num_sub_graphs = info->num_sub_graphs; > + struct apm_graph_mgmt_cmd *mgmt_cmd; > + struct apm_module_param_data *param_data; > + struct audioreach_sub_graph *sg; > + > + payload_size = APM_GRAPH_MGMT_PSIZE(num_sub_graphs); > + > + p = audioreach_alloc_apm_cmd_pkt(payload_size, opcode, 0); > + if (IS_ERR(p)) > + return -ENOMEM; > + > + pkt = p; > + p = p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; > + > + mgmt_cmd = p; > + mgmt_cmd->num_sub_graphs = num_sub_graphs; > + > + param_data = &mgmt_cmd->param_data; > + param_data->module_instance_id = APM_MODULE_INSTANCE_ID; > + param_data->param_id = APM_PARAM_ID_SUB_GRAPH_LIST; > + param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE; > + > + list_for_each_entry(sg, &info->sg_list, node) { > + mgmt_cmd->sub_graph_id_list[i++] = sg->sub_graph_id; > + } > + > + rc = q6apm_send_cmd_sync(apm, pkt, 0); > + > + kfree(pkt); > + > + return rc; > +} > + > +static void q6apm_put_audioreach_graph(struct kref *ref) > +{ > + struct audioreach_graph *graph; > + struct q6apm *apm; > + unsigned long flags; > + > + graph = container_of(ref, struct audioreach_graph, refcount); > + apm = graph->apm; > + > + audioreach_graph_mgmt_cmd(graph, APM_CMD_GRAPH_CLOSE); > + > + spin_lock_irqsave(&apm->lock, flags); > + graph = idr_remove(&apm->graph_idr, graph->id); > + spin_unlock_irqrestore(&apm->lock, flags); > + > + kfree(graph->graph); > + kfree(graph); earlier in the _get routine, you had a kref_get(&graph->refcount) is it intentional that there's kref_put? adding a comment on the refcounts might be useful...
next prev parent reply other threads:[~2021-07-14 17:14 UTC|newest] Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-14 15:30 [PATCH v2 00/16] ASoC: qcom: Add AudioReach support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 01/16] soc: dt-bindings: qcom: add gpr bindings Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:05 ` Pierre-Louis Bossart 2021-07-14 16:05 ` Pierre-Louis Bossart 2021-07-14 15:30 ` [PATCH v2 02/16] soc: qcom: apr: make code more reuseable Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 20:36 ` kernel test robot 2021-07-14 20:36 ` kernel test robot 2021-07-14 20:36 ` kernel test robot 2021-07-14 15:30 ` [PATCH v2 03/16] soc: qcom: apr: Add GPR support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:20 ` Pierre-Louis Bossart 2021-07-14 16:20 ` Pierre-Louis Bossart 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 04/16] ASoC: qcom: dt-bindings: add bindings Audio Processing manager Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-28 17:36 ` Rob Herring 2021-07-28 17:36 ` Rob Herring 2021-07-29 9:18 ` Srinivas Kandagatla 2021-07-29 9:18 ` Srinivas Kandagatla 2021-07-29 11:13 ` Mark Brown 2021-07-29 11:13 ` Mark Brown 2021-07-30 11:06 ` Srinivas Kandagatla 2021-07-30 11:06 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 05/16] ASoC: qcom: audioreach: add basic pkt alloc support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:30 ` Pierre-Louis Bossart 2021-07-14 16:30 ` Pierre-Louis Bossart 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 06/16] ASoC: qcom: audioreach: add q6apm support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:40 ` Pierre-Louis Bossart [this message] 2021-07-14 16:40 ` Pierre-Louis Bossart 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 07/16] ASoC: qcom: audioreach: add module configuration command helpers Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:48 ` Pierre-Louis Bossart 2021-07-14 16:48 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 08/16] ASoC: qcom: audioreach: add topology support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 09/16] ASoC: qcom: audioreach: add q6apm-dai support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:59 ` Pierre-Louis Bossart 2021-07-14 16:59 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 10/16] ASoC: qcom: audioreach: add bedai support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 17:03 ` Pierre-Louis Bossart 2021-07-14 17:03 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 11/16] ASoC: qcom: dt-bindings: add bindings for Proxy Resource Manager Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 12/16] ASoC: qcom: audioreach: add q6prm support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 17:09 ` Pierre-Louis Bossart 2021-07-14 17:09 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 7:40 ` kernel test robot 2021-07-15 7:40 ` kernel test robot 2021-07-15 7:40 ` kernel test robot 2021-07-14 15:30 ` [PATCH v2 13/16] ASoC: qcom: dt-bindings: add audioreach soundcard compatibles Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 14/16] ASoC: qcom: audioreach: add volume ctrl module support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 15/16] ASoC: qcom: audioreach: topology add dapm pga support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 16/16] ASoC: qcom: sm8250: Add audioreach support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 17:12 ` Pierre-Louis Bossart 2021-07-14 17:12 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` Srinivas Kandagatla
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=77b9d17d-33b6-8a7a-bb1d-e32543d9da79@linux.intel.com \ --to=pierre-louis.bossart@linux.intel.com \ --cc=alsa-devel@alsa-project.org \ --cc=bgoswami@codeaurora.org \ --cc=bjorn.andersson@linaro.org \ --cc=broonie@kernel.org \ --cc=devicetree@vger.kernel.org \ --cc=lgirdwood@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=plai@codeaurora.org \ --cc=robh@kernel.org \ --cc=srinivas.kandagatla@linaro.org \ --cc=tiwai@suse.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.