Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933571AbbFJHdN (ORCPT ); Wed, 10 Jun 2015 03:33:13 -0400 Received: from ozlabs.org ([103.22.144.67]:35445 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932309AbbFJHdJ (ORCPT ); Wed, 10 Jun 2015 03:33:09 -0400 In-Reply-To: <1433486126-23551-18-git-send-email-aik@ozlabs.ru> To: Alexey Kardashevskiy , linuxppc-dev@lists.ozlabs.org From: Michael Ellerman Cc: Wei Yang , Alexey Kardashevskiy , Gavin Shan , linux-kernel@vger.kernel.org, Alex Williamson , Paul Mackerras , David Gibson Subject: Re: [kernel, v12, 17/34] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group Message-Id: <20150610073307.948391402AE@ozlabs.org> Date: Wed, 10 Jun 2015 17:33:07 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1575 Lines: 50 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. ... > + 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); > +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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/