From patchwork Fri Jan 26 18:15:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13533105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96601C47422 for ; Fri, 26 Jan 2024 18:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Tv+nl3V/NxslMOArYaqdrklgKA9XoQsn2tp5AFGNaZc=; b=1WDNT6IyjcowBu 6TRr+HHGT2kiFL50FARKsqqpn+3nfXSNYHZzDuvAdocnLBfisbA4Gv/5P2YN+Vry8YMIUKhxgyTqm 0O8vbhz6InjID1EZ9bMssU6EnYPoQtsOp3NrWei9orknoAmSWoLqY67G8iaktot4Zech0vmGPMgXL GCNw8HbHo2cSxbrI47JFfeMIDWJ/eVtExXLaLNWjarhiatmifNpAcjeJriqRtW2vKjEFQBl9NN1HL Q/muwboAdQVLAgxKKdlQElSIUT/3li0hpPzBiPRan8z6OUorT4IScJTpvmifOHAQzfUqIrL4bnKli V8Tw/Xb+Rb8WLyQxeW0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTQkP-000000051sY-3gxQ; Fri, 26 Jan 2024 18:16:13 +0000 Received: from mail-dm6nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2417::600] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTQjz-000000051Ud-1wEi for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2024 18:15:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=koScWp7Si3684QH01G7oao7DYiQ1QQaExhWiCZBbT/+MY6FJh/mO8JvrKlxgA966smaDC83oXSbAWuzJmicsoi+Uk5UNZeOfBGgR9H7kHQEYb/8gPnVd+KRxJZtBgMkRYhzo9H21WwsO3SQtnsE/54Vyom4nEJU/hBHyI1MzjobddH6frSMn6pzihcSEATxfygFxEEvF6XAL6H6W2XJwR8bd+mv6DhAhqu2WBERmH+aVgQgg/5tYCxjligC4rn2ZocNyoDJhr8YUZs2Aj+g2soArLTye1UWK8QqaUDa0RdfXJIP7JDzf78eaxc+TBaSUVP/XvEh3lZ2ITCvuGokCXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5QmwQZ4cuOWhCzdZDns8VH3h4yjbgfnMJjHw/Bn9WvI=; b=BhS7aZuht4C0olQvArCghXRqNKv3eD9T2rMwPG0VFWsyluLQu7MVEGPj7UMivkGBeOdLVowK2y5q2FyJ5LEwYbu3iXC2tGbFWa1YdCrG7NkLxfYe+hCeuclku1C8TGarwMEFjMMmPMq4LjThsFdoLOeBkT5q8kNyvtcq9QOhBiS8crjxyHY+rC6218oX82pmsCVpaXrW96MAXCJ8qetNRefviK3H+0rij3t+bwxSGs+VUsZX1xvuMGgZvw1y/LR3dxXT4lE2EBqz55jLoG6o3jDQHj8Iw3TWwzsiklOD26rEpzdEwcvAqm/sf0E7tDfwfb3kiYdJ+zb4Uto3hN/Dtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5QmwQZ4cuOWhCzdZDns8VH3h4yjbgfnMJjHw/Bn9WvI=; b=l/41OOUQDsFZOFL1wA6cT/7Icbcn3yQovov5yEt0qiHOg1+eehMhVrtdoXC9jmcRVk7iljYvDis2pBkEwNo6YoQrp2M6ueF3LmTRQJHbnPkfRD1NDI8tTVTkHyBR5bfGwZvhKec77li1MaZ8CV6qK2NlQSifFQMV3xekyOBKFBkGd+vLgCbYnUD6m0aWPsDccOP59/Xqcc5lKqy2JxMKk3os5TiBIHw3GBsSuEHhiPZPzcARyQeaqFfWj587J+kK85PcJAT/EzfmdWMw+9mbkW/3qjFZuICt5yNtW0ydjSZyfNSf/WnAvbnxE5RTma3TMbIVnwABNx0X/9HlxLDfDg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by IA1PR12MB8079.namprd12.prod.outlook.com (2603:10b6:208:3fb::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Fri, 26 Jan 2024 18:15:32 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873%6]) with mapi id 15.20.7228.022; Fri, 26 Jan 2024 18:15:32 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Eric Auger , Jean-Philippe Brucker , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameerali Kolothum Thodi Subject: [PATCH v4 03/27] iommu/arm-smmu-v3: Do not ATC invalidate the entire domain Date: Fri, 26 Jan 2024 14:15:05 -0400 Message-ID: <3-v4-e7091cdd9e8d+43b1-smmuv3_newapi_p2_jgg@nvidia.com> In-Reply-To: <0-v4-e7091cdd9e8d+43b1-smmuv3_newapi_p2_jgg@nvidia.com> References: X-ClientProxiedBy: SN4PR0501CA0101.namprd05.prod.outlook.com (2603:10b6:803:42::18) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB8079:EE_ X-MS-Office365-Filtering-Correlation-Id: 491eda78-db73-4e93-61df-08dc1e9ac832 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: htPiFTztq4V3xaPEw8dym4GleqdYKF2svE2/s2NG9X63cJCQ6Akgpe11/QMyEsryDNZDxIBK0yTWXmkpKxg0Aeqz8DbBv0Hhpzd+oNlveGeWpdC7whWWUIqQXjflZNQ+AsPfuk38QXMbJ52xd3yt5oYOFIXrG879DashC8Dc9mzTZioPKZ8kmgdAhPuno67PztopDRrnIaSRNC+oDzk6PGBwgXXTML0L2019vO16rKQBvCtJyVTuk5gXzwTFiIa/wt0edV5erpcKFH2kt0JzQmT6zkf+qD61n2DbByEVeh4PLdE1dlwQTMU3n1OjvG3aDr2ZNQJYTuPU+eED65GAjKJ5ocTrr5LSHfmOdiAg53DLi62+M5UmNiXhUzgH8kTvQ79RP3Cy4+4YaNFZzLzBERWmi/9fvEu9IBJzXEqfksrmLUVz3tQqOsQygLkAeLmzjmdm07huLIFmmOZOzmCJ6wToAyMAXOb0sEcMPSfDnKeZldNew4b59QiTZ9AZjAjwUwPzpYYuFULEEyc0HbCgAc2pvMNCexT19hNpQ+SzdrOyv7sAaN9NuV/gJx/+kLkaO+dw/6DjKhhVtbkztUFD3HKPpZf9uYbDMzKW52NGjxA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(39860400002)(376002)(396003)(366004)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(83380400001)(6486002)(6512007)(38100700002)(54906003)(2616005)(5660300002)(8936002)(478600001)(2906002)(8676002)(4326008)(7416002)(110136005)(6666004)(6506007)(316002)(66476007)(66556008)(66946007)(36756003)(26005)(86362001)(41300700001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VUU0NodfsEYZy2+i+A7vInt9aE82Ki5p5KjbgND/ftpFOLEqxtgXllNrSsCU+IJkdO+DCBr7R9ieToGnd57+IEHp8klsf6TmdJkielmaq1czJ76jwkWKzoYSTU45OaZXSIJ35D8sKfyaB7XilF+DNeuIUMqd3aHOmiZsLxsz/ZVNJVNVSS7s+0iJl/Gf4AqUldC/L5hJu5vuYVkcgVkG8uvlBVidndgCox/j31LW8LyUQr8Ia77W3oyqN9v9EyoU0tvTTZvzppKB3jXCijxoGoMSTNQSdQQT+IOG6UsSLyBjXsErCphL63ajefi15Jb2ZuAREFy6hSDv7etM1KbKQMZErHXlHpsQOW/DyskxiVNt/VZ1P/eAixKCrhqA1Q7Mub8lROEKU8mOq1MLxBd85SrMwMLe9KbKjupOCWqYGQ6N8pIutl0daq37W7qx5KThi3datax9Gw+oVB6QiY3vTkPextgXmCKCog++OkHWC7bMzqLeK3jGpDIZWBdC1gjyie8wga92fPALGa755d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G1lu3WXJKdZIYO X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 491eda78-db73-4e93-61df-08dc1e9ac832 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 18:15:31.3065 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3y2PLV2VL2dhWGo6X3jpi5Q8As0j6yBpjm31IHIhG87IrZmuRrxUweFIhTPK9N3k X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8079 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_101547_619740_0ED23BEF X-CRM114-Status: GOOD ( 11.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org At this point we know which master we are going to change the PCI config on, this is the only device we need to invalidate. Switch arm_smmu_atc_inv_domain() for arm_smmu_atc_inv_master(). Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index f890abe95e57f7..710016ec41af13 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2471,7 +2471,10 @@ static void arm_smmu_enable_ats(struct arm_smmu_master *master, pdev = to_pci_dev(master->dev); atomic_inc(&smmu_domain->nr_ats_masters); - arm_smmu_atc_inv_domain(smmu_domain, IOMMU_NO_PASID, 0, 0); + /* + * ATC invalidation of PASID 0 causes the entire ATC to be flushed. + */ + arm_smmu_atc_inv_master(master); if (pci_enable_ats(pdev, stu)) dev_err(master->dev, "Failed to enable ATS (STU %zu)\n", stu); }