Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp737605rdg; Thu, 10 Aug 2023 19:25:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJGT8ljlTXszA3SKEXSz0eZ4St6HE2v12+Lr/lVp8YzDNpIRfARHTM7sVSw2sSSVOxAn6o X-Received: by 2002:aca:2b17:0:b0:3a4:644:b482 with SMTP id i23-20020aca2b17000000b003a40644b482mr597498oik.52.1691720747559; Thu, 10 Aug 2023 19:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691720747; cv=none; d=google.com; s=arc-20160816; b=vPPjSbUcPFFEPYExkKxsSme2NwN1knDKT7J0BiZW7VpYG59fGvCAOjUDkj4gy7c1JM G0xe02V1gME72dIr3Mb+K76FmX9c5VNnCCADo5/ZJeo9NTFDC30LiJ3kJH3K+DIpJpxm wivh/ZlxXIqS3dJ6iTvqgeuGXQV6JkoY1yE/3/FZlpdnjOzVDr6eoeXCMFdHrZGV5twS I1MTkixCXUk4mJQnGtru9JU7Wm7nW7mg7q6kxejwDXTMvjaDbEOML2La6H91V1pg7XJz 8OzD4lgYRBcWlz/8MCQS9j0ENksBsuPOqE+g6jR/tKItfhcHeHyBM1EwAtf6kYkjMamQ BR5A== 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 :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=SaaN7tvk759BObBrZUhmfSpLvLa8u9qXsRwQtBKpibA=; fh=r+VlOdz9yHieXWJnz0Rf9gwDu6JsUzRZtfjjcVRKdpQ=; b=nqm6y4waiAcA5nreF+FYyphLGFGFCzK59bBZS3KieNeBr5v2DKuXdouZWyQa1udiLP e1aKp8pdETFeBX+bJhKj0c+/7G6UV/AaG2TR2q18v4TAP63qBezEmKRYlP3rpT73zotN 98ebxzopt2MirmFGn707QSVJaMBe//o4EgzuS7mFpqIAFE9pcLVCKUv8LpJAvHuWMYsM KEgODZatlZEt3W+YpwV8hd3lRDUIYZoJBglbZbi4desVUUHuHcFWhAnSSnxRGckvlqWs wufzb2Qd2AuknzkhTwAoKxhHFA6oChtO+zapnIvezeVGnd1o/C5gzTELYbJOtRRkQJdd YxEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CoNmGeF8; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a636903000000b005578994f212si2537084pgc.425.2023.08.10.19.25.36; Thu, 10 Aug 2023 19:25:47 -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=@intel.com header.s=Intel header.b=CoNmGeF8; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232628AbjHKBzP (ORCPT + 99 others); Thu, 10 Aug 2023 21:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjHKBzO (ORCPT ); Thu, 10 Aug 2023 21:55:14 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3050D2D52; Thu, 10 Aug 2023 18:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691718914; x=1723254914; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=IfHlH8JUVTQwrnI9x4YcZdegqcZ29aRj1abmEHrpcbI=; b=CoNmGeF8wOdLmoXeP8TmIqvQ0iri7KmvAim4PVCjjOK4Ci9B62w1EgQN tgWZP7I6wiKV/IoGfGfsYBKpVeqXbbziGG56XyKNZixjnMN3j/D9Clml1 F7u+GZwBQJPfLV2zDSfGfog+4U78Uet525ttqGeK+Xj8f80B4ZuN5GWZ9 z1iIndMWgqjOtsrZCXJyLvSteGXrxmmFU8vA27KwReE48LHnpqsT3ZXKt nnObYfCimUVZLUhAk9pgKgDfOcy7J0Y/ghiFrLIi9JugCcxoyKtImTzTZ 4yp8CEcr9eadKUmiX0sWZJjJ7iceyjwj3Y9Mq18un3Lka1J9DAhkakMUz g==; X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="374336803" X-IronPort-AV: E=Sophos;i="6.01,164,1684825200"; d="scan'208";a="374336803" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2023 18:55:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="802480468" X-IronPort-AV: E=Sophos;i="6.01,164,1684825200"; d="scan'208";a="802480468" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.254.214.70]) ([10.254.214.70]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2023 18:55:09 -0700 Message-ID: <74234ff1-492c-5934-49b6-69b08b732b91@linux.intel.com> Date: Fri, 11 Aug 2023 09:55:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Cc: baolu.lu@linux.intel.com, 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 Content-Language: en-US To: Jason Gunthorpe References: <20230727054837.147050-1-baolu.lu@linux.intel.com> <20230727054837.147050-10-baolu.lu@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,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 2023/8/11 3:02, Jason Gunthorpe wrote: > 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. You are right. This happens in the latter patch. > SVA starts at domain->iopf_handler > > Jason > Best regards, baolu