From patchwork Mon Sep 30 20:56:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 11167477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C922C1747 for ; Mon, 30 Sep 2019 20:58:18 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A51BB224FE for ; Mon, 30 Sep 2019 20:58:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="x+JDGCzI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A51BB224FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iF2im-0004ej-8R; Mon, 30 Sep 2019 20:56:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iF2ik-0004ee-Uu for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 20:56:38 +0000 X-Inumbo-ID: cb5453f8-e3c4-11e9-bf31-bc764e2007e4 Received: from mail.kernel.org (unknown [198.145.29.99]) by localhost (Halon) with ESMTPS id cb5453f8-e3c4-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 20:56:38 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D1EB224FE; Mon, 30 Sep 2019 20:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569876997; bh=l4J92BlFI+IbnssZg7FIBDzaige2BuGLjWU+LNK5mWc=; h=From:To:Cc:Subject:Date:From; b=x+JDGCzIMdsNm3c7IoXpRT17eYYlVKUw3eKmLHuFEfkIPzIRU+anFGPIRVwdwxwyH NYY2wHEma50Ae3gZSSOPNL2yDMRbZzoEdwrmnwSy8yinnzvHM4Uyi5NdtPLoTgr/3r pETJ04ilDibOD1Sp2glkLTbHPSf7WAwO2IlMO3Ng= From: Stefano Stabellini To: julien.grall@arm.com Date: Mon, 30 Sep 2019 13:56:18 -0700 Message-Id: <20190930205618.29942-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH for-4.13] xen/arm: boot with device trees with "mmu-masters" and "iommus" X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: olekstysh@gmail.com, xen-devel@lists.xenproject.org, sstabellini@kernel.org, Stefano Stabellini MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Some Device Trees may expose both legacy SMMU and generic IOMMU bindings together. However, the SMMU driver in Xen is only supporting the legacy SMMU bindings, leading to fatal initialization errors at boot time. This patch fixes the booting problem by adding a check to iommu_add_dt_device: if the Xen driver doesn't support the new generic bindings, and the device is behind an IOMMU, do not return error. The following iommu_assign_dt_device should succeed. This check will become superfluous, hence removable, once the Xen SMMU driver gets support for the generic IOMMU bindings. Signed-off-by: Stefano Stabellini Reviewed-by: Oleksandr Tyshchenko Acked-by: Julien Grall --- xen/drivers/passthrough/device_tree.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index cc900bac70..27e265b936 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -155,7 +155,22 @@ int iommu_add_dt_device(struct dt_device_node *np) * these callback implemented. */ if ( !ops->add_device || !ops->dt_xlate ) - return -EINVAL; + { + /* + * Some Device Trees may expose both legacy SMMU and generic + * IOMMU bindings together. However, the SMMU driver is only + * supporting the former and will protect them during the + * initialization. So we need to skip them and not return + * error here. + * + * XXX: This can be dropped when the SMMU is able to deal + * with generic bindings. + */ + if ( dt_device_is_protected(np) ) + return 0; + else + return -EINVAL; + } if ( !dt_device_is_available(iommu_spec.np) ) break;