Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2756754rdb; Fri, 22 Sep 2023 07:38:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVveaF+v0Agy93RC3isB8nN6je9efFqksyomWrL2j3QsviMxPLXRJDgrUemClwqAR5we3X X-Received: by 2002:a05:6a20:12c9:b0:157:7568:6796 with SMTP id v9-20020a056a2012c900b0015775686796mr8638311pzg.60.1695393533027; Fri, 22 Sep 2023 07:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695393533; cv=none; d=google.com; s=arc-20160816; b=sQ0URnJVB2nR3RRD94udrAluQBSd6oT1J8aO3AseK2zcbP6WmnQ6+AyjNucNtTvrow vHKBlyw0w/v0XqEiqKaxv4gYbwfmB2lPPT4qnw0GXe5HbAW5FP4STVYWtkoWxlMwK2rF r7zz1eZg+gT828xK/OyqS2V3hnf/YzwhWUeOoN37fzxyxPcVyDRJrbRuEqxd/307FARh uMyQBzZhWW2vL5hxUuRsuasjCSC/jlCHr6TwpcCXThb4FkZy4l4vq5NPW1Cu2dD+bQZK uw4M+wA7dbLg29rsWBPuCm6IRMH3BVj+5dwcYCgC1AGU+YH+yVonZ/q3IrHDawY8hwEA vJKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=G2bNRb+mgVCv+EpdLjgrlTQUM7kBp8yCoXN70beqUk8=; fh=p8B338r7GbjcKKRIuRQ2Hz/zFEc8Z5fBpvFFONT9lIw=; b=mczkr9VshBNHPQwEG1uoWOzg2HkOhnlztBvjotGHGs575DK7U7Ngs2sFX9SpWErsuy YQ6AUw+7oQbMGCmGXEa24jkw1LJhwyJv0VvCdJwauo0P6Mx5WGb571jo/gcYF69A6+pO vD3APYOo1VA6uFWWSBEAvy7presbulhEfON+TN41Jtk0XWvjLwb8+IE/cTI4JjUdDAIl ifKOFWC8l73p9wL4MX1VggoopVMCEUHAlqv4LH2fZzRq/TQDxwzvrjWHPL2VVtp3CHIq tTNHKtSf4lI+hmZewbHV+5g0o/+peIwZ7rcZqzEks/eKjpXlVKliHchOmoys1L1TbtCK 8k+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ca24-20020a056a00419800b0068fea05ecdasi3949211pfb.182.2023.09.22.07.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 07:38:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id AE36085C6A9F; Fri, 22 Sep 2023 07:21:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234204AbjIVOVd (ORCPT + 99 others); Fri, 22 Sep 2023 10:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233368AbjIVOVc (ORCPT ); Fri, 22 Sep 2023 10:21:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D24AAB; Fri, 22 Sep 2023 07:21:24 -0700 (PDT) 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 D47BCDA7; Fri, 22 Sep 2023 07:22:00 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2EE4D3F67D; Fri, 22 Sep 2023 07:21:22 -0700 (PDT) Message-ID: <2ea199a1-d20d-2fde-d1bd-76ecad14a68d@arm.com> Date: Fri, 22 Sep 2023 15:21:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH REGRESSION] iommu: Only allocate FQ domains for IOMMUs that support them Content-Language: en-GB To: Hector Martin , Joerg Roedel , Will Deacon , Jason Gunthorpe , Jerry Snitselaar Cc: Joerg Roedel , Neal Gompa , "Justin M. Forbes" , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, stable@vger.kernel.org, regressions@lists.linux.dev References: <20230922-iommu-type-regression-v1-1-1ed3825b2c38@marcan.st> From: Robin Murphy In-Reply-To: <20230922-iommu-type-regression-v1-1-1ed3825b2c38@marcan.st> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 07:21:36 -0700 (PDT) On 22/09/2023 2:40 pm, Hector Martin wrote: > Commit a4fdd9762272 ("iommu: Use flush queue capability") hid the > IOMMU_DOMAIN_DMA_FQ domain type from domain allocation. A check was > introduced in iommu_dma_init_domain() to fall back if not supported, but > this check runs too late: by that point, devices have been attached to > the IOMMU, and the IOMMU driver might not expect FQ domains at > ops->attach_dev() time. > > Ensure that we immediately clamp FQ domains to plain DMA if not > supported by the driver at device attach time, not later. > > This regressed apple-dart in v6.5. Apologies, I missed that apple-dart was doing something unusual here. However, could we just fix that directly instead? diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 2082081402d3..0b8927508427 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -671,8 +671,7 @@ static int apple_dart_attach_dev(struct iommu_domain *domain, return ret; switch (domain->type) { - case IOMMU_DOMAIN_DMA: - case IOMMU_DOMAIN_UNMANAGED: + default: ret = apple_dart_domain_add_streams(dart_domain, cfg); if (ret) return ret; That's pretty much where we're headed with the domain_alloc_paging redesign anyway - at the driver level, operations on a paging domain should not need to know about the higher-level usage intent of that domain. Ideally, blocking and identity domains should have their own distinct ops now as well, but that might be a bit too big a change for an immediate fix here. Thanks, Robin. > > Cc: regressions@lists.linux.dev > Cc: stable@vger.kernel.org > Fixes: a4fdd9762272 ("iommu: Use flush queue capability") > Signed-off-by: Hector Martin > --- > drivers/iommu/iommu.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index 3bfc56df4f78..12464eaa8d91 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -2039,6 +2039,15 @@ static int __iommu_attach_device(struct iommu_domain *domain, > if (unlikely(domain->ops->attach_dev == NULL)) > return -ENODEV; > > + /* > + * Ensure we do not try to attach devices to FQ domains if the > + * IOMMU does not support them. We can safely fall back to > + * non-FQ. > + */ > + if (domain->type == IOMMU_DOMAIN_DMA_FQ && > + !device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH)) > + domain->type = IOMMU_DOMAIN_DMA; > + > ret = domain->ops->attach_dev(domain, dev); > if (ret) > return ret; > > --- > base-commit: ce9ecca0238b140b88f43859b211c9fdfd8e5b70 > change-id: 20230922-iommu-type-regression-25b4f43df770 > > Best regards,