Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp294089lqo; Tue, 7 May 2024 22:59:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGY7P+wcF+3SOq7UEEngJhU5xuZKNwyvPOTrfZJP06DkLPYcG4+s9y2+NOVtndpMZ5iVfE+JIvDEYc3TfoWr7Z5T/vBRDimstZ7Oi3KQ== X-Google-Smtp-Source: AGHT+IHHx6KDzlzgHwPf2rqOD+o7Yl43phq1qw60FugEW9Fd/VFmCZzF/LqRlaY27uwrwzsFI25o X-Received: by 2002:a05:6a20:9496:b0:1a9:b2ee:5f72 with SMTP id adf61e73a8af0-1afc8db30d2mr1667102637.36.1715147942778; Tue, 07 May 2024 22:59:02 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b6290d0472si669711a91.171.2024.05.07.22.59.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 22:59:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172722-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=FNV8PfsV; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-172722-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172722-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9E97FB2455A for ; Wed, 8 May 2024 05:57:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5E802375F; Wed, 8 May 2024 05:57:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="FNV8PfsV" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2046.outbound.protection.outlook.com [40.107.244.46]) (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 B3DC817756; Wed, 8 May 2024 05:57:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.46 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715147835; cv=fail; b=W97xXPy48ScC7vUTi5cNj3jAQ1p1y399fQIFULNPkt+qeVwve28yS66lsU0Vd5WDYxGZqnOkB0gCng03kWGTROozX4DdFouMc2b5Sly3GkYlaytKNkz/3j6JVKsNBIRx0QC0JGMP/Mv80wQl7avBFPLzN1cdgplNp6G7w1nQtdo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715147835; c=relaxed/simple; bh=XVE03uIpMY0FeXh8chuEupcsWRErhMpyOchMt7eFFSI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D/VYjRMitDfwzjAbh3VQIC5VbFXSQV70h0WWxhiDYQJt8HgG1kF1sCH5lzoy0mOav6aoxxQqScIxM0C/Lrz923Sn1nXock0dFTnUj8fXF4FVlfqG6NvLbbCyBgZJ8LZuaWUGTPR+GU+6ZygEuIAnIpqM+ns6n0+EhU41nlhrdPg= 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=FNV8PfsV; arc=fail smtp.client-ip=40.107.244.46 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=arcselector9901; d=microsoft.com; cv=none; b=MrWEpkWvCE59Hy18ZmnIkPG6VCTy34eQrc+Z+6cbqfd4rwavCzBQltXkGo+xOHoxmQJcRwnZsSCKJaZrxYs7pOkpeQ8zvJWRV6Sf/XpZJK/vnaQgpJPVO4WnTylg2vP7lc3Dy12RwnSwXQ+20/KRXUganHfKeua1+TiafqxpDTRT8Wq34HfBVSRRBXSXIycUYsyq6Sw9pNndFz+ZjxJ8Oi9zM9Ae+YdsQEGtCRBUcAOED6GZwmJkG6SEuoHg3SvEZk6EzyHHiDaCd3T6jbUvOzt29ZxGDgk9xsoTua6m9lwfMsrJbBRlGhvpfudOc3Flo58dH+gpZuxOGE31J9jobA== 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=iu2TOEjvH/yZDfNQRQVTwEqdJxBr0Ttj+DfhUe/NV9s=; b=eIjzeHWfTNkDqwtz8eh+RD++jP8e46bjbv1P7wN1lnnjtLoWwG/yJGM4hGdsqAp2MnLCiytz9+xi9d5il4VP+7zS9YusB3V9fTIl80h3OjnmpAgnT+wJTYuvLSW6Aejn8bb0PICTQYaKCPBP0iEfjl6JSy9J6EVV68W9SlkOTQMrTjtoGwV4MhuTcqaWZroxT5DdgEA9yyM8ek/w+S6gBr5KgwemxA4SNFVqK16HqzGIV9QTAN4IOyy8nzNdI9frwAC/6hWgS8gsMivv3rNJM+MOmIzhsZvA45hn7pMlqQ5EXdfa0FTm4Vuhb9Vq3fKTQqeq+Gv9UCHLAs0SKzJFiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=iu2TOEjvH/yZDfNQRQVTwEqdJxBr0Ttj+DfhUe/NV9s=; b=FNV8PfsVhYpdlmeXgwjZvcu10YTFYoyTOyo3pFNLVnKJgG/RUnY07H0gHcpNhFHd2t7P1GWIHZjGJmOOGbj7fsK/8xwtyfOU9oN2Z5HxpOltRueNZ/ujfTis1lh7fV41l26b1XQTvINR+P5iZe7QWQtCxvis3b4uNjQFe20B1SOaJSVlnpfPcUaBqzlqWKH6NdBIVnwFztrHXuP+qqNjDuLTdeHIvQK1YTn0cvkFbB62OQfM2zftny/rh183nofLtNAOynCc6ei/Ul3OYtpgpVWFe4svk/ALbY6BDeNJUplxvdSE0bS+Y2n7d2+wT68peP508G3UQzRaOYSZSm4ddg== Received: from SJ0PR05CA0189.namprd05.prod.outlook.com (2603:10b6:a03:330::14) by CH3PR12MB8546.namprd12.prod.outlook.com (2603:10b6:610:15f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.42; Wed, 8 May 2024 05:57:09 +0000 Received: from SJ5PEPF000001CD.namprd05.prod.outlook.com (2603:10b6:a03:330:cafe::26) by SJ0PR05CA0189.outlook.office365.com (2603:10b6:a03:330::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.46 via Frontend Transport; Wed, 8 May 2024 05:57:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SJ5PEPF000001CD.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Wed, 8 May 2024 05:57:09 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 7 May 2024 22:57:02 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.1544.4; Tue, 7 May 2024 22:57:01 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 7 May 2024 22:57:01 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v7 2/6] iommu/arm-smmu-v3: Issue a batch of commands to the same cmdq Date: Tue, 7 May 2024 22:56:50 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CD:EE_|CH3PR12MB8546:EE_ X-MS-Office365-Filtering-Correlation-Id: 838c6522-bbb7-4afa-00f6-08dc6f23b2a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|82310400017|1800799015|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DnjGezKZw/ftucafxoD6nPOgectkGfW0C/lpFL0mgCCWcv7i5it4pHXakCha?= =?us-ascii?Q?NHKP93TpRLkN+g+AF+hx6jYFAB8BrC0kyNdiW3ogxuOrXvspJ8lTCJcT5fom?= =?us-ascii?Q?YKjhsyKIr6uRlu21u2QWTmPduZ0T40loCIMeKPzP3fgSeFv3vq4PL/oPnmck?= =?us-ascii?Q?gsmXVFPBd942yzFWcLfoZA41Em/UqFNTReKqa2pzhdlS5Ul4ZmsuWaZJMs8b?= =?us-ascii?Q?8oDHyS26Er184b8AORXiMNmwjOdGaitDBTSh5EYOXYB6UZkE21mL0ZiXcDds?= =?us-ascii?Q?87E7ZGMHaFEaojRQEWhnyrLTtHBQhEHd8UfyT4P+4tSMwB3vj0tqG6XqxBk3?= =?us-ascii?Q?WwjpNyFsr3lGf4LPB3VRrCeO/R5BLqUW6h/zKT+laQvfwBHpfivQxPRLlI5E?= =?us-ascii?Q?M+7nadRTXDc9AUsrsGkD3FMKqmS6bT8R5fy+VIj/6xqDYiDfiEzGQcSMNXMN?= =?us-ascii?Q?HrPy7OIJPdpvUg5gzR4iAzPVYUKiyhsdBJcld+42RwmPRB+GPrwX2BU91Rlf?= =?us-ascii?Q?4y5fmWYntb2v0yNpRBuqIl1+E/d8T0lfy90+qeIwHXMvLb2XRupb/OMsOALI?= =?us-ascii?Q?Vw29E+kaFE5ix6R9iMt8Joa1HbcoQbzkllVunNEfeUjeLevyzLc6y/4K4MrY?= =?us-ascii?Q?XqIeoFmLWVkniZYW25at5rqw6e+ZRP3niCsqqpP/VrVQkX3tblQS9FHQeA+5?= =?us-ascii?Q?t9nhMLW5WrRy0W8TjDilB/ESdvyaRgCS41SrolhaIoXvDyT0jELoYt0EKnTY?= =?us-ascii?Q?G9RnjhNN3Gbu7IFhTGBwXfDRScByN5G0vg4IMJ6r/21gpszMBSwYSbk+ZIPX?= =?us-ascii?Q?pHgkqrk0lZkaXxcqjrvlYCiMf6q0pHGZ0CcIOvGo5k1/vYz8zsbfHPujAZgq?= =?us-ascii?Q?1+M4//sLZAieTv2KIZrp2HPkBQh6D2BhB6wcLuBWBmyTSskzH4667B6+SDot?= =?us-ascii?Q?925h71AGv5wyIOHfkkuzwp/9T5FdJXO25G2nR21XX7MX4SSHJr9Keq3eFM56?= =?us-ascii?Q?6qAHd/r72M0rNwyttUoEORffgih4w2GMzjtkFBFYraVdrLP7wgWfROKC1ABX?= =?us-ascii?Q?2kRDfET8jyrBBp0L1KFatpptF/k2EDkNzvPnxXYFKg8Wp8CS9z38W1QXGU31?= =?us-ascii?Q?kv52O3BLN5rr1O2jrkio9b3isVa22Yw3ipW46jN/XKYbdEUAVuGn3Z40aJW3?= =?us-ascii?Q?52e4vRVsY8BHziUxXAH4fID0FFye9i7GWM8r3KAQ5U94QVRQAxvR0z1bxKvC?= =?us-ascii?Q?BvHiLCyDek4F1n9FsTjOo2QX0W+maJ87Qv1tIlllkVidp76i9Y/DvleqMNv0?= =?us-ascii?Q?yvf05h8BPEISxrP9jsqC6luyNfM2v23Dp23Lcz4zEyqadsiUVrujjPFcxjFI?= =?us-ascii?Q?Ng1/tQo=3D?= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(82310400017)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2024 05:57:09.1046 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 838c6522-bbb7-4afa-00f6-08dc6f23b2a1 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.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001CD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8546 The driver calls in different places the arm_smmu_get_cmdq() helper, and it's fine to do so since the helper always returns the single SMMU CMDQ. However, with NVIDIA CMDQV extension or SMMU ECMDQ, there can be multiple cmdqs in the system to select one from. And either case requires a batch of commands to be issued to the same cmdq. Thus, a cmdq has to be decided in the higher-level callers. Add a cmdq pointer in arm_smmu_cmdq_batch structure, and decide the cmdq when initializing the batch. Pass it down to the bottom function. Update __arm_smmu_cmdq_issue_cmd() accordingly for single command issuers. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 44 +++++++++++++-------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + 2 files changed, 29 insertions(+), 16 deletions(-) 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 31ada4c7b87d..3d2962f6dbda 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -588,11 +588,11 @@ static void arm_smmu_cmdq_poll_valid_map(struct arm_smmu_cmdq *cmdq, /* Wait for the command queue to become non-full */ static int arm_smmu_cmdq_poll_until_not_full(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq, struct arm_smmu_ll_queue *llq) { unsigned long flags; struct arm_smmu_queue_poll qp; - struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu); int ret = 0; /* @@ -623,11 +623,11 @@ static int arm_smmu_cmdq_poll_until_not_full(struct arm_smmu_device *smmu, * Must be called with the cmdq lock held in some capacity. */ static int __arm_smmu_cmdq_poll_until_msi(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq, struct arm_smmu_ll_queue *llq) { int ret = 0; struct arm_smmu_queue_poll qp; - struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu); u32 *cmd = (u32 *)(Q_ENT(&cmdq->q, llq->prod)); queue_poll_init(smmu, &qp); @@ -647,10 +647,10 @@ static int __arm_smmu_cmdq_poll_until_msi(struct arm_smmu_device *smmu, * Must be called with the cmdq lock held in some capacity. */ static int __arm_smmu_cmdq_poll_until_consumed(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq, struct arm_smmu_ll_queue *llq) { struct arm_smmu_queue_poll qp; - struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu); u32 prod = llq->prod; int ret = 0; @@ -697,12 +697,13 @@ static int __arm_smmu_cmdq_poll_until_consumed(struct arm_smmu_device *smmu, } 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) - return __arm_smmu_cmdq_poll_until_msi(smmu, llq); + return __arm_smmu_cmdq_poll_until_msi(smmu, cmdq, llq); - return __arm_smmu_cmdq_poll_until_consumed(smmu, llq); + return __arm_smmu_cmdq_poll_until_consumed(smmu, cmdq, llq); } static void arm_smmu_cmdq_write_entries(struct arm_smmu_cmdq *cmdq, u64 *cmds, @@ -739,13 +740,13 @@ static void arm_smmu_cmdq_write_entries(struct arm_smmu_cmdq *cmdq, u64 *cmds, * CPU will appear before any of the commands from the other CPU. */ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq, u64 *cmds, int n, bool sync) { u64 cmd_sync[CMDQ_ENT_DWORDS]; u32 prod; unsigned long flags; bool owner; - struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu); struct arm_smmu_ll_queue llq, head; int ret = 0; @@ -759,7 +760,7 @@ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, while (!queue_has_space(&llq, n + sync)) { local_irq_restore(flags); - if (arm_smmu_cmdq_poll_until_not_full(smmu, &llq)) + if (arm_smmu_cmdq_poll_until_not_full(smmu, cmdq, &llq)) dev_err_ratelimited(smmu->dev, "CMDQ timeout\n"); local_irq_save(flags); } @@ -835,7 +836,7 @@ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, /* 5. If we are inserting a CMD_SYNC, we must wait for it to complete */ if (sync) { llq.prod = queue_inc_prod_n(&llq, n); - ret = arm_smmu_cmdq_poll_until_sync(smmu, &llq); + ret = arm_smmu_cmdq_poll_until_sync(smmu, cmdq, &llq); if (ret) { dev_err_ratelimited(smmu->dev, "CMD_SYNC timeout at 0x%08x [hwprod 0x%08x, hwcons 0x%08x]\n", @@ -870,7 +871,8 @@ static int __arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu, return -EINVAL; } - return arm_smmu_cmdq_issue_cmdlist(smmu, cmd, 1, sync); + return arm_smmu_cmdq_issue_cmdlist( + smmu, arm_smmu_get_cmdq(smmu), cmd, 1, sync); } static int arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu, @@ -885,6 +887,13 @@ static int arm_smmu_cmdq_issue_cmd_with_sync(struct arm_smmu_device *smmu, return __arm_smmu_cmdq_issue_cmd(smmu, ent, true); } +static void arm_smmu_cmdq_batch_init(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq_batch *cmds) +{ + cmds->num = 0; + cmds->cmdq = arm_smmu_get_cmdq(smmu); +} + static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu, struct arm_smmu_cmdq_batch *cmds, struct arm_smmu_cmdq_ent *cmd) @@ -893,12 +902,14 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu, if (cmds->num == CMDQ_BATCH_ENTRIES - 1 && (smmu->options & ARM_SMMU_OPT_CMDQ_FORCE_SYNC)) { - arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmds, cmds->num, true); + arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds, + cmds->num, true); cmds->num = 0; } if (cmds->num == CMDQ_BATCH_ENTRIES) { - arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmds, cmds->num, false); + arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds, + cmds->num, false); cmds->num = 0; } @@ -915,7 +926,8 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu, static int arm_smmu_cmdq_batch_submit(struct arm_smmu_device *smmu, struct arm_smmu_cmdq_batch *cmds) { - return arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmds, cmds->num, true); + return arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds, + cmds->num, true); } static void arm_smmu_page_response(struct device *dev, struct iopf_fault *unused, @@ -1156,7 +1168,7 @@ static void arm_smmu_sync_cd(struct arm_smmu_master *master, }, }; - cmds.num = 0; + arm_smmu_cmdq_batch_init(smmu, &cmds); for (i = 0; i < master->num_streams; i++) { cmd.cfgi.sid = master->streams[i].id; arm_smmu_cmdq_batch_add(smmu, &cmds, &cmd); @@ -1995,7 +2007,7 @@ static int arm_smmu_atc_inv_master(struct arm_smmu_master *master) arm_smmu_atc_inv_to_cmd(IOMMU_NO_PASID, 0, 0, &cmd); - cmds.num = 0; + arm_smmu_cmdq_batch_init(master->smmu, &cmds); for (i = 0; i < master->num_streams; i++) { cmd.atc.sid = master->streams[i].id; arm_smmu_cmdq_batch_add(master->smmu, &cmds, &cmd); @@ -2035,7 +2047,7 @@ int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid, arm_smmu_atc_inv_to_cmd(ssid, iova, size, &cmd); - cmds.num = 0; + arm_smmu_cmdq_batch_init(smmu_domain->smmu, &cmds); spin_lock_irqsave(&smmu_domain->devices_lock, flags); list_for_each_entry(master, &smmu_domain->devices, domain_head) { @@ -2112,7 +2124,7 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd, num_pages++; } - cmds.num = 0; + arm_smmu_cmdq_batch_init(smmu_domain->smmu, &cmds); while (iova < end) { if (smmu->features & ARM_SMMU_FEAT_RANGE_INV) { 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 67b0ca0b1b79..8e4fbf4f50f3 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -564,6 +564,7 @@ struct arm_smmu_cmdq { struct arm_smmu_cmdq_batch { u64 cmds[CMDQ_BATCH_ENTRIES * CMDQ_ENT_DWORDS]; + struct arm_smmu_cmdq *cmdq; int num; }; -- 2.43.0