Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3807973iog; Tue, 28 Jun 2022 03:14:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s0qVcfdp9/JU49RcQUaXahAxuZorTJV7Z22qMphj4oFXcPlXfHQLkGtIH23kkxsjxhIBOn X-Received: by 2002:a63:4c:0:b0:408:c003:a45c with SMTP id 73-20020a63004c000000b00408c003a45cmr17456316pga.252.1656411288366; Tue, 28 Jun 2022 03:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656411288; cv=none; d=google.com; s=arc-20160816; b=DY9nGO+SF4x6VC/bYl5UdZ/1C2uMKpTC91SrMUSodQolFEAbKXGpqH56XBRQ8RKq6N +VjlK519CtKYmXpV/guAV92VJqgvbgfPevGMnDqddjkWXixv1VL3iXWGQ2DYS5HVsWt0 Dp9K3BvH42/IIi+nke5Lf2laQNSuVqDXBXDm0l9By3ndzmCAJ8ufeyIX560F+wjEW1PE eRKlXlzZ2LewjkVBgDekuCWfrmWbbvJFKGn05I6QZWc0GNK4dW1S79TkFFnO9bLXEodp a88Fe6o3auV8wMgn0EAY3Fy+uQO8c+7wnDobP96iej+YNXChpiEgwhVTe9TmCmULIru7 p9IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wi1R/bUTiY7+3hGQ5VIW8xv0nt+HW5ohTHS2cOsUuxA=; b=EggKuL4f69nRMZr0HgmUhvw1D3V+YSRYGk7BiVUm0uH8geT56l/z4Fka0b+d37//m+ /ZYyt1TlliylPsY5XxKnf4uIFgE5cajFrGBlNZvyXm5k1NTaLlKow6yIbKlKkFEPPHGt Kcb0erBMrxnHLX4Z89cgLOTxs2KPJOrvKGv5TqdTjyfa873wgIsCJ1AJE6rhx1mAMpwQ myUEaj7Ibh7DfM0ixYIX7E+Ddj3WTv+yaPdiFjPjQFFDXYvO7k0m+PG1owPdYLq9HDy/ 12TouJUsqxm5bpO+pUxNQCP5x+u/SJT4jCqk8wdwDLxjpf9fxhX0CMZF4LOsg/6TCM+H XmOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eCCsODKy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t5-20020a634605000000b003c1ff3d56a4si15403548pga.386.2022.06.28.03.14.27; Tue, 28 Jun 2022 03:14:48 -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; dkim=pass header.i=@linaro.org header.s=google header.b=eCCsODKy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244961AbiF1Joj (ORCPT + 99 others); Tue, 28 Jun 2022 05:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241860AbiF1Joh (ORCPT ); Tue, 28 Jun 2022 05:44:37 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13BA25C68 for ; Tue, 28 Jun 2022 02:44:35 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id c130-20020a1c3588000000b0039c6fd897b4so9054047wma.4 for ; Tue, 28 Jun 2022 02:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wi1R/bUTiY7+3hGQ5VIW8xv0nt+HW5ohTHS2cOsUuxA=; b=eCCsODKyUzUbN1l+lGklBxP8DoyEl8UmwdVrUn6DZyD9ii78730U+Cbd30f/zxSYeI yCiAHujMhO733mZ5V6alMA8quWRk1Pf5nh1HVEohYgs3Gja59ggRrPil6gz/kA+3tXX1 A4lhouHwDfP9cSkOeBmKou4+fC1/rLn0QJhxTThQtXEV/LHO564Di3ht8/rwb+q0l4f/ LAwjukId2/g9qceJansG1tgOOMtQ+w8le1lsc3ODF9mnJaMHi60ySGLEEN5+Ge3AKlba LaWoebxIcMycIJgzd5O+WwYc7juwHC+e6SmYoZgOgMU7SArd7RwqeY+9M7IamZd5NPKg Rtrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wi1R/bUTiY7+3hGQ5VIW8xv0nt+HW5ohTHS2cOsUuxA=; b=iIFWBtnY8zw9c7dq8UnrczRsiGwyLib1Zv9+Nnc5Ld+nTtCrltK2DSMmZH/INLNgm1 He1qXibNi/DT577TpMwz/6Zj4JlDc0dXVQnWlVclyuUqhuyfNyx2xanmtvbTMJ6YdSHA dR2Dm+JT8M2uMe8USbxbvBSDwqZ+V8nOknC1IHnrch/DZzHK0tl2XrNR1lVMVZAwRF7v x0l17A5C1oGXPxa7NxazX0jvLr5BGf/Oq6o7iMYlzc4PcawePGt9A2XQoVWm9pCEFu4I aBk1ePh5lkRUQWL8O800HiZ90Am3QyZNwtLMiE/nhRtFXkzK9FOcxWDf5ajjMXVDZIav RHoA== X-Gm-Message-State: AJIora9kEiRKfljLC8kccGxrymLGrEf5R9kna0NfioOsOP+9NQeTHfHX VJCdc/NBaPIllk+kJFnrGVHugg== X-Received: by 2002:a05:600c:1d0e:b0:3a0:50bb:55e0 with SMTP id l14-20020a05600c1d0e00b003a050bb55e0mr4035158wms.89.1656409474286; Tue, 28 Jun 2022 02:44:34 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id j9-20020a05600c1c0900b0039c7f790f6asm22093111wms.30.2022.06.28.02.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 02:44:33 -0700 (PDT) Date: Tue, 28 Jun 2022 10:44:10 +0100 From: Jean-Philippe Brucker To: "Tian, Kevin" Cc: Lu Baolu , Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , "Raj, Ashok" , Will Deacon , Robin Murphy , Jean-Philippe Brucker , "Jiang, Dave" , Vinod Koul , Eric Auger , "Liu, Yi L" , "Pan, Jacob jun" , "iommu@lists.linux-foundation.org" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v9 10/11] iommu: Per-domain I/O page fault handling Message-ID: References: <20220621144353.17547-1-baolu.lu@linux.intel.com> <20220621144353.17547-11-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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 Tue, Jun 28, 2022 at 08:39:36AM +0000, Tian, Kevin wrote: > > From: Lu Baolu > > Sent: Tuesday, June 21, 2022 10:44 PM > > > > Tweak the I/O page fault handling framework to route the page faults to > > the domain and call the page fault handler retrieved from the domain. > > This makes the I/O page fault handling framework possible to serve more > > usage scenarios as long as they have an IOMMU domain and install a page > > fault handler in it. Some unused functions are also removed to avoid > > dead code. > > > > The iommu_get_domain_for_dev_pasid() which retrieves attached domain > > for a {device, PASID} pair is used. It will be used by the page fault > > handling framework which knows {device, PASID} reported from the iommu > > driver. We have a guarantee that the SVA domain doesn't go away during > > IOPF handling, because unbind() waits for pending faults with > > iopf_queue_flush_dev() before freeing the domain. Hence, there's no need > > to synchronize life cycle of the iommu domains between the unbind() and > > the interrupt threads. > > I found iopf_queue_flush_dev() is only called in intel-iommu driver. Did > I overlook anything? The SMMU driver will need it as well when we upstream PRI support. Currently it only supports stall, and that requires the device driver to flush all DMA including stalled transactions *before* calling unbind(), so ne need for iopf_queue_flush_dev() in this case. Thanks, Jean > > > static void iopf_handle_group(struct work_struct *work) > > { > > struct iopf_group *group; > > + struct iommu_domain *domain; > > struct iopf_fault *iopf, *next; > > enum iommu_page_response_code status = > > IOMMU_PAGE_RESP_SUCCESS; > > > > group = container_of(work, struct iopf_group, work); > > + domain = iommu_get_domain_for_dev_pasid(group->dev, > > + group->last_fault.fault.prm.pasid); > > + if (!domain || !domain->iopf_handler) > > + status = IOMMU_PAGE_RESP_INVALID; > > Miss a comment on why no refcnt is required on domain as explained > in the commit msg.