Skip to content

Commit a5fd951

Browse files
LeoBrasmpe
authored andcommitted
powerpc/pseries/iommu: Update remove_dma_window() to accept property name
Update remove_dma_window() so it can be used to remove DDW with a given property name. This enables the creation of new property names for DDW, so we can have different usage for it, like indirect mapping. Also, add return values to it so we can check if the property was found while removing the active DDW. This allows skipping the remaining property names while reducing the impact of multiple property names. Signed-off-by: Leonardo Bras <[email protected]> Reviewed-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fc8cba8 commit a5fd951

File tree

1 file changed

+10
-8
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+10
-8
lines changed

arch/powerpc/platforms/pseries/iommu.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,31 +844,33 @@ static void remove_dma_window(struct device_node *np, u32 *ddw_avail,
844844
__remove_dma_window(np, ddw_avail, liobn);
845845
}
846846

847-
static void remove_ddw(struct device_node *np, bool remove_prop)
847+
static int remove_ddw(struct device_node *np, bool remove_prop, const char *win_name)
848848
{
849849
struct property *win;
850850
u32 ddw_avail[DDW_APPLICABLE_SIZE];
851851
int ret = 0;
852852

853+
win = of_find_property(np, win_name, NULL);
854+
if (!win)
855+
return -EINVAL;
856+
853857
ret = of_property_read_u32_array(np, "ibm,ddw-applicable",
854858
&ddw_avail[0], DDW_APPLICABLE_SIZE);
855859
if (ret)
856-
return;
860+
return 0;
857861

858-
win = of_find_property(np, DIRECT64_PROPNAME, NULL);
859-
if (!win)
860-
return;
861862

862863
if (win->length >= sizeof(struct dynamic_dma_window_prop))
863864
remove_dma_window(np, ddw_avail, win);
864865

865866
if (!remove_prop)
866-
return;
867+
return 0;
867868

868869
ret = of_remove_property(np, win);
869870
if (ret)
870871
pr_warn("%pOF: failed to remove direct window property: %d\n",
871872
np, ret);
873+
return 0;
872874
}
873875

874876
static bool find_existing_ddw(struct device_node *pdn, u64 *dma_addr, int *window_shift)
@@ -921,7 +923,7 @@ static int find_existing_ddw_windows(void)
921923
for_each_node_with_property(pdn, DIRECT64_PROPNAME) {
922924
direct64 = of_get_property(pdn, DIRECT64_PROPNAME, &len);
923925
if (!direct64 || len < sizeof(*direct64)) {
924-
remove_ddw(pdn, true);
926+
remove_ddw(pdn, true, DIRECT64_PROPNAME);
925927
continue;
926928
}
927929

@@ -1565,7 +1567,7 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti
15651567
* we have to remove the property when releasing
15661568
* the device node.
15671569
*/
1568-
remove_ddw(np, false);
1570+
remove_ddw(np, false, DIRECT64_PROPNAME);
15691571
if (pci && pci->table_group)
15701572
iommu_pseries_free_group(pci->table_group,
15711573
np->full_name);

0 commit comments

Comments
 (0)