Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3586236rwb; Mon, 16 Jan 2023 09:55:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXt5JFVUM7xG64ylRuVT89phAyv8/UKXFbo53Qlp5HyJMKAhgVizGNk2c/U2ui+rjWVTw4B1 X-Received: by 2002:a05:6402:189:b0:499:376e:6b27 with SMTP id r9-20020a056402018900b00499376e6b27mr175304edv.5.1673891727466; Mon, 16 Jan 2023 09:55:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673891727; cv=pass; d=google.com; s=arc-20160816; b=SRpYszQwiuAtVFim/VQdMLznVnXiiLVbiBgfFk4bUqoeaLJriS0OXBs7AaXwQicPWn BeDw6wIU7Z0Y22Pdq4S0HLsjtDbYUEcbB7hlDug6aZt3qg4BabtaNHOOiSXhuyipkuR9 bYBKLBT7WfZI9yKt5QojOcYHDirW6DBbX0Zunw5G0w0mlfbWRwhYv0DPTAPuQQuIF/Sb 1zikdN5gok9/SCRG3cINXIf7WRDW9CPoT90nWF4HbUD0IruYiv3O97gZ3ip5wq90tW1I T3iYbzxGdSb7a/lMUL3im4IqRq7fVjupl7aVk51+xNyaRAGKYoRjvaUgmuk4fXcvLIaP MvLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=7Pi7PQavYvowI+ojX1CZBqATdwmzD7vygis1tykgKis=; b=Enigk9f1qeXYoTwIfpYxn6gdLC0Fpmix83e/DZ89vicElSH94uIJgc/Frdhn+WTGXz bMRs13fpmfqpCPuuGQtXNs4eUrWO8i00KUXb/6dejWXtuwoJcBkMtf1EsjGcBSEVfcYm Ud2t577HJjeB3EOQ+Y11iym8V5J3PUsWmf1EiG24jno7kBSnmBXRYPqsR8BNpp6h0Ebz befZmq2wRPRTDyZmbuypW6DTHlPrfHMVdgTw165dIHmoNXHnSSAw7kOzr5Dn914qckvr iaiFLUcVlgJawX/YC+jQVl9NVHWWspe66ZxCGvo9LLEqWp5JAYFT2ebejUnyw80Pq6KH 5Kmw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=QjmUQqPD; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a508a86000000b004912ada1d97si30741741edj.173.2023.01.16.09.55.15; Mon, 16 Jan 2023 09:55:27 -0800 (PST) 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=@Nvidia.com header.s=selector2 header.b=QjmUQqPD; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbjAPPmu (ORCPT + 50 others); Mon, 16 Jan 2023 10:42:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbjAPPms (ORCPT ); Mon, 16 Jan 2023 10:42:48 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2082.outbound.protection.outlook.com [40.107.212.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EFDC7ED7; Mon, 16 Jan 2023 07:42:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTptGHOpus90+3ou3kvIJsLxMtqvrOl74q/ipTAdQosgc1JG2h9YsXGkcXPZpa8RP1YdaEvuuAIgKPse8G8qTeWcKNXY/vG/ASjnQqgHcqgoTCKnKdxtGRa0HBRopgc5k89Wk95NJBKU1C8T7xj+iLCPxfqGH7qppkEQX4gyJ7k0S96meRHqQyjvm5a3SHHo7F6NY4CkzXX5YtOQcPt2squ7gDLciMibGdMkug7V33aT4tdSwQVckGb06e8wKG61+sffZhj2YS/qU7ocbvjhm4XqYtryl36fQJb/Y5ZwfImoF/5zjkz3UHMJtHYpehz91E76rq+Ep46ZBg6G+8NHsA== 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=7Pi7PQavYvowI+ojX1CZBqATdwmzD7vygis1tykgKis=; b=MHHU3TEVaJSkmF91lWT0M49zdiTF2NHR+CqjLeftgfJyWW+mCX6Km0KioEuH9SrMsQOFW+EIbmB1yaTeIRRwBuFsLO4o309N6enabDDB5d33cW2h2pO6N50+kf3dtVGxg/dpY868Z5KsIZuvXhVG8BApDTKU51YZwVP/wM84rU5X7rvL5yudoZnCq998M3/r0lIYEi+HkS61MqW760wEogBss7PViDcsRiXgzoV8YXge6znvF1Vtx8fhm1EY6IjM4pVMy2PbgFp5t+S+RnYf45vBN87qgQBJ/edncSnZl7B11zFTVbdNZ2VbK97RPfY6kjsHwnX1xL7t5dD9vDwpdQ== 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=7Pi7PQavYvowI+ojX1CZBqATdwmzD7vygis1tykgKis=; b=QjmUQqPD0aFT0EqnI0Zr45NgxOH+j0mcdO2KNj3rXcM1l4NX8xQTYA0MP0AGBCz9xxXrkKb/pncZ5BXjdLUoDay4fswEzM+6b1QNvDqM3JHzXAyjmzn2pAw4m8iTKK/T2vLV8JLFdTWkk/LeO5vbWbnfJ1L1Gls3SlQ9m/kEm6XyWJeX47daOkG8gNGk26rhMKyq3cff8ljCXslPpad+Jw8DlmTc/r9SKnuBHeu/0D1ntxBv5Zo4E9D9/RxZcgITkCwrZExPdrnd4qdjiT8SH2gOkOYV/rIQ75YTcz3GKDgDppkZeZiRbiO4moaXTfUp3URGhDSP9JphqjZ0e7lVbw== 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 CY5PR12MB6384.namprd12.prod.outlook.com (2603:10b6:930:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Mon, 16 Jan 2023 15:42:45 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Mon, 16 Jan 2023 15:42:45 +0000 Date: Mon, 16 Jan 2023 11:42:43 -0400 From: Jason Gunthorpe To: Lu Baolu Cc: Bjorn Helgaas , Joerg Roedel , Matt Fagnani , Christian =?utf-8?B?S8O2bmln?= , Kevin Tian , Vasant Hegde , Tony Zhu , linux-pci@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/1] PCI: Add translated request only flag for pci_enable_pasid() Message-ID: References: <20230114073420.759989-1-baolu.lu@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230114073420.759989-1-baolu.lu@linux.intel.com> X-ClientProxiedBy: MN2PR18CA0011.namprd18.prod.outlook.com (2603:10b6:208:23c::16) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|CY5PR12MB6384:EE_ X-MS-Office365-Filtering-Correlation-Id: 29f89b59-7386-49f4-a9be-08daf7d84faf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o1TrsPxPc0GpjFVyrlwoqwhzdSX5zq+TV375GR6J1WYkcZzOabHnSIR/Eqf63UP/boCIB48P4VT8OXIJ9FsTU3K6I6cLQ6CgWtXBJl7ojD2n5FFMKFVh8ealHaSWYmdNoK5etbvFJO++SlufFWDgWDNohPzTMqHBtU3W1QbAVnhSM6Q6tD3CQrNsKbwSPHTjAS5b7uD+2DDqZR3xOq+BfQIPKzs8zjNS31rNv6qLsHP287ys6bwe7WTrtbmzXwGaIkanLPGrrSmMIxGPtM0bGQ9T9SpEVaWPScWTZyBvBZQHeQCgWhO9b/rn7YKy9OPlZ3z2jSs623X69IUxbuUiPbwWk4g/nrRAPu+dwFTwSWw16ghD5fCvY+qcZPgVmlOb94xcSUO704m5D0S0hickc9XC+RBItODGB+Vdo1yRodZgZdT5Q0dMiFm1bXTgoFEzQwymVA83cZ008MMfZjVYSJarD83/WpLYAYuKGHgWJURLEKh6vxBtwQRWLseJzw9i6lSIlKSSXLSZOw3Lty3DJPKxU/gvNl7DnN2kkeNHrLCLw9JaF0TyY89OIeb2rWSvL+gRpmreQj9JhG8bQDX6a0EI49+sL+vQxNOAe2cVD0pcwc5i0TmjZmEVROZ5IKWsiJIN9efATyoh9dKzawP+w98ztDE3Pg9hulIisUiD1hTlZVNIuSyDesChIeSSnx46xDNZCd73T5YrEcukzKUy1x1FpXefRLgjaykwTuFs/P8cR3RhqCulvtDbTkjvIp1ckHatNMBy2BmYGGrqST9NsA== 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:(13230022)(4636009)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199015)(2616005)(6916009)(66476007)(4326008)(26005)(8676002)(186003)(6512007)(66946007)(66556008)(478600001)(54906003)(41300700001)(66574015)(8936002)(7416002)(2906002)(5660300002)(83380400001)(316002)(6506007)(38100700002)(86362001)(966005)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QjFzWnRIMFhjU25LNERTN0hZSnpJQ3JoSzhtb0MwcW9uTFp6d1N6ZEdiT1Nj?= =?utf-8?B?LzFRMEZzUlVzRjFxUlptYzRkTUxmclhMZUdCN0V3cDNQVVFXbi8vY2dKMjFE?= =?utf-8?B?VHVOa0o1UUpxYmxsVlpuZnpCWFpQaTZ2SXdJN3NNdXlPZ2VET2JWc0JETzMr?= =?utf-8?B?VWRKV09KRU9yelp0RVhIVXcwMjFHbDBHMjNDUlVkdFE3TS9DcHo2bjdmUlls?= =?utf-8?B?Y3MvSis0bzB5ck80ZDFWSVhMaVZZamF1elFqeFRSOHllM2JHNWZuUm9jZ0tC?= =?utf-8?B?clhiRlgvR2pOb0NJaU9jZlNaVnVaYWdTZTZCRmV5NjU1UXZIVUhQR0lTNUUv?= =?utf-8?B?VUR5ZXNvYTM4cHdWSjJxS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nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29f89b59-7386-49f4-a9be-08daf7d84faf X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2023 15:42:44.9348 (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: jLdi1pccP4JdR1SOkytM615vbKFoT+rzE72pRuygz6Wlba0uP1V/jVZxnuu9F7wl X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6384 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no 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 On Sat, Jan 14, 2023 at 03:34:20PM +0800, Lu Baolu wrote: > The PCIe fabric routes Memory Requests based on the TLP address, ignoring > the PASID. In order to ensure system integrity, commit 201007ef707a ("PCI: > Enable PASID only when ACS RR & UF enabled on upstream path") requires > some ACS features being supported on device's upstream path when enabling > PCI/PASID. > > One alternative is ATS/PRI which lets the device resolve the PASID + addr > pair before a memory request is made into a routeable TLB address through > the translation agent. Those resolved addresses are then cached on the > device instead of in the IOMMU TLB and the device always sets translated > bit for PASID. One example of those devices are AMD graphic devices that > always have ACS or ATS/PRI enabled together with PASID. > > This adds a flag parameter in the pci_enable_pasid() helper, with which > the device driver could opt-in the fact that device always sets the > translated bit for PASID. > > It also applies this opt-in for AMD graphic devices. Without this change, > kernel boots to black screen on a system with below AMD graphic device: > > 00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. > [AMD/ATI] Wani [Radeon R5/R6/R7 Graphics] (rev ca) > (prog-if 00 [VGA controller]) > DeviceName: ATI EG BROADWAY > Subsystem: Hewlett-Packard Company Device 8332 > > At present, it is a common practice to enable/disable PCI PASID in the > iommu drivers. Considering that the device driver knows more about the > specific device, we will follow up by moving pci_enable_pasid() into > the specific device drivers. > > Fixes: 201007ef707a ("PCI: Enable PASID only when ACS RR & UF enabled on upstream path") > Reported-and-tested-by: Matt Fagnani > Link: https://bugzilla.kernel.org/show_bug.cgi?id=216865 > Link: https://lore.kernel.org/r/15d0f9ff-2a56-b3e9-5b45-e6b23300ae3b@leemhuis.info/ > Suggested-by: Jason Gunthorpe > Suggested-by: Christian König > Reviewed-by: Kevin Tian > Signed-off-by: Lu Baolu > --- > include/linux/pci-ats.h | 6 ++++-- > drivers/iommu/amd/iommu.c | 2 +- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +- > drivers/iommu/intel/iommu.c | 3 ++- > drivers/pci/ats.c | 8 ++++++-- > 5 files changed, 14 insertions(+), 7 deletions(-) Reviewed-by: Jason Gunthorpe Jason