From patchwork Sat Aug 24 00:10:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 1976322 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=hXggmO23; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3431-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WrHRF5nhnz1yXd for ; Sat, 24 Aug 2024 10:11:21 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8F2621F23328 for ; Sat, 24 Aug 2024 00:11:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29075125DB; Sat, 24 Aug 2024 00:11:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="hXggmO23" X-Original-To: linux-tegra@vger.kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2056.outbound.protection.outlook.com [40.107.244.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FFB1A47; Sat, 24 Aug 2024 00:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724458277; cv=fail; b=P2G9rZy36luZhiAAz2EqfWGjKkDuKw1i9u2hDmSyHhfhyTNZsO3rZTUHvFyKDRdnjQdi9wrWzkG9scDrSW910OYkXBgsBYwh5wtPVChfSKlkdYQf4iVp2tWcXRXhEaulHLOhuV5bujtxQzITMbni5ZiE+Fo61UjZwiHEfOAZZdQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724458277; c=relaxed/simple; bh=4DC4uj11Soy7leWJaUpC6bgguswwsoymoQFmCD5Zep0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BVit2WuFO0Avfslj8Zd+xACM/figzAHqYU7jHF7Wc2OwCfv7LhIn/KnnJGTo9J9fK2U4yZZ37F2V0+Hu9yAUixbSV7waN2XlJRPfaTe5RroeouHRtsj35ul3oTSroB1WAfwG+pNDEGyplyDXkkAmNwznNSW2RCJut06wOcZ00Ek= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=hXggmO23; arc=fail smtp.client-ip=40.107.244.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lzL1dfRpQHjJTRg8NKpoMujQAjJCzQJvOXBw307cn5mIhQPmXhMowiODPqg4H8tG9kDewY/BmaA2e3IAPQqh0aM6UE+ZuJZmsNCK8qMO3U0Naq6d67z1yxdxLtHZm8aGGwD9zxxGsNJf4jq6Kkp7em84VivbNCEI0B8Xb71DYBeblsr+2BhWFqr+VW1ZfpZYJH5a4DEOvVG0FBzxDLwFTJVgBlj1pX/59zt64vWbGPSvajYIPH0E/kaRiH+/+9+XLbrjtTxiuMC41FY1HJrFHB5+t6YveOvmqiQ2wT6XTQNYn3xDh790Tngd5MUsYomREs1KKZm5KhuvZeVq7r9L3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=OwBx4r2h/uES9cX/oczIVPnh/oby6SE6pHn4Cu15FUU=; b=wBDKOW63QK3KRZ8TSuOZxBRYZ2OproJZmFCVa8pO+YPRgsoI+sij5fX3EMoVdH4AYfOFtogDsUDvSf7Uvbdm3h8O/iRxyjpH5kGlwxuVGWpsMHtyxA0ek4/7Wi3liapnGTfjeGbXrj7BxwL8qSiWrfGYTJxrXcFkc/eODlB/e+ZbKag1dfz+YwYFh1aziOtU0c6VWFi3ZVx3WUK6eVn3hT2yI6mhRlLuvbWIsZhfhPK+4+m3eKsTCRY9zVjVbXZsKVB6aSJpZD54ZNWY5InjAy8+MW1ak1AuRLb9aDg+syFAHyrnKLITUfmHnkx1KDmIRyHIL8bqqz/7dpWbhsnTmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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 (0) 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=OwBx4r2h/uES9cX/oczIVPnh/oby6SE6pHn4Cu15FUU=; b=hXggmO23bt5KEMsXxrn+AwTKW3J8yVtF0xA8WR1QLTy3eKIABiIutOn8rrWfWH070xP/MH7UjpRhMt49MWKtiXslSVzJlyJW4NF4WtBRXfBvnCBkp1jVwqWQAzUy8cxdsF0CpZAQ0bRx7lUSp9aw3ZKm2sRyhXWmpcEpNx/awUAVbZmTacCiOzCRg9NLKsP2/pMrGclmy8esn7MLXJoAafb7mFM1Fb7tTM6aDBKpwpVcz5lh4LMnYxkx58IOXLhLCRFDTn+CgL5rWMNOzhEcowYE8fQ0yzToUTN/T1iCubC+sSOSaKxadOUe5aFBvRtnEi0XQhaiI3vDE3hZPPVDRQ== Received: from BYAPR05CA0050.namprd05.prod.outlook.com (2603:10b6:a03:74::27) by DM3PR12MB9414.namprd12.prod.outlook.com (2603:10b6:0:47::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Sat, 24 Aug 2024 00:11:10 +0000 Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2603:10b6:a03:74:cafe::b8) by BYAPR05CA0050.outlook.office365.com (2603:10b6:a03:74::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Sat, 24 Aug 2024 00:11:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.11 via Frontend Transport; Sat, 24 Aug 2024 00:11:09 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 23 Aug 2024 17:10:53 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 23 Aug 2024 17:10:53 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 23 Aug 2024 17:10:52 -0700 From: Nicolin Chen To: CC: , , , , , , , , , Subject: [PATCH v13 05/10] iommu/arm-smmu-v3: Add ARM_SMMU_OPT_TEGRA241_CMDQV Date: Fri, 23 Aug 2024 17:10:39 -0700 Message-ID: <6584495a46d8c3e1b6b5e32831f4b6b884ca1a8d.1724453781.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|DM3PR12MB9414:EE_ X-MS-Office365-Filtering-Correlation-Id: 35d4036d-c031-4f20-56de-08dcc3d1419a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-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KJJ+loY90KMblDd+vA0O6pP2iQuTpDyTkxWiCRUSOWS6t0w3BKPGPG16mvigCKbeQZkCamJu3w5jDMWE8R7+izlKqzmKDaJ0ca/NzSDcjgZTjnpV1OcCMopNFfLRswmKte4Qkpu1aZIGbXhzmXKrkckiHpsGRf9Tb6/aj44VqqLgsSi0wKUiZ/v0TEGUYcBVzkcpZCLYmcI5kLjJReUKXcPuSmpHNveinukzod+iz0SKaIes0oDGfRc4QGBuZKkvGk/RrThe8l3or6BnJ+fGUQ3pIMjTpx7O9Gg+YltzONLdlIJxlWtBWeaM8oiZZsx7/UiabM39hoZCvfjLoJjnAeoEB1kMaoNvddhyJ7EyqhzKWsUPKpJxuCHy0DruCOalW07MLxAV+8okiUXZ6c X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2024 00:11:09.4576 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35d4036d-c031-4f20-56de-08dcc3d1419a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9414 The CMDQV extension in NVIDIA Tegra241 SoC only supports CS_NONE in the CS field of CMD_SYNC. Add a new SMMU option to accommodate that. Suggested-by: Will Deacon Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 16 +++++++++++++++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + 2 files changed, 16 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 214b2bce28fa..afdb8a76a72a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -351,6 +351,15 @@ static struct arm_smmu_cmdq *arm_smmu_get_cmdq(struct arm_smmu_device *smmu) return &smmu->cmdq; } +static bool arm_smmu_cmdq_needs_busy_polling(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq) +{ + if (cmdq == &smmu->cmdq) + return false; + + return smmu->options & ARM_SMMU_OPT_TEGRA241_CMDQV; +} + static void arm_smmu_cmdq_build_sync_cmd(u64 *cmd, struct arm_smmu_device *smmu, struct arm_smmu_cmdq *cmdq, u32 prod) { @@ -369,6 +378,8 @@ static void arm_smmu_cmdq_build_sync_cmd(u64 *cmd, struct arm_smmu_device *smmu, } arm_smmu_cmdq_build_cmd(cmd, &ent); + if (arm_smmu_cmdq_needs_busy_polling(smmu, cmdq)) + u64p_replace_bits(cmd, CMDQ_SYNC_0_CS_NONE, CMDQ_SYNC_0_CS); } void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu, @@ -423,6 +434,8 @@ void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu, /* Convert the erroneous command into a CMD_SYNC */ arm_smmu_cmdq_build_cmd(cmd, &cmd_sync); + if (arm_smmu_cmdq_needs_busy_polling(smmu, cmdq)) + u64p_replace_bits(cmd, CMDQ_SYNC_0_CS_NONE, CMDQ_SYNC_0_CS); queue_write(Q_ENT(q, cons), cmd, q->ent_dwords); } @@ -706,7 +719,8 @@ static int arm_smmu_cmdq_poll_until_sync(struct arm_smmu_device *smmu, struct arm_smmu_cmdq *cmdq, struct arm_smmu_ll_queue *llq) { - if (smmu->options & ARM_SMMU_OPT_MSIPOLL) + if (smmu->options & ARM_SMMU_OPT_MSIPOLL && + !arm_smmu_cmdq_needs_busy_polling(smmu, cmdq)) return __arm_smmu_cmdq_poll_until_msi(smmu, cmdq, llq); return __arm_smmu_cmdq_poll_until_consumed(smmu, cmdq, llq); diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index ce76357b6fc2..ebd9db4789ff 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -665,6 +665,7 @@ struct arm_smmu_device { #define ARM_SMMU_OPT_PAGE0_REGS_ONLY (1 << 1) #define ARM_SMMU_OPT_MSIPOLL (1 << 2) #define ARM_SMMU_OPT_CMDQ_FORCE_SYNC (1 << 3) +#define ARM_SMMU_OPT_TEGRA241_CMDQV (1 << 4) u32 options; struct arm_smmu_cmdq cmdq;