Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2407594rdb; Thu, 21 Sep 2023 19:06:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsM8ZRWcivC9eSA+z59UdqGtx54eLhK3xiN7Dl6bkHpu0jmdm0SstwSrTWF7aluQkGuX+r X-Received: by 2002:a9d:5e0f:0:b0:6be:ffdd:efb9 with SMTP id d15-20020a9d5e0f000000b006beffddefb9mr7538750oti.32.1695348372778; Thu, 21 Sep 2023 19:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695348372; cv=none; d=google.com; s=arc-20160816; b=r6N0Hr4S5KTugXV7ZE68MZ5u2Z+cC+o8GdcS+3l6cOm6UQAJ4LSMb46+8xChs58PUr Vlm+Bsw0gl9xWT4wtTLtHt972qtrBtGmuVPeOg46i9E2MkEsd6o0FcEp8RCI9f+ena1w zvvnZTr7jJTbzjRxIxOJPm0Kgmk6LSrD7kYtf7MQOW+pvsrMdDD04iA0pca9xvKci556 42AVGdz/vSIRlCPW0MltDVNyhdtppD9Q3sbCQgseUuYQwoYUr0NxBYooENwcdNSJ2n2i mI6MSGqwFqnYMx/ehsBldhjRTlVqtnxVJIxEd0qSXL8f860wsXzj7dTwyNoRbVTPvQTe aOOQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GedEWxpKSzrGPRM6lMkTBIu3LFHKqvL1k9LSqu1VR6k=; fh=argXuveD7EhXy5WWBpQeqoTKdzFS6uKIHBeTVsU7mtc=; b=0ynS4ZV8oVHov5eWdAGcI6zMDXD4zix4R5nnOnonuxm5vH9O3XQ6R/3sUcXwWR5542 M5nqtH4tpLFTBS057P6tSCmloXVbWTzUZnDXADbCKOrAoFSmzDf6EG4Aimi4gRbI+YO/ gn4zgJMaM5B8LaaZTodJspf99q64WxhFoZ+r9VSMJDl/5H/PGU5ZRBZhH8bOVZtNbouV ENQADUyu5B0XTRNRKY+3auu3RA3f5xYMKaA3hLPfV4Ee4ML7WD1afjRGEhqdLZmIE9MT 0HOU9xTGHipfweu7prwlZt7MHQYhY7L3FDBqVlPzMbxDHyY1EL8yTTWwlbIM3ufHeOYb XFOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=nymOKQgk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id cb11-20020a056a00430b00b0068e380c3654si2810912pfb.395.2023.09.21.19.06.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 19:06:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=nymOKQgk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EDB868387EED; Thu, 21 Sep 2023 16:34:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229870AbjIUXeM (ORCPT + 99 others); Thu, 21 Sep 2023 19:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjIUXeK (ORCPT ); Thu, 21 Sep 2023 19:34:10 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A5788F for ; Thu, 21 Sep 2023 16:34:04 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id 6a1803df08f44-6562330d68dso7998596d6.2 for ; Thu, 21 Sep 2023 16:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1695339243; x=1695944043; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=GedEWxpKSzrGPRM6lMkTBIu3LFHKqvL1k9LSqu1VR6k=; b=nymOKQgkXMA6woRCS2H0juZvdrRpL3SW+Hf1u5ftOTpQecml4IebiIRPBVClQsXPed BNFiaS8IXnJIGWImNlm3WRQbQ0SyOTk+GXmdwOXUxgtWo6JhmLZGYYCBj4KN+hkTjuwg ildXGaYheLJ77IQq9L1kRtLhQzT0rT9M+D9pfQpirThrq6zXeLXuquifT3nn1MsD+V9s jRMGUdiu+5VFar6X+EBXMxtyqbkNhNUgYcHDZy19wPQYEK40oOowu68Z60kbhjyQw7vQ Fr99DnK7xfniqJMmiVLOITqDycMPhaJ+nq+jv7uyecRAXuyhzBzXPY81RoMH0v04nOZT NPFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695339243; x=1695944043; h=in-reply-to:content-transfer-encoding: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=GedEWxpKSzrGPRM6lMkTBIu3LFHKqvL1k9LSqu1VR6k=; b=kUpIGfIX0G6FX9MR5oYaNfHLFSwTsVfjS1a46o8FIFF/s8oeeX2T29k/WQ+F1YR/0E SXEdcaXkkT+1+TSM9oHq1utUYF9F/4GkE3DAammRKbYmyPJ010KJHnH0HYcFd4CWDsg7 2I02KjDhc1ypLleRfNCh5vzH3FazltCDYH5VFrP95I+C5R+Uo1UtFy9MhaZBOyFED7HU nr9pATpZBhkbsR7l7OxxUjwkL+hIJCmWxAYMJi6nZUUAAvMBam79qZO/Ou9sz1scEJUZ /YVONEug4ORN6SNhDS3iO0jiWadcKlc5Rk0zOqFKRgRF2lZOXspgYb6SFws5HgmjDYkS SIXA== X-Gm-Message-State: AOJu0YzGvDvsVLkYA0MQFUORAi93KmkJfoKjP6EcIxxzg+PNZdNQ//Bu Lbyy6qyEbLwPRWeVmmF2f3PekA== X-Received: by 2002:a05:6214:4602:b0:658:310c:f6ca with SMTP id oq2-20020a056214460200b00658310cf6camr7598389qvb.42.1695339243709; Thu, 21 Sep 2023 16:34:03 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-26-201.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.26.201]) by smtp.gmail.com with ESMTPSA id o3-20020a0ce403000000b006263a9e7c63sm947595qvl.104.2023.09.21.16.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 16:34:03 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qjTBK-000Uup-Kq; Thu, 21 Sep 2023 20:34:02 -0300 Date: Thu, 21 Sep 2023 20:34:02 -0300 From: Jason Gunthorpe To: "Liu, Jingqi" Cc: Lu Baolu , 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 v5 09/12] iommu: Make iommu_queue_iopf() more generic Message-ID: <20230921233402.GC13795@ziepe.ca> References: <20230914085638.17307-1-baolu.lu@linux.intel.com> <20230914085638.17307-10-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 16:34:21 -0700 (PDT) On Thu, Sep 21, 2023 at 11:25:56PM +0800, Liu, Jingqi wrote: > > On 9/14/2023 4:56 PM, Lu Baolu wrote: > > Make iommu_queue_iopf() more generic by making the iopf_group a minimal > > set of iopf's that an iopf handler of domain should handle and respond > > to. Add domain parameter to struct iopf_group so that the handler can > > retrieve and use it directly. > > > > Change iommu_queue_iopf() to forward groups of iopf's to the domain's > > iopf handler. This is also a necessary step to decouple the sva iopf > > handling code from this interface. > > > > Signed-off-by: Lu Baolu > > --- > > include/linux/iommu.h | 4 ++-- > > drivers/iommu/iommu-sva.h | 6 ++--- > > drivers/iommu/io-pgfault.c | 49 ++++++++++++++++++++++++++++---------- > > drivers/iommu/iommu-sva.c | 3 +-- > > 4 files changed, 42 insertions(+), 20 deletions(-) > > > ...... > > > @@ -112,6 +110,7 @@ int iommu_queue_iopf(struct iommu_fault *fault, struct device *dev) > > { > > int ret; > > struct iopf_group *group; > > + struct iommu_domain *domain; > > struct iopf_fault *iopf, *next; > > struct iommu_fault_param *iopf_param; > > struct dev_iommu *param = dev->iommu; > > @@ -143,6 +142,19 @@ int iommu_queue_iopf(struct iommu_fault *fault, struct device *dev) > > return 0; > > } > > + if (fault->prm.flags & IOMMU_FAULT_PAGE_REQUEST_PASID_VALID) > > + domain = iommu_get_domain_for_dev_pasid(dev, fault->prm.pasid, 0); > > + else > > + domain = iommu_get_domain_for_dev(dev); > > + > > + if (!domain || !domain->iopf_handler) { > > Does it need to check if 'domain' is error ?  Like below: > >          if (!domain || IS_ERR(domain) || !domain->iopf_handler) Urk, yes, but not like that The IF needs to be moved into the else block as each individual function has its own return convention. Jason