Re: [kernel, v12, 17/34] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group

From
Michael Ellerman <mpe@ellerman.id.au>
Date
2015-06-10 07:33:13
Also in
lkml
Reply to
Alexey Kardashevskiy, 2015-06-05
On Fri, 2015-05-06 at 06:35:09 UTC, Alexey Kardashevskiy wrote:
So far one TCE table could only be used by one IOMMU group. However
IODA2 hardware allows programming the same TCE table address to
multiple PE allowing sharing tables.
...
quoted hunk ↗ jump to hunk
+	pnv_pci_link_table_and_group(phb->hose->node, 0, tbl, &pe->table_group);
+	pnv_pci_link_table_and_group(phb->hose->node, 0, tbl, &pe->table_group);
+		pnv_pci_link_table_and_group(phb->hose->node, 0,
+				tbl, &phb->p5ioc2.table_group);
quoted hunk ↗ jump to hunk
+long pnv_pci_link_table_and_group(int node, int num,
+		struct iommu_table *tbl,
+		struct iommu_table_group *table_group)
+{
+	struct iommu_table_group_link *tgl = NULL;
+
+	BUG_ON(!tbl);
+	BUG_ON(!table_group);
+	BUG_ON(!table_group->group);
+
+	tgl = kzalloc_node(sizeof(struct iommu_table_group_link), GFP_KERNEL,
+			node);
+	if (!tgl)
+		return -ENOMEM;
+
+	tgl->table_group = table_group;
+	list_add_rcu(&tgl->next, &tbl->it_group_list);
+
+	table_group->tables[num] = tbl;
+
+	return 0;
I'm not a fan of the BUG_ONs here.

This routine is so important that you have to BUG_ON three times at the start,
yet you never check the return code if it fails? That doesn't make sense to me.

If anything this should be sufficient:

	if (WARN_ON(!tbl || !table_group))
		return -EINVAL;

cheers
Thread (46 messages) 46 messages, 3 authors, 2015-06-11
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help