From patchwork Tue Mar 21 17:21:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 9637193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF523602CC for ; Tue, 21 Mar 2017 17:21:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC801281F9 for ; Tue, 21 Mar 2017 17:21:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0FF228418; Tue, 21 Mar 2017 17:21:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4E158281F9 for ; Tue, 21 Mar 2017 17:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KN2O3fj6+vgppYTQ8GvazRryHTuFj0r2W7TB420G710=; b=kDXNuFJ8aL/EZh ulL1clGK2RRiZgDyjg9bG7pSvta27nRBrQO2kNrv2VDIDoQOi1MJ0WHmOgnMt7cb4InNmS0oHNjc3 8j8wMkT3p/DF0duNZguR/s5Q8DY/Af3r/U6twIXMnkm5zpwYXG5Gi/Bfsa2Qz9g7+aHuQoL5CCW/D W5Pp7ugHqiY7ZcqGEaxqMJZgCjPQJHcF54EphC+IQu0tN6eSMyaI3PuSjhTKr5AVnSRZYqkTEyJvS Sjn1OYD5tATirGxGGR0cu2JnSVJ89DmgcAQrdkpvTHXuSINySySlO5mJxxGtjhkcSgWOTdueckOsE 1ZAL5ukqBiO4r4y20VwA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqNTg-00006v-Ra; Tue, 21 Mar 2017 17:21:48 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqNTd-00005N-Kl for linux-arm-kernel@lists.infradead.org; Tue, 21 Mar 2017 17:21:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 12A4B2B; Tue, 21 Mar 2017 10:21:25 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D9CA53F2E5; Tue, 21 Mar 2017 10:21:24 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 90AC51AE2F3B; Tue, 21 Mar 2017 17:21:37 +0000 (GMT) Date: Tue, 21 Mar 2017 17:21:37 +0000 From: Will Deacon To: Joerg Roedel Subject: Re: [PATCH v2 5/5] iommu: Allow default domain type to be set on the kernel command line Message-ID: <20170321172137.GF30948@arm.com> References: <1489178976-15353-1-git-send-email-will.deacon@arm.com> <1489178976-15353-6-git-send-email-will.deacon@arm.com> <20170321154527.GB29659@8bytes.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170321154527.GB29659@8bytes.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170321_102145_715955_4C100464 X-CRM114-Status: GOOD ( 15.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: iommu@lists.linux-foundation.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Mar 21, 2017 at 04:45:27PM +0100, Joerg Roedel wrote: > On Fri, Mar 10, 2017 at 08:49:36PM +0000, Will Deacon wrote: > > @@ -1014,8 +1027,8 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev) > > * IOMMU driver. > > */ > > if (!group->default_domain) { > > - group->default_domain = __iommu_domain_alloc(dev->bus, > > - IOMMU_DOMAIN_DMA); > > + group->default_domain = > > + __iommu_domain_alloc(dev->bus, iommu_def_domain_type); > > It would be good to have a fall-back here if we are talking to an IOMMU > driver that uses default domains, but does not support identity-mapped > domains (yet). Exynos and Rockchip IOMMU drivers seem to fall into this > category. A dev_warn() also makes sense in case allocating a identity > domain fails. Sure, something like the diff below? Will --->8 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 42a842e3f95f..f787626a745d 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1027,10 +1027,19 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev) * IOMMU driver. */ if (!group->default_domain) { - group->default_domain = - __iommu_domain_alloc(dev->bus, iommu_def_domain_type); + struct iommu_domain *dom; + + dom = __iommu_domain_alloc(dev->bus, iommu_def_domain_type); + if (!dom) { + dev_warn(dev, + "failed to allocate default IOMMU domain of type %u; falling back to IOMMU_DOMAIN_DMA", + iommu_def_domain_type); + dom = __iommu_domain_alloc(dev->bus, IOMMU_DOMAIN_DMA); + } + + group->default_domain = dom; if (!group->domain) - group->domain = group->default_domain; + group->domain = dom; } ret = iommu_group_add_device(group, dev);