From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Deacon Subject: Re: [PATCH 02/15] iommu: Introduce iommu domain types Date: Wed, 28 Jan 2015 14:19:34 +0000 Message-ID: <20150128141934.GP1569@arm.com> References: <1422316305-19216-1-git-send-email-joro@8bytes.org> <1422316305-19216-3-git-send-email-joro@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1422316305-19216-3-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Joerg Roedel Cc: Alexandre Courbot , "linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Heiko Stuebner , Arnd Bergmann , Stephen Warren , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" , "iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org" , Kukjin Kim , Thierry Reding , "jroedel-l3A5Bk7waGM@public.gmane.org" , "linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , David Woodhouse , "linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" List-Id: linux-tegra@vger.kernel.org Hi Joerg, Thanks for posting this! On Mon, Jan 26, 2015 at 11:51:32PM +0000, Joerg Roedel wrote: > From: Joerg Roedel > > This allows to handle domains differently based on their > type in the future. An IOMMU driver can implement certain > optimizations for DMA-API domains for example. > > Signed-off-by: Joerg Roedel > --- > drivers/iommu/iommu.c | 5 +++-- > include/linux/iommu.h | 11 ++++++++++- > 2 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index 684efc0..ab24d77 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -909,14 +909,15 @@ struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) > ops = bus->iommu_ops; > > if (ops->domain_alloc) > - domain = ops->domain_alloc(); > + domain = ops->domain_alloc(IOMMU_DOMAIN_UNMANAGED); > else > domain = kzalloc(sizeof(*domain), GFP_KERNEL); > > if (!domain) > return NULL; > > - domain->ops = bus->iommu_ops; > + domain->ops = bus->iommu_ops; > + domain->type = IOMMU_DOMAIN_UNMANAGED; > > if (ops->domain_init && domain->ops->domain_init(domain)) > goto out_free; > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 69d1d12..0b67f65 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -51,7 +51,16 @@ struct iommu_domain_geometry { > bool force_aperture; /* DMA only allowed in mappable range? */ > }; > > +/* This are the possible domain-types */ > +enum iommu_domain_type { > + IOMMU_DOMAIN_DMA, /* Domain used for DMA-API */ > + IOMMU_DOMAIN_IDENTITY, /* Identity mapped domain */ What happens if somebody calls map or unmap on an identity-mapping domain? Can we catch that in the IOMMU core before calling the IOMMU driver? That also implies we need something extra to parameterise the attributes for the mapping (e.g. cacheable, read-only) and also potentially the address range. > + IOMMU_DOMAIN_UNMANAGED, /* Domain mappings are managed by a third party > + user (like KVM or VFIO) */ We already have the domain attributes (iommu_attr) to describe features of a domain. Is there really a need for this extra type, or can we extend the attribute set and allow for domain allocation with attributes? Will From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755546AbbA1USM (ORCPT ); Wed, 28 Jan 2015 15:18:12 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:45498 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755516AbbA1USH (ORCPT ); Wed, 28 Jan 2015 15:18:07 -0500 Date: Wed, 28 Jan 2015 14:19:34 +0000 From: Will Deacon To: Joerg Roedel Cc: "iommu@lists.linux-foundation.org" , Kukjin Kim , David Woodhouse , Heiko Stuebner , Hiroshi Doyu , Stephen Warren , Thierry Reding , Alexandre Courbot , Alex Williamson , Arnd Bergmann , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-samsung-soc@vger.kernel.org" , "linux-rockchip@lists.infradead.org" , "linux-tegra@vger.kernel.org" , "jroedel@suse.de" Subject: Re: [PATCH 02/15] iommu: Introduce iommu domain types Message-ID: <20150128141934.GP1569@arm.com> References: <1422316305-19216-1-git-send-email-joro@8bytes.org> <1422316305-19216-3-git-send-email-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1422316305-19216-3-git-send-email-joro@8bytes.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, Thanks for posting this! On Mon, Jan 26, 2015 at 11:51:32PM +0000, Joerg Roedel wrote: > From: Joerg Roedel > > This allows to handle domains differently based on their > type in the future. An IOMMU driver can implement certain > optimizations for DMA-API domains for example. > > Signed-off-by: Joerg Roedel > --- > drivers/iommu/iommu.c | 5 +++-- > include/linux/iommu.h | 11 ++++++++++- > 2 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index 684efc0..ab24d77 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -909,14 +909,15 @@ struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) > ops = bus->iommu_ops; > > if (ops->domain_alloc) > - domain = ops->domain_alloc(); > + domain = ops->domain_alloc(IOMMU_DOMAIN_UNMANAGED); > else > domain = kzalloc(sizeof(*domain), GFP_KERNEL); > > if (!domain) > return NULL; > > - domain->ops = bus->iommu_ops; > + domain->ops = bus->iommu_ops; > + domain->type = IOMMU_DOMAIN_UNMANAGED; > > if (ops->domain_init && domain->ops->domain_init(domain)) > goto out_free; > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 69d1d12..0b67f65 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -51,7 +51,16 @@ struct iommu_domain_geometry { > bool force_aperture; /* DMA only allowed in mappable range? */ > }; > > +/* This are the possible domain-types */ > +enum iommu_domain_type { > + IOMMU_DOMAIN_DMA, /* Domain used for DMA-API */ > + IOMMU_DOMAIN_IDENTITY, /* Identity mapped domain */ What happens if somebody calls map or unmap on an identity-mapping domain? Can we catch that in the IOMMU core before calling the IOMMU driver? That also implies we need something extra to parameterise the attributes for the mapping (e.g. cacheable, read-only) and also potentially the address range. > + IOMMU_DOMAIN_UNMANAGED, /* Domain mappings are managed by a third party > + user (like KVM or VFIO) */ We already have the domain attributes (iommu_attr) to describe features of a domain. Is there really a need for this extra type, or can we extend the attribute set and allow for domain allocation with attributes? Will From mboxrd@z Thu Jan 1 00:00:00 1970 From: will.deacon@arm.com (Will Deacon) Date: Wed, 28 Jan 2015 14:19:34 +0000 Subject: [PATCH 02/15] iommu: Introduce iommu domain types In-Reply-To: <1422316305-19216-3-git-send-email-joro@8bytes.org> References: <1422316305-19216-1-git-send-email-joro@8bytes.org> <1422316305-19216-3-git-send-email-joro@8bytes.org> Message-ID: <20150128141934.GP1569@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Joerg, Thanks for posting this! On Mon, Jan 26, 2015 at 11:51:32PM +0000, Joerg Roedel wrote: > From: Joerg Roedel > > This allows to handle domains differently based on their > type in the future. An IOMMU driver can implement certain > optimizations for DMA-API domains for example. > > Signed-off-by: Joerg Roedel > --- > drivers/iommu/iommu.c | 5 +++-- > include/linux/iommu.h | 11 ++++++++++- > 2 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index 684efc0..ab24d77 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -909,14 +909,15 @@ struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) > ops = bus->iommu_ops; > > if (ops->domain_alloc) > - domain = ops->domain_alloc(); > + domain = ops->domain_alloc(IOMMU_DOMAIN_UNMANAGED); > else > domain = kzalloc(sizeof(*domain), GFP_KERNEL); > > if (!domain) > return NULL; > > - domain->ops = bus->iommu_ops; > + domain->ops = bus->iommu_ops; > + domain->type = IOMMU_DOMAIN_UNMANAGED; > > if (ops->domain_init && domain->ops->domain_init(domain)) > goto out_free; > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 69d1d12..0b67f65 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -51,7 +51,16 @@ struct iommu_domain_geometry { > bool force_aperture; /* DMA only allowed in mappable range? */ > }; > > +/* This are the possible domain-types */ > +enum iommu_domain_type { > + IOMMU_DOMAIN_DMA, /* Domain used for DMA-API */ > + IOMMU_DOMAIN_IDENTITY, /* Identity mapped domain */ What happens if somebody calls map or unmap on an identity-mapping domain? Can we catch that in the IOMMU core before calling the IOMMU driver? That also implies we need something extra to parameterise the attributes for the mapping (e.g. cacheable, read-only) and also potentially the address range. > + IOMMU_DOMAIN_UNMANAGED, /* Domain mappings are managed by a third party > + user (like KVM or VFIO) */ We already have the domain attributes (iommu_attr) to describe features of a domain. Is there really a need for this extra type, or can we extend the attribute set and allow for domain allocation with attributes? Will