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 d41ce7b1bc
("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>
This commit is contained in:
parent
847e6563aa
commit
b04149c2dd
|
@ -129,6 +129,11 @@ long pnv_npu_set_window(struct pnv_ioda_pe *npe, int num,
|
||||||
tbl->it_level_size : tbl->it_size;
|
tbl->it_level_size : tbl->it_size;
|
||||||
const __u64 start_addr = tbl->it_offset << tbl->it_page_shift;
|
const __u64 start_addr = tbl->it_offset << tbl->it_page_shift;
|
||||||
const __u64 win_size = tbl->it_size << tbl->it_page_shift;
|
const __u64 win_size = tbl->it_size << tbl->it_page_shift;
|
||||||
|
int num2 = (num == 0) ? 1 : 0;
|
||||||
|
|
||||||
|
/* NPU has just one TVE so if there is another table, remove it first */
|
||||||
|
if (npe->table_group.tables[num2])
|
||||||
|
pnv_npu_unset_window(npe, num2);
|
||||||
|
|
||||||
pe_info(npe, "Setting up window %llx..%llx pg=%lx\n",
|
pe_info(npe, "Setting up window %llx..%llx pg=%lx\n",
|
||||||
start_addr, start_addr + win_size - 1,
|
start_addr, start_addr + win_size - 1,
|
||||||
|
@ -159,6 +164,9 @@ long pnv_npu_unset_window(struct pnv_ioda_pe *npe, int num)
|
||||||
struct pnv_phb *phb = npe->phb;
|
struct pnv_phb *phb = npe->phb;
|
||||||
int64_t rc;
|
int64_t rc;
|
||||||
|
|
||||||
|
if (!npe->table_group.tables[num])
|
||||||
|
return 0;
|
||||||
|
|
||||||
pe_info(npe, "Removing DMA window\n");
|
pe_info(npe, "Removing DMA window\n");
|
||||||
|
|
||||||
rc = opal_pci_map_pe_dma_window(phb->opal_id, npe->pe_number,
|
rc = opal_pci_map_pe_dma_window(phb->opal_id, npe->pe_number,
|
||||||
|
|
|
@ -2667,23 +2667,14 @@ static struct pnv_ioda_pe *gpe_table_group_to_npe(
|
||||||
static long pnv_pci_ioda2_npu_set_window(struct iommu_table_group *table_group,
|
static long pnv_pci_ioda2_npu_set_window(struct iommu_table_group *table_group,
|
||||||
int num, struct iommu_table *tbl)
|
int num, struct iommu_table *tbl)
|
||||||
{
|
{
|
||||||
struct pnv_ioda_pe *npe = gpe_table_group_to_npe(table_group);
|
|
||||||
int num2 = (num == 0) ? 1 : 0;
|
|
||||||
long ret = pnv_pci_ioda2_set_window(table_group, num, tbl);
|
long ret = pnv_pci_ioda2_set_window(table_group, num, tbl);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (table_group->tables[num2])
|
ret = pnv_npu_set_window(gpe_table_group_to_npe(table_group), num, tbl);
|
||||||
pnv_npu_unset_window(npe, num2);
|
if (ret)
|
||||||
|
|
||||||
ret = pnv_npu_set_window(npe, num, tbl);
|
|
||||||
if (ret) {
|
|
||||||
pnv_pci_ioda2_unset_window(table_group, num);
|
pnv_pci_ioda2_unset_window(table_group, num);
|
||||||
if (table_group->tables[num2])
|
|
||||||
pnv_npu_set_window(npe, num2,
|
|
||||||
table_group->tables[num2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2692,24 +2683,12 @@ static long pnv_pci_ioda2_npu_unset_window(
|
||||||
struct iommu_table_group *table_group,
|
struct iommu_table_group *table_group,
|
||||||
int num)
|
int num)
|
||||||
{
|
{
|
||||||
struct pnv_ioda_pe *npe = gpe_table_group_to_npe(table_group);
|
|
||||||
int num2 = (num == 0) ? 1 : 0;
|
|
||||||
long ret = pnv_pci_ioda2_unset_window(table_group, num);
|
long ret = pnv_pci_ioda2_unset_window(table_group, num);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (!npe->table_group.tables[num])
|
return pnv_npu_unset_window(gpe_table_group_to_npe(table_group), num);
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = pnv_npu_unset_window(npe, num);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (table_group->tables[num2])
|
|
||||||
ret = pnv_npu_set_window(npe, num2, table_group->tables[num2]);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pnv_ioda2_npu_take_ownership(struct iommu_table_group *table_group)
|
static void pnv_ioda2_npu_take_ownership(struct iommu_table_group *table_group)
|
||||||
|
|
Loading…
Reference in New Issue