From patchwork Tue Aug 8 10:55:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meenakshi Aggarwal X-Patchwork-Id: 13346245 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 9F53EC04FE2 for ; Tue, 8 Aug 2023 16:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231547AbjHHQH3 (ORCPT ); Tue, 8 Aug 2023 12:07:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbjHHQF4 (ORCPT ); Tue, 8 Aug 2023 12:05:56 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2067.outbound.protection.outlook.com [40.107.249.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E4A16EBA; Tue, 8 Aug 2023 08:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kIXViJCxQCgigSoL1muRELRXnjCh4I6GTVQkgu3MovIpkqsnz02/r6D26K2I+Sq0zajEw3/HEL6X6L7o2afEUXmJ/OBQ2Vf2T9g9jsjSIXLe0+Cj0bPea6lGG2I6fJJpy1pfbNvgtH35xYs6qU5vEKIz5Bkm02Ru4eVWPW8tuxng4BBHxQqmzOBPf6YpRAPoCrc8v4yxZU+ZhPJh/ys5T74DTV9YtnrAVWOp9OEG15Z4SFcfN1t3IptFAlPGw8LFjFwMoKLWejyV9IvslzE1Ga8GEHMWiAF7VpFiuHi1NoNfD0zMcHnWLdfZFp1YoRuFHBldTQU4oIyhOx2qBC7I/w== 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=dPEDWiHu9fH89Rs2xhF+r4W7ZJCqZzBWOeNAe1hhsyc=; b=WYRlBg0JzD52Zxe6PuRMZygqxldxIvY6aN1gUtjfPwnQ4L0ERug/KsOx0BlbmQj0pCAjFByM3CzJVXX7jUD/cbiPhZ+4bT9gFc4Xs+FSzD94TuSnSB9lwMJm3Lavle1a5hC6ctVrpGJODXUP3H0TNNtGRBlqy9NFvcGXPvZF0dVTH1JqPUF22ZAYbleM9YDVxtkU6tr8LDQcDPXUG5Ji4UGFVXMZzlphwOQThhMUJ1yLLUwMzWhnk/2qh4oL89cYfaC5D+mSHgF6aGY04Eo+MvcWr/9WvVN26s3IWiSRVeAdknDZHqgGDIwa6J52hj5qzBeP+Gsv1XPDjIAaaK9qnQ== 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=dPEDWiHu9fH89Rs2xhF+r4W7ZJCqZzBWOeNAe1hhsyc=; b=iIDdfE8EdDAHtLqt/zbnsoJuKwcJ1jqI6olqc7NQiSuaAZJ00efB6+RaLxINp9Ufh2FS3OCmWjgXkhX/1pflT6H/gLPTJY+FG4VU+U+5CiYOpUdX7+3DYblFCPOKLp1vBF8fJsFrt7NBFAPmYBpPzjrrOOXxUHiOfuma3+URfYk= 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 AS8PR04MB8101.eurprd04.prod.outlook.com (2603:10a6:20b:3f6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Tue, 8 Aug 2023 10:55:46 +0000 Received: from DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::15ed:8451:b0a2:ec64]) by DU0PR04MB9563.eurprd04.prod.outlook.com ([fe80::15ed:8451:b0a2:ec64%4]) with mapi id 15.20.6652.026; Tue, 8 Aug 2023 10:55:46 +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: Iuliana Prodan , Meenakshi Aggarwal Subject: [PATCH] crypto: caam - increase the domain of write memory barrier to full system Date: Tue, 8 Aug 2023 12:55:26 +0200 Message-Id: <20230808105527.1707039-2-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230808105527.1707039-1-meenakshi.aggarwal@nxp.com> References: <20230808105527.1707039-1-meenakshi.aggarwal@nxp.com> X-ClientProxiedBy: AM0PR04CA0028.eurprd04.prod.outlook.com (2603:10a6:208:122::41) To DU0PR04MB9563.eurprd04.prod.outlook.com (2603:10a6:10:314::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9563:EE_|AS8PR04MB8101:EE_ X-MS-Office365-Filtering-Correlation-Id: bd421307-2c54-404a-dcb1-08db97fe04d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z6P/YwkLADMgbFrDZHW01ZAhDQFefK6qv/7HK7bS0F8+5Hm4TsZNPFAgm+iXb7DXW7e6y2boIDEY/CTV7FpVxaSBnJZE6fA5bDlMJQvHgkfASgMIIrPJHaadbP1PJw+x6/AtFPAq6q7AF6wz4yXsD1SZ8Pg4GkyqPGYPOshaUx+gAw/VOMHn4fFZwWRz8RqCmJunOfnTNfcWQFrEceb5RhDDA3g6xap+FLGo5o6mHCQpgBkQnPu48oItZaGP9IXkXR5m69CGdl3wpOmYfoiBZfQQ+gQAFusgyBnKExd0swU5pX5v7S3QclDfTST+asvwyvI0T1iAOPM0qiAaIHOU8wpNbxV0i05lW5EzeSwt/PgOopjcm6umq61IQ2T5EvvE8c8jQqoeQYxaDOnCOXWkscmmCrrY5+RXHz4FKf1vONiMIdUnvgllMnCJDhXtBJhipnmSSt2W40R1aNY2ipiBBuGVCejIc4lrPO/Dhxwcax1pXbPDjOYIvA7Ox28+sCDqVKHPiXfycEUeJrOjD7tH/0RqJKeRFTsJdcrQ0h6KIItJilr/A5eH0dXe3RlV2ImoRgZWmXtZopi34jyt+LQPeolFJY9xPvxJYpSRnUJCzFZK2zsJLiVKT5fGSD9hptJ+ 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)(366004)(39860400002)(376002)(396003)(136003)(346002)(1800799003)(186006)(451199021)(2616005)(6486002)(478600001)(83380400001)(66556008)(9686003)(6512007)(26005)(6506007)(1076003)(66476007)(41300700001)(8676002)(316002)(52116002)(8936002)(66946007)(2906002)(4326008)(6666004)(54906003)(36756003)(38100700002)(38350700002)(86362001)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fNgbRVAMey+0joEdtvaERxtY72ZanYIVlO1fuvDzarZl/CaoZ7m3crVVUXdLT9/3qGemHuMrzfOVKr/PNJdgAh03jDqH6Xk7LIjwnDIA8H1fZDElWaPezmtUCMWY53u8CFqLfHst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Nag/XKx+8+ZfG4NufQmLDPB0/oqkEJSef276IsA8tMQJGDJ9m39wqirYqg4yYxipeaKlkJ5tSajUaFKPOAlnDmjh7ZqRXPr9C3+S5YLIYZWWCgFF5pXqqPjny3hjiD+E5X7Vh9IsujywvPikK3ykkMt7hWt/UobHTrJZfAXCRHMKkkbltglNuF1cI9BVQmF4RWMCh6Lo1GYMbNdWjc2sVkMfc0fB/fq0NiVS200oVr+ta9RtqDDtuDKiIcVVvVtOoxuynGDEMZjCawVduSWghcEVDeYgyVdFgGT+rjruCUB5vMmc3NkbJhmq0vtjXkV52FC8aHUCSchIhk/gzAVzWmETrEPkVqAGQGCvFq+83HBdya/eP4qbj/jyp24pB6Y1NnkUi4EOelXFYRWs4c6pDCFMhHP7BaiH6SSbOrXV36Wg7g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd421307-2c54-404a-dcb1-08db97fe04d7 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9563.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 10:55:46.3956 (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: BXRQ7WTFOZ3U3QzdldYZ+NpZMfO/4oru/RuQvTPyoAiqhMMgMK3QFg5yaCHmyC3SW/LcD+zumkv8ESCdOykDvW2+cddp/TUQ2zyNA5n6dNQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8101 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Iuliana Prodan In caam_jr_enqueue, under heavy DDR load, smp_wmb() or dma_wmb() fail to make the input ring be updated before the CAAM starts reading it. So, CAAM will process, again, an old descriptor address and will put it in the output ring. This will make caam_jr_dequeue() to fail, since this old descriptor is not in the software ring. To fix this, use wmb() which works on the full system instead of inner/outer shareable domains. Signed-off-by: Iuliana Prodan Signed-off-by: Meenakshi Aggarwal Reviewed-by: Gaurav Jain --- drivers/crypto/caam/jr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index 767fbf052536..5507d5d34a4c 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -464,8 +464,16 @@ int caam_jr_enqueue(struct device *dev, u32 *desc, * Guarantee that the descriptor's DMA address has been written to * the next slot in the ring before the write index is updated, since * other cores may update this index independently. + * + * Under heavy DDR load, smp_wmb() or dma_wmb() fail to make the input + * ring be updated before the CAAM starts reading it. So, CAAM will + * process, again, an old descriptor address and will put it in the + * output ring. This will make caam_jr_dequeue() to fail, since this + * old descriptor is not in the software ring. + * To fix this, use wmb() which works on the full system instead of + * inner/outer shareable domains. */ - smp_wmb(); + wmb(); jrp->head = (head + 1) & (JOBR_DEPTH - 1);