iommu/tegra: Use tegra_dev_iommu_get_stream_id() in the remaining places
authorJason Gunthorpe <jgg@nvidia.com>
Thu, 7 Dec 2023 18:03:14 +0000 (14:03 -0400)
committerJoerg Roedel <jroedel@suse.de>
Tue, 12 Dec 2023 09:18:51 +0000 (10:18 +0100)
This API was defined to formalize the access to internal iommu details on
some Tegra SOCs, but a few callers got missed. Add them.

The helper already masks by 0xFFFF so remove this code from the callers.

Suggested-by: Thierry Reding <thierry.reding@gmail.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/7-v2-16e4def25ebb+820-iommu_fwspec_p1_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/dma/tegra186-gpc-dma.c
drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gp10b.c
drivers/memory/tegra/tegra186.c

index fa4d4142a68a2183744a46f8d36da5e51fe2b18c..88547a23825b18aece9f4eb00221549e02eaadd1 100644 (file)
@@ -1348,8 +1348,8 @@ static int tegra_dma_program_sid(struct tegra_dma_channel *tdc, int stream_id)
 static int tegra_dma_probe(struct platform_device *pdev)
 {
        const struct tegra_dma_chip_data *cdata = NULL;
-       struct iommu_fwspec *iommu_spec;
-       unsigned int stream_id, i;
+       unsigned int i;
+       u32 stream_id;
        struct tegra_dma *tdma;
        int ret;
 
@@ -1378,12 +1378,10 @@ static int tegra_dma_probe(struct platform_device *pdev)
 
        tdma->dma_dev.dev = &pdev->dev;
 
-       iommu_spec = dev_iommu_fwspec_get(&pdev->dev);
-       if (!iommu_spec) {
+       if (!tegra_dev_iommu_get_stream_id(&pdev->dev, &stream_id)) {
                dev_err(&pdev->dev, "Missing iommu stream-id\n");
                return -EINVAL;
        }
-       stream_id = iommu_spec->ids[0] & 0xffff;
 
        ret = device_property_read_u32(&pdev->dev, "dma-channel-mask",
                                       &tdma->chan_mask);
index e7e8fdf3adab7a0c9454f57b8ad91f4e787bc6da..29682722b0b36b584d4e3a8088d70e74507d78b7 100644 (file)
@@ -28,19 +28,14 @@ static void
 gp10b_ltc_init(struct nvkm_ltc *ltc)
 {
        struct nvkm_device *device = ltc->subdev.device;
-       struct iommu_fwspec *spec;
+       u32 sid;
 
        nvkm_wr32(device, 0x17e27c, ltc->ltc_nr);
        nvkm_wr32(device, 0x17e000, ltc->ltc_nr);
        nvkm_wr32(device, 0x100800, ltc->ltc_nr);
 
-       spec = dev_iommu_fwspec_get(device->dev);
-       if (spec) {
-               u32 sid = spec->ids[0] & 0xffff;
-
-               /* stream ID */
+       if (tegra_dev_iommu_get_stream_id(device->dev, &sid))
                nvkm_wr32(device, 0x160000, sid << 2);
-       }
 }
 
 static const struct nvkm_ltc_func
index 533f85a4b2bdb7ee24175d0b4be3be9e560cb029..9cbf22a10a8270f40de59b3185a20eca1dece6cd 100644 (file)
@@ -111,9 +111,12 @@ static void tegra186_mc_client_sid_override(struct tegra_mc *mc,
 static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)
 {
 #if IS_ENABLED(CONFIG_IOMMU_API)
-       struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
        struct of_phandle_args args;
        unsigned int i, index = 0;
+       u32 sid;
+
+       if (!tegra_dev_iommu_get_stream_id(dev, &sid))
+               return 0;
 
        while (!of_parse_phandle_with_args(dev->of_node, "interconnects", "#interconnect-cells",
                                           index, &args)) {
@@ -121,11 +124,10 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)
                        for (i = 0; i < mc->soc->num_clients; i++) {
                                const struct tegra_mc_client *client = &mc->soc->clients[i];
 
-                               if (client->id == args.args[0]) {
-                                       u32 sid = fwspec->ids[0] & MC_SID_STREAMID_OVERRIDE_MASK;
-
-                                       tegra186_mc_client_sid_override(mc, client, sid);
-                               }
+                               if (client->id == args.args[0])
+                                       tegra186_mc_client_sid_override(
+                                               mc, client,
+                                               sid & MC_SID_STREAMID_OVERRIDE_MASK);
                        }
                }