Skip to content

Commit bf9cd9f

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/tegra: Use tegra_dev_iommu_get_stream_id() in the remaining places
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>
1 parent cdbc723 commit bf9cd9f

3 files changed

Lines changed: 13 additions & 18 deletions

File tree

drivers/dma/tegra186-gpc-dma.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,8 @@ static int tegra_dma_program_sid(struct tegra_dma_channel *tdc, int stream_id)
13481348
static int tegra_dma_probe(struct platform_device *pdev)
13491349
{
13501350
const struct tegra_dma_chip_data *cdata = NULL;
1351-
struct iommu_fwspec *iommu_spec;
1352-
unsigned int stream_id, i;
1351+
unsigned int i;
1352+
u32 stream_id;
13531353
struct tegra_dma *tdma;
13541354
int ret;
13551355

@@ -1378,12 +1378,10 @@ static int tegra_dma_probe(struct platform_device *pdev)
13781378

13791379
tdma->dma_dev.dev = &pdev->dev;
13801380

1381-
iommu_spec = dev_iommu_fwspec_get(&pdev->dev);
1382-
if (!iommu_spec) {
1381+
if (!tegra_dev_iommu_get_stream_id(&pdev->dev, &stream_id)) {
13831382
dev_err(&pdev->dev, "Missing iommu stream-id\n");
13841383
return -EINVAL;
13851384
}
1386-
stream_id = iommu_spec->ids[0] & 0xffff;
13871385

13881386
ret = device_property_read_u32(&pdev->dev, "dma-channel-mask",
13891387
&tdma->chan_mask);

drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gp10b.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,14 @@ static void
2828
gp10b_ltc_init(struct nvkm_ltc *ltc)
2929
{
3030
struct nvkm_device *device = ltc->subdev.device;
31-
struct iommu_fwspec *spec;
31+
u32 sid;
3232

3333
nvkm_wr32(device, 0x17e27c, ltc->ltc_nr);
3434
nvkm_wr32(device, 0x17e000, ltc->ltc_nr);
3535
nvkm_wr32(device, 0x100800, ltc->ltc_nr);
3636

37-
spec = dev_iommu_fwspec_get(device->dev);
38-
if (spec) {
39-
u32 sid = spec->ids[0] & 0xffff;
40-
41-
/* stream ID */
37+
if (tegra_dev_iommu_get_stream_id(device->dev, &sid))
4238
nvkm_wr32(device, 0x160000, sid << 2);
43-
}
4439
}
4540

4641
static const struct nvkm_ltc_func

drivers/memory/tegra/tegra186.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,23 @@ static void tegra186_mc_client_sid_override(struct tegra_mc *mc,
111111
static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)
112112
{
113113
#if IS_ENABLED(CONFIG_IOMMU_API)
114-
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
115114
struct of_phandle_args args;
116115
unsigned int i, index = 0;
116+
u32 sid;
117+
118+
if (!tegra_dev_iommu_get_stream_id(dev, &sid))
119+
return 0;
117120

118121
while (!of_parse_phandle_with_args(dev->of_node, "interconnects", "#interconnect-cells",
119122
index, &args)) {
120123
if (args.np == mc->dev->of_node && args.args_count != 0) {
121124
for (i = 0; i < mc->soc->num_clients; i++) {
122125
const struct tegra_mc_client *client = &mc->soc->clients[i];
123126

124-
if (client->id == args.args[0]) {
125-
u32 sid = fwspec->ids[0] & MC_SID_STREAMID_OVERRIDE_MASK;
126-
127-
tegra186_mc_client_sid_override(mc, client, sid);
128-
}
127+
if (client->id == args.args[0])
128+
tegra186_mc_client_sid_override(
129+
mc, client,
130+
sid & MC_SID_STREAMID_OVERRIDE_MASK);
129131
}
130132
}
131133

0 commit comments

Comments
 (0)