Re: [RFC PATCH v2 11/22] ASoC: qcom: Add USB backend ASoC driver for Q6

From: Srinivas Kandagatla
Date: Thu Jan 26 2023 - 11:36:01 EST




On 26/01/2023 03:14, Wesley Cheng wrote:
+}
+
+static int q6usb_dai_dev_probe(struct platform_device *pdev)
+{
...
+ data->priv.domain = iommu_domain_alloc(pdev->dev.bus);
+ if (!data->priv.domain) {
+ dev_err(&pdev->dev, "failed to allocate iommu domain\n");
+ return -ENODEV;
+ }
+
+ /* attach to external processor iommu */
+ ret = iommu_attach_device(data->priv.domain, &pdev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to attach device ret = %d\n", ret);
+ goto free_domain;
+ }
+
Why are we doing this manually here? device core should take care of attaching iommu to the device instance.

...


+detach_device:
+ iommu_detach_device(data->priv.domain, &pdev->dev);
+free_domain:
+ iommu_domain_free(data->priv.domain);
+
+ return ret;
+}
+
+static int q6usb_dai_dev_remove(struct platform_device *pdev)
+{
+ struct q6usb_port_data *data = platform_get_drvdata(pdev);
+
+ iommu_detach_device(data->priv.domain, &pdev->dev);
+ iommu_domain_free(data->priv.domain);
+