linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: srinivas.kandagatla@linaro.org, mathias.nyman@intel.com,
	perex@perex.cz, conor+dt@kernel.org, dmitry.torokhov@gmail.com,
	corbet@lwn.net, broonie@kernel.org, lgirdwood@gmail.com,
	krzk+dt@kernel.org, pierre-louis.bossart@linux.intel.com,
	Thinh.Nguyen@synopsys.com, tiwai@suse.com, robh@kernel.org,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-sound@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-input@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v37 24/31] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6
Date: Fri, 4 Apr 2025 11:54:10 +0200	[thread overview]
Message-ID: <Z--sQj-fXwXkk5iS@linaro.org> (raw)
In-Reply-To: <20250404002728.3590501-25-quic_wcheng@quicinc.com>

On Thu, Apr 03, 2025 at 05:27:21PM -0700, Wesley Cheng wrote:
> Create a USB BE component that will register a new USB port to the ASoC USB
> framework.  This will handle determination on if the requested audio
> profile is supported by the USB device currently selected.
> 
> Check for if the PCM format is supported during the hw_params callback.  If
> the profile is not supported then the userspace ALSA entity will receive an
> error, and can take further action.
> 
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
>  include/sound/q6usboffload.h  |  20 +++
>  sound/soc/qcom/Kconfig        |  12 ++
>  sound/soc/qcom/qdsp6/Makefile |   1 +
>  sound/soc/qcom/qdsp6/q6usb.c  | 278 ++++++++++++++++++++++++++++++++++
>  4 files changed, 311 insertions(+)
>  create mode 100644 include/sound/q6usboffload.h
>  create mode 100644 sound/soc/qcom/qdsp6/q6usb.c
> 
> diff --git a/include/sound/q6usboffload.h b/include/sound/q6usboffload.h
> new file mode 100644
> index 000000000000..35ae26ba6509
> --- /dev/null
> +++ b/include/sound/q6usboffload.h
> @@ -0,0 +1,20 @@
> +/* SPDX-License-Identifier: GPL-2.0
> + *
> + * sound/q6usboffload.h -- QDSP6 USB offload
> + *
> + * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +/**
> + * struct q6usb_offload - USB backend DAI link offload parameters
> + * @dev: dev handle to usb be
> + * @domain: allocated iommu domain
> + * @sid: streamID for iommu
> + * @intr_num: usb interrupter number
> + **/
> +struct q6usb_offload {
> +	struct device *dev;
> +	struct iommu_domain *domain;
> +	long long sid;

"long long" feels like overkill for sid, given that it's essentially
either an u8 or -1. I see you just copied this from q6asm-dai.c, but
unlike q6asm-dai, you don't seem to check for sid < 0 in PATCH 28/31
(qc_audio_offload.c).

Looking at the logic in q6asm-dai.c, it feels like this could really
just be an "u8", since the -1 for "no iommus specified" is effectively
just handled like sid = 0.

> +	u16 intr_num;
> +};
> [...]
> diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
> new file mode 100644
> index 000000000000..cb8c4a62a816
> --- /dev/null
> +++ b/sound/soc/qcom/qdsp6/q6usb.c
> [...]
> +static int q6usb_dai_dev_probe(struct platform_device *pdev)
> +{
> +	struct device_node *node = pdev->dev.of_node;
> +	struct q6usb_port_data *data;
> +	struct device *dev = &pdev->dev;
> +	struct of_phandle_args args;
> +	int ret;
> +
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	ret = of_property_read_u16(node, "qcom,usb-audio-intr-idx",
> +				   &data->priv.intr_num);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to read intr idx.\n");
> +		return ret;
> +	}
> +
> +	ret = of_parse_phandle_with_fixed_args(node, "iommus", 1, 0, &args);
> +	if (ret < 0)
> +		data->priv.sid = -1;
> +	else

Could just do if (ret == 0) here and drop the if branch above, if you
make sid an u8 like I suggested above.

> +		data->priv.sid = args.args[0] & Q6_USB_SID_MASK;
> +
> +	data->priv.domain = iommu_get_domain_for_dev(&pdev->dev);
> +
> +	data->priv.dev = dev;
> +	INIT_LIST_HEAD(&data->devices);

I think you also need devm_mutex_init(&data->lock) or separate
mutex_init()/mutex_destroy() here, if someone enables
CONFIG_DEBUG_MUTEXES.

Thanks,
Stephan

  reply	other threads:[~2025-04-04  9:54 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-04  0:26 [PATCH v37 00/31] Introduce QC USB SND audio offloading support Wesley Cheng
2025-04-04  0:26 ` [PATCH v37 01/31] xhci: sideband: add initial api to register a secondary interrupter entity Wesley Cheng
2025-04-04  0:26 ` [PATCH v37 02/31] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 03/31] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 04/31] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 05/31] usb: host: xhci: Notify xHCI sideband on transfer ring free Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 06/31] usb: dwc3: Specify maximum number of XHCI interrupters Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 07/31] ALSA: Add USB audio device jack type Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 08/31] ALSA: usb-audio: Export USB SND APIs for modules Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 09/31] ALSA: usb-audio: Check for support for requested audio format Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 10/31] ALSA: usb-audio: Save UAC sample size information Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 11/31] ALSA: usb-audio: Prevent starting of audio stream if in use Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 12/31] ALSA: usb-audio: Introduce USB SND platform op callbacks Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 13/31] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 14/31] ASoC: Add SoC USB APIs for adding an USB backend Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 15/31] ASoC: usb: Add PCM format check API for " Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 16/31] ASoC: usb: Create SOC USB SND jack kcontrol Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 17/31] ASoC: usb: Fetch ASoC card and pcm device information Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 18/31] ASoC: usb: Rediscover USB SND devices on USB port add Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 19/31] ASoC: doc: Add documentation for SOC USB Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 20/31] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 21/31] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 22/31] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2025-04-04  9:24   ` Stephan Gerhold
2025-04-07 23:01     ` Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 23/31] ASoC: qcom: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 24/31] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6 Wesley Cheng
2025-04-04  9:54   ` Stephan Gerhold [this message]
2025-04-07 22:59     ` Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 25/31] ASoC: qcom: qdsp6: Add headphone jack for offload connection status Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 26/31] ASoC: qcom: qdsp6: Fetch USB offload mapped card and PCM device Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 27/31] ALSA: usb-audio: qcom: Add USB QMI definitions Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 28/31] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 29/31] ALSA: usb-audio: qcom: Don't allow USB offload path if PCM device is in use Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 30/31] ALSA: usb-audio: qcom: Add USB offload route kcontrol Wesley Cheng
2025-04-04  0:27 ` [PATCH v37 31/31] ALSA: usb-audio: qcom: Notify USB audio devices on USB offload probing Wesley Cheng

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=Z--sQj-fXwXkk5iS@linaro.org \
    --to=stephan.gerhold@linaro.org \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=quic_wcheng@quicinc.com \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).