From patchwork Wed Jan 25 00:23:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 47979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp10371wrn; Tue, 24 Jan 2023 16:25:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXvrd8USzhiohgftGqhI9PGzkaHjbJkkNOVFoV9kPKN6p+NvBBjtyb2cNiCKotGqxbJ8m7tW X-Received: by 2002:a05:6a21:3996:b0:b8:610f:cd43 with SMTP id ad22-20020a056a21399600b000b8610fcd43mr31069690pzc.35.1674606312747; Tue, 24 Jan 2023 16:25:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674606312; cv=none; d=google.com; s=arc-20160816; b=ewhlp72GVTIOORSVRpeibXS83VvzW2BlkHCyVI7g48lw7u0l9EGAFI05L8lEF9pIiF ULuxpmpe5gFqtfHGXyINwZmRS19GtjH3EUHOHbbIufq7Z430MeqYsNv/sySKc5PPERhg vj0waCf/saGdcv5iF3maA3AHG7rouESELQgEoRZvL/xs3uFz6Ss+nfnyT8XEwiNm/Cqd cTj3DCqzl/320YRb8VFQrB4WiXuAqJTfSkqJ/DmygkrNakGc2zBKq1z/56i+PbzjFZJi wddk1pGz3RY+h8VmsZz1mA8KzOUBN8VA+D5aAsAmN5IaKxS5SJjudmFIeVgBNSnujIuH gPRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=dZ27p7zF4T27+K/nN0SUmKAuxZywkQG/U6QyG5d8NyA=; b=xG+Vyo6ssc900z3ifsgVT6bh3IvmOlOPuOolMxBCHTcS3ek9dfRzJj30r3lcpn62xS zGnAfGdKger2LeZ1XfobXYDsrJGGNAh0Stop43Uy8e0k5baibHHtZSPTp40YCdt7j7w1 FvSjsWeK9qktTjEpR6+er/vTdlia6k4ErFP61hNV7fyP2WiXcyiAZAEGR4bNA6UsYeIc CphEP1SpQDKnwqPl2yGqL+Aq6VKo/LmbksGGkDrAr7eRKrx9B1wv88g/FNVZ/ngKTcHF n8M+HhXl7M70JIgBNv9BI2VChoOXlQBRf/vS62ixxXBfn5o+hmL5ybCWzQoFrsjOsejd EDew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QJ/19TCg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x63-20020a638642000000b0043adff6d43dsi3574708pgd.583.2023.01.24.16.24.58; Tue, 24 Jan 2023 16:25:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QJ/19TCg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234585AbjAYAXn (ORCPT + 99 others); Tue, 24 Jan 2023 19:23:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234250AbjAYAX2 (ORCPT ); Tue, 24 Jan 2023 19:23:28 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF8F4CE4E for ; Tue, 24 Jan 2023 16:23:24 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id ud5so43542466ejc.4 for ; Tue, 24 Jan 2023 16:23:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dZ27p7zF4T27+K/nN0SUmKAuxZywkQG/U6QyG5d8NyA=; b=QJ/19TCg14yqvOQLmIFg24XehYjzB9j13SdaTs1rKJ83AU1VbzHGuKuUMnia3DaMML LYwAkiPjcpm6NzEf2MRfedGuZXWLPbji4TBfQVe1kb2+bizrSabk+mvVD4ucmqmdHomI sOzZQOyU62Vj1y/SnnJ7ovCeQmu4/ovGgcCLS58UHYkmDqA9IS737Fa8dcPPHHX8FyKU X6ffSN2Y1q2FZbNMIoB5MCFOrEAHXpIJuP732o9D10rrJkvmhIKXIgz+muzpARYPOoYa 4oXKc+9TN6pU4/ulqMYkpcDIyOvjw7ARw0qoWqgw9n9iDD42cWOsF+YLPNx9JYP0EXLl oJsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dZ27p7zF4T27+K/nN0SUmKAuxZywkQG/U6QyG5d8NyA=; b=fE9EVATpSImB6mM2c663kUs9tSI0E8ZeBb9Shy8E/EK4x10EsTMAuUYWnGPFR4Bb80 GPfugIoeeRNC3jWVPpx6zu49FAD09mLHr1y+mdah+qpLrqcMjaKcyw2WVhyLcrWI7Qvq yMvwtZPQ1O6VvVScYzX1G6WkPPeG9S+NhNwTZtkq4O1wSUb6PD1OdU2LClVpDE/ZuHMJ ZMeeIKNNq/kDVpZc/VPtNcfURdKYhKpKjR/MWkjGFnQNqAKvB0GvBW35m+e7aL035+Qi 6o60JsS11dMI0HQ3zNZkHXw00xguBV1ZaKIIMY9TUroERHyu2MVj3ma+xdCUoiLNsNLo LL1w== X-Gm-Message-State: AFqh2koAKaHU4IDll2JN1mWlVLIQdDMG9aEnsIOyFz+ueW9XicnMCDGO rJ3uQN6mrhTq0tP9SsSlHQrjog== X-Received: by 2002:a17:906:a3cf:b0:861:3ed5:e029 with SMTP id ca15-20020a170906a3cf00b008613ed5e029mr44674312ejb.49.1674606202741; Tue, 24 Jan 2023 16:23:22 -0800 (PST) Received: from fedora.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id if10-20020a170906df4a00b00738795e7d9bsm1584606ejc.2.2023.01.24.16.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 16:23:22 -0800 (PST) From: Linus Walleij Date: Wed, 25 Jan 2023 01:23:08 +0100 Subject: [PATCH v3 3/6] crypto: stm32/hash: Use existing busy poll function MIME-Version: 1.0 Message-Id: <20221227-ux500-stm32-hash-v3-3-32ee12cd6f06@linaro.org> References: <20221227-ux500-stm32-hash-v3-0-32ee12cd6f06@linaro.org> In-Reply-To: <20221227-ux500-stm32-hash-v3-0-32ee12cd6f06@linaro.org> To: Herbert Xu , "David S. Miller" , Rob Herring , Krzysztof Kozlowski , Maxime Coquelin , Alexandre Torgue , Lionel Debieve Cc: linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linus Walleij , Rob Herring X-Mailer: b4 0.11.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755951989165803369?= X-GMAIL-MSGID: =?utf-8?q?1755951989165803369?= When exporting state we are waiting indefinitely in the same was as the ordinary stm32_hash_wait_busy() poll-for-completion function but without a timeout, which means we could hang in an eternal loop. Fix this by waiting for completion like the rest of the code. Acked-by: Lionel Debieve Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - No changes ChangeLog v1->v2: - Pick up Lionel's ACK --- drivers/crypto/stm32/stm32-hash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 0473ced7b4ea..cc0a4e413a82 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -960,11 +960,13 @@ static int stm32_hash_export(struct ahash_request *req, void *out) struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx); u32 *preg; unsigned int i; + int ret; pm_runtime_get_sync(hdev->dev); - while ((stm32_hash_read(hdev, HASH_SR) & HASH_SR_BUSY)) - cpu_relax(); + ret = stm32_hash_wait_busy(hdev); + if (ret) + return ret; rctx->hw_context = kmalloc_array(3 + HASH_CSR_REGISTER_NUMBER, sizeof(u32),