Skip to content

Commit 746a71d

Browse files
Lorenzo Pieralisictmarinas
authored andcommitted
of/iommu: Make of_map_rid() PCI agnostic
There is nothing PCI specific (other than the RID - requester ID) in the of_map_rid() implementation, so the same function can be reused for input/output IDs mapping for other busses just as well. Rename the RID instances/names to a generic "id" tag. No functionality change intended. Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Rob Herring <[email protected]> Acked-by: Joerg Roedel <[email protected]> Cc: Rob Herring <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Robin Murphy <[email protected]> Cc: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent b8e069a commit 746a71d

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

drivers/iommu/of_iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int of_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data)
129129
struct of_phandle_args iommu_spec = { .args_count = 1 };
130130
int err;
131131

132-
err = of_map_rid(info->np, alias, "iommu-map", "iommu-map-mask",
132+
err = of_map_id(info->np, alias, "iommu-map", "iommu-map-mask",
133133
&iommu_spec.np, iommu_spec.args);
134134
if (err)
135135
return err == -ENODEV ? NO_IOMMU : err;
@@ -145,7 +145,7 @@ static int of_fsl_mc_iommu_init(struct fsl_mc_device *mc_dev,
145145
struct of_phandle_args iommu_spec = { .args_count = 1 };
146146
int err;
147147

148-
err = of_map_rid(master_np, mc_dev->icid, "iommu-map",
148+
err = of_map_id(master_np, mc_dev->icid, "iommu-map",
149149
"iommu-map-mask", &iommu_spec.np,
150150
iommu_spec.args);
151151
if (err)

drivers/of/base.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,15 +2201,15 @@ int of_find_last_cache_level(unsigned int cpu)
22012201
}
22022202

22032203
/**
2204-
* of_map_rid - Translate a requester ID through a downstream mapping.
2204+
* of_map_id - Translate an ID through a downstream mapping.
22052205
* @np: root complex device node.
2206-
* @rid: device requester ID to map.
2206+
* @id: device ID to map.
22072207
* @map_name: property name of the map to use.
22082208
* @map_mask_name: optional property name of the mask to use.
22092209
* @target: optional pointer to a target device node.
22102210
* @id_out: optional pointer to receive the translated ID.
22112211
*
2212-
* Given a device requester ID, look up the appropriate implementation-defined
2212+
* Given a device ID, look up the appropriate implementation-defined
22132213
* platform ID and/or the target device which receives transactions on that
22142214
* ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or
22152215
* @id_out may be NULL if only the other is required. If @target points to
@@ -2219,11 +2219,11 @@ int of_find_last_cache_level(unsigned int cpu)
22192219
*
22202220
* Return: 0 on success or a standard error code on failure.
22212221
*/
2222-
int of_map_rid(struct device_node *np, u32 rid,
2222+
int of_map_id(struct device_node *np, u32 id,
22232223
const char *map_name, const char *map_mask_name,
22242224
struct device_node **target, u32 *id_out)
22252225
{
2226-
u32 map_mask, masked_rid;
2226+
u32 map_mask, masked_id;
22272227
int map_len;
22282228
const __be32 *map = NULL;
22292229

@@ -2235,7 +2235,7 @@ int of_map_rid(struct device_node *np, u32 rid,
22352235
if (target)
22362236
return -ENODEV;
22372237
/* Otherwise, no map implies no translation */
2238-
*id_out = rid;
2238+
*id_out = id;
22392239
return 0;
22402240
}
22412241

@@ -2255,22 +2255,22 @@ int of_map_rid(struct device_node *np, u32 rid,
22552255
if (map_mask_name)
22562256
of_property_read_u32(np, map_mask_name, &map_mask);
22572257

2258-
masked_rid = map_mask & rid;
2258+
masked_id = map_mask & id;
22592259
for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) {
22602260
struct device_node *phandle_node;
2261-
u32 rid_base = be32_to_cpup(map + 0);
2261+
u32 id_base = be32_to_cpup(map + 0);
22622262
u32 phandle = be32_to_cpup(map + 1);
22632263
u32 out_base = be32_to_cpup(map + 2);
2264-
u32 rid_len = be32_to_cpup(map + 3);
2264+
u32 id_len = be32_to_cpup(map + 3);
22652265

2266-
if (rid_base & ~map_mask) {
2267-
pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n",
2266+
if (id_base & ~map_mask) {
2267+
pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores id-base (0x%x)\n",
22682268
np, map_name, map_name,
2269-
map_mask, rid_base);
2269+
map_mask, id_base);
22702270
return -EFAULT;
22712271
}
22722272

2273-
if (masked_rid < rid_base || masked_rid >= rid_base + rid_len)
2273+
if (masked_id < id_base || masked_id >= id_base + id_len)
22742274
continue;
22752275

22762276
phandle_node = of_find_node_by_phandle(phandle);
@@ -2288,20 +2288,20 @@ int of_map_rid(struct device_node *np, u32 rid,
22882288
}
22892289

22902290
if (id_out)
2291-
*id_out = masked_rid - rid_base + out_base;
2291+
*id_out = masked_id - id_base + out_base;
22922292

2293-
pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n",
2294-
np, map_name, map_mask, rid_base, out_base,
2295-
rid_len, rid, masked_rid - rid_base + out_base);
2293+
pr_debug("%pOF: %s, using mask %08x, id-base: %08x, out-base: %08x, length: %08x, id: %08x -> %08x\n",
2294+
np, map_name, map_mask, id_base, out_base,
2295+
id_len, id, masked_id - id_base + out_base);
22962296
return 0;
22972297
}
22982298

2299-
pr_info("%pOF: no %s translation for rid 0x%x on %pOF\n", np, map_name,
2300-
rid, target && *target ? *target : NULL);
2299+
pr_info("%pOF: no %s translation for id 0x%x on %pOF\n", np, map_name,
2300+
id, target && *target ? *target : NULL);
23012301

23022302
/* Bypasses translation */
23032303
if (id_out)
2304-
*id_out = rid;
2304+
*id_out = id;
23052305
return 0;
23062306
}
2307-
EXPORT_SYMBOL_GPL(of_map_rid);
2307+
EXPORT_SYMBOL_GPL(of_map_id);

drivers/of/irq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
587587
* "msi-map" property.
588588
*/
589589
for (parent_dev = dev; parent_dev; parent_dev = parent_dev->parent)
590-
if (!of_map_rid(parent_dev->of_node, rid_in, "msi-map",
590+
if (!of_map_id(parent_dev->of_node, rid_in, "msi-map",
591591
"msi-map-mask", np, &rid_out))
592592
break;
593593
return rid_out;

include/linux/of.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ bool of_console_check(struct device_node *dn, char *name, int index);
554554

555555
extern int of_cpu_node_to_id(struct device_node *np);
556556

557-
int of_map_rid(struct device_node *np, u32 rid,
557+
int of_map_id(struct device_node *np, u32 id,
558558
const char *map_name, const char *map_mask_name,
559559
struct device_node **target, u32 *id_out);
560560

@@ -978,7 +978,7 @@ static inline int of_cpu_node_to_id(struct device_node *np)
978978
return -ENODEV;
979979
}
980980

981-
static inline int of_map_rid(struct device_node *np, u32 rid,
981+
static inline int of_map_id(struct device_node *np, u32 id,
982982
const char *map_name, const char *map_mask_name,
983983
struct device_node **target, u32 *id_out)
984984
{

0 commit comments

Comments
 (0)