Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965796AbbD0WS1 (ORCPT ); Mon, 27 Apr 2015 18:18:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42213 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965427AbbD0WSZ (ORCPT ); Mon, 27 Apr 2015 18:18:25 -0400 Message-ID: <1430173102.4472.118.camel@redhat.com> Subject: Re: [PATCH kernel v9 30/32] vfio: powerpc/spapr: Use 32bit DMA window properties from table_group From: Alex Williamson To: Alexey Kardashevskiy Cc: linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Paul Mackerras , Gavin Shan , David Gibson , linux-kernel@vger.kernel.org Date: Mon, 27 Apr 2015 16:18:22 -0600 In-Reply-To: <1429964096-11524-31-git-send-email-aik@ozlabs.ru> References: <1429964096-11524-1-git-send-email-aik@ozlabs.ru> <1429964096-11524-31-git-send-email-aik@ozlabs.ru> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3069 Lines: 90 On Sat, 2015-04-25 at 22:14 +1000, Alexey Kardashevskiy wrote: > A table group might not have a table but it always has the default 32bit > window parameters so use these. > > No change in behavior is expected. > > Signed-off-by: Alexey Kardashevskiy > --- > Changes: > v9: > * new in the series - to make the next patch simpler > --- > drivers/vfio/vfio_iommu_spapr_tce.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) Acked-by: Alex Williamson > diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c > index 4cfc2c1..a7d6729 100644 > --- a/drivers/vfio/vfio_iommu_spapr_tce.c > +++ b/drivers/vfio/vfio_iommu_spapr_tce.c > @@ -185,7 +185,6 @@ static int tce_iommu_enable(struct tce_container *container) > { > int ret = 0; > unsigned long locked; > - struct iommu_table *tbl; > struct iommu_table_group *table_group; > > if (!container->grp) > @@ -221,13 +220,19 @@ static int tce_iommu_enable(struct tce_container *container) > * this is that we cannot tell here the amount of RAM used by the guest > * as this information is only available from KVM and VFIO is > * KVM agnostic. > + * > + * So we do not allow enabling a container without a group attached > + * as there is no way to know how much we should increment > + * the locked_vm counter. > */ > table_group = iommu_group_get_iommudata(container->grp); > if (!table_group) > return -ENODEV; > > - tbl = &table_group->tables[0]; > - locked = (tbl->it_size << tbl->it_page_shift) >> PAGE_SHIFT; > + if (!table_group->tce32_size) > + return -EPERM; > + > + locked = table_group->tce32_size >> PAGE_SHIFT; > ret = try_increment_locked_vm(locked); > if (ret) > return ret; > @@ -504,7 +509,6 @@ static long tce_iommu_ioctl(void *iommu_data, > > case VFIO_IOMMU_SPAPR_TCE_GET_INFO: { > struct vfio_iommu_spapr_tce_info info; > - struct iommu_table *tbl; > struct iommu_table_group *table_group; > > if (WARN_ON(!container->grp)) > @@ -512,8 +516,7 @@ static long tce_iommu_ioctl(void *iommu_data, > > table_group = iommu_group_get_iommudata(container->grp); > > - tbl = &table_group->tables[0]; > - if (WARN_ON_ONCE(!tbl)) > + if (!table_group) > return -ENXIO; > > minsz = offsetofend(struct vfio_iommu_spapr_tce_info, > @@ -525,8 +528,8 @@ static long tce_iommu_ioctl(void *iommu_data, > if (info.argsz < minsz) > return -EINVAL; > > - info.dma32_window_start = tbl->it_offset << tbl->it_page_shift; > - info.dma32_window_size = tbl->it_size << tbl->it_page_shift; > + info.dma32_window_start = table_group->tce32_start; > + info.dma32_window_size = table_group->tce32_size; > info.flags = 0; > > if (copy_to_user((void __user *)arg, &info, minsz)) -- 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/