From patchwork Wed Sep 20 20:52:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 14290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4418700vqi; Wed, 20 Sep 2023 13:54:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElDU8OpTqjzOc6xLTu+9M6+DVZr7gle5bhtOZ1UhI/+2zBsdPQS6YwAJglzeq4cmoRuLHn X-Received: by 2002:a05:6a00:22c4:b0:68e:496a:7852 with SMTP id f4-20020a056a0022c400b0068e496a7852mr3866481pfj.27.1695243251552; Wed, 20 Sep 2023 13:54:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695243251; cv=pass; d=google.com; s=arc-20160816; b=i4e5Vy/gUkH7qiuG5iocEM2yhfHTRijSkkYt/MdlQ018XVbVwTR4SVE+HHyz/8VVk9 5/NXna3uwsEZjgawFsl12PqMEL1+IljAvDkO47KTZY06ube1dSCRvQHiYcV620sXl8OZ /Y4gONtWRem3UVotZrRo4s4yFr5Lj3zZi168ZRS0wKAmhajKaqpqQUEIZqboVg1NV8xR oEZcZGkTUcncOM2d1j+AwAeW/flS4A+D+4E1/iFW93JfE8R1R9RUrQ11kZl5woQGgBSX p/n35GsDrDoN0P2zqXDlJtyYknzcaiRJebMdUU8024pmZ7oGojAJHUuOvdN8qAK5CFf/ JZuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/BiL26q7Ussw2gAXW2RtQEwNrzdQxhI3t5+7gynbRek=; fh=Mutf2LojUj+MQzQSosopTZpjeh4SmaI+JNoxrqCYPiw=; b=xhMY9rmhcxNC2Sbbim3zLyMjAcXqsewRCYAwjM2A1IRjiXkDuGcPf9BKGtumjCH8gN BqUBLR2BjO/HxFX+j4VhvcQE9XvheRu2/rgLSDdyzq+WviT1N5CHV0TMOZzGmQtUb0qR hbdIKzgPWBwFutcre+/OfFd7RmPEkhxNaVmLl8w01QLdp1KukNiziHgF0mDMi+g/fVzL vpN8uTvkPStNWrX1tBQFcIGMHoNjdv9KVn3ve2XWXIg0QOL0ZAf8FbxlZelLbkwMkIJn InS0ZY4FZV4JD/D8LtEXAiyO0KoL1bR/T0T/bjl+vUAchzXJz2pt3CnbJoED/49vUqo1 f6Gw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=KOCbkhwA; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id g8-20020a056a0023c800b0068fba70d25dsi12838263pfc.33.2023.09.20.13.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 13:54:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=KOCbkhwA; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C49D0837D49F; Wed, 20 Sep 2023 13:53:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbjITUxA (ORCPT + 27 others); Wed, 20 Sep 2023 16:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbjITUw6 (ORCPT ); Wed, 20 Sep 2023 16:52:58 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2081.outbound.protection.outlook.com [40.107.223.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD02CA for ; Wed, 20 Sep 2023 13:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C0UPufvFBCnDveQdihqOgSXfpypr6O61FAt65/2T1Z//PigeH0FJKnYjateb2bxh2V3kW3DR0RRJXzBCJPm3oe5AOef0RRWqTL+thqswr10sLM3UAZuFAjs5sfDb1a1trwZi9yu55vo/80x8wcceXOzavgsOiQ2O9BuTmyE2sUKHolAcbvKNawllrGZ7sENbtHKhBt36AxQ1k3IMRJKY6Mj94RmomVOEY++shFOz3o7AngaJ8lA0DNPgSO+Y1cm6WXdzqeZ6T5IscqKci8NLGCostSQkQAO/FNMnSq+uu9OK4eanA2VuQnIEnNhB5cCndP4ChDaegR8KmbSFewMyiQ== 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=/BiL26q7Ussw2gAXW2RtQEwNrzdQxhI3t5+7gynbRek=; b=k2qz1PqSx9JSH1cCRkQUWTTfWUh02gQu/HsK4hXTjHG1TJHRMYqI0UvBIgw5CJOuWmukFIPGmWhXUQkkyG96y0/jgtQTUYASS0eRPWRd2LvM9dbgn9OBWc/VepJRxFyFe+bnlGDTuDJAazC4SM4RfdTM8i8Xj1epjMIfohtxAgf4apakvfY8BCj4sgkjlBmsvWium72SwDHzGUcPxP3K1vXvogqIlZ5lUOU5wZBAxbanSBJ1GhKCfzzYx/XYfPfpi60d9QUmE+ISmGmFmJGCzbWkvO2vbO0X/65Xzkhp5GM5VfOUJwtxAJliuNpYiGCwlz/kcHXMarQEI1KZQOJ7Ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=/BiL26q7Ussw2gAXW2RtQEwNrzdQxhI3t5+7gynbRek=; b=KOCbkhwAQcldrh9Nktv0jYB9AOhux3oiLXi7jX908HJoE3t4iLnGgonKVjKhFwhN3nj+1Tcm7cJxQe2Vf1K7rwj+1qsmTAdRrd5g1msYuc6iZ31U+1dVkHZyk6Ud5mmj/1LvL5PQWMtpubsr6rKB4103/7wf4WajaLOFtLDBtOaHshsqjYF/UxRzTH98TwiCMbzZicGW/W06jMxzkwXkGVhnpfd0yApsUk/qP9t5wTCmWaA8X2sxDOyQTswb+xYzUfPxHlV+qFEvv5abO9dY08I4RMbWRqKuviz9ddjRrZtFkafxa3tY+6F/rHCwiNk5854ExFNWA/IS+VlrcQe2Ng== Received: from BL1PR13CA0269.namprd13.prod.outlook.com (2603:10b6:208:2ba::34) by IA1PR12MB7543.namprd12.prod.outlook.com (2603:10b6:208:42d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Wed, 20 Sep 2023 20:52:50 +0000 Received: from MN1PEPF0000ECD7.namprd02.prod.outlook.com (2603:10b6:208:2ba:cafe::7b) by BL1PR13CA0269.outlook.office365.com (2603:10b6:208:2ba::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28 via Frontend Transport; Wed, 20 Sep 2023 20:52:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by MN1PEPF0000ECD7.mail.protection.outlook.com (10.167.242.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Wed, 20 Sep 2023 20:52:49 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 20 Sep 2023 13:52:38 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 20 Sep 2023 13:52:37 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Wed, 20 Sep 2023 13:52:37 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH v4 0/2] iommu/arm-smmu-v3: Allow default substream bypass with a pasid support Date: Wed, 20 Sep 2023 13:52:02 -0700 Message-ID: X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD7:EE_|IA1PR12MB7543:EE_ X-MS-Office365-Filtering-Correlation-Id: 601cc50d-ed5a-4738-cce9-08dbba1b8d48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A4P+3zSto94vySv9gQuQZpSk8sAbszsXgfEAcKNz9soNZS/ldkuiCQFsJZtaQhWJkkHbLOvwISw+/yourRooU2kXoP9YJBNoj9rXWArjtWnfKkRC9DPDTrlFeRtMjpbe0BVgxYz2UrikOtz0RLUYllsgmpBLym1YJ8fcsJEK5mjHP1z+3VMEzfw/V4ohIKw8xdS1x+SxIAXiGnFlLq+vZYma6JmcYiDInp0+TPGoVZY0JtzVQ3Ql+BFLGXcOouepz4uJvW3fhsBSg1RJd8ct7PK2VcSDLgsuVYmKOqsZ7QKx4FzrhH8AJXRLEWr0FXNn7OOx46BZwEyh1GS/pT/uAWpvxW//8keXjspuQlxWCse8gQX7RhPtgNb3hqSkdw/IrEx69ry+EOpedjAKd5g4FJj+pHB7xbT6pLeckXHnx9zZApnrkf8sWZk/eo2z2ZmHnFfgSUADRsyICG2BTtrmB/G+6Zy8XLUB7duFs1nEnOW/n+6oI3j9h7P8Z9PF4Y2dlZnixjKntavMZafQX5x7lN9oI8a4DlMM3YDjs4MCm67DW4smbhu0lTu02wytMHqDOlmomsqcCAKCIAYDHlYA7N4linvnrSlzg7r429hxXO8k8rF1WZNcRnNajOSmYbjjyIxhJmH6rnb3gQA9IAiaQPB8umWLA5N8qt7TOAobkizRqtHJvuCqPv1YFJ5aDhI+TLPrA0h0mGj7dYp5wBnka+avE+LalVPicaEoG465L3A7H5a0xCSxYzTC07OmWnFdCzxWS9DQ6OISe+GE6UHcRIax0Nyfc1BC5GsBg1C3hmNFSdPQarltVZU1fTo6pYPT X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(346002)(396003)(136003)(82310400011)(451199024)(186009)(1800799009)(36840700001)(46966006)(40470700004)(336012)(426003)(478600001)(41300700001)(40480700001)(2906002)(6666004)(356005)(966005)(70206006)(83380400001)(40460700003)(70586007)(54906003)(82740400003)(36756003)(7696005)(7636003)(110136005)(86362001)(2616005)(26005)(6636002)(316002)(4326008)(8676002)(8936002)(36860700001)(5660300002)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 20:52:49.8424 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 601cc50d-ed5a-4738-cce9-08dbba1b8d48 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000ECD7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7543 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Wed, 20 Sep 2023 13:53:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777591387592402346 X-GMAIL-MSGID: 1777591387592402346 (This series is rebased on top of Michael's refactor series [1]) When an iommu_domain is set to IOMMU_DOMAIN_IDENTITY, the driver sets the arm_smmu_domain->stage to ARM_SMMU_DOMAIN_BYPASS and skips the allocation of a CD table, and then sets STRTAB_STE_0_CFG_BYPASS to the CONFIG field of the STE. This works well for devices that only have one substream, i.e. pasid disabled. With a pasid-capable device, however, there could be a use case where it allows an IDENTITY domain attachment without disabling its pasid feature. This requires the driver to allocate a multi-entry CD table to attach the IDENTITY domain to its default substream and to configure the S1DSS filed of the STE to STRTAB_STE_1_S1DSS_BYPASS. So, there is a missing link here between the STE setup and an IDENTITY domain attachment. This series fills the gap for the use case above. The first patch corrects the conditions at ats_enabled capability and arm_smmu_alloc_cd_tables() so that the use case above could set the ats_enabled and allocate a CD table correctly. The second patch reworks the arm_smmu_write_strtab_ent() in a fashion of all possible configurations of STE.Config fields. [1] https://lore.kernel.org/all/20230915132051.2646055-1-mshavit@google.com/ --- Changelog v4: * Rebased on top of v6.6-rc2 and Michael's refactor series v8 [1] v3: https://lore.kernel.org/all/cover.1692959239.git.nicolinc@nvidia.com/ * Replaced ARM_SMMU_DOMAIN_BYPASS_S1DSS with two boolean flags to correct conditions of STE bypass and CD table allocation. * Reworked arm_smmu_write_strtab_ent() with four helper functions v2: https://lore.kernel.org/all/20230817042135.32822-1-nicolinc@nvidia.com/ * Rebased on top of Michael's series reworking CD table ownership * Added a new ARM_SMMU_DOMAIN_BYPASS_S1DSS stage to tag the use case v1: https://lore.kernel.org/all/20230627033326.5236-1-nicolinc@nvidia.com/ Nicolin Chen (2): iommu/arm-smmu-v3: Add boolean bypass_ste and skip_cdtab flags iommu/arm-smmu-v3: Refactor arm_smmu_write_strtab_ent() drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 232 ++++++++++++-------- 1 file changed, 137 insertions(+), 95 deletions(-) base-commit: 8bab08e86afa9e0afd25887c0c273c1506d16c0f