Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1008177rdg; Fri, 11 Aug 2023 07:06:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKC2m6qFWkr6nNlatZD5T6tey+TXuQSLCJa89R6daK70cR+Wf1G1OgDVXj6zw+j3hByz2c X-Received: by 2002:a05:6a20:a11d:b0:12f:d350:8a12 with SMTP id q29-20020a056a20a11d00b0012fd3508a12mr2675531pzk.21.1691762801921; Fri, 11 Aug 2023 07:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691762801; cv=none; d=google.com; s=arc-20160816; b=ApHLqDR3uwr6I1Uce+DubM1SKPQfiA7lYy8naC9aZ0lrD5AE9sxh+rslNCRSX+jVk/ r3rfhZbKDPWtA+BCpUHJidP5mpUhyfPLOHHO4ZGhb8nvOR6o8kYdMgNxHUXpQnOcCV62 Su+qYmTzs5VwYGu3aRz50YFcaXIMA+wlzmGQBbOCg5SxNfT3k1eGy/TIS72npN/la2Cz AUUiPNgqY+sExl+aeW2RPDkgAbNgfiFzhCksG4JftNq98bG4WAQwfEVbB+YtZ0dpDRKI Uz0kCgS5/yzFoODm7MfOcGwfPWzRf1YWnPpGWMecbg2ST2anr0sL72650xrSZrmnroPq MYGg== 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=8LOpgoLGoY3DjpumPQsfCr46GfyFnwJ6iRRs1mZps+8=; fh=FROtWkHcmTxsik+/ln5NelbIOlFcfMWoBfzDbH+Lmak=; b=J7plxfQhw4vwN+ombfvMu2g5gJTBf8cQoXNG5bz7RhYq4C7OiAN7RbwcyydXh5faR9 NmRJtkStuHaha+z0x0/o8gmYBFJFV9sLyG2D8kByEKVOTl6t+114Myl1vMCm49yMW+JW I1/d+upR7eDaxzBWxOME8tcQa+O4KQDiDMgn/G5b6lM3ko3wwBcxnzxSxgHRDm3n1Fc6 d7T0cNoQ2ctKaQGgqTp6v/ZPd7dLmv3+o/mzFyZiD6iHXLZO9csvn7+EY0UKfelfxGMs LRDNNolL7yMnItymA1mfuZH9DoC33F14hGgoBrhbKwZ5GP0x6huTp/4Vm7+qyjE9uePI PdWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=P23nqss6; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a056a0022d400b006875170380asi3563923pfj.121.2023.08.11.07.06.28; Fri, 11 Aug 2023 07:06:41 -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=@ziepe.ca header.s=google header.b=P23nqss6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235591AbjHKN3V (ORCPT + 99 others); Fri, 11 Aug 2023 09:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230486AbjHKN3U (ORCPT ); Fri, 11 Aug 2023 09:29:20 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63E8B1FDD for ; Fri, 11 Aug 2023 06:29:20 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-686be3cbea0so2198143b3a.0 for ; Fri, 11 Aug 2023 06:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1691760560; x=1692365360; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8LOpgoLGoY3DjpumPQsfCr46GfyFnwJ6iRRs1mZps+8=; b=P23nqss6FVvXml5SxPmyBOySoi8G56V8QNGw1aeNOAT1Kv2QSV9LHYmLlAxDbc2BTb X6o6yj1C+5iPCmclzAsBq8c01yvJd63vxN4x4DoJMg8Duwxnq4/CBUagn0SavWX0d8eG FJ6+frmZ0L/Z7WKdGHMkRKqKRmndj/aO/ZLYrUQk44b/3GpuP4AOux4smSG/g6cTP81L UQES66jdJvnUvW9fQ1TBxkUAa3lCRldj3aZOn0ttqJ3pbfrJP6ie8cgr/i6ptVkfPDIm bQYVuQiyXTMum16UfRPvpQLeEygFnDYFQx94Knx+zxFQuMzEy9Of8lEmoueGfMrwfH2P ArKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691760560; x=1692365360; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8LOpgoLGoY3DjpumPQsfCr46GfyFnwJ6iRRs1mZps+8=; b=WIPvycYAvjfvcgMDyvqIouOTe1hd98fiip6ZLufz8ZG0vzZM5tR3oG8ufw40TpV+s6 WSTRApuc7zbKwF7vw0VFVroJwafWpFBpqr6f9jyCttXNQxT5Z4UptsjBxxOe/Ok0ngFe w+enBxwr1nzO8GqvGklbg/FRnw1GDshivHykba3Iaj1Zlhc94PN6RgAkGZwmpEVM0cm9 MH8NM/Nps4crdIzMRFuMdkfV5nlshsfjkaCf1gRS6JoXNmmAf+JlFem/phPRwG4W+xdH bSZpRVjcK2bJv9iYM1MezRUC3jxjkDZ5VR7fto3GiYQYu59ku8pwYB+bO93j4/6Z3PLR YmOQ== X-Gm-Message-State: AOJu0YzcXzOD/1ShuzgNmL6eKFs3hYDOQZNXJWMJCErusD8iKn2xOnmi iFptWlBFn8/jF4j+j2fV1828hg== X-Received: by 2002:a17:90a:648e:b0:268:220a:7080 with SMTP id h14-20020a17090a648e00b00268220a7080mr6628903pjj.2.1691760559815; Fri, 11 Aug 2023 06:29:19 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id ju9-20020a170903428900b001a6d4ea7301sm3890733plb.251.2023.08.11.06.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 06:29:19 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qUSCb-005RAj-Ge; Fri, 11 Aug 2023 10:29:17 -0300 Date: Fri, 11 Aug 2023 10:29:17 -0300 From: Jason Gunthorpe To: Baolu Lu Cc: Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan , iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 10/12] iommu: Make iommu_queue_iopf() more generic Message-ID: References: <20230727054837.147050-1-baolu.lu@linux.intel.com> <20230727054837.147050-11-baolu.lu@linux.intel.com> <7fc396d5-e2bd-b126-b3a6-88f8033c14b4@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7fc396d5-e2bd-b126-b3a6-88f8033c14b4@linux.intel.com> 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,URIBL_BLOCKED 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 Fri, Aug 11, 2023 at 10:21:20AM +0800, Baolu Lu wrote: > > This also has lifetime problems on the mm. > > > > The domain should flow into the iommu_sva_handle_iopf() instead of the > > void *data. > > Okay, but I still want to keep void *data as a private pointer of the > iopf consumer. For SVA, it's probably NULL. I'd rather give the iommu_domain some 'private' void * than pass around weird pointers all over the place... That might be broadly useful, eg iommufd could store the hwpt in there. > > We need to document/figure out some how to ensure that the faults are > > all done processing before a fault enabled domain can be freed. > > This has been documented in drivers/iommu/io-pgfault.c: > > [...] > * Any valid page fault will be eventually routed to an iommu domain and the > * page fault handler installed there will get called. The users of this > * handling framework should guarantee that the iommu domain could only be > * freed after the device has stopped generating page faults (or the iommu > * hardware has been set to block the page faults) and the pending page > faults > * have been flushed. > * > * Return: 0 on success and <0 on error. > */ > int iommu_queue_iopf(struct iommu_fault *fault, void *cookie) > [...] > > > This patch would be better ordered before the prior patch. > > Let me try this in the next version. Okay.. but can we have some debugging to enforce this maybe? Also add a comment when we obtain the domain on this path to see the above about the lifetime Jason