Skip to content

Commit b04149c

Browse files
aikmpe
authored andcommitted
powerpc/powernv/npu: Move single TVE handling to NPU PE
Normal PCI PEs have 2 TVEs, one per a DMA window; however NPU PE has only one which points to one of two tables of the corresponding PCI PE. So whenever a new DMA window is programmed to PEs, the NPU PE needs to release old table in order to use the new one. Commit d41ce7b ("powerpc/powernv/npu: Do not try invalidating 32bit table when 64bit table is enabled") did just that but in pci-ioda.c while it actually belongs to npu-dma.c. This moves the single TVE handling to npu-dma.c. This does not implement restoring though as it is highly unlikely that we can set the table to PCI PE and cannot to NPU PE and if that fails, we could only set 32bit table to NPU PE and this configuration is not really supported or wanted. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 847e656 commit b04149c

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

arch/powerpc/platforms/powernv/npu-dma.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ long pnv_npu_set_window(struct pnv_ioda_pe *npe, int num,
129129
tbl->it_level_size : tbl->it_size;
130130
const __u64 start_addr = tbl->it_offset << tbl->it_page_shift;
131131
const __u64 win_size = tbl->it_size << tbl->it_page_shift;
132+
int num2 = (num == 0) ? 1 : 0;
133+
134+
/* NPU has just one TVE so if there is another table, remove it first */
135+
if (npe->table_group.tables[num2])
136+
pnv_npu_unset_window(npe, num2);
132137

133138
pe_info(npe, "Setting up window %llx..%llx pg=%lx\n",
134139
start_addr, start_addr + win_size - 1,
@@ -159,6 +164,9 @@ long pnv_npu_unset_window(struct pnv_ioda_pe *npe, int num)
159164
struct pnv_phb *phb = npe->phb;
160165
int64_t rc;
161166

167+
if (!npe->table_group.tables[num])
168+
return 0;
169+
162170
pe_info(npe, "Removing DMA window\n");
163171

164172
rc = opal_pci_map_pe_dma_window(phb->opal_id, npe->pe_number,

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,23 +2667,14 @@ static struct pnv_ioda_pe *gpe_table_group_to_npe(
26672667
static long pnv_pci_ioda2_npu_set_window(struct iommu_table_group *table_group,
26682668
int num, struct iommu_table *tbl)
26692669
{
2670-
struct pnv_ioda_pe *npe = gpe_table_group_to_npe(table_group);
2671-
int num2 = (num == 0) ? 1 : 0;
26722670
long ret = pnv_pci_ioda2_set_window(table_group, num, tbl);
26732671

26742672
if (ret)
26752673
return ret;
26762674

2677-
if (table_group->tables[num2])
2678-
pnv_npu_unset_window(npe, num2);
2679-
2680-
ret = pnv_npu_set_window(npe, num, tbl);
2681-
if (ret) {
2675+
ret = pnv_npu_set_window(gpe_table_group_to_npe(table_group), num, tbl);
2676+
if (ret)
26822677
pnv_pci_ioda2_unset_window(table_group, num);
2683-
if (table_group->tables[num2])
2684-
pnv_npu_set_window(npe, num2,
2685-
table_group->tables[num2]);
2686-
}
26872678

26882679
return ret;
26892680
}
@@ -2692,24 +2683,12 @@ static long pnv_pci_ioda2_npu_unset_window(
26922683
struct iommu_table_group *table_group,
26932684
int num)
26942685
{
2695-
struct pnv_ioda_pe *npe = gpe_table_group_to_npe(table_group);
2696-
int num2 = (num == 0) ? 1 : 0;
26972686
long ret = pnv_pci_ioda2_unset_window(table_group, num);
26982687

26992688
if (ret)
27002689
return ret;
27012690

2702-
if (!npe->table_group.tables[num])
2703-
return 0;
2704-
2705-
ret = pnv_npu_unset_window(npe, num);
2706-
if (ret)
2707-
return ret;
2708-
2709-
if (table_group->tables[num2])
2710-
ret = pnv_npu_set_window(npe, num2, table_group->tables[num2]);
2711-
2712-
return ret;
2691+
return pnv_npu_unset_window(gpe_table_group_to_npe(table_group), num);
27132692
}
27142693

27152694
static void pnv_ioda2_npu_take_ownership(struct iommu_table_group *table_group)

0 commit comments

Comments
 (0)