Re: [PATCH v3 08/28] ASoC: qcom: Add USB backend ASoC driver for Q6

From: Wesley Cheng
Date: Fri Mar 24 2023 - 21:17:44 EST


Hi Srini,

On 3/9/2023 11:21 PM, Srinivas Kandagatla wrote:


On 09/03/2023 19:38, Wesley Cheng wrote:
Hi Srinivas,

On 3/9/2023 1:01 AM, Srinivas Kandagatla wrote:


On 08/03/2023 23:57, 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.

Signed-off-by: Wesley Cheng <quic_wcheng@xxxxxxxxxxx>

Thanks Wesley for the patch, I have few minor comments.


Thanks for the review!

---
  include/sound/q6usboffload.h  |  20 ++++
  sound/soc/qcom/Kconfig        |   4 +
  sound/soc/qcom/qdsp6/Makefile |   1 +
  sound/soc/qcom/qdsp6/q6usb.c  | 208 ++++++++++++++++++++++++++++++++++
  4 files changed, 233 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..4fb1912d9f55
--- /dev/null
+++ b/include/sound/q6usboffload.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * linux/sound/q6usboffload.h -- QDSP6 USB offload
+ *
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+/**
+ * struct q6usb_offload
+ * @dev - dev handle to usb be
+ * @sid - streamID for iommu
+ * @intr_num - usb interrupter number
+ * @domain - allocated iommu domain
+ **/
+struct q6usb_offload {
+    struct device *dev;
+    long long sid;
+    u32 intr_num;
+    struct iommu_domain *domain;
Why do we need to store this domain, You can remove this along with the one line that gets domain in probe function.


We'll need a reference to the iommu domain, because the QC USB offload driver will be the one that is going to map the XHCI interrupter and transfer ring regions for the audio DSP.  This happens when a USB QMI

this is okay, AFAIU, as long as uaudio_qdev->dev pointer is used in dma alloc apis like dma_map*, dma_alloc_* you would not need to handle iommu_domain directly like this in drivers.


Was looking into this a bit more, but couldn't figure out the proper DMA API that would achieve what we're attempting to do. So we are trying to map the PA of the memory allocated by the XHCI driver, for say...the xfer buffers being used for the ISOC ep.

If I call the DMA MAP variants, ie dma_map_single_attrs, we pass in a virtual address only, and the DMA map api will map to a PA that it derives from that. However, we're trying to map to memory accessible by the audio DSP, which is the virtual address we're passing into iommu_map(), and the PA mapping to is the XHCI xfer buffer. There wasn't a similar API that achieved this. Please clarify if there might be something I'm missing.

Thanks
Wesley Cheng