From patchwork Tue Apr 30 17:21:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13649703 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 D0879C4345F for ; Tue, 30 Apr 2024 17:22:05 +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=4i9dPrfNQLQ8FbRKabvJbMQoG7pG48BYmu8laUqLmfE=; b=slgq9DMq3Nhonn 1LHaQqsMyvvGz+p1/LF25zQlft5wrnjuzSGzpPlsnM+CeY2jRSmm0Rs/5qEyzm2/N2i6qQuDO/EM7 eUTlWEnn2G/2WVQ4vS6kMMn8iRco3Nk+JgzC890miGmEbySk/y6JmuknZceynVR5RyGz5KInJEC3H 9dqLwCILjTv3MiZnolWgFMtnA/zmqW5xlndjPuzzuA2cK3IKYgF5VpyRjTE7nnIbilKXkdhzfmFGc neZtp2JjrC0pszLrP0lTpM1Z399sl4GpqTRCjpvcM4fi1Ua4xWCSpGdyzup0BS7BCDGVtP9xG8PvO TNTJZCHPA49lePs8MrHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1rAx-00000007OXT-3a54; Tue, 30 Apr 2024 17:21:55 +0000 Received: from mail-bn8nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2418::600] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1rAu-00000007OVf-3Gya for linux-arm-kernel@lists.infradead.org; Tue, 30 Apr 2024 17:21:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YntBr160H3bNPOb/anPl5IJaRmL92srcw+9zdg4MInLuVIVkpTUkhcAlwE9aWBCaQ6PKff/tgI1OEo8ZCDMchF/mHNPkirquBNyv6HCqWTMD7wB3WEZcYz+VEz0EzQpkeNnAMjHiPkHfgVCojQH5PDf7DzMbldM/FBGFYGfqbq2kfJh+nrhQY5k5XcuvgF2FKdl1mnS5pnIdV7g1cG/SNtUOLvFA+/6/bOfb2EJ1FlmCs0eALVfim3U59d1gJ77Be9Lz80J0/eRw+7n9QfdCtxh1uIEA2hmppePqyX4d5IKNrjHtb8Bs7ZtvRS+GVA9QaAavHZo+Xz0gZ65+podPNA== 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=u0PSPwTMKz929rCyULVrpInHYArcUbpgRlrKoxMH+xU=; b=dEGSQqceM4eQTAwK1Sj5g4sxY0+Dzbh3+4NIpF+YG0XtDEVej6bEfbIQrGSIPWEclgqT/km0sqFAWv9xCp/6wu3KZT8FClk3ZfjULZKSJFEZZhjDoAcb8gezBoQuJPgwdvynbfKNqRSiqh1ejMM6G+z+gR5p+9NvhrMAqKOHzyZHTnuTEZhYPMFTnYdiuW9kaoXJz5u7ThblgIV7cRKVkUblhYcijhqKDqzRu6IlCtvU35ZVhL0xvCp8sR5UYvIJ1Oq41Xb6IaXDIFyt45Zv2dELQjcRjZ35orDXD2E34X9JK5IyySafOwkysjRrpQa0ao3YWJ7PuglRGEw8n6xVCg== 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=u0PSPwTMKz929rCyULVrpInHYArcUbpgRlrKoxMH+xU=; b=XMkGetLzilUdzNIrtkhcSB+0BCylb8myAufjCO1JQldsu7aV4KamOY403dmiGGP3760Z/BUYwoHQLIyaISgRUigzzudrqdKZa0pR04hqMckNsMEWtXVaG8LNnQ4+S0NHlomyyNFtJ5LEtnZ/617Q08mDNWm3llmU3pRzYYrJTuGVo6jfbSKXzvv40rF6bLHnLG5Cmipxn/GlaMDZ5EPRFZVicnJUAT7cYySNFxF7qhJaywz3PDiJX5Q0X0EXZ7IXLZuT0CFyCzgvby3Ex0R94NaHyXVbcR10v9AjVi/DNlDvFOA47Kah5xIugNMbDaLqtepb2/40eMT/yATPZ9WEtg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by DM6PR12MB4172.namprd12.prod.outlook.com (2603:10b6:5:212::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35; Tue, 30 Apr 2024 17:21:42 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%3]) with mapi id 15.20.7519.031; Tue, 30 Apr 2024 17:21:42 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Eric Auger , Moritz Fischer , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameer Kolothum , Mostafa Saleh Subject: [PATCH v9 2/9] iommu/arm-smmu-v3: Make CD programming use arm_smmu_write_entry() Date: Tue, 30 Apr 2024 14:21:34 -0300 Message-ID: <2-v9-5040dc602008+177d7-smmuv3_newapi_p2_jgg@nvidia.com> In-Reply-To: <0-v9-5040dc602008+177d7-smmuv3_newapi_p2_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0136.namprd03.prod.outlook.com (2603:10b6:208:32e::21) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|DM6PR12MB4172:EE_ X-MS-Office365-Filtering-Correlation-Id: 90f85db0-51fc-4c90-5d21-08dc693a0105 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: kjVtH45K1ccQRLRTKGbD4qMcl/T9up9bIRtg8ec8uYHsK5QeqUmIrCXsuLt3b2RZVvpTGguWi1WlkzOLXOBCQzik3j3Q62/AAoLQIS+5oirp+iQIAK/455YOAlssYTwBcVzi6VBOVT1YXNVxixMVOsIdblTbC0rLvYg0D27IibcYJZrLGXzXPqpi3abKhA0NjwOrxchI4hU5jMT5SKXToHIMc4dBobFNdcsW3wRcpHxixXYAorcHyOpl4lwlC48RxGT5xWXLS9jfAGNbyaxKJV5VSlM1uBIHlWsNKh6zo5dHrWIbL2KcHWldFt7vzPUADWG9lFUMrR1lkTJGreiWjlu/cuJ4/RO8MDMArOkvIg1G5KNL8uJQMyZn6SuDAMs5ARqCbJ+ubdtlckWgJWxWP3vPCoQ0cnRZ5FuwpXkZ9tPaeOcC5d0mRaxQJXp/4Kl0gcWvLdgwjExRDbrEYkeIjkjAZyHSqXGwEVUqwzliDVj0mZWgZLBj9d5yCHkyiZqVWNNmUIZtvbdIuzJUaDMTjSBQCSHiMvkFoXQe1PJvHj9aTK6JQQGsEy13jILAlMpsYo6wL0XtNJKdgpovMFURdUGZW5Kd97BCsk16VZuGghbIAFnugaz6t6TKcTC6vwUwpl3GJCQ8rhpMF8lgCqq9udgBU+yFfBPQVEucFqjSqPUJowMh+E1pmsWNKIEhcY0mqdJ8LAAyywNS8dpvMDQVJMWfdqEGxoAC6FwCXgsEDzH07V8DPMUmYHvUp1HG9hhlmgxKq9GPlpha//WLJ9wl979/cmFPubas5RRKA0he4dxk3n9SyOc+wycJItcoTAqEVb67BFtFTd6o6uQrnrRAq7sYvUf80IV9iPvlCDXAXuOP/QzL3cCCeZcM/4T3ut3W/4eIzBuNYc/0mL3DWVF/CRE6AitBGbg2UTZEeYaOTO13K/UWH4LfzJcfiCOrJZS0CprV6YbF2mFo0l6heJ4kj4m1OkEP9PNx1XshlJ6j2W+3vxvExDGgeMacz6L51QS5Z/wX0qm63eEB1uWZ6M2CAhljuSIjl3nlj1Bn3N5B5By8wg14vpp7Hg/b50ahadg+f5PYsAc2t5DjAqAxNiK6oco4zezwOCFo/MIhfEnv/Fx0b1DXE9V6DF/YZHEv7XCRt6moQzfq1K+P/XSWNPdNmiRLIeSDoWS1SKzX05tNzdmXfhgrA8wuMYW1TxKnF2pO0U3Kio7BraKc+ZMQFkJqqsS1xa2tE7rYIOPN9E3TmTQFx85jEjqAlpr9p97imz3upFBqn2FJh8M8G2MHmHzvpQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: trP1GRP74cznjEoJP+TqoeJjmNQ+OngzB/a4zX0ghdbfrkA8XZ0L/T1FCJ+PX3U/DGOd5VS6WqbczV+oEivLDQBQwvMOabZOm6S5P4votQmsmWlsARyw3SMOI8GSr9sKdVLQSyeCLjjU3+Xd6ZrFFeZeFhboTKluOrd7TSqjeSRgqSfif/JVa5RBDJcVm2DNbbLZhSRUMOE4u5Lpy5jwe70ZWZfRNMwm+TMNzAH25uaR3w41QJYGEsaaVjXgo3Z4QCeAwNEZS0QIkYLbVdZj0DYu+2dYPG2fF1uEQtFN32LV7U9mofh1cbzBc3rgvj64/sGiTnGcyjL9SW23vnZYFl7aPKwRoJZNsbMYUw5eRPwwIiMSETGmv/qP89TJixx9hMN/kHWuzBU9iP3ySbaRP5w67bRs4XLWF8Q70wWcL++OxJ1w9Yd2KUpsQSRsl7Kr5Ks7ZqQsjjKDL1kF3bk2Wc/kP3/TxqJaCyIbPbZ6fShIFsAiiz7/Ir1zm9PHH+jnKMJozy6Q7vIB183tUK0T2WuvzaKg0IVWPJw98z5rIxoBI4H0zjQDc1hn2BC7KRVHFA18wnk8xZn2CU6ktZFUv4iRr3G2JAClIWA7Kfgg9iSeT/wU9wtoCO9eTezA9b4C9mTafb8HAJfRd0pNK+FqdKMuMmKqSecR1Q4H18SPTfg9IXjkLmvTz/dDTZ6+UcQgF0YUf8TS6gpnojA19tvJke1DN1ppH7oaXg/MdjzHWjYKOWTHrZyVQFul8QA+xxJx3rDOC+jNM3llj4RIENlHqVyZT2wyNDk5yZafqPT9CVUuBw29zjV4XIOdnTGKr/aorwDo7I7Bshb8mSRuEJ51F0Qp5a2XD/pbIeSsjDbm644H+JXkIMbJg/WzmpBPFSmc5jiynP8glH+ObbPFepuys0YGT5NeKJ54fd7Tq4uMScaqIenMQ/FIKSjMuZY2BNbB5/KMUKbqrS9XXvVIeP7Q4pyOxXFyT2IVuXtZVTwq+M7gEkLOAC/qbTrPyDh+kp/st9vn3iLip6V14cph8+yKlowVTLzdaBmhsnIxku8WAYLC3c/lcoPgkSpWxEScFeV8x6pwDGF+O/sizNncK3NggYcEpjlp+uk8Nh3n+hnnLfLrgWc8bHduZdS9+3/fNC62vW5NZyx2hySQzuYpoCQPCzYRSG+dzjyAqXnpYS08nM6F7K9I9+zdh2cNM5IJKuN5Pqt52o1l8ppb3ulwE4Kw5G/6KDmDkGxGmWH8U28RXFU4sl43IPU8qnA4qc+r9PVK/et+ZkCSEPOE5ZnMGVkeNmaTX0lj5nK7AYqsSKTfMSgKtq0fLuRKRshvcBHC3ldM4vDn+xPtrdYG23DYfgujz9SuVxUKskKUWCXVLw7QFYuw5Ya64/ueV0hmxsfAjqsUPmfRhsBwQXhpI0iSd8aZblmB0OB7VRlMPnQs88OF28VXE2iZJY/ylwxEXleSXr3dyVVu010xPuIRCWzbIcZigsqZjiYMgj/Omw7AaBb8rrmKnEYQxk1/JMcCsZXO57z3mIwDa3uH2iKNrM/8DKAqSJ4qYSEJgENj4evBbfkmrOk5sgOlBVU4aeaqcKd7iv5f X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90f85db0-51fc-4c90-5d21-08dc693a0105 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2024 17:21:42.6978 (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: SjZ7QG0vBAic+seBuuaAnNyGFZ7Zgpa1OPMBgl+LQIOXCslXAS4g8qeqWuPI/JHa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4172 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240430_102152_974986_74BB3818 X-CRM114-Status: GOOD ( 20.87 ) 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 CD table entries and STE's have the same essential programming sequence, just with different types. Use the new ops indirection to link CD programming to the common writer. In a few more patches all CD writers will call an appropriate make function and then directly call arm_smmu_write_cd_entry(). arm_smmu_write_ctx_desc() will be removed. Until then lightly tweak arm_smmu_write_ctx_desc() to also use the new programmer by using the same logic as right now to build the target CD on the stack, sanitizing it to meet the used rules, and then using the writer. Sanitizing is necessary because the writer expects that the currently programmed CD follows the used rules. Next patches add new make functions and new direct calls to arm_smmu_write_cd_entry() which will require this. Signed-off-by: Michael Shavit Tested-by: Nicolin Chen Tested-by: Shameer Kolothum Reviewed-by: Moritz Fischer Reviewed-by: Nicolin Chen Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 89 ++++++++++++++++----- 1 file changed, 67 insertions(+), 22 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 196aeaf280042c..3504c25de4306b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -55,6 +55,7 @@ struct arm_smmu_entry_writer_ops { #define NUM_ENTRY_QWORDS 8 static_assert(sizeof(struct arm_smmu_ste) == NUM_ENTRY_QWORDS * sizeof(u64)); +static_assert(sizeof(struct arm_smmu_cd) == NUM_ENTRY_QWORDS * sizeof(u64)); static phys_addr_t arm_smmu_msi_cfg[ARM_SMMU_MAX_MSIS][3] = { [EVTQ_MSI_INDEX] = { @@ -1230,6 +1231,59 @@ static struct arm_smmu_cd *arm_smmu_get_cd_ptr(struct arm_smmu_master *master, return &l1_desc->l2ptr[idx]; } +struct arm_smmu_cd_writer { + struct arm_smmu_entry_writer writer; + unsigned int ssid; +}; + +static void arm_smmu_get_cd_used(const __le64 *ent, __le64 *used_bits) +{ + used_bits[0] = cpu_to_le64(CTXDESC_CD_0_V); + if (!(ent[0] & cpu_to_le64(CTXDESC_CD_0_V))) + return; + memset(used_bits, 0xFF, sizeof(struct arm_smmu_cd)); + + /* + * If EPD0 is set by the make function it means + * T0SZ/TG0/IR0/OR0/SH0/TTB0 are IGNORED + */ + if (ent[0] & cpu_to_le64(CTXDESC_CD_0_TCR_EPD0)) { + used_bits[0] &= ~cpu_to_le64( + CTXDESC_CD_0_TCR_T0SZ | CTXDESC_CD_0_TCR_TG0 | + CTXDESC_CD_0_TCR_IRGN0 | CTXDESC_CD_0_TCR_ORGN0 | + CTXDESC_CD_0_TCR_SH0); + used_bits[1] &= ~cpu_to_le64(CTXDESC_CD_1_TTB0_MASK); + } +} + +static void arm_smmu_cd_writer_sync_entry(struct arm_smmu_entry_writer *writer) +{ + struct arm_smmu_cd_writer *cd_writer = + container_of(writer, struct arm_smmu_cd_writer, writer); + + arm_smmu_sync_cd(writer->master, cd_writer->ssid, true); +} + +static const struct arm_smmu_entry_writer_ops arm_smmu_cd_writer_ops = { + .sync = arm_smmu_cd_writer_sync_entry, + .get_used = arm_smmu_get_cd_used, +}; + +static void arm_smmu_write_cd_entry(struct arm_smmu_master *master, int ssid, + struct arm_smmu_cd *cdptr, + const struct arm_smmu_cd *target) +{ + struct arm_smmu_cd_writer cd_writer = { + .writer = { + .ops = &arm_smmu_cd_writer_ops, + .master = master, + }, + .ssid = ssid, + }; + + arm_smmu_write_entry(&cd_writer.writer, cdptr->data, target->data); +} + int arm_smmu_write_ctx_desc(struct arm_smmu_master *master, int ssid, struct arm_smmu_ctx_desc *cd) { @@ -1246,26 +1300,34 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_master *master, int ssid, */ u64 val; bool cd_live; - struct arm_smmu_cd *cdptr; + struct arm_smmu_cd target; + struct arm_smmu_cd *cdptr = ⌖ + struct arm_smmu_cd *cd_table_entry; struct arm_smmu_ctx_desc_cfg *cd_table = &master->cd_table; struct arm_smmu_device *smmu = master->smmu; if (WARN_ON(ssid >= (1 << cd_table->s1cdmax))) return -E2BIG; - cdptr = arm_smmu_get_cd_ptr(master, ssid); - if (!cdptr) + cd_table_entry = arm_smmu_get_cd_ptr(master, ssid); + if (!cd_table_entry) return -ENOMEM; + target = *cd_table_entry; val = le64_to_cpu(cdptr->data[0]); cd_live = !!(val & CTXDESC_CD_0_V); if (!cd) { /* (5) */ + memset(cdptr, 0, sizeof(*cdptr)); val = 0; } else if (cd == &quiet_cd) { /* (4) */ + val &= ~(CTXDESC_CD_0_TCR_T0SZ | CTXDESC_CD_0_TCR_TG0 | + CTXDESC_CD_0_TCR_IRGN0 | CTXDESC_CD_0_TCR_ORGN0 | + CTXDESC_CD_0_TCR_SH0); if (!(smmu->features & ARM_SMMU_FEAT_STALL_FORCE)) val &= ~(CTXDESC_CD_0_S | CTXDESC_CD_0_R); val |= CTXDESC_CD_0_TCR_EPD0; + cdptr->data[1] &= ~cpu_to_le64(CTXDESC_CD_1_TTB0_MASK); } else if (cd_live) { /* (3) */ val &= ~CTXDESC_CD_0_ASID; val |= FIELD_PREP(CTXDESC_CD_0_ASID, cd->asid); @@ -1278,13 +1340,6 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_master *master, int ssid, cdptr->data[2] = 0; cdptr->data[3] = cpu_to_le64(cd->mair); - /* - * STE may be live, and the SMMU might read dwords of this CD in any - * order. Ensure that it observes valid values before reading - * V=1. - */ - arm_smmu_sync_cd(master, ssid, true); - val = cd->tcr | #ifdef __BIG_ENDIAN CTXDESC_CD_0_ENDI | @@ -1298,18 +1353,8 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_master *master, int ssid, if (cd_table->stall_enabled) val |= CTXDESC_CD_0_S; } - - /* - * The SMMU accesses 64-bit values atomically. See IHI0070Ca 3.21.3 - * "Configuration structures and configuration invalidation completion" - * - * The size of single-copy atomic reads made by the SMMU is - * IMPLEMENTATION DEFINED but must be at least 64 bits. Any single - * field within an aligned 64-bit span of a structure can be altered - * without first making the structure invalid. - */ - WRITE_ONCE(cdptr->data[0], cpu_to_le64(val)); - arm_smmu_sync_cd(master, ssid, true); + cdptr->data[0] = cpu_to_le64(val); + arm_smmu_write_cd_entry(master, ssid, cd_table_entry, &target); return 0; }