From patchwork Thu Mar 2 06:20:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meenakshi Aggarwal X-Patchwork-Id: 658236 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4E77C6FA8E for ; Thu, 2 Mar 2023 06:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbjCBGWe (ORCPT ); Thu, 2 Mar 2023 01:22:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbjCBGWd (ORCPT ); Thu, 2 Mar 2023 01:22:33 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2070.outbound.protection.outlook.com [40.107.21.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93462311F4; Wed, 1 Mar 2023 22:22:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d45zRWpl6YnaGikN30IcZVetUSap63jVmGOIvdF5/ND4L7owRatgisDOt5cy5hKt4Dvl8dvdpt4dEebTXE6q1idExGO2c4fMud//apGDMd+CZKYtHzTjCp2PrqjGssIe4EBjyvC2yXnCUq+rt5FoTV/aGbkm4U9uzI0gkijyf0SQ2s+RyakwY/mVA9P6/0X3jWLpocYG54t8cpjZpND6imCHh4w3lc2YDZqjKDhS/yVCM43O8Mr4/6jCXs7it1yQyYq4MOySWADWOxHMC3e1QANKt26dFvdbdQPaw9EnLU3kqEKF31l0/UySYAlu3kNfFNdJr6vY7nLeA2/Rzk0/dQ== 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=KO/hIEwWizTSq0ebr3mr/6YT3LFI430ANBpfFfYKrb4=; b=WK//fFVseAWwOGLvnhGRyXO9LgER4mXd6PdKTe/kC5Hfdu5+W/aTG/k/Dc6fwkaoSNhHs8yogCfK5ODZE6qoJWgLHSHYsbgSpLy8nECYG7kHD468H/lz+LyCPGcuZok52NW/pw8c58F9Xm+8Wy+/UxcjZmxUMLu696O0rPeqRSy9t1FNNisI43fYPyr+CRKzLKo77VSdgXzWtZkx33LIBLr4irWKg772reHDP6lSPB0wihU8jSmEreSWY696b0ohGNdKnsQeEN/XdjEmNeD9iAOc1kMp89P3PHEfEgTA6KDr2WVkfw9kTWyHusVPOKC/+HNlYV56DxFlZ2gMqmQqLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KO/hIEwWizTSq0ebr3mr/6YT3LFI430ANBpfFfYKrb4=; b=KkqmUWIQ/RYa4geuRUIixTv7FZbQMhBneHWfKZX3V3EMeswsHcb/mE1QJKhsiW15LRyNNHFhaB5lhBrLLHWZDeAwLgI2pEeBPj/eUxKNS3w6dQxL4S0WsS0E/wF9Dy9AQnjYgYF6eH7hjHD8nJJPk1XP5x4VnERr57+bi1sM2Vk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU0PR04MB9563.eurprd04.prod.outlook.com (2603:10a6:10:314::7) by DU2PR04MB8632.eurprd04.prod.outlook.com (2603:10a6:10:2df::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19; Thu, 2 Mar 2023 06:21:26 +0000 Received: from DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::a518:512c:4af1:276e]) by DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::a518:512c:4af1:276e%4]) with mapi id 15.20.6134.026; Thu, 2 Mar 2023 06:21:26 +0000 From: meenakshi.aggarwal@nxp.com To: horia.geanta@nxp.com, V.sethi@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] crypto: caam - reduce page 0 regs access to minimum Date: Thu, 2 Mar 2023 11:50:54 +0530 Message-Id: <20230302062055.1564514-2-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302062055.1564514-1-meenakshi.aggarwal@nxp.com> References: <20230302062055.1564514-1-meenakshi.aggarwal@nxp.com> X-ClientProxiedBy: SI2PR02CA0032.apcprd02.prod.outlook.com (2603:1096:4:195::12) To DU0PR04MB9563.eurprd04.prod.outlook.com (2603:10a6:10:314::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9563:EE_|DU2PR04MB8632:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fb12a61-e1da-4e16-0373-08db1ae65a77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pfi63zh9rsiaAqv0byXS7lUntk62/nL9Dg/ZH1SYmt4Aqe+XrZwdPN4jc4Dfcf49zdEENPhnL6pube6to4aZ8UHjtS2GpNmx/wEgfNLF1cecCSKRT41WLz+UACz1OUdU1yigGLP1pb/f+Gdcl2hXLbR68OEHtZWWEgU7ReWwyMC0jmidofE7PVZKPw+HQZ8AcH7FKIL03awG0nNR6k5DbH1jBjhCbHIGainxPOF7CIX1KcTzGCjyPCZLYPz1tm0rNVYKERgOkTyw1ZA//XtrtqOzjhkU6ZduFEcUqot0DlrhulSt+LURsHoPIJFXzVrps8Bzxblav5Tf5b8+kVBk3SHnEcvxHTn2YLFa9WWQeAXvNXvP+LA/dguboPCkbx4fTWcuiAhqdNSBfXjPnX/kdDOYRSnbr7V2BAUKqLTIcpRgYtkbF5hdcOqYu4POPmqRMwiXb/yxVzaqxJ6BECCA9EBlVDX00FX11A2gLSpnaylhHYvE0Xp9YXzaa5VflVkBIVfzRyEFjIs82jm18Z0E0ELUOHvVsMtGsG2JH9vdNjSFdL6HCq87KIqx1RwU1l3pXH+H5et7u0PAi1LZxIhCqXs8LwVGL6LttRIEscGHx7kbAQqFcI6J1EJdTKIaSHgBFdFVk9CcduUGRB0+qIp/lgnoC56+IFosKb8xWXq2KPi99+Xi9bpw++Jlhy3KLZmUta3VTDfBQV1QpwyJ35VWiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9563.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(346002)(366004)(39860400002)(376002)(136003)(396003)(451199018)(5660300002)(41300700001)(8936002)(38100700002)(38350700002)(8676002)(83380400001)(186003)(2906002)(66946007)(66556008)(2616005)(66476007)(30864003)(316002)(86362001)(6486002)(478600001)(36756003)(9686003)(6506007)(1076003)(26005)(6512007)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qZdsrITqHaqtnbca5+nITpbTM/o8d1y82fBDLb27hCu6OA/Wz86/MTR7sHrmbMgKxJsWBktzZe2ukFSTIMIWw5QdRe4gkEEaTQaS+rG1gUFSOjU9S+37dDQWZxY8LLxCdUkAGjTXNTD/0qNn8LNLnvuscOgsC9NeUSHbmguWLfLNKru7PcGUoJ4hy/1brQxqpyTtv0SC3WALvPgFLKzrO7+GbDqnq14CSdjbHvZps1p3nMdxn1woY7NDbITd253SRiBfk8kbG/Lai1IW6+hxiIQylhh4U5fIBAe6KDKzEdjCpGl6N+GUBpYYw66n9TwuRlhORbcF5LDxYqwKQSTGPml5J9sQFOeem4VIg3tyB0cH8R7zh/ANTBovqpIWpdInQHahuRblczLPv6XZk9je8ADwd+bDmBk5Azer5vi8gv2fyINL+Pi3gN8DBdpFBrqQiQhMCBo5BPm/BwTGWfJBJ6avU4hxftOtcIZVxDFqLTDbiqWYVWS+DmOOCqSb1GNQ1cYYGoIdgK6dZRONDLDzTz9kHPbHrPRzUs9bnCNtnBksosKqIEuWm8y+uPPsfSi6rKH2ZdSpNWLJqpWr0piUwTERF739iXwAZ/dWNHhkYGfObbhWK7BxTIJvy1l16h7Bdhsh/hDlwpLaFfx/O+uiGQ1B2sSCjM2TcLFUJUhucWrwqcobjaU/+R1xKJQ366hRpxsC1C4j+fxCbnIrZasc7RKPNPOylreyDslWupIR8ACj5o5ENA3Y16IKrKG//vAigKsR4vQaMSW4zbh5YuDMLHuE8S9m8glJ+x4OA9Go34PUf4HPrZKBcMC/rbmS28ipLDcxarfupqR/deVCxCPpGRwn+gR3o15if2gPWX1vmdvvmbhAyzrvH/9R5GKzkqrGB85/9WAYMHH70BywNuC141tIxu34es1O7cG2FFXKbJRRecPuLwwxjqSKJnvRMeTlhDNDaxlFlJ3MXcJvNVP5vwRFaCoyJtL6a8RhqXI7XBB/JedlS/qNT7hPz4i6aiMrEwLTn87dHOjk97KPNiX2rKHe0RtdfM6x4tIdzdH2GVngrAi+UsOW5R508Ph7o5mH8rx1+m6zJLU+2tIH2telKbcYp6ADDML8vkh6hrhP+qQs8S2cAeYO0KBOEjixi8xcnSguyvzH4iLSsh/yldtV8G/UBpBJm6PfkGO8WhJ5GypGe713khY/TNKf+8xKmk+fbITqEt1QilQvctIUlZANKGdR1KXeaqee07QXUu/YwmNZPps8nmt1Jq5SnCScivlPll2f046ocTPbz5pcO0zKf1368WYIhpFUYgflzF+zPqt9K9WCHQiMlkzahVIJrhfkCQp6KbNq2/P6LqTPiX1a1oAYGlqQvMyGQRKRqVBsH5UP74H/r5JYowhTG8i6Axa1uaBjyT635bBYibqE3d2CpiMXXWua3NAy5ke3/0tfoy/5/6CnHoxdh3XW9vi2VIs/R1ufKHx2vqvXbtAmkRVCyJ3gVPcGWdaNSTGUEm6aNhFxc/o3S6NixMoFxV0lk8HRW5ijNBqX+9W+Bjrd6VYNBjQGBxaYGD2HWq4uN53mHhVwaCwTphFJ5ZIViYwXXUUQmUMFKTFv4zQkscrIFfYLnA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fb12a61-e1da-4e16-0373-08db1ae65a77 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9563.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 06:21:26.7481 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C8mIdE5Zf/3r+VyK3/MwW8ahEmKwIMhsv2H4fhi3m6V8SACLvjyZDHcmoQrGf/h3Up2jbT2++xW5WuwysW2Tp6geS9ULHgjUzw9tzQYM36A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8632 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Horia GeantA Use job ring register map, in place of controller register map to access page 0 registers, as access to the controller register map is not permitted. Signed-off-by: Horia GeantA --- drivers/crypto/caam/caamalg.c | 21 +++++----- drivers/crypto/caam/caamhash.c | 10 +++-- drivers/crypto/caam/caampkc.c | 6 +-- drivers/crypto/caam/caamrng.c | 6 +-- drivers/crypto/caam/ctrl.c | 74 +++++++++++++++++++++------------- drivers/crypto/caam/debugfs.c | 8 ++-- drivers/crypto/caam/debugfs.h | 7 +++- 7 files changed, 78 insertions(+), 54 deletions(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 4a9b998a8d26..29838b80a0bb 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -3,7 +3,7 @@ * caam - Freescale FSL CAAM support for crypto API * * Copyright 2008-2011 Freescale Semiconductor, Inc. - * Copyright 2016-2019 NXP + * Copyright 2016-2019, 2023 NXP * * Based on talitos crypto API driver. * @@ -3530,13 +3530,14 @@ int caam_algapi_init(struct device *ctrldev) * First, detect presence and attributes of DES, AES, and MD blocks. */ if (priv->era < 10) { + struct caam_perfmon __iomem *perfmon = &priv->jr[0]->perfmon; u32 cha_vid, cha_inst, aes_rn; - cha_vid = rd_reg32(&priv->ctrl->perfmon.cha_id_ls); + cha_vid = rd_reg32(&perfmon->cha_id_ls); aes_vid = cha_vid & CHA_ID_LS_AES_MASK; md_vid = (cha_vid & CHA_ID_LS_MD_MASK) >> CHA_ID_LS_MD_SHIFT; - cha_inst = rd_reg32(&priv->ctrl->perfmon.cha_num_ls); + cha_inst = rd_reg32(&perfmon->cha_num_ls); des_inst = (cha_inst & CHA_ID_LS_DES_MASK) >> CHA_ID_LS_DES_SHIFT; aes_inst = cha_inst & CHA_ID_LS_AES_MASK; @@ -3544,23 +3545,23 @@ int caam_algapi_init(struct device *ctrldev) ccha_inst = 0; ptha_inst = 0; - aes_rn = rd_reg32(&priv->ctrl->perfmon.cha_rev_ls) & - CHA_ID_LS_AES_MASK; + aes_rn = rd_reg32(&perfmon->cha_rev_ls) & CHA_ID_LS_AES_MASK; gcm_support = !(aes_vid == CHA_VER_VID_AES_LP && aes_rn < 8); } else { + struct version_regs __iomem *vreg = &priv->jr[0]->vreg; u32 aesa, mdha; - aesa = rd_reg32(&priv->ctrl->vreg.aesa); - mdha = rd_reg32(&priv->ctrl->vreg.mdha); + aesa = rd_reg32(&vreg->aesa); + mdha = rd_reg32(&vreg->mdha); aes_vid = (aesa & CHA_VER_VID_MASK) >> CHA_VER_VID_SHIFT; md_vid = (mdha & CHA_VER_VID_MASK) >> CHA_VER_VID_SHIFT; - des_inst = rd_reg32(&priv->ctrl->vreg.desa) & CHA_VER_NUM_MASK; + des_inst = rd_reg32(&vreg->desa) & CHA_VER_NUM_MASK; aes_inst = aesa & CHA_VER_NUM_MASK; md_inst = mdha & CHA_VER_NUM_MASK; - ccha_inst = rd_reg32(&priv->ctrl->vreg.ccha) & CHA_VER_NUM_MASK; - ptha_inst = rd_reg32(&priv->ctrl->vreg.ptha) & CHA_VER_NUM_MASK; + ccha_inst = rd_reg32(&vreg->ccha) & CHA_VER_NUM_MASK; + ptha_inst = rd_reg32(&vreg->ptha) & CHA_VER_NUM_MASK; gcm_support = aesa & CHA_VER_MISC_AES_GCM; } diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 82d3c730a502..80deb003f0a5 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -3,7 +3,7 @@ * caam - Freescale FSL CAAM support for ahash functions of crypto API * * Copyright 2011 Freescale Semiconductor, Inc. - * Copyright 2018-2019 NXP + * Copyright 2018-2019, 2023 NXP * * Based on caamalg.c crypto API driver. * @@ -1956,12 +1956,14 @@ int caam_algapi_hash_init(struct device *ctrldev) * presence and attributes of MD block. */ if (priv->era < 10) { - md_vid = (rd_reg32(&priv->ctrl->perfmon.cha_id_ls) & + struct caam_perfmon __iomem *perfmon = &priv->jr[0]->perfmon; + + md_vid = (rd_reg32(&perfmon->cha_id_ls) & CHA_ID_LS_MD_MASK) >> CHA_ID_LS_MD_SHIFT; - md_inst = (rd_reg32(&priv->ctrl->perfmon.cha_num_ls) & + md_inst = (rd_reg32(&perfmon->cha_num_ls) & CHA_ID_LS_MD_MASK) >> CHA_ID_LS_MD_SHIFT; } else { - u32 mdha = rd_reg32(&priv->ctrl->vreg.mdha); + u32 mdha = rd_reg32(&priv->jr[0]->vreg.mdha); md_vid = (mdha & CHA_VER_VID_MASK) >> CHA_VER_VID_SHIFT; md_inst = mdha & CHA_VER_NUM_MASK; diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index e40614fef39d..72afc249d42f 100644 --- a/drivers/crypto/caam/caampkc.c +++ b/drivers/crypto/caam/caampkc.c @@ -3,7 +3,7 @@ * caam - Freescale FSL CAAM support for Public Key Cryptography * * Copyright 2016 Freescale Semiconductor, Inc. - * Copyright 2018-2019 NXP + * Copyright 2018-2019, 2023 NXP * * There is no Shared Descriptor for PKC so that the Job Descriptor must carry * all the desired key parameters, input and output pointers. @@ -1168,10 +1168,10 @@ int caam_pkc_init(struct device *ctrldev) /* Determine public key hardware accelerator presence. */ if (priv->era < 10) { - pk_inst = (rd_reg32(&priv->ctrl->perfmon.cha_num_ls) & + pk_inst = (rd_reg32(&priv->jr[0]->perfmon.cha_num_ls) & CHA_ID_LS_PK_MASK) >> CHA_ID_LS_PK_SHIFT; } else { - pkha = rd_reg32(&priv->ctrl->vreg.pkha); + pkha = rd_reg32(&priv->jr[0]->vreg.pkha); pk_inst = pkha & CHA_VER_NUM_MASK; /* diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index 1fd8ff965006..50eb55da45c2 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c @@ -3,7 +3,7 @@ * caam - Freescale FSL CAAM support for hw_random * * Copyright 2011 Freescale Semiconductor, Inc. - * Copyright 2018-2019 NXP + * Copyright 2018-2019, 2023 NXP * * Based on caamalg.c crypto API driver. * @@ -227,10 +227,10 @@ int caam_rng_init(struct device *ctrldev) /* Check for an instantiated RNG before registration */ if (priv->era < 10) - rng_inst = (rd_reg32(&priv->ctrl->perfmon.cha_num_ls) & + rng_inst = (rd_reg32(&priv->jr[0]->perfmon.cha_num_ls) & CHA_ID_LS_RNG_MASK) >> CHA_ID_LS_RNG_SHIFT; else - rng_inst = rd_reg32(&priv->ctrl->vreg.rng) & CHA_VER_NUM_MASK; + rng_inst = rd_reg32(&priv->jr[0]->vreg.rng) & CHA_VER_NUM_MASK; if (!rng_inst) return 0; diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 6278afb951c3..be9724d05d01 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -3,7 +3,7 @@ * Controller-level driver, kernel property detection, initialization * * Copyright 2008-2012 Freescale Semiconductor, Inc. - * Copyright 2018-2019 NXP + * Copyright 2018-2019, 2023 NXP */ #include @@ -395,7 +395,7 @@ static void kick_trng(struct platform_device *pdev, int ent_delay) RTMCTL_SAMP_MODE_RAW_ES_SC); } -static int caam_get_era_from_hw(struct caam_ctrl __iomem *ctrl) +static int caam_get_era_from_hw(struct caam_perfmon __iomem *perfmon) { static const struct { u16 ip_id; @@ -421,12 +421,12 @@ static int caam_get_era_from_hw(struct caam_ctrl __iomem *ctrl) u16 ip_id; int i; - ccbvid = rd_reg32(&ctrl->perfmon.ccb_id); + ccbvid = rd_reg32(&perfmon->ccb_id); era = (ccbvid & CCBVID_ERA_MASK) >> CCBVID_ERA_SHIFT; if (era) /* This is '0' prior to CAAM ERA-6 */ return era; - id_ms = rd_reg32(&ctrl->perfmon.caam_id_ms); + id_ms = rd_reg32(&perfmon->caam_id_ms); ip_id = (id_ms & SECVID_MS_IPID_MASK) >> SECVID_MS_IPID_SHIFT; maj_rev = (id_ms & SECVID_MS_MAJ_REV_MASK) >> SECVID_MS_MAJ_REV_SHIFT; @@ -446,7 +446,7 @@ static int caam_get_era_from_hw(struct caam_ctrl __iomem *ctrl) * * @ctrl: controller region */ -static int caam_get_era(struct caam_ctrl __iomem *ctrl) +static int caam_get_era(struct caam_perfmon __iomem *perfmon) { struct device_node *caam_node; int ret; @@ -459,7 +459,7 @@ static int caam_get_era(struct caam_ctrl __iomem *ctrl) if (!ret) return prop; else - return caam_get_era_from_hw(ctrl); + return caam_get_era_from_hw(perfmon); } /* @@ -626,6 +626,7 @@ static int caam_probe(struct platform_device *pdev) struct device_node *nprop, *np; struct caam_ctrl __iomem *ctrl; struct caam_drv_private *ctrlpriv; + struct caam_perfmon __iomem *perfmon; struct dentry *dfs_root; u32 scfgr, comp_params; u8 rng_vid; @@ -665,9 +666,36 @@ static int caam_probe(struct platform_device *pdev) return ret; } - caam_little_end = !(bool)(rd_reg32(&ctrl->perfmon.status) & + ring = 0; + for_each_available_child_of_node(nprop, np) + if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || + of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { + u32 reg; + + if (of_property_read_u32_index(np, "reg", 0, ®)) { + dev_err(dev, "%s read reg property error\n", + np->full_name); + continue; + } + + ctrlpriv->jr[ring] = (struct caam_job_ring __iomem __force *) + ((__force uint8_t *)ctrl + reg); + + ctrlpriv->total_jobrs++; + ring++; + } + + /* + * Wherever possible, instead of accessing registers from the global page, + * use the alias registers in the first (cf. DT nodes order) + * job ring's page. + */ + perfmon = ring ? (struct caam_perfmon *)&ctrlpriv->jr[0]->perfmon : + (struct caam_perfmon *)&ctrl->perfmon; + + caam_little_end = !(bool)(rd_reg32(&perfmon->status) & (CSTA_PLEND | CSTA_ALT_PLEND)); - comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ms); + comp_params = rd_reg32(&perfmon->comp_parms_ms); if (comp_params & CTPR_MS_PS && rd_reg32(&ctrl->mcr) & MCFGR_LONG_PTR) caam_ptr_sz = sizeof(u64); else @@ -778,7 +806,7 @@ static int caam_probe(struct platform_device *pdev) return ret; } - ctrlpriv->era = caam_get_era(ctrl); + ctrlpriv->era = caam_get_era(perfmon); ctrlpriv->domain = iommu_get_domain_for_dev(dev); dfs_root = debugfs_create_dir(dev_name(dev), NULL); @@ -789,7 +817,7 @@ static int caam_probe(struct platform_device *pdev) return ret; } - caam_debugfs_init(ctrlpriv, dfs_root); + caam_debugfs_init(ctrlpriv, perfmon, dfs_root); /* Check to see if (DPAA 1.x) QI present. If so, enable */ if (ctrlpriv->qi_present && !caam_dpaa2) { @@ -808,19 +836,6 @@ static int caam_probe(struct platform_device *pdev) #endif } - ring = 0; - for_each_available_child_of_node(nprop, np) - if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || - of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { - ctrlpriv->jr[ring] = (struct caam_job_ring __iomem __force *) - ((__force uint8_t *)ctrl + - (ring + JR_BLOCK_NUMBER) * - BLOCK_OFFSET - ); - ctrlpriv->total_jobrs++; - ring++; - } - /* If no QI and no rings specified, quit and go home */ if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) { dev_err(dev, "no queues configured, terminating\n"); @@ -836,12 +851,17 @@ static int caam_probe(struct platform_device *pdev) * check both here. */ if (ctrlpriv->era < 10) { - rng_vid = (rd_reg32(&ctrl->perfmon.cha_id_ls) & + rng_vid = (rd_reg32(&perfmon->cha_id_ls) & CHA_ID_LS_RNG_MASK) >> CHA_ID_LS_RNG_SHIFT; ctrlpriv->blob_present = ctrlpriv->blob_present && (rd_reg32(&ctrl->perfmon.cha_num_ls) & CHA_ID_LS_AES_MASK); } else { - rng_vid = (rd_reg32(&ctrl->vreg.rng) & CHA_VER_VID_MASK) >> + struct version_regs __iomem *vreg; + + vreg = ring ? (struct version_regs *)&ctrlpriv->jr[0]->vreg : + (struct version_regs *)&ctrl->vreg; + + rng_vid = (rd_reg32(&vreg->rng) & CHA_VER_VID_MASK) >> CHA_VER_VID_SHIFT; ctrlpriv->blob_present = ctrlpriv->blob_present && (rd_reg32(&ctrl->vreg.aesa) & CHA_VER_MISC_AES_NUM_MASK); @@ -925,8 +945,8 @@ static int caam_probe(struct platform_device *pdev) /* NOTE: RTIC detection ought to go here, around Si time */ - caam_id = (u64)rd_reg32(&ctrl->perfmon.caam_id_ms) << 32 | - (u64)rd_reg32(&ctrl->perfmon.caam_id_ls); + caam_id = (u64)rd_reg32(&perfmon->caam_id_ms) << 32 | + (u64)rd_reg32(&perfmon->caam_id_ls); /* Report "alive" for developer to see */ dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id, diff --git a/drivers/crypto/caam/debugfs.c b/drivers/crypto/caam/debugfs.c index 806bb20d2aa1..73fe8530c0d6 100644 --- a/drivers/crypto/caam/debugfs.c +++ b/drivers/crypto/caam/debugfs.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2019 NXP */ +/* Copyright 2019, 2023 NXP */ #include #include "compat.h" @@ -42,16 +42,14 @@ void caam_debugfs_qi_init(struct caam_drv_private *ctrlpriv) } #endif -void caam_debugfs_init(struct caam_drv_private *ctrlpriv, struct dentry *root) +void caam_debugfs_init(struct caam_drv_private *ctrlpriv, + struct caam_perfmon *perfmon, struct dentry *root) { - struct caam_perfmon *perfmon; - /* * FIXME: needs better naming distinction, as some amalgamation of * "caam" and nprop->full_name. The OF name isn't distinctive, * but does separate instances */ - perfmon = (struct caam_perfmon __force *)&ctrlpriv->ctrl->perfmon; ctrlpriv->ctl = debugfs_create_dir("ctl", root); diff --git a/drivers/crypto/caam/debugfs.h b/drivers/crypto/caam/debugfs.h index 661d768acdbf..fd2f0fc46d53 100644 --- a/drivers/crypto/caam/debugfs.h +++ b/drivers/crypto/caam/debugfs.h @@ -1,16 +1,19 @@ /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ -/* Copyright 2019 NXP */ +/* Copyright 2019, 2023 NXP */ #ifndef CAAM_DEBUGFS_H #define CAAM_DEBUGFS_H struct dentry; struct caam_drv_private; +struct caam_perfmon; #ifdef CONFIG_DEBUG_FS -void caam_debugfs_init(struct caam_drv_private *ctrlpriv, struct dentry *root); +void caam_debugfs_init(struct caam_drv_private *ctrlpriv, + struct caam_perfmon *perfmon, struct dentry *root); #else static inline void caam_debugfs_init(struct caam_drv_private *ctrlpriv, + struct caam_perfmon *perfmon, struct dentry *root) {} #endif From patchwork Thu Mar 2 06:20:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Meenakshi Aggarwal X-Patchwork-Id: 658858 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70734C678D4 for ; Thu, 2 Mar 2023 06:22:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbjCBGWs (ORCPT ); Thu, 2 Mar 2023 01:22:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230087AbjCBGWq (ORCPT ); Thu, 2 Mar 2023 01:22:46 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2081.outbound.protection.outlook.com [40.107.21.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 414553BDA8; Wed, 1 Mar 2023 22:22:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ad8q4bpPZqTkXMhPC/C/ikn3LP8qaDCeWx2Uq43QQanPr/hmC6lmwJkT2jYJF9iCcFYezr+Ga6xuWpYyyTuBW8T3VnctuGpv7ZF6+hgoxlUZxLpdJqlw5RP6mROrSR+/n/niTpQK8uPQTgcqEfq2ZmafJT9Uf041XGoRyJcHcokgIHI/sA9U+8YMC/NlU6Jo4i1XbZHTDfmhbt/q5dTsMxXX2JPQDUlczOjrfa0P8gSAt17sXuPT4WyIFBMIdoLfVNcjR1gt8M0iiOrIGRge4Rn3SKelQ3pvmgJbQKrN+vIdnbhZRrauLgS4/rcQEnqWmQWGkxVa3imUhpj63lbReA== 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=p0L8UxVO0mJp5RvLSztyzX4a7F21cDJJjEg31u3E704=; b=OFvcst0eVtplvwaV2M8E234JMjRYInWKNovuoS2W45SFmfiMv/3mQ1ZMSzIFqx2zLLANkCgrOmIEyfFKMMrokiv7e8FFF9EXqMCMDWS8RAql6v8Jn0FfvVFHtsFFQq17USB/07PkWidK8qFAUxAGWsCZz759Z1PBZ0n/JsQ2NsSeGZsyqye3OxUCJpmIsbiS1rUxPbyzKlGNbIVplsIJQQnOoNYg10yZAxBPBMLFWHpDEFu84BdJw6SA6tTfMH7FQthjdPReonVbtz/h1jOtFGLAtoCWnobU3J8KJvEfkLF5DR0NBU37p58wV4hSnnyQHId/9Ou1S6ZzSbSFEc2efg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p0L8UxVO0mJp5RvLSztyzX4a7F21cDJJjEg31u3E704=; b=D1mCjsn95HgeoIRowEC656l+2SBmlHEX6pjWAJVaczWwYRZ04UAL7mmIWXGo7AutUKGbu7/y2UWPBLbGyiXXaqPsfv5YVq8P9iLA8R6Op7KaHdVnS+qzNPGo/hvvwGm8wnKbnzRKIsCmsgTuI0rrfjVnVetWxLJBvNZq9FTKrz0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU0PR04MB9563.eurprd04.prod.outlook.com (2603:10a6:10:314::7) by DU2PR04MB8632.eurprd04.prod.outlook.com (2603:10a6:10:2df::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19; Thu, 2 Mar 2023 06:21:31 +0000 Received: from DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::a518:512c:4af1:276e]) by DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::a518:512c:4af1:276e%4]) with mapi id 15.20.6134.026; Thu, 2 Mar 2023 06:21:31 +0000 From: meenakshi.aggarwal@nxp.com To: horia.geanta@nxp.com, V.sethi@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Meenakshi Aggarwal Subject: [PATCH 2/2] crypto: caam - OP-TEE firmware support Date: Thu, 2 Mar 2023 11:50:55 +0530 Message-Id: <20230302062055.1564514-3-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302062055.1564514-1-meenakshi.aggarwal@nxp.com> References: <20230302062055.1564514-1-meenakshi.aggarwal@nxp.com> X-ClientProxiedBy: SI2PR02CA0032.apcprd02.prod.outlook.com (2603:1096:4:195::12) To DU0PR04MB9563.eurprd04.prod.outlook.com (2603:10a6:10:314::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9563:EE_|DU2PR04MB8632:EE_ X-MS-Office365-Filtering-Correlation-Id: c8404737-230b-4671-2004-08db1ae65d6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sVlXWJpMrOw6mubJ9WOTv5QmNxPyS3SWMrzwuDT82gmaJW8Lssp5dSbxgKj0G+FtSOufpqyhIpEMy8j4yO93aL50FON31/dXzrY9nrHSaG6pbuIzANCs8/OiNrjbvz/hwhzUzT2y9h/BznB0iCY0241CUU+jCf2+SZrqvsBqlxiDk63ZfH3xr5tZvD761wx3JbpPBvZjBaSYfj5zDnoKO57AnNWBlF9pIPRmScTREUbBlOLJmZnv0d8zYidO1fmDRL9WI5dC7q4T4Y9csCHAN1OmsNkBNI+Ii6k7UPTfMMc/u66vThNNfCFwCyDDNZzEfO9vbR1yDDYXYq2aAvrczq49o6n8pWt9a0PYHzNeThTeLTdl2iKX6qmsQRgItj10ZkDFBAvhm4a6gQx4U8OYZUEiRu1jV1Da9tAIa2zC7B7RmlB43zrFZkjObrgSN6PH9f10K2DhmxaY/iJci6VB70vynQ1zKOjMNM90zojhFsuocCuaJKBVqOkSuivmEorCLKWEZBuFsE93lCd4kTAu7Z0nmJ7Q0jd0OkOJaV5dTAfCpVRQMDalvtR8lX1MVemc9H8r8nNg9LVgC+cnczl3VK2ZnA7THFmWXiZ0ydQuy54qB0D+LihaJkJ1wn0C48iwmIkSHDmFpw9Ez0gyjzec5QSG4zx9UWRkFJFbGk2lDIlJ2nRweerd272HqdnqNjFAsbFF4DKrJcnbFneMPJlBjj+gn9/Dzk0lgLp/rLRhcJs= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9563.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(346002)(366004)(39860400002)(376002)(136003)(396003)(451199018)(5660300002)(41300700001)(8936002)(38100700002)(38350700002)(4326008)(8676002)(83380400001)(186003)(2906002)(66946007)(66556008)(2616005)(66476007)(316002)(86362001)(6486002)(478600001)(36756003)(9686003)(6506007)(1076003)(26005)(6512007)(52116002)(6666004)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?W0/Y47YVyT1eVhbtU0o5GgyO//eT?= =?utf-8?q?LHMgXjGirFZUky5FmmfB/0utBTqtr6azFR4rDEgFRAuciKOOvILSWgwwmgznkAqTx?= =?utf-8?q?Wbbj4MGA6JCqnQiuAbhlepqZ8r02LhY3jiiBLNHNGKyNC7tu/2oWh3efQf6hGCDGf?= =?utf-8?q?yp8YaKw7Otk6Wy2jQJ69wAytBuJd2wODdBjWtbeM2sBb4/MkgDG50sSuNx1UE+BBI?= =?utf-8?q?jz8M3thsEHV2a+TQBfDY9wgZCKovbBeq7y7h710Z7caKpkgErvPvkBUcgnpRsk0dG?= =?utf-8?q?i5wrbMCDhw2uYujRUvW6t4ugcqzCfL7ZiAmGX6uAwj0Nk+FMS/kF01qMG8iDihLgN?= =?utf-8?q?zlWLfjJu3VgSY4ueqrCl7430eGBPMzSQBOXvn7sK6cCqmpLLL+6B7mG6ssl5sabhJ?= =?utf-8?q?aHYS2VSb6UsFucIiC0x1DAuUCbBaH7Eqofh2DFgoxlcLnpxJ2CLKE9IzuopvxXJM6?= =?utf-8?q?CSjRHLZ5pDZcRvHtQh38fAJs04q1LPSNhf9BTvq4CJsjRwbdtpitTu9u08u0uSXqU?= =?utf-8?q?iVXHp50DzxjM11x78KTWA6u1lLN/HtzX8SjQjgeu9cQ7xa2ZPF+rEpUBEERIRATRW?= =?utf-8?q?wUZga4iLzIi/2pxQjaqBt4ahBf3zY4hT3MsvCuN5uE4auvYO3gKfaAd3T1B0Xj6qJ?= =?utf-8?q?HTC1HomtR5LcVy1PHjB7DfKqu6RNTump2kKNl//kY9SSVFmH8NNv3YWaFgvoCf5bX?= =?utf-8?q?xiTaPE2/DSecWCNMQ2l8oGxyZiuIe/un0Ahidi0j33ALMA7X2cirK64IpibfqHTJg?= =?utf-8?q?hzdHPT7Jmb9R7YhGacMbsBoBgpCSRLxKhEd09lFfCbpnyFnFW743VH7Yi8Z/aVqkn?= =?utf-8?q?ALNaCovyP2Stgyknqh0wY17gQTapouEM331olR+4/zFbzYK3+QplRREU3tLojphPq?= =?utf-8?q?Gl6zbaooXZ7uooz8oIWdP2GHUyjD+Es8v/8WlnvWDZwNzuf5kW1ISwFl2fV5GdCDj?= =?utf-8?q?4muaMPT2Pgl9Rh+RNEASDo9rh7SRHtIHZS0wkO56ecw7kyW00MPvqpJCMm+vbl5go?= =?utf-8?q?/RurEU1aU3WhtiPh9gWbyPtmuy/vxlUfb6BEiPTanToY3itFSgSVmptFI1/ZiFT5Q?= =?utf-8?q?+X8tEUxYkoUfIHdplYQ+GyO57NpMClvx6HEHjW5vXJCLhULtWQz2RzBTofUbUmvoN?= =?utf-8?q?1gmvy163HKO5harMaPH9BpZrFX3cduSLfDfAbNbN5MydX08qwkBorFRHg6i/NNZH7?= =?utf-8?q?9D6NUNoCP+wS+J5lj/yAqGw+vH7HiA1n5fCPyZZkiFvPgUoj80SVpbL804qMYZjAZ?= =?utf-8?q?eGqDJ6iCKIr5t0Bxbc9pDVNTJGPuh5izpOpuIDm2bDzfJiqjmhdOy7Empf2IWQZ41?= =?utf-8?q?VwsWUz2lEY1qs3QmWaZ6yJiiB2x4abAZxHTMjY9n3JQEGGnCF5Fg9jHsLcjq8zukT?= =?utf-8?q?rlen6mMJS/qUI7LNgUaWDZHBIK3LQ9mEfktCLHXQKDL5dl9y4EtsMRayfJ9Hygect?= =?utf-8?q?qwtHviAhlO+kwCJF+dLeYNXS213yxN/qvI5VIMIj2NF2nE1ModOaB4KhwF7WkDb7a?= =?utf-8?q?Hxgg1libISZe+rNc6cpX1WGL+l8fPAl8JQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8404737-230b-4671-2004-08db1ae65d6d X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9563.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 06:21:31.7164 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: H7T4kVdN6g4pw2KvJ75uPyvfi0WDCXn18WS/DRQdTOzIVAXXGnYawooYoQb/qfZlaUjXwe33G93VUtfII3K9p6xcUUe1pm0s5qwW30IIsAk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8632 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Horia Geantă caam driver needs to be aware of OP-TEE f/w presence, since some things are done differently: 1. there is no access to controller's register page (note however that some registers are aliased in job rings' register pages) 2 Due to this, MCFGR[PS] cannot be read and driver assumes MCFGR[PS] = b'0 - engine using 32-bit address pointers. This is in sync with the fact that: -all i.MX SoCs currently use MCFGR[PS] = b'0 -only i.MX OP-TEE use cases don't allow access to controller register page Signed-off-by: Horia Geantă Signed-off-by: Meenakshi Aggarwal --- drivers/crypto/caam/ctrl.c | 24 ++++++++++++++++++++++-- drivers/crypto/caam/debugfs.c | 3 +++ drivers/crypto/caam/intern.h | 3 ++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index be9724d05d01..5a6cd63742a4 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -633,6 +633,7 @@ static int caam_probe(struct platform_device *pdev) int pg_size; int BLOCK_OFFSET = 0; bool pr_support = false; + bool reg_access = true; ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(*ctrlpriv), GFP_KERNEL); if (!ctrlpriv) @@ -646,6 +647,17 @@ static int caam_probe(struct platform_device *pdev) caam_imx = (bool)imx_soc_match; if (imx_soc_match) { + /* + * Until Layerscape and i.MX OP-TEE get in sync, + * only i.MX OP-TEE use cases disallow access to + * caam page 0 (controller) registers. + */ + np = of_find_compatible_node(NULL, NULL, "linaro,optee-tz"); + ctrlpriv->optee_en = !!np; + of_node_put(np); + + reg_access = ctrlpriv->optee_en; + if (!imx_soc_match->data) { dev_err(dev, "No clock data provided for i.MX SoC"); return -EINVAL; @@ -696,7 +708,8 @@ static int caam_probe(struct platform_device *pdev) caam_little_end = !(bool)(rd_reg32(&perfmon->status) & (CSTA_PLEND | CSTA_ALT_PLEND)); comp_params = rd_reg32(&perfmon->comp_parms_ms); - if (comp_params & CTPR_MS_PS && rd_reg32(&ctrl->mcr) & MCFGR_LONG_PTR) + if (reg_access && comp_params & CTPR_MS_PS && + rd_reg32(&ctrl->mcr) & MCFGR_LONG_PTR) caam_ptr_sz = sizeof(u64); else caam_ptr_sz = sizeof(u32); @@ -761,6 +774,9 @@ static int caam_probe(struct platform_device *pdev) } #endif + if (!reg_access) + goto set_dma_mask; + /* * Enable DECO watchdogs and, if this is a PHYS_ADDR_T_64BIT kernel, * long pointers in master configuration register. @@ -799,7 +815,7 @@ static int caam_probe(struct platform_device *pdev) clrsetbits_32(&ctrl->jrstart, 0, JRSTART_JR0_START | JRSTART_JR1_START | JRSTART_JR2_START | JRSTART_JR3_START); - +set_dma_mask: ret = dma_set_mask_and_coherent(dev, caam_get_dma_mask(dev)); if (ret) { dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret); @@ -842,6 +858,9 @@ static int caam_probe(struct platform_device *pdev) return -ENOMEM; } + if (!reg_access) + goto report_live; + comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ls); ctrlpriv->blob_present = !!(comp_params & CTPR_LS_BLOB); @@ -945,6 +964,7 @@ static int caam_probe(struct platform_device *pdev) /* NOTE: RTIC detection ought to go here, around Si time */ +report_live: caam_id = (u64)rd_reg32(&perfmon->caam_id_ms) << 32 | (u64)rd_reg32(&perfmon->caam_id_ls); diff --git a/drivers/crypto/caam/debugfs.c b/drivers/crypto/caam/debugfs.c index 73fe8530c0d6..42081224f568 100644 --- a/drivers/crypto/caam/debugfs.c +++ b/drivers/crypto/caam/debugfs.c @@ -76,6 +76,9 @@ void caam_debugfs_init(struct caam_drv_private *ctrlpriv, debugfs_create_file("fault_status", 0444, ctrlpriv->ctl, &perfmon->status, &caam_fops_u32_ro); + if (ctrlpriv->optee_en) + return; + /* Internal covering keys (useful in non-secure mode only) */ ctrlpriv->ctl_kek_wrap.data = (__force void *)&ctrlpriv->ctrl->kek[0]; ctrlpriv->ctl_kek_wrap.size = KEK_KEY_SIZE * sizeof(u32); diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 572cf66c887a..efe2bc2f1103 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -4,7 +4,7 @@ * Private/internal definitions between modules * * Copyright 2008-2011 Freescale Semiconductor, Inc. - * Copyright 2019 NXP + * Copyright 2019, 2023 NXP */ #ifndef INTERN_H @@ -94,6 +94,7 @@ struct caam_drv_private { u8 qi_present; /* Nonzero if QI present in device */ u8 blob_present; /* Nonzero if BLOB support present in device */ u8 mc_en; /* Nonzero if MC f/w is active */ + u8 optee_en; /* Nonzero if OP-TEE f/w is active */ int secvio_irq; /* Security violation interrupt number */ int virt_en; /* Virtualization enabled in CAAM */ int era; /* CAAM Era (internal HW revision) */