Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4056538rwd; Mon, 29 May 2023 23:05:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6WHWdoRPpObZy2h8lfdryooo/H8qboNmzR4lS1q0/JIucf/0CqjrtfV3yAtze5OG0Xeh8w X-Received: by 2002:a05:6a20:72a7:b0:110:32ba:33d8 with SMTP id o39-20020a056a2072a700b0011032ba33d8mr1554164pzk.28.1685426726767; Mon, 29 May 2023 23:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685426726; cv=none; d=google.com; s=arc-20160816; b=fXnyzAzEVAbKGF0PFRl865xxfRe8qb47r3aiVMVdtse16kYPCXgKNW/zcG43ggRgSG bFbniqjDkzJ/LEcJYxgdPop6Fh6pIWhn3fsMwDJxnwmeM1xQdkRyuejVoqxl/qFSi4WP pRXsdBCQ8Qj+j15YwHPfziFpZr1wZFPytVDpkg3d6lAFuplpulF/FbGpczwwuNJx+S2K mtOArc3jLSVZAhPqXvghXvMEuvw+J5eNreX3Ob9biwfEth4+QDyIRhH2XqGxHP+aDnWE JbmzqSGVlC7zc89jL5kG8gpiX1SAoSppofAj/WrgvdPkH+nQG6T+hqhj4XtK1fp1bktv f2Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aN7IFQXTAFuFepqPqBh+/FQqrQcVnDF73a3DyEoG2S0=; b=LQzSc+wcbhzK3VV95m+zb2lEftbtod15rq9DuAC666kG7nZpfY5I16fJnI2plqE7nS x0jfQ/rUciodBxusfeY9qFmb0Au8pKCm7hrZQppw56CWcg5ywWGQ8MRH5lskuDa6LGQ1 dg7Jmxk++lK8nUpx22DAi38dRoXTUGL0xLq/gBxfzBr0iOooqcnEk2Id95BYwTM399Ep Xh/pr2tahqqTtaSMMwc/+M54yAMLTGciGtsMgads7jMpRC22xa84nw4ONjhB8JaWs+bX w0K5X6EqJMOZVdSqK5++KhFbfJeVNai78RdTPEPL+58DIYpop1B2tGjEkuSTJxexI9p5 NQiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PLebcoLR; 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 23-20020a631657000000b0051ae6c4084dsi5144796pgw.512.2023.05.29.23.05.12; Mon, 29 May 2023 23:05:26 -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=PLebcoLR; 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 S230226AbjE3Fig (ORCPT + 99 others); Tue, 30 May 2023 01:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230208AbjE3Fie (ORCPT ); Tue, 30 May 2023 01:38:34 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0842FAD; Mon, 29 May 2023 22:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685425112; x=1716961112; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4cYj8sTyvLBKZg/N54/ZRBBAlaG5CsvyE1vXMZic30o=; b=PLebcoLRb5OjFmUdFAOtZKVqGqbcDjj9LbpFXKwUhnudaVAFmYgZ64U5 zqPaoROMCtMC27FmhxuyKiKIJqibiU8N402QMpAkjtNA2kR7eCiHvNd8Z 9Mb1JyQpoiD9HPgP53uCaz7MvaTJ2KtOursNBta0m2VSAv+AI0OXSpuP+ fy6QVXaDhvsYPQ2WrUkUOetvnaa4e3bXXeBHX1RXHqNc9RUZBXcy2BriP GH/NgxwaWUHwirFNtRPVBrvTlCKNRBc6JVR5tkAyZfk3ePmJQs3kEJA0/ i7QCiiqsNRXYKL1dsCwRmLq5jkIIopknpE0BtRJwkWaXrsiDBCf6RWzc1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="420579608" X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="420579608" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2023 22:38:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="739369425" X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="739369425" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga001.jf.intel.com with ESMTP; 29 May 2023 22:38:29 -0700 From: Lu Baolu To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan Cc: iommu@lists.linux.dev, linux-kselftest@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [RFC PATCHES 02/17] iommu: Support asynchronous I/O page fault response Date: Tue, 30 May 2023 13:37:09 +0800 Message-Id: <20230530053724.232765-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530053724.232765-1-baolu.lu@linux.intel.com> References: <20230530053724.232765-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,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 Add a new page response code, IOMMU_PAGE_RESP_ASYNC, to indicate that the domain's page fault handler doesn't respond the hardware immediately, but do it in an asynchronous way. The use case of this response code is the nested translation, where the first-stage page table is owned by the VM guest and any page fault on it should be propagated to the VM guest and page fault will be responded in a different thread context later. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 2 ++ drivers/iommu/io-pgfault.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d6a93de7d1dd..fce7ad81206f 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -164,11 +164,13 @@ struct iommu_fault { * this device if possible. This is "Response Failure" in PCI PRI. * @IOMMU_PAGE_RESP_INVALID: Could not handle this fault, don't retry the * access. This is "Invalid Request" in PCI PRI. + * @IOMMU_PAGE_RESP_ASYNC: Will response later by calling iommu_page_response(). */ enum iommu_page_response_code { IOMMU_PAGE_RESP_SUCCESS = 0, IOMMU_PAGE_RESP_INVALID, IOMMU_PAGE_RESP_FAILURE, + IOMMU_PAGE_RESP_ASYNC, }; /** diff --git a/drivers/iommu/io-pgfault.c b/drivers/iommu/io-pgfault.c index e5b8b9110c13..83f8055a0e09 100644 --- a/drivers/iommu/io-pgfault.c +++ b/drivers/iommu/io-pgfault.c @@ -96,7 +96,8 @@ static void iopf_handler(struct work_struct *work) kfree(iopf); } - iopf_complete_group(group->dev, &group->last_fault, status); + if (status != IOMMU_PAGE_RESP_ASYNC) + iopf_complete_group(group->dev, &group->last_fault, status); kfree(group); } -- 2.34.1