From patchwork Wed Apr 5 09:07:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meenakshi Aggarwal X-Patchwork-Id: 13201434 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 63836C761AF for ; Wed, 5 Apr 2023 09:08:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237189AbjDEJIa (ORCPT ); Wed, 5 Apr 2023 05:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237052AbjDEJI2 (ORCPT ); Wed, 5 Apr 2023 05:08:28 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2075.outbound.protection.outlook.com [40.107.6.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7E493; Wed, 5 Apr 2023 02:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ljy+5GwgqY/OSUz7XsOh/Fbqft5FPpZiQKU9P7km0pWpgzumswKvTPSiNwNRBOJvTjqRRE0bscZBW2HUik7DMMoQFbV8v7RF5x7/sDBo6V6etd31tiPZNgJoPaSdQAge0yDUGmGr5PCwfqKvKXcmUgRSkPVlJkNz+eNxN/77WHAJlLe84OdwMWqOQh0DhG8AVjFIirE2nYMMzmM3+HvaLjRl20CXQaBEcJKamV3pF8J0+eTznQXv1YxtKvesqOajhnpi7NDYqHeH8E2jFRljjp8TTYGA5wPl1xHvGga/Bw+T8HR1ai2aMSg5bQ2Vl3vSd8PACShJoYIBu1Gekzdwgg== 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=QD3459cwMhznOuzvdaKRcmOH5t8xzsn0l0Hb0cK0uh4=; b=fqqNXL4YKtpYKMI7hIlzKhHUhhzb2d9wGTSgKRTyTgr0tZJBOYet63AJejP5Gh+JPJEw6Qf1VGLVFHPze/HkQQaMIvdGk86GPU15OzyWaetvT7bzF7t/rXeIDkC8VCY4EuMbtvY9Vn11Q50FmoZ3yoHXI0yfWhLtA2aZzdGIiFoZcTy8kXPCGWwI3oaEwSBCwoPw5fTCmujk8xEn8hnCqAvdzSSKsYmW7sK7PIiLcwtHZxvLnIyX8ZNfAPSHc+Yq3tPSX9kHVbN1NMwuqQxPw9SzET4wd2vF+Z5f2WH78PXcH7YaHL1xlqESSTE0EUhTg4g/Bk5Hu4KPawq3xWF7Ug== 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=QD3459cwMhznOuzvdaKRcmOH5t8xzsn0l0Hb0cK0uh4=; b=cg/04NkTIYAxDe59h2pFi177o0/MpsL5hoNa/RFr8uFxUTo+0q+w/+xGFczDUV5SOrwdEfXD9/BrrTsw99jvuGRiw7U51d2h0LYPXfs5k5Z4xHVB5m3frUKCI7FV3zDXXFsr7I2zxViYDt0igGrdJ0fDKSbZt2DHm5eFQqiqn8Y= 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 AM8PR04MB7473.eurprd04.prod.outlook.com (2603:10a6:20b:1d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.29; Wed, 5 Apr 2023 09:08:20 +0000 Received: from DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::dca6:e1e8:f142:2bc5]) by DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::dca6:e1e8:f142:2bc5%8]) with mapi id 15.20.6254.033; Wed, 5 Apr 2023 09:08:20 +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 , Varun Sethi Subject: [PATCH v3 1/2] crypto: caam - reduce page 0 regs access to minimum Date: Wed, 5 Apr 2023 11:07:51 +0200 Message-Id: <20230405090752.1708455-2-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405090752.1708455-1-meenakshi.aggarwal@nxp.com> References: <20230322061716.3195841-3-meenakshi.aggarwal@nxp.com> <20230405090752.1708455-1-meenakshi.aggarwal@nxp.com> X-ClientProxiedBy: AM8P251CA0029.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::34) To DU0PR04MB9563.eurprd04.prod.outlook.com (2603:10a6:10:314::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9563:EE_|AM8PR04MB7473:EE_ X-MS-Office365-Filtering-Correlation-Id: abcefffc-1c80-4875-69e3-08db35b54d2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: khdZC0MjuJfZgJdZRQI36ivgNBGem4pt+q0cK2PfTtNR31HtOJlNOOAQ6Is1ANVIf0YvVtYAiXWLnaaDnOS8qF/5Yb4Yg6znfYjYg5fPbz3PfsZcNgVjViQhCeV3RvwNbiM2xzBZZntdEs2AjmyzzuA295+5pmO+GYQg3BSU+dIQdwvSyl4J1nXNhLgav1+Hjt4Q8QEA7EaowBrhYYG6YU5PsWClg+nB5Pmek3fo+oEkC/mZFNnqm3uVAkGl98iaLcOP9e10iWA0CU6q8xw69XB0It6tM5OkPKGru37dnwamJ5c2ZDza7EI/36Lzk68+ah6T+79jMaCgK0GFgzQmgJ4WYYMviOzMMzJKkiVccyUOeM0/ta2/nfSvkA0uryr9wP+ADt/H6swRrdWTEAX0y7OsXpUR0uRkqc8n2dj4Dak8H47dPEOtpiZGZTYCTg1BpDc0C5FiEjp85QfbXuPbtJNFW1XqPFd0sdFF+HRpIYDvUc/BMjhfSae0947ma6swfw/T9uxccqRbetZJfW3e5Kb9jvdBjyOxrrumMA5OB41DBSiK/2yxaWwCFVh+InO6tKvtoNDPZMNQNR/BDtnpy9wqNuOgbNK2l+Ay9yVCqaoCJrTOXLeLTOTJdkJDrjBP 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:(13230028)(4636009)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199021)(6666004)(86362001)(41300700001)(36756003)(186003)(30864003)(54906003)(6486002)(4326008)(8676002)(52116002)(478600001)(38100700002)(2906002)(66476007)(83380400001)(66946007)(66556008)(316002)(8936002)(38350700002)(26005)(5660300002)(2616005)(6512007)(9686003)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0h6wg6ooGc4RmAbMzcqncNSACUPN9/AYGtLlQdOkutAz7UGGaFuAq4W/V0dzo80AOZfY9VN2Hte4wkC5u3scRCoH8IQdiWv4wVKDJwGMHXZ1EFRcR8doR0Jlr6Yk+dNlpFthoBaQRDJ0dc2fjjJYnsCVurg+Y1BNm/65g+AYMEcuEd56JSPCwHJoMqVFhlrxIyr4Th3iRKzvoM+0spykZRPE4c2sBrd3bnXlWjspW+cp2MKC7v+8j9gPwVKROYNSwmfU345gGmL+VRG+PIbOH3GHRGISLHtUNG/bYSWJ+w/Qpts7Tv2BWquI1XmPd7qTubElxNwf8NOk7PrB+uFX1v6j3cEWt10B1oAQP26GnLNtCdFLxvLAX4SVDGfIEW8G8gb65bDD++17f3Fi5xtAdb2FEivIP3kSi+PTAYThVG5qwp+rqY+IT/KA/GmCLwUhJvTHOjJOFZ7igGJW+yVjV9T15y5BwKGgFllB2QG5YGmuEEtHw3Yl7kRuAL3RrLESIfYrvV/f9uKArfRkWmtgiq1YQ+/Z4ILiw/svOMTO5onn1RRqTQel+uYeE65qaLZUKOyAZlL3nN16WGh2Nb1LT/3pYYPehy0cmRAvAwG8SZTfnCWyAk2tijERYUjff7OouKdmB5756skPYc9Tm/ieId3ytJeM4o7mHTBnmooOjD5NX7URf373HO4SUR96vxQweDS/80h3dEo+/K8B7HtUAF/0wnRzk5I0VPo/JpN2mdsHULKA3PAIKG/uUEf5PJpghpQ/x3/Qxz1fVpTN9wHlK4bXrAtRoOS6LvYs99XTawnZMA5FupQWR5aaEWUA2WXq4MQjC2hPA+CKbdXG6TfXnaVInTZrW86dt2zNFh65VOAPGP479W5+Y+ulk9CRJ5BmMEHzBw4k4YTQ1V/GZKixTRCR/9dIqS+jS/XseWtPcNMcrq6JDC9QzTD7A0m2f0blNr3ZVFvxrv0SghmiyTRD4bu6GM5BMt5J6lr5dZWQGEMxO1TUzo9qa9Rayhvk9yv34Kt9pBPA6MDxneqavJINm0WqjfI8NRtS+7M5kekd+hLzwlKOOz8fmkaDPD4+0/2nqIrk65fvc+skAg4iA9AYRtgM155IMv2/a7p80RTLnAQjD8kA7gJOIhxVfVTQiq6ka9XLNlhr6pM98qm1IHCqJYgRGzMC3LDujKSWTJrYfEnkK74yWLZcs0fr2YspEmWn6AKoiTwA6z4wXlo4C1w1PMzk/Iw2ybrn6sMJOVJkBPVpifKxGs32qwQcIpw0iBwkcKmci/rTSwCLpkBEVSZKvXA0KR3YolHAZPdAxgz3oNDbZwC3Jr5cAdUPx2tgmdLBbYO3Flc09Lssdqahhpa8ju148620YrFGDIlCUbtpNbLBSqmYwbjpNUFgWrz/YojN/gjg9cUYHIM0xqSd1vKgWnYnrPDhbNy7H/YskoLvIg1FzgssWpwRwDQ56XDceM9GDn10Nnt/f6su6UsVWaCj02uB4kuJBaMltbV41tTdEfnhdUh4IIwRGyKVYWsxgqW0f/P1iXcOL37O2cncCf/g8zFHO4atr8kQ+komtSwtXYUSgRRcvRZYT8yXghSqdCFgkUKV/q00UhjfgiFTaDAI7g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: abcefffc-1c80-4875-69e3-08db35b54d2e X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9563.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2023 09:08:20.4807 (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: TzSGYuDNoPtl3pr5GQA/PFLnBGpWSumV3sMAVhGJ5UYAHYP2VbsoAJPSOf+yGuMuGN444A4PFuOKkjU29gMU9om0EZBEValNcNfxtFiK7aQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7473 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 Signed-off-by: Gaurav Jain Signed-off-by: Meenakshi Aggarwal Reviewed-by: Varun Sethi Reviewed-by: Gaurav Jain --- 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 | 83 +++++++++++++++++++++------------- drivers/crypto/caam/debugfs.c | 9 ++-- drivers/crypto/caam/debugfs.h | 7 ++- 7 files changed, 84 insertions(+), 58 deletions(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 12b1c8346243..feb86013dbf6 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. * @@ -3542,13 +3542,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; @@ -3556,23 +3557,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..de1f0acdb712 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; @@ -444,9 +444,9 @@ static int caam_get_era_from_hw(struct caam_ctrl __iomem *ctrl) * In case this property is not passed an attempt to retrieve the CAAM * era via register reads will be made. * - * @ctrl: controller region + * @perfmon: Performance Monitor Registers */ -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 __iomem *)&ctrlpriv->jr[0]->perfmon : + (struct caam_perfmon __iomem *)&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,26 +836,13 @@ 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"); return -ENOMEM; } - comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ls); + comp_params = rd_reg32(&perfmon->comp_parms_ls); ctrlpriv->blob_present = !!(comp_params & CTPR_LS_BLOB); /* @@ -836,15 +851,21 @@ 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); + (rd_reg32(&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 = ctrlpriv->total_jobrs ? + (struct version_regs __iomem *)&ctrlpriv->jr[0]->vreg : + (struct version_regs __iomem *)&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); + (rd_reg32(&vreg->aesa) & CHA_VER_MISC_AES_NUM_MASK); } /* @@ -925,8 +946,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..b2ef2273298d 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,15 @@ 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 __force *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..8b5d1acd21a7 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 __force *perfmon, struct dentry *root); #else static inline void caam_debugfs_init(struct caam_drv_private *ctrlpriv, + struct caam_perfmon __force *perfmon, struct dentry *root) {} #endif From patchwork Wed Apr 5 09:07:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meenakshi Aggarwal X-Patchwork-Id: 13201435 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 B461DC7619A for ; Wed, 5 Apr 2023 09:08:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237601AbjDEJIn (ORCPT ); Wed, 5 Apr 2023 05:08:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237394AbjDEJIa (ORCPT ); Wed, 5 Apr 2023 05:08:30 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2075.outbound.protection.outlook.com [40.107.6.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D428010F9; Wed, 5 Apr 2023 02:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ai5jWHJb69H67MSX6NNEaeVjyCj9vGfOTW5yt5FIqlSQFamQpn55vlNLfvpwX3sNyhy3GncmLMmMRLJiKM05cRs3UsaOFRqnlDb7sUmws2RSONOTckgG4QBMBczoRty/588SbUGBLUyZC4rxX4FcbktP81Do0ytS93T3edcAFQcMMDMvxG8fdoHnSbk9h/pqHYmApSRgZDsvMEb+z1PeSYXq6ydfzSHlgE309n3D9nPCzW029lMvvd8yLVv8JU6ys/XAaM2T537gEJeFlFjF1xpTRHfI3hiV35gPe7FnOHq9hoQ/QhfJrz8Ru0KPlflUViLsFAEu63S2bUrqXjZv3g== 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=Ei7J33+PihTCCgUfyvNxA1s2Hz/Q3GjwGH9WjKWHp3c=; b=mv50FRPEpjA8mOb8ibyND82mEFqy6ueKEShVOJka9puu6K/PWNZb+EiE3cT10eaa0qbUk+ttG12rcjTKNf02IgdMWP2rxGKxnkrzVVBTCtoQhy6RAo5tarpMtry4agQ5ZGzGKYt1Yk5yvKiexFg6kopMCPUCrUbsLEdyuw96dq13vq3EfQZTr1Z6hY7BSGzsoqt95lC4Zw8MjtZuXGfK/KPdKfkTcTM68OZyCglw5YEKb0Jdu0TT6fz8esLB+NDAUNXJT8lAx8shJaPMQSux9VwVtUIY0OwWYxrbHujGMX/uBufGkjLIx/V/SDkezcy3boY/z64eUFoeh3exI2EA4Q== 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=Ei7J33+PihTCCgUfyvNxA1s2Hz/Q3GjwGH9WjKWHp3c=; b=Cmc4x/uJ+r2kwEPBOMs6zfP4UDPt/cwd7SzNuya1bkAOdHDsaJZCH5TP1dE1LS11cw+tZjheL482GV+L5a6/MuhcNWA7x7nrX9wp88ZspHZVyIjPKumNr14LvKAEYjjnd5oKUcoZeBKS6GKWQMvSPM1Bonqa9gsOk2LfkWtWzvM= 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 AM8PR04MB7473.eurprd04.prod.outlook.com (2603:10a6:20b:1d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.29; Wed, 5 Apr 2023 09:08:21 +0000 Received: from DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::dca6:e1e8:f142:2bc5]) by DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::dca6:e1e8:f142:2bc5%8]) with mapi id 15.20.6254.033; Wed, 5 Apr 2023 09:08:21 +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 v3 2/2] crypto: caam - OP-TEE firmware support Date: Wed, 5 Apr 2023 11:07:52 +0200 Message-Id: <20230405090752.1708455-3-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405090752.1708455-1-meenakshi.aggarwal@nxp.com> References: <20230322061716.3195841-3-meenakshi.aggarwal@nxp.com> <20230405090752.1708455-1-meenakshi.aggarwal@nxp.com> X-ClientProxiedBy: AM8P251CA0029.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::34) To DU0PR04MB9563.eurprd04.prod.outlook.com (2603:10a6:10:314::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9563:EE_|AM8PR04MB7473:EE_ X-MS-Office365-Filtering-Correlation-Id: c57c5c55-76e4-488d-8a8d-08db35b54d73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b45e8ecsKgYB/JW3wfSwx70qZIiusczzz7rUloWAwg2n5wSrx0YKy0bHeDj21Agsm4tTA6DuXDPZVUijAja95sUSUdZ+/jdmS4b8G7SO6keLDcLpeGFGU4t9RJ7/k1+N0ZoOm7561tiQZe9r9samdfPGyVHLEe8LLSMYnMNx5t0v7hTfs2j8rKXp1Os+DOvDsj/DBXY3WmuTrfhSoBjiwj/nIewss3HCpNu/jtUkIcWvWkOC8Jen1fLwvPVU5yAGbSl1WHdhnD8dxvNewD/YPzrNWjCtChTCuLtwevdgpPxPIUqC5/VTEbqx0vYqVXKD5O9wVZyv0ox27YOfVDxV7UhfldjFDaxW65dvKgFhX4dcUqyNra3J8kTBT5qJICwY8M6tFLFDR2dV+8q3Ig1SP93O/FateML8noFL99xrS5SRaJbTrXkZkV0LWddvphvBCPSjtBX4Lffx2CVuHNiwJGWuFby5yWxf2KoEH4DGDyl1aVY6MX1zDu1V+UQNn8nwbJ17IFRWmIQoDbQQOu7CncrsxZPaJI9R6+U9m6BsagJ1gihq9H1kNnxImcxSAAfy4a7oAFjz45t2gH/fwRWX8/U57RkTf2LBAtfbCleC8xKX15nKaGsZJ+ETwJ6Bi76OQCFHI9eyzKbYavSxjVZpYQ== 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:(13230028)(4636009)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199021)(6666004)(86362001)(41300700001)(36756003)(186003)(6486002)(4326008)(8676002)(52116002)(478600001)(38100700002)(2906002)(66476007)(83380400001)(66946007)(66556008)(316002)(8936002)(38350700002)(26005)(5660300002)(2616005)(6512007)(9686003)(6506007)(1076003)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4wz6ZRgOEhL7MOrVJ6V27PT/Zcf5yjQ9EOmcjokEyzCcNSucswviLaUcXQhTlkDOrnIMWgQdBKybaUmJO6DpceUjYw8ZWOA3EZrx/Z82mGP1KvAb0lTwMs/BrP8m1JjicDHVrSfk2nUCbRHRF43OiHASApBk93Sa6G4XWp93DcjkbaYvKAD47rr0UwfDEKk2XS/8th7TzjIUofuT0sm+yj6S0lZpoSDvy1K9+APxhMtvo9Sila2L/aW3p/Uyoae945jVwsfxA9aGhBWBV5UTZ1bTekxXFhWLhEOEt0g2f14nPVpF2P2SXLwl55ZOQtrFUUTXz0PZ8PtLQw1oNp5FfLjrxaNAJGg8KRrU04JVky4eUImsKUKIZMPShaEEDiAdOniolP/2A4/YJ8XxykjvaER6axLKOxdibHJwUn7GYTOmDg2rIn4lmNYL+Q03jbhmKfwnRlvX/b8d6E6heah8LEWBlhlSLiKVh4yWmoarOQ9j5IXMrQc/VbwRT+z+mTVal//J1vR0wAiixyY5ekPXj7YFGI7L/O0ah9SB1/WzOqsE+tbfnotQwzkLrKhMMCUVpj4qE0rZVTdVnCaau7vZgtuvlxjgWAJRsdiJpKruEPc1l+nvqHuEqnbowVGewhmtiTP17Z/fDfmI7BnSip1B5TMcOoK3WeTqPeZXkIMMRUBX9ZXshE2sO96mn39MVT5LtQsTpDP2CCsblgq5JkfaC8NiSJOobGJT6Mu4CVQhaiOTpko2j9Wi+hew7QwOntE4PhydNfEphRBrQxrI497oGcdhb3H/w6wEldAIxP+TWP1/Sg40YzlbudgSkPHlo6RW+/MdXRaXryMcpIEUZsarisrnpSIFgJJu3OmDTehwzIufnMqVcmWqUVlMWikhImlphXZCbYCzmIrJ4Hs9T3waevz6F02SEZFVfqX3C3oQtop/iPUKI/sTedRITrJMklt9gFxUIQNmbfhur4pBoVPWLmf7OqoNxU9sgDmWgS5yq2LMv3INAzBvvzbGkRxqXv0nkExDxQxe9XpS09F7Ea3As6BGdqUXbj1AWPegJVJOGEa8g/sZXOpvYqMj/YwgHbTGn0iskXuJaHZPsaLcwfnEpPCM5Bd0JTLEJhAaeH4aJqWP6xAjR94Go0HzKvylK0EUvvCJjGXgunxJi8tzVcM1VtdwU7O/G+j3gQRoQu0eyTGMJGaoX9YItUyZPVRo+LaCM5vH9f2Hbi7+FmCw4dey848FYF+PtKxzwxU4QIF4vW3VrmQp7NuMQxIv3xaxja/tN8zTMpLWS4gnjRR2b8giXB6ZO+bQ6EQ49AYhCgCk0zMmbuc3shDUoegbuc4R3P3fPk1iU0v0AYn5X1R+3vZ85YdLiryYi8PHQ5Q9UoPnnCHmnGCB5gvMJk7i/yk1eFMKeBamnvH+D6jg2DOK+eNcQH/mjdRMEidsZPM4J1PvWnIkcl5BnpeXKj+O+lURsX5VpQEj1uYipeiml6gau9bAMID+wOKwg+fKKuYGUS0QUFLj4uHzjTQe+CxeOs1p/G8ZhYuUTcu2QtuixCT0RL4Skpyx5ObIWf2JUEhrw09N9/Bpn9BQpYxP5dnTm6sdtMrAmle798QUncxXYjWm5s9h/g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c57c5c55-76e4-488d-8a8d-08db35b54d73 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9563.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2023 09:08:20.9550 (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: XXYco8enPe/21usqiZwaRvJ6ZVd5CPs1/VdzuyAoUoRGeryYrm/Uc3BT1cCCtQtJeBcxP25vcXtbcqYj596rba9FyRuVvG4qmBA6Lmzbkek= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7473 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Horia GeantA 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 GeantA Signed-off-by: Meenakshi Aggarwal Reviewed-by: Gaurav Jain --- drivers/crypto/caam/ctrl.c | 23 ++++++++++++++++++++++- drivers/crypto/caam/debugfs.c | 3 +++ drivers/crypto/caam/intern.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index de1f0acdb712..9c5a035e1b96 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. @@ -800,6 +816,7 @@ static int caam_probe(struct platform_device *pdev) 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 +859,9 @@ static int caam_probe(struct platform_device *pdev) return -ENOMEM; } + if (!reg_access) + goto report_live; + comp_params = rd_reg32(&perfmon->comp_parms_ls); ctrlpriv->blob_present = !!(comp_params & CTPR_LS_BLOB); @@ -944,6 +964,7 @@ static int caam_probe(struct platform_device *pdev) clrsetbits_32(&ctrl->scfgr, 0, SCFGR_RDBENABLE); } +report_live: /* NOTE: RTIC detection ought to go here, around Si time */ caam_id = (u64)rd_reg32(&perfmon->caam_id_ms) << 32 | diff --git a/drivers/crypto/caam/debugfs.c b/drivers/crypto/caam/debugfs.c index b2ef2273298d..6358d3cabf57 100644 --- a/drivers/crypto/caam/debugfs.c +++ b/drivers/crypto/caam/debugfs.c @@ -77,6 +77,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..86ed1b91c22d 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/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) */