Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9934937ybi; Wed, 24 Jul 2019 12:36:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/5sV14hm7RKCcgDAk2dY8APE2DuT4hIAiQBkD7ySVyet3slZgZGoq1fse7LlzYn/jArbu X-Received: by 2002:a17:90a:8984:: with SMTP id v4mr89020413pjn.133.1563997016554; Wed, 24 Jul 2019 12:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563997016; cv=none; d=google.com; s=arc-20160816; b=a7RGsCE2qYGCw19HmJTluDrWoeHU8D6xzc7PWFFBORrTfm/A9WRSGqS/GHeCaH97HM FVEnC7uvwYEjs3i6N9FVCygYdAxkLUAfNLVqRTvuu1PLyw+snXPTHRggdonm6HOcxdOK Fx2D62Gwtot9E9+Q3+dSe+wOHm2SRSTgruYJ2KFMcM4ZUebAPzkbcEwt6BhjnLqMN+Lk yOq9BkdnlRl74wcbiNSwwp+PZoReHktaL05+vbuiTSmbmZcz0o1MXifiFJSH9Qt0e7Se V5aOiiKrkGHfOaA3s5dFxYSL7gktxjUmS1YEmK5Eo/f4ceQBfXVVRdURsZ00EDD6EQmE G1jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lo+zKiHalndE7yOmDyIrODDa4RHAxVRT/3AhK1b+Io8=; b=zOjNiJYYPMasd/4edQH4X1xHhP58psFcpqEaBe8ZHMLko9eL40x2PNx/F6iI30iMAK ZFX+E3Rgiwb24u8/ic9i53P9wq7EuePmpWMULZZhDUIob4K+urF8Ld8U79EvYp5tN9ti t+DtpBlda4yp//M/v+Zcu/JYCW3FF9ptmWtuvkQGwkFqzcMSf/2ecEs1aidQ7C6RHPIy W0vWhtzP8XD2pTfbgBs81SXzyFClPk90jyHPw2mD3gxr1MRD0h6v2tg3kxxGht5Ou+aU GiT8nVmXIQSpu3UMEUteyc7fRh3qo/YFa24Vs/E+BvqI0uicvnqJ8v57K5tFk3PXQr1C Iilg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="lml/9AUr"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cj12si14492327plb.237.2019.07.24.12.36.41; Wed, 24 Jul 2019 12:36:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="lml/9AUr"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389050AbfGXTf3 (ORCPT + 99 others); Wed, 24 Jul 2019 15:35:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:55198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388927AbfGXTdY (ORCPT ); Wed, 24 Jul 2019 15:33:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6DE3B229F4; Wed, 24 Jul 2019 19:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996803; bh=Ag/Y4uB+I8AbYtTVHO4ERvH1pTAoGtX+TNBxH7ChFPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lml/9AUr61onDU/eTkilOunP5vaNnnDLJDJ9/wqggZqLCgJRCVlhN/RWoR232nbdx C9UHTPTBLQuZqcp15x6kVrMn4nEGFZOBNOFSpSP0zPUkkPNNAqilrXIZzT6zdvsYPA H2WTNIsFlaA7l+LbWGdK8DAsY3hHJxycN3E2b2sM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manoj Kumar , Robin Murphy , Jean-Philippe Brucker , Will Deacon , Joerg Roedel , Sasha Levin Subject: [PATCH 5.2 223/413] iommu/arm-smmu-v3: Invalidate ATC when detaching a device Date: Wed, 24 Jul 2019 21:18:34 +0200 Message-Id: <20190724191750.813644164@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 8dd8f005bdd45823fc153ef490239558caf6ff20 ] We make the invalid assumption in arm_smmu_detach_dev() that the ATC is clear after calling pci_disable_ats(). For one thing, only enabling the PCIe ATS capability constitutes an implicit invalidation event, so the comment was wrong. More importantly, the ATS capability isn't necessarily disabled by pci_disable_ats() in a PF, if the associated VFs have ATS enabled. Explicitly invalidate all ATC entries in arm_smmu_detach_dev(). The endpoint cannot form new ATC entries because STE.EATS is clear. Fixes: 9ce27afc0830 ("iommu/arm-smmu-v3: Add support for PCI ATS") Reported-by: Manoj Kumar Reported-by: Robin Murphy Signed-off-by: Jean-Philippe Brucker Acked-by: Will Deacon Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/arm-smmu-v3.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 4d5a694f02c2..0fee8f7957ec 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1884,9 +1884,13 @@ static int arm_smmu_enable_ats(struct arm_smmu_master *master) static void arm_smmu_disable_ats(struct arm_smmu_master *master) { + struct arm_smmu_cmdq_ent cmd; + if (!master->ats_enabled || !dev_is_pci(master->dev)) return; + arm_smmu_atc_inv_to_cmd(0, 0, 0, &cmd); + arm_smmu_atc_inv_master(master, &cmd); pci_disable_ats(to_pci_dev(master->dev)); master->ats_enabled = false; } @@ -1906,7 +1910,6 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master) master->domain = NULL; arm_smmu_install_ste_for_dev(master); - /* Disabling ATS invalidates all ATC entries */ arm_smmu_disable_ats(master); } -- 2.20.1