Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp999906rwl; Fri, 24 Mar 2023 05:06:22 -0700 (PDT) X-Google-Smtp-Source: AKy350aAGkpscgvCykZI2sOLSdQNlo+KQvkYKj1hNGSkiAaeOlDENHzWw4PZlEn3XOz75hjWXsqP X-Received: by 2002:a17:90b:3885:b0:23a:6be8:9446 with SMTP id mu5-20020a17090b388500b0023a6be89446mr2549366pjb.48.1679659581806; Fri, 24 Mar 2023 05:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679659581; cv=none; d=google.com; s=arc-20160816; b=Uda9GMVaGttfSZuS5N4at74qLEgNoDwxYlrdb2reqfRZ42zEBUrp+qvmTTEURf4JwB MXs9w4bdmHxkKIGv79m5MGXhk++B/L+r/U2Eu3Q+imaAZpQiJO81w7TdTFU0qxSKGpJu 9hd9akmz4WEIZgJeqT0G1q8VDYo7iQEicO+plrCRqFTDYXvkRDLaGC73D76eaTIDaNOp TNKQrKdzJmMe+CSyWh034i5e9Jnl+QHjfKj8HVWBSrvULmyqVHCJxiJCazYLqavDW3VU PcU0LeKQ5nxJxxudW+m+lvK0cGF1vvFq1f9YdmvYerVkcnINGhtA/41vpS2imxZiUUZ/ 3HQA== 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=VqftfafkG8Qc4HhH2K2mFjxYxGgS4ILhCjDbKnbYsIU=; b=h3EUC9mYQb6E2MezpcM6RGK/k1JfhJ4zQLNahqRrmSLLqI6NnxFz4Ye9OwOYHFHKXX XwRK2psTAY95C7DYypbQg7ewDc6saeuO+GwnFcK7BCTouBPJU7Y8hiF2w7b25BNPCpyZ AKap1tmgaHVfrbwSCfeTQ1+XNEei6L868j9NXFinjkdJnf5stfFoqBRHpy1Dpd6fJwMK NRaI6Yejfh41eKHDlc2R1Zdj47u49LuSkaJBrA6tFEmMVeH2bxbbkBPScg5ckrnpMuV5 Vv2Xv3zJNOoEx3UC7hSKZ8HdJFIT/L9h4WVUdRE7FU28WnPhb0WsmArn/fEzbgba1hn5 dvnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tp5a5DlI; 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 c5-20020a6566c5000000b00502f344050csi21887018pgw.313.2023.03.24.05.06.08; Fri, 24 Mar 2023 05:06:21 -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=Tp5a5DlI; 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 S231857AbjCXMDJ (ORCPT + 99 others); Fri, 24 Mar 2023 08:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbjCXMCv (ORCPT ); Fri, 24 Mar 2023 08:02:51 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A205265B8; Fri, 24 Mar 2023 05:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679659361; x=1711195361; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M/Jk/NyOL6YOkh9WpMFp/FMLnkzRYwNbBzLyoNFzzAU=; b=Tp5a5DlI92vpGpnCNmXRTLEMyGYXWHELMjRzcubt+IXqopxokZmzqfSW KVSN/K4KyaboIXyMOiehaL3XB5f6R1ZWMjduEBj56Sv/oZXVUYU2goAvK 5VbV+QrGuVMk4L6DHat3uMMRt2WcZF2ZUdb0TLcB4k+AxCRd8QucJSKys 89HQLLUybgG+nAwV4980m3FlgoSsJcBkHx0+kbrPL2hWtRBdAYUFeKtkf kQzvBdqY6XWAu2splMDWXmziMo4J5r/lzKq+O0+b3GvVF5j4tqjQkSkLO 9dgZMZzQ+W1F1XjNd3hPwzDnhrb28DP2wakcng75YVM0MXbDF7p1Fwe8o g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="323634194" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="323634194" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2023 05:02:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="682674914" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="682674914" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga002.jf.intel.com with ESMTP; 24 Mar 2023 05:02:38 -0700 From: Lu Baolu To: iommu@lists.linux.dev, dmaengine@vger.kernel.org Cc: Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , Fenghua Yu , Dave Jiang , Vinod Koul , Jacob Pan , linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 6/6] iommu/vt-d: Remove unnecessary checks in iopf disabling path Date: Fri, 24 Mar 2023 20:02:34 +0800 Message-Id: <20230324120234.313643-7-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230324120234.313643-1-baolu.lu@linux.intel.com> References: <20230324120234.313643-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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 iommu_unregister_device_fault_handler() and iopf_queue_remove_device() are called after device has stopped issuing new page falut requests and all outstanding page requests have been drained. They should never fail. Trigger a warning if it happens unfortunately. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index cd3a3c4b5e64..c771233d6f2a 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4707,7 +4707,6 @@ static int intel_iommu_disable_iopf(struct device *dev) { struct device_domain_info *info = dev_iommu_priv_get(dev); struct intel_iommu *iommu = info->iommu; - int ret; if (!info->pri_enabled) return -EINVAL; @@ -4723,15 +4722,15 @@ static int intel_iommu_disable_iopf(struct device *dev) pci_disable_pri(to_pci_dev(dev)); info->pri_enabled = 0; - ret = iommu_unregister_device_fault_handler(dev); - if (ret) - return ret; - - ret = iopf_queue_remove_device(iommu->iopf_queue, dev); - if (ret) - iommu_register_device_fault_handler(dev, iommu_queue_iopf, dev); + /* + * With PRI disabled and outstanding PRQs drained, unregistering + * fault handler and removing device from iopf queue should never + * fail. + */ + WARN_ON(iommu_unregister_device_fault_handler(dev)); + WARN_ON(iopf_queue_remove_device(iommu->iopf_queue, dev)); - return ret; + return 0; } static int -- 2.34.1