From patchwork Tue Nov 14 01:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 164697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1580359vqg; Mon, 13 Nov 2023 17:16:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IG641miPIhMt1CYSgRUFzggfYPPpEcsK9R4JBNb19T9QaSq9/ecekp7j3WByJs/35o10nz0 X-Received: by 2002:a05:6a20:8e0d:b0:13f:13cb:bc50 with SMTP id y13-20020a056a208e0d00b0013f13cbbc50mr1984010pzj.25.1699924582618; Mon, 13 Nov 2023 17:16:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699924582; cv=none; d=google.com; s=arc-20160816; b=XeFSLwNC3HrMrnRMkMmM7x1iam9CttYIN7xIN4Uw9aLgmLvv3I/GiAzjdJ1EJb6cYh NQ+W9bo282bamrt1PNG+ZFUQzSKDXEdD3UHk3W67OH/3ThnxshS3PqbFY/S4ZoUwlrUP 6n4aQj6PeaEngB9KAQqCJAzR4ORVFgD3mOHzw8YlEh7VEZ9L0cK+P/9dqaTuHc/KE6Lk csbMA8JNeqvJfG8463rDgbfQhgHBtetluwPMr3OSonpNr/Ot1fb49H71nVeLUINJx2F6 zflnlVUqvH4dUfj+W5uzoysKB+GwFvIMNzubf/XQuclAoAG8hhurLhCLb7qYrRnXWIxf 34YA== 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=GgLEvyRkjrvrOQy9GGPaDY/O58rfweXUrP+Eeh4b4o8=; fh=5K4v/0ku97kpa0vTvhWLyUEWwXZiIFVMmzwLLirrjJ4=; b=0xbuD+wyRYwGJ2Vhok7HF9S7pv2kAYGUliUzBtmcpc5yOud8DoUh6b4srBfZtNaY5r I6dONGvCcHrnyeNVuDMbXTwkE9RDrGF6mX7vTZQ2dnTxA9G1GfKF5dZvz5pg/i1QvaHE ErmAsdXt16pdbEaxZvoSDgReGw5ASR614JW8FE/xwTzjMm0JZ8M8N4EbpBjmP3DAcBj/ 9t7LOEsJZebWWRYWnZ4IKntbUqKR+XHeLd4ZGgXyMd5gfvfG13Zpmx1GjGpxHfPoUTTD 6i/VAEpBcaSRy5JZ/x4FyQ6YBzPFb6iLZK84HGvBcwQXbGjr88LuEcwgIJtQpKL9R7Sk wq8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LZhNXfpM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id c131-20020a633589000000b005ac8d44bad4si6567349pga.592.2023.11.13.17.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 17:16:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LZhNXfpM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 81A5E8092EEB; Mon, 13 Nov 2023 17:15:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231557AbjKNBPL (ORCPT + 30 others); Mon, 13 Nov 2023 20:15:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbjKNBPE (ORCPT ); Mon, 13 Nov 2023 20:15:04 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5BA4D5A for ; Mon, 13 Nov 2023 17:15:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699924501; x=1731460501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S/Mo+SEe2nMEOiLcS05N5VORyWVbnY8E6CLbpkYork4=; b=LZhNXfpMUADYlrle3BHoUpZIcFSC27t+fGkUD3kqCR4r4jm3D8KwEz5U Djn8gmsevry98Z+Ey20gko+7hOVIRzzd9ze+OL6yEgMHohHVAvnU2PbZE RaFZEg5K3lDWAxNOAocDLH1CPebWoPSuKn255Q/zyoTh0xt0HUH55Qwp9 7FP6Ed4X0WtCoqQleXhkwYq25J654qaiSUYW5k5CcOcVzp4CJaVTFDXBK q00QR63sQHC0gIqaXUV2bnfOk4lC/KksHlN4pLATutfPDqof9iZVj9q++ kBBs/MlAsByUzA9jko0fQ3Y9V3sQ7kI1WwoXjReVIAYBXusdFC70xcyY3 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="454833584" X-IronPort-AV: E=Sophos;i="6.03,299,1694761200"; d="scan'208";a="454833584" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2023 17:15:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="740928125" X-IronPort-AV: E=Sophos;i="6.03,299,1694761200"; d="scan'208";a="740928125" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga006.jf.intel.com with ESMTP; 13 Nov 2023 17:14:59 -0800 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 1/1] iommu/vt-d: Make context clearing consistent with context mapping Date: Tue, 14 Nov 2023 09:10:36 +0800 Message-Id: <20231114011036.70142-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114011036.70142-1-baolu.lu@linux.intel.com> References: <20231114011036.70142-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 17:15:19 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782500119177893484 X-GMAIL-MSGID: 1782500119177893484 In the iommu probe_device path, domain_context_mapping() allows setting up the context entry for a non-PCI device. However, in the iommu release_device path, domain_context_clear() only clears context entries for PCI devices. Make domain_context_clear() behave consistently with domain_context_mapping() by clearing context entries for both PCI and non-PCI devices. Fixes: 579305f75d34 ("iommu/vt-d: Update to use PCI DMA aliases") Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian --- drivers/iommu/intel/iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index c3ec09118ab1..061df1b68ff7 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3931,8 +3931,8 @@ static int domain_context_clear_one_cb(struct pci_dev *pdev, u16 alias, void *op */ static void domain_context_clear(struct device_domain_info *info) { - if (!info->iommu || !info->dev || !dev_is_pci(info->dev)) - return; + if (!dev_is_pci(info->dev)) + domain_context_clear_one(info, info->bus, info->devfn); pci_for_each_dma_alias(to_pci_dev(info->dev), &domain_context_clear_one_cb, info);