Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1173456ybl; Wed, 28 Aug 2019 10:41:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdpAd/03IVP6cKExpawjc3BZrjR87JyDdGbW/plz1HL6aUNCXP4LYizngM0++jP6fwTah6 X-Received: by 2002:a17:90a:a897:: with SMTP id h23mr5513836pjq.44.1567014073563; Wed, 28 Aug 2019 10:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567014073; cv=none; d=google.com; s=arc-20160816; b=XNgMCpiQwEbE1bv+Wlh0MK9XRW0x/5FmeshxxjLIMNtcCjWuXDQvVxya8XcSxqVSr4 cLHM241342YutOAzZPRNRUnXFuoPTC/ypRT/XYEf6dZBEaWsIjoXdpwInWX7psILUguZ SZTBlIyv9SpLPEZy3eh2wsplVveT1UQjIMHzZ2GvQE4Q0cWwS9m5CHi9zgJUvxPGTQXn 3qHUdtQNESzw9xItvidAx5s8eTksuUwxWFyZ5+uSIC52NQhHmGaeUg9MeL6wGLruX6yi atVkTztIiVyoySK4X/Rld1Iw15CU2KD74p5/X2n91mf876i/RSPM+BqCUpkK2twAX/PB PrIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=CiU935fJGTT97VjrhJkPzG4xzbWpvsWf6k+gBOrjbZQ=; b=neQkwmsQvk7KDg3eyITUdMiqfpEhURf2GeHYwx+hwhu+50yS7ZxJJkzLtdiPBVFZt/ QDqQUEbIaTZSpJpsg3SI4+TonAHKA5dQw1D2GQJWiXTst0LTad9nKOEMt2u4vItOB4Tc 3q7+Wombn86OeiRlzcHySdltMv/z2Bm+K0oALBw2iSFdqm9W1d/vvdePx0QHXdcouDYJ nhMNls272xob+F5uwZSDDUqnBLbT10y9JLakfnVtXitikQBZbRJMbeHzAacssdqGpWUe 7aQYcw9jCyIS9rX+vYsR/G3Svyc38sDq4SgdpvsA1NQ+B2uJc2qIB8z+tSXJNCn/k709 IhrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mFFmsoI2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cu10si2378476pjb.16.2019.08.28.10.40.57; Wed, 28 Aug 2019 10:41:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mFFmsoI2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbfH1Riu (ORCPT + 99 others); Wed, 28 Aug 2019 13:38:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:43726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbfH1Rit (ORCPT ); Wed, 28 Aug 2019 13:38:49 -0400 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 69D4F2077B; Wed, 28 Aug 2019 17:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567013928; bh=RIt/H8XgVifTEhugC1lEufb4AZAcq59OXKgKcWpAXrM=; h=From:To:Cc:Subject:Date:From; b=mFFmsoI2WrO9CnnAGYaAzhzpXYFxVVg9B1B5BCL83R/9wuur9d4dRBFfL8iMMd4hi W+BLxOuQOCNffysulPuuGslQVUWOHw/40PAdmxLOV9uTxovYH9PTbypJI5oSdu+TUL pr+4j0JgPlICgAjAu0M7l4Q5vmQfBvVbBboU8gl0= From: Stefano Stabellini To: will@kernel.org Cc: robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org, michal.simek@xilinx.com, sstabellini@kernel.org, git@xilinx.com, linux-kernel@vger.kernel.org, Stefano Stabellini Subject: [PATCH] arm-smmu: check for generic bindings first Date: Wed, 28 Aug 2019 10:38:37 -0700 Message-Id: <20190828173837.29617-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefano Stabellini Today, the arm-smmu driver checks for mmu-masters on device tree, the legacy property, if it is absent it assumes that we are using the new bindings. If it is present it assumes that we are using the legacy bindings. All arm-smmus need to use the same bindings: legacy or new. There are two issues with this: - we are not actually checking for the new bindings explicitly It would be better to have an explicit check for the new bindings rather than assuming we must be using the new if the old are not there. - old and new bindings cannot coexist It would be nice to be able to provide both old and new bindings so that software that hasn't been updated yet is still able to get IOMMU information from the legacy bindings while at the same time newer software can get the latest information via the new bindings. (Xen has not been updated to use the new binding yet for instance.) The current code breaks under these circumstances because if the old bindings are present, the new are not even checked. This patch changes the scheme by checking for #iommu-cells, which is only present with the new bindings, before checking for mmu-masters. The new bindings are always favored when present. All SMMUs still need to use the same bindings: mix-and-matching new and old bindings between different SMMUs is not allowed. Signed-off-by: Stefano Stabellini --- Let me know if you'd like me to turn the two using_*_binding variables into a single one. Also, please note that this is not meant as an excuse not to get Xen updated to use the new binding. drivers/iommu/arm-smmu.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 64977c131ee6..79b518ff215c 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -2118,7 +2118,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, { const struct arm_smmu_match_data *data; struct device *dev = &pdev->dev; - bool legacy_binding; + bool legacy_binding, generic_binding; if (of_property_read_u32(dev->of_node, "#global-interrupts", &smmu->num_global_irqs)) { @@ -2132,16 +2132,20 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, parse_driver_options(smmu); - legacy_binding = of_find_property(dev->of_node, "mmu-masters", NULL); - if (legacy_binding && !using_generic_binding) { - if (!using_legacy_binding) - pr_notice("deprecated \"mmu-masters\" DT property in use; DMA API support unavailable\n"); - using_legacy_binding = true; - } else if (!legacy_binding && !using_legacy_binding) { + generic_binding = of_find_property(dev->of_node, "#iommu-cells", NULL); + if (generic_binding && !using_legacy_binding) { using_generic_binding = true; } else { - dev_err(dev, "not probing due to mismatched DT properties\n"); - return -ENODEV; + legacy_binding = of_find_property(dev->of_node, "mmu-masters", + NULL); + if (legacy_binding && !using_generic_binding) { + if (!using_legacy_binding) + pr_notice("deprecated \"mmu-masters\" DT property in use; DMA API support unavailable\n"); + using_legacy_binding = true; + } else { + dev_err(dev, "not probing due to mismatched DT properties\n"); + return -ENODEV; + } } if (of_dma_is_coherent(dev->of_node)) -- 2.17.1