Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp617953rdg; Thu, 10 Aug 2023 13:38:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQXU6dI9haw7jmi1jflPEcWRsrDts2pFKIJtO4MkvdBB/nNAvnqvCsDFIdCSSD0F9so56a X-Received: by 2002:a9d:4f11:0:b0:6bc:d519:d7b3 with SMTP id d17-20020a9d4f11000000b006bcd519d7b3mr3527667otl.37.1691699890823; Thu, 10 Aug 2023 13:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691699890; cv=none; d=google.com; s=arc-20160816; b=PbMDj0oKCWDanmxjmtxX79XDDXgmJCcw7h+CCxo6ntStUpskt49BdYMY13lfDT3fG4 J/yeqTFmf08THRIQi5QLcSCnC1sp3wIHi6iMT03ZRJDFV8yVbhp7MB1MGMVT3nd9sbMe HMvOvCNdm1ht9n/s9+S7CUwdwDRn4jHxn+IRCdczvbX/EQTRWiSYBrUxDk00Ov7iu3tw UW4c8mjCYxrNyqBcarp1/0E654XLGUmQ7LZwpEogN652E92VKLSQ6uHeRf0/mLe1yGKv 4UATNl2ZSMoZ60v/B7AICZxKsGvhvRxyHNytjh5VFo9naX2lH9yuznVAgGtk3ATl/ZSv yyxQ== 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=ol8o111D6X16s4/vdk4snMP1jvmYUyrjvsKNZNa6i6w=; fh=xltAmSPd/yLdUi9FHi45DAi3RH3y0htPE7VC5DZecA8=; b=kP7CReQ9+hWsjvxPu6/QhAU24w6S/CruDSB4UDOUrzIx7kWJvRJG0S52qSdn8PX7c6 EyMZu1yazMQ05DVbr+7Seww5az8q4DTlMni1BdST9WVYVWqmSrBWd8eBeHhUJhpJogbo S/CpX5TPG2j7nIEupse5nAYB96ibkrY8+8lOWg322Vv8usnKkUF4b0wL/LUpVchb7VHW CHZFqLhbqFVb9CEIw34wyh3x2NzkX9Tw+q1hCpuZa8yUwSUKF5D+RW+vKq2vL+tSQA2B dA3Wodhfczgpnw4oH8R7uWtZI2uOboDolHU1WOruVFH92hTcyB8TAJaeicstzD/bNZXi Re9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=j8xQ5eta; 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 o11-20020a17090ac70b00b00267a487f014si4092685pjt.167.2023.08.10.13.37.57; Thu, 10 Aug 2023 13:38:10 -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=j8xQ5eta; 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 S236199AbjHJTCr (ORCPT + 99 others); Thu, 10 Aug 2023 15:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234097AbjHJTCq (ORCPT ); Thu, 10 Aug 2023 15:02:46 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00BE26BC for ; Thu, 10 Aug 2023 12:02:45 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-76c8dd2ce79so102889985a.1 for ; Thu, 10 Aug 2023 12:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1691694165; x=1692298965; 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=ol8o111D6X16s4/vdk4snMP1jvmYUyrjvsKNZNa6i6w=; b=j8xQ5etaEWczcx0UpChvNBhWH4pGMmMqfPSDxt8lVA94h4iCSj/YmaLHgsOzPIgTtJ Ee00wZmKsoZRTdPbpngP3tdhd7Lzj1EsL3h4a+z/JQh5bZjk/le27wTBDpyMlffdee3q 1y7utSBEMRegnuHGC1K83jeW7N5jQocQv471zdiA7pNJJafQk/neRBMwPkjM+uzfUkqG wUI7nzmUMCP85you7O/gAEwhzYjpUypvAVIppJ17U/qxfotuNv1pQ0XDLhHy1baFJz1P xFf/ny3SyCb9bWjFwRiX5zAd3JxZ4WPny/ZCy0SVOSI3C43c0gXWVIaJuQhIhuPpJSif zrYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691694165; x=1692298965; 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=ol8o111D6X16s4/vdk4snMP1jvmYUyrjvsKNZNa6i6w=; b=OuuL3AtgNnfMbMRVZFP7Kqr5PWrtGGzZUZ1A0TXeJ5oJbANLhZQjl3kFM8D0cpF879 shLpn2FOEv9CH4HlWf1YjjGhdfG2MLk3+qqN1Gb6pl+wuA0LBSb7AdFS7GfdJM9BtReJ AtHx3CeHoFqIFhAgPjEQzRXhF1tBUzOSr+rFEvagLNbX8q9gwVHZT0SJ57JysKoXFegZ mlcLYNcbCs8Hi4iVC+x+faXxckWIOABsoutiQKpq6jDcCeiUC+wnDoNmYP1TBMocNtiH LSBe/GEvK31VQNyq3mwLUS+fMSk7GSN+5M2hDI+2OA/OnJwtttqo0NgfyydhPjzhEZR0 XDgA== X-Gm-Message-State: AOJu0YxmztbkhySZ7aKZIpqswVJkbm/gSmaJ9EQ7SQUQfREjKkU9w/dE hwLpl/tmIYsM4KwFja8yuSQB5A== X-Received: by 2002:a05:620a:4412:b0:765:a9d7:2ca2 with SMTP id v18-20020a05620a441200b00765a9d72ca2mr4080265qkp.48.1691694164969; Thu, 10 Aug 2023 12:02:44 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id g3-20020ae9e103000000b0076cda271e54sm680981qkm.112.2023.08.10.12.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 12:02:44 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qUAvj-005Ihx-JK; Thu, 10 Aug 2023 16:02:43 -0300 Date: Thu, 10 Aug 2023 16:02:43 -0300 From: Jason Gunthorpe To: Lu Baolu 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 09/12] iommu: Move iopf_handler() to iommu-sva.c Message-ID: References: <20230727054837.147050-1-baolu.lu@linux.intel.com> <20230727054837.147050-10-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230727054837.147050-10-baolu.lu@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_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Thu, Jul 27, 2023 at 01:48:34PM +0800, Lu Baolu wrote: > The iopf_handler() function handles a fault_group for a SVA domain. Move > it to the right place. > > Signed-off-by: Lu Baolu > --- > drivers/iommu/iommu-sva.h | 17 +++++++++++++ > drivers/iommu/io-pgfault.c | 50 +++----------------------------------- > drivers/iommu/iommu-sva.c | 49 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 69 insertions(+), 47 deletions(-) > diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c > index 05c0fb2acbc4..ab42cfdd7636 100644 > --- a/drivers/iommu/iommu-sva.c > +++ b/drivers/iommu/iommu-sva.c > @@ -219,3 +219,52 @@ void mm_pasid_drop(struct mm_struct *mm) > +static void iopf_handler(struct work_struct *work) > +{ > + struct iopf_fault *iopf; > + struct iopf_group *group; > + struct iommu_domain *domain; > + 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, 0); > + if (!domain || !domain->iopf_handler) > + status = IOMMU_PAGE_RESP_INVALID; > + > + list_for_each_entry(iopf, &group->faults, list) { > + /* > + * For the moment, errors are sticky: don't handle subsequent > + * faults in the group if there is an error. > + */ > + if (status == IOMMU_PAGE_RESP_SUCCESS) > + status = domain->iopf_handler(&iopf->fault, > + domain->fault_data); > + } > + > + iopf_complete_group(group->dev, &group->last_fault, status); > + iopf_free_group(group); > +} Routing faults to domains is generic code, not SVA code. SVA starts at domain->iopf_handler Jason