From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>, 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 03/16] soc: qcom: apr: Add GPR support Date: Thu, 15 Jul 2021 11:31:45 +0100 [thread overview] Message-ID: <da7c8e4d-fe79-de54-025e-2bb25dc16698@linaro.org> (raw) In-Reply-To: <349b94b8-0ce3-20f1-d7e3-b6d0609ecdc4@linux.intel.com> Many thanks Pierre for the review, On 14/07/2021 17:20, Pierre-Louis Bossart wrote: > >> +void gpr_free_port(gpr_port_t *port) >> +{ >> + struct packet_router *gpr = port->pr; >> + unsigned long flags; >> + >> + spin_lock_irqsave(&gpr->svcs_lock, flags); >> + idr_remove(&gpr->svcs_idr, port->id); >> + spin_unlock_irqrestore(&gpr->svcs_lock, flags); > > maybe add a comment somewhere on why you need the irqsave/irqrestore version of spin_lock/unlock? All the responses to the messages arrive in interrupt context which could try to find the matching svc idr, so we needed this irq version of spinlock here. I did move this handling to a work queue in the past, so we should be able to relax this lock to non-irq version. > > It's not very clear by looking at this patch only that those locks are handled in interrupt context. > >> + >> + kfree(port); >> +} >> +EXPORT_SYMBOL_GPL(gpr_free_port); >> + >> +gpr_port_t *gpr_alloc_port(struct apr_device *gdev, struct device *dev, >> + gpr_port_cb cb, void *priv) >> +{ >> + struct packet_router *pr = dev_get_drvdata(gdev->dev.parent); >> + gpr_port_t *port; >> + struct pkt_router_svc *svc; >> + int id; >> + >> + port = kzalloc(sizeof(*port), GFP_KERNEL); >> + if (!port) >> + return ERR_PTR(-ENOMEM); >> + >> + svc = port; >> + svc->callback = cb; >> + svc->pr = pr; >> + svc->priv = priv; >> + svc->dev = dev; >> + spin_lock_init(&svc->lock); >> + >> + spin_lock(&pr->svcs_lock); >> + id = idr_alloc_cyclic(&pr->svcs_idr, svc, GPR_DYNAMIC_PORT_START, >> + GPR_DYNAMIC_PORT_END, GFP_ATOMIC); >> + if (id < 0) { >> + dev_err(dev, "Unable to allocate dynamic GPR src port\n"); >> + kfree(port); >> + spin_unlock(&pr->svcs_lock); > > nit-pick: more this before the dev_err? I agree, will do that in next spin. > >> + return ERR_PTR(-ENOMEM); >> + } >> + >> + svc->id = id; >> + spin_unlock(&pr->svcs_lock); >> + >> + dev_info(dev, "Adding GPR src port (%x)\n", svc->id); >> + >> + return port; >> +} > >> +static int gpr_do_rx_callback(struct packet_router *gpr, struct apr_rx_buf *abuf) >> +{ >> + uint16_t hdr_size, ver; >> + struct pkt_router_svc *svc = NULL; > > unnecessary init? it's overritten... > Yep. --srini >> + struct gpr_resp_pkt resp; >> + struct gpr_hdr *hdr; >> + unsigned long flags; >> + void *buf = abuf->buf; >> + int len = abuf->len; >> + >> + hdr = buf; >> + ver = hdr->version; >> + if (ver > GPR_PKT_VER + 1) >> + return -EINVAL; >> + >> + hdr_size = hdr->hdr_size; >> + if (hdr_size < GPR_PKT_HEADER_WORD_SIZE) { >> + dev_err(gpr->dev, "GPR: Wrong hdr size:%d\n", hdr_size); >> + return -EINVAL; >> + } >> + >> + if (hdr->pkt_size < GPR_PKT_HEADER_BYTE_SIZE || hdr->pkt_size != len) { >> + dev_err(gpr->dev, "GPR: Wrong packet size\n"); >> + return -EINVAL; >> + } >> + >> + resp.hdr = *hdr; >> + resp.payload_size = hdr->pkt_size - (hdr_size * 4); >> + >> + /* >> + * NOTE: hdr_size is not same as GPR_HDR_SIZE as remote can include >> + * optional headers in to gpr_hdr which should be ignored >> + */ >> + if (resp.payload_size > 0) >> + resp.payload = buf + (hdr_size * 4); >> + >> + >> + spin_lock_irqsave(&gpr->svcs_lock, flags); >> + svc = idr_find(&gpr->svcs_idr, hdr->dest_port); > > ... here > >> + spin_unlock_irqrestore(&gpr->svcs_lock, flags); >> + >> + if (!svc) { >> + dev_err(gpr->dev, "GPR: Port(%x) is not registered\n", >> + hdr->dest_port); >> + return -EINVAL; >> + } >> + >> + if (svc->callback) >> + svc->callback(&resp, svc->priv, 0); >> + >> + return 0; >> +} >> + >
WARNING: multiple messages have this Message-ID (diff)
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>, 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 03/16] soc: qcom: apr: Add GPR support Date: Thu, 15 Jul 2021 11:31:45 +0100 [thread overview] Message-ID: <da7c8e4d-fe79-de54-025e-2bb25dc16698@linaro.org> (raw) In-Reply-To: <349b94b8-0ce3-20f1-d7e3-b6d0609ecdc4@linux.intel.com> Many thanks Pierre for the review, On 14/07/2021 17:20, Pierre-Louis Bossart wrote: > >> +void gpr_free_port(gpr_port_t *port) >> +{ >> + struct packet_router *gpr = port->pr; >> + unsigned long flags; >> + >> + spin_lock_irqsave(&gpr->svcs_lock, flags); >> + idr_remove(&gpr->svcs_idr, port->id); >> + spin_unlock_irqrestore(&gpr->svcs_lock, flags); > > maybe add a comment somewhere on why you need the irqsave/irqrestore version of spin_lock/unlock? All the responses to the messages arrive in interrupt context which could try to find the matching svc idr, so we needed this irq version of spinlock here. I did move this handling to a work queue in the past, so we should be able to relax this lock to non-irq version. > > It's not very clear by looking at this patch only that those locks are handled in interrupt context. > >> + >> + kfree(port); >> +} >> +EXPORT_SYMBOL_GPL(gpr_free_port); >> + >> +gpr_port_t *gpr_alloc_port(struct apr_device *gdev, struct device *dev, >> + gpr_port_cb cb, void *priv) >> +{ >> + struct packet_router *pr = dev_get_drvdata(gdev->dev.parent); >> + gpr_port_t *port; >> + struct pkt_router_svc *svc; >> + int id; >> + >> + port = kzalloc(sizeof(*port), GFP_KERNEL); >> + if (!port) >> + return ERR_PTR(-ENOMEM); >> + >> + svc = port; >> + svc->callback = cb; >> + svc->pr = pr; >> + svc->priv = priv; >> + svc->dev = dev; >> + spin_lock_init(&svc->lock); >> + >> + spin_lock(&pr->svcs_lock); >> + id = idr_alloc_cyclic(&pr->svcs_idr, svc, GPR_DYNAMIC_PORT_START, >> + GPR_DYNAMIC_PORT_END, GFP_ATOMIC); >> + if (id < 0) { >> + dev_err(dev, "Unable to allocate dynamic GPR src port\n"); >> + kfree(port); >> + spin_unlock(&pr->svcs_lock); > > nit-pick: more this before the dev_err? I agree, will do that in next spin. > >> + return ERR_PTR(-ENOMEM); >> + } >> + >> + svc->id = id; >> + spin_unlock(&pr->svcs_lock); >> + >> + dev_info(dev, "Adding GPR src port (%x)\n", svc->id); >> + >> + return port; >> +} > >> +static int gpr_do_rx_callback(struct packet_router *gpr, struct apr_rx_buf *abuf) >> +{ >> + uint16_t hdr_size, ver; >> + struct pkt_router_svc *svc = NULL; > > unnecessary init? it's overritten... > Yep. --srini >> + struct gpr_resp_pkt resp; >> + struct gpr_hdr *hdr; >> + unsigned long flags; >> + void *buf = abuf->buf; >> + int len = abuf->len; >> + >> + hdr = buf; >> + ver = hdr->version; >> + if (ver > GPR_PKT_VER + 1) >> + return -EINVAL; >> + >> + hdr_size = hdr->hdr_size; >> + if (hdr_size < GPR_PKT_HEADER_WORD_SIZE) { >> + dev_err(gpr->dev, "GPR: Wrong hdr size:%d\n", hdr_size); >> + return -EINVAL; >> + } >> + >> + if (hdr->pkt_size < GPR_PKT_HEADER_BYTE_SIZE || hdr->pkt_size != len) { >> + dev_err(gpr->dev, "GPR: Wrong packet size\n"); >> + return -EINVAL; >> + } >> + >> + resp.hdr = *hdr; >> + resp.payload_size = hdr->pkt_size - (hdr_size * 4); >> + >> + /* >> + * NOTE: hdr_size is not same as GPR_HDR_SIZE as remote can include >> + * optional headers in to gpr_hdr which should be ignored >> + */ >> + if (resp.payload_size > 0) >> + resp.payload = buf + (hdr_size * 4); >> + >> + >> + spin_lock_irqsave(&gpr->svcs_lock, flags); >> + svc = idr_find(&gpr->svcs_idr, hdr->dest_port); > > ... here > >> + spin_unlock_irqrestore(&gpr->svcs_lock, flags); >> + >> + if (!svc) { >> + dev_err(gpr->dev, "GPR: Port(%x) is not registered\n", >> + hdr->dest_port); >> + return -EINVAL; >> + } >> + >> + if (svc->callback) >> + svc->callback(&resp, svc->priv, 0); >> + >> + return 0; >> +} >> + >
next prev parent reply other threads:[~2021-07-15 10:31 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 [this message] 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 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=da7c8e4d-fe79-de54-025e-2bb25dc16698@linaro.org \ --to=srinivas.kandagatla@linaro.org \ --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=pierre-louis.bossart@linux.intel.com \ --cc=plai@codeaurora.org \ --cc=robh@kernel.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.