Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1260625ybl; Wed, 28 Aug 2019 11:56:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaQgWXERIuft7+dZbEigsED1Ge3LxjFFAVTu2v8AvOj4gicrUsEytiC8ZPFWenp0M7U7F2 X-Received: by 2002:a63:125c:: with SMTP id 28mr4715377pgs.255.1567018618119; Wed, 28 Aug 2019 11:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567018618; cv=none; d=google.com; s=arc-20160816; b=uKBekCjXL2eQy2JcWh8qqoUFa3gp7mN1ZXDg8WB1jM1Xm8VnQy5cVbf458w4AwpkjE MWpJQ5P980xnfZ5UHUv45fYQyEwytSvQcAvdJsUo03Anf81HctxlWLv1pOcFnex2MmmF caEaI2PxHBW5zNlBKLd2lO3NQ6w0yEUlnU+7xIwixvuzCgRt2ey/PR01LjzOCQLtZcK5 NaeOqG1+F8x2v/Se6frLXHW7WUtHagRXwthlgt5tQYlshEOtG5jMQDHwY1+aaWODfQ6F gYTRxuHV1x7wAHk4llaR+5HOJcKRgBTy8nk0t1PVbcmYoCJKu8Tf78jjUE9X1uj76WSt VASg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=6oLU2A2QL3A5DXCMJt6nfq8nYU4wX3kx4HOBVC1+C08=; b=fbyzF1d2aQVVB8Kg/Io9hkFyz6Ok3s8e5McB/EszoUD4jtjDzUeZrQ9NwN0FrPGhCY ZxeWJJS1KWDUkhQ20UAmlq4mak/1WiVMvrDQMC9dcuNkwwqI7uhq8lLa1cugk63fv3yk ycbisFGVeLR1RdLHkS0Bo8Iudmdf1YDRVmc7DsSu1IQ744NYzWsGYwUAekbIIgTIZmea NYy7C9JxWRrIWdlwbKVNFooJWSvUExdCg1QfpRJLYzoT3uhGW/rGF7mzHQzYZsnqXeA7 Ec5057clUYnuj3YJlX+uk3nDrmsoTFpw0Vbl3VCs5daITvir0VqEeV7joh8olZDVkjWJ n4LQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si2554pjo.48.2019.08.28.11.56.41; Wed, 28 Aug 2019 11:56:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbfH1Szb (ORCPT + 99 others); Wed, 28 Aug 2019 14:55:31 -0400 Received: from foss.arm.com ([217.140.110.172]:35458 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbfH1Sza (ORCPT ); Wed, 28 Aug 2019 14:55:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D8A53337; Wed, 28 Aug 2019 11:55:29 -0700 (PDT) Received: from [10.1.197.57] (e110467-lin.cambridge.arm.com [10.1.197.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF12F3F59C; Wed, 28 Aug 2019 11:55:28 -0700 (PDT) Subject: Re: [PATCH] arm-smmu: check for generic bindings first To: Stefano Stabellini , will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, michal.simek@xilinx.com, git@xilinx.com, linux-kernel@vger.kernel.org, Stefano Stabellini References: <20190828173837.29617-1-sstabellini@kernel.org> From: Robin Murphy Message-ID: Date: Wed, 28 Aug 2019 19:55:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190828173837.29617-1-sstabellini@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/08/2019 18:38, Stefano Stabellini wrote: > 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. The legacy binding is the special case, though. Isn't it perfectly logical to check for the special case, and assume the normal case otherwise? ;) > - 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. FWIW that was a deliberate design decision. We didn't want to see DTs with both bindings at once - the legacy binding support remains only for the sake of DTBs deployed in fossilised firmware that can't/won't ever be updated. And I'm pretty sure the intervening 3 years have only reinforced that position. Only a couple more months now until it will have been deprecated for longer than it wasn't :) Do note that "mmu-masters" isn't just deprecated for giggles either - the binding made some flawed assumptions, and there are Stream ID topologies that it cannot possibly describe, which do exist in the real world. > 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. Fair enough, but conversely, what makes it Linux's responsibility to handle? If Xen wants to deal with funky hybrid DTs then why shouldn't it be Xen's job to just filter deprecated properties out of whatever it presents to Linux? Robin. > 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)) >