Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp999570rwe; Thu, 1 Sep 2022 10:46:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Ec1mgvqyy6W170yX7cW1w/g+zL15V0WxRC7pGJt1VuwT+VNjbgK3PYKZe3ICM/0fy+mxQ X-Received: by 2002:a05:6402:510e:b0:448:9d4b:c760 with SMTP id m14-20020a056402510e00b004489d4bc760mr14979808edd.156.1662054385479; Thu, 01 Sep 2022 10:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662054385; cv=none; d=google.com; s=arc-20160816; b=wxdtylhKuw6M1PfYidKVQ6VkTbBe5PwAhD3j/tVM+xhvbBz/zkWrsvpXklrZYw4yv7 tarFM+c165TyKrSdWS0UgDILXsX7T+ZyMwfn0GpD8tMzmM8PcqH3rIz8x/Jzs/aGKHcF +NWxnE08KMFyLVlHr9W08dNfR1A92BosscYbTjWBtePCKNnewhZvS0mXt/RmyfHBl2CK n+2KUppy8cvdYaG94yMTqsO+oQjLqS5cYjRlgUiHQwIciQ9Pht8ujrlZ0e+PbUeyK2Av DgC4OsSrZw+7KYy63R/Y0JlLVTfex3wRqqMFd1kL4FIvatz4O2lV9b3g1Aw18uIjM5BD fUbw== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=vbd4usiDbzDxjZJ3ukN8xN0FI/YqZEJ/KKBeZH152M4=; b=utXROGl7Y2v/Zhadmtfl9qD7JAoWB3ch0P/pDrDlJO+EPmPDZcweXTjhjO0cFHTZKq 6XUiNsDKXR2+tGOujtQu618zAl94ZZaHNCjPDj8uPbqGabJRlX7anDQlqv6ABTRE/2YN GjEHqxNc/6SAVcqeiCqXpRTon5Igl8GcIwAB/kkRR7zfSdF2tMvbDDJxwgx876B4mKQx 6irVs0zRrfI9WlZeXTJ5SNn7DzHj2axkuboGaYBbPsMoiDVYrPYgbRWr5GSrP2ZNHck2 EYuKpgOVtr5IJZM2zRqpANFMX7ADqcoIWwtojsVWFCnUxlzmiL4tuR0AULuvLfP5K/Mq AUmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq4-20020a1709073f0400b007263a6115adsi15613464ejc.893.2022.09.01.10.45.42; Thu, 01 Sep 2022 10:46:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235083AbiIARBD (ORCPT + 99 others); Thu, 1 Sep 2022 13:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235082AbiIARBA (ORCPT ); Thu, 1 Sep 2022 13:01:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9E3726B647; Thu, 1 Sep 2022 10:00:58 -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 6BC00D6E; Thu, 1 Sep 2022 10:01:04 -0700 (PDT) Received: from [10.57.15.167] (unknown [10.57.15.167]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A9DC3F7B4; Thu, 1 Sep 2022 10:00:54 -0700 (PDT) Message-ID: <31269d99-5ffc-7060-2af2-ce1f5bc33de2@arm.com> Date: Thu, 1 Sep 2022 18:00:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v4 1/2] iommu/s390: Fix race with release_device ops To: Jason Gunthorpe Cc: Niklas Schnelle , Pierre Morel , Matthew Rosato , iommu@lists.linux.dev, linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, joro@8bytes.org, will@kernel.org, linux-kernel@vger.kernel.org References: <20220831201236.77595-1-mjrosato@linux.ibm.com> <20220831201236.77595-2-mjrosato@linux.ibm.com> <9887e2f4-3f3d-137d-dad7-59dab5f98aab@linux.ibm.com> <52d3fe0b86bdc04fdbf3aae095b2f71f4ea12d44.camel@linux.ibm.com> <8b561ad3023fc146ba0779cbd8fff14d6409c6aa.camel@linux.ibm.com> <3e402947-61f9-b7e8-1414-fde006257b6f@arm.com> <58d14cfc-f8ba-777b-a975-371ff2b29e5a@arm.com> Content-Language: en-GB From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On 2022-09-01 16:49, Jason Gunthorpe wrote: > On Thu, Sep 01, 2022 at 04:03:36PM +0100, Robin Murphy wrote: >> On 2022-09-01 15:34, Jason Gunthorpe wrote: >>> On Thu, Sep 01, 2022 at 03:29:16PM +0100, Robin Murphy wrote: >>> >>>> Right, the next step would be to bridge that gap to iommu-dma to dump the >>>> flush queue when IOVA allocation failure implies we've reached the >>>> "rollover" point, and perhaps not use the timer at all. By that point a >>>> dedicated domain type, or at least some definite internal flag, for this >>>> alternate behaviour seems like the logical way to go. >>> >>> At least on this direction, I've been thinking it would be nice to >>> replace the domain type _FQ with a flag inside the domain, maybe the >>> ops, saying how the domain wants the common DMA API to operate. If it >>> wants FQ mode or other tuning parameters >> >> Compare the not-necessarily-obvious matrix of "strict" and "passthrough" >> command-line parameters with the nice understandable kconfig and sysfs >> controls for a reminder of why I moved things *from* that paradigm in the >> first place ;) > > I'm looking at it from a code perspective, where the drivers don't > seem to actually care about DMA_FQ. eg search for it in the drivers > and you mostly see: > > (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_DMA_FQ)) > > The exception is domain_alloc which fails in cases where the domain > doesn't 'support' FQ. > > But support FQ or not can be cast as a simple capability flag in the > domain. We don't need a whole type for the driver to communicate it. Right, since the rest of DMA domain setup got streamlined into the core code this one remaining vestige of the old world order is ripe for cleanup, I've just had bigger fish to fry. Or as the case may be, bigger chunks of repetitive boilerplate to remove from elsewhere in the drivers :) > The strictness level belongs completely in the core code, it shouldn't > leak into the driver. It's already not about drivers having any influence on strictness, it's about there being good reason to treat these as distinct domain types through the core code, and as things stand those domain types are exposed to drivers, so drivers need to not freak out at seeing them. Indeed Any driver can "support" IOMMU_DOMAIN_DMA now, so if you've got time to come up with a way of making that completely transparent to drivers then please go ahead, though IIRC there were one or two cases where folks explicitly *didn't* want it being used, so those might need proper IOMMU_DOMAIN_IDENTITY support and a def_domain_type override adding. The thing with IOMMU_DOMAIN_DMA_FQ is that drivers *do* need to somehow indicate that they implement the relevant optimisations in their unmap path, otherwise using a flush queue is objectively worse in every respect than not using a flush queue. Given the status quo, rejecting the domain type at allocation was by far the simplest and most obvious way to achieve that. Once again, please do propose moving it to a more explicit "I can support deferred unmap" driver capability if you'd like, otherwise I'll get there eventually. Thanks, Robin.