From patchwork Tue Dec 3 09:19:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847023 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 950AF1DE4EE for ; Tue, 3 Dec 2024 09:19:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217593; cv=none; b=OcPKTUKHAgmE+jW2lIDocJCfLhaa9VMswaKYK7WVpIubQxTHUDCa4dYhC6BrnDe+D9q5HsAVRF/DEIPYyDzMXWsnLPM53UkXuhb4x7fkOOxrtPCOri6KNsYsiYbVcxZ4+am2xQ0vSHxcZ+MtH+o48rKKj8SgPr6BVnLUyfhEUtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217593; c=relaxed/simple; bh=nLThmMAA2N57J/MS2sf+bnzXenpNMRykKU0iA87ZQGk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X02Dp8CaUO1BwrHFy8dfix6ihS4HH/q/NS5zraAux8jES2Ipe3x3d0q1XstJ+TUNsSZABIocEsjmjqRYT1NkDo3R/hd46uM7e4GHdRThSZyJCgkJj1+levLHAZa4n5fopn5V5PwXK6W5xTvQ2TOUoL1aTIFRyYliCLNmcbzMhMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=EPQ+3M2m; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="EPQ+3M2m" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2ffc86948dcso53418911fa.2 for ; Tue, 03 Dec 2024 01:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1733217589; x=1733822389; darn=vger.kernel.org; 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=pJIGF7RI3yQ0jOMcBQ0mbBInLSfp4wTYHHtbYsIeWVc=; b=EPQ+3M2mV9MTR4TAJzCzgH/ZEgJACgHshLjDeMKxTri8A5mbkVcf7PEqyfujq05wWR CauXwlgwDaw8M+UxmRvzEXkK0p7MTvFQrM5JwSi3j50oNf0ZBZZttfpmBvhkTBqfTYS8 meDzjPL8GOlhRXqM6kMqd00ArW1UFeF7+Fw/crAydnmC87Z37bCWBFHuClmVozXBGOki OO4Rmhkx5i1A+UfBWmHDm4Ms5nskUsx5eHgU5ZsqeO/CTuFEx7fyUCLuNujpdO7x56tE l4ESI9nwkPDxCRAEcpJA44rraPpOYnzVbw2n0EzKWoPIYpDwzzh0pOZ9qpbgOPt9dm8B iahA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217589; x=1733822389; 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=pJIGF7RI3yQ0jOMcBQ0mbBInLSfp4wTYHHtbYsIeWVc=; b=Vc3/0mPu9ZNs0ZR6Ad5RWZ7ZStjgVFT5u9u3UOFw1Ou3r5t5CzTqn/DjKHV52nw3Jc P1JeUHFmRmG/PlT1yEjK9MaarsYclzyk6Ci412gT2KPIefVD3QmZwFLUT308aFfHhN/u zXm4UEURT9CEQhc1mOhCGZGRYOduvRQ4ULNKTarjYTU5etES3jRRUuDInmtZ/NaKyMSS AxfJk7zAmi6GExx2P1Ctt7oPH+JlrP+5Vd+9Tab/dmDfHQaT+EmSA0mRSzvkYOm+rom9 92exjAVIdG0YTQCLmyyn6AbN1bOVcSYiaD9AxFYkWICdx07XPvFTSceSJnPmZCoY3q9u zubQ== X-Forwarded-Encrypted: i=1; AJvYcCXYVYSxByzbHr1AbjY2uIxFW73U3QRyvGDJ5uXrJ4scOMI0R6IJu2kqy8qettJdE94we+w8TzQNRrm2LWm4@vger.kernel.org X-Gm-Message-State: AOJu0YyO/sUxtdqVO3q5NTjg3NwevMV6uxhHvn0QMCvPEmS5J4RNnHfO q2hFKFul5eHAZoWaDAkB5+GxkMN6PvpYIscExTZFRiqRN9gvI9SsMNKDgSQYByztHD3whc9BA01 NeMk= X-Gm-Gg: ASbGnctPqhjf8w6RHWnWIrmL/KMus8cb2bhj1uGqJylsrXfMQ5vlSMrmuZ6lTtrmm2G JpHTDr3igQdAkscHzPVPR/TIhGu4PWYM9kEiNgrPtwzsEuKcrNFDVk/qUNfZXxlLtg854IPwHaw IEBVQLEFoOXkLC3ei7BH6Eu8X46TuNWRuQdW0L7YNM0u+aXu2/q1Du/Hi7Xn7mSgMipZItagT68 e16wSd2P+HSS2TcJqEj89scVqmAJS6jz22WWqfnJyYWNu3ZEKu6y5mT9LqkO0W15RbHs8zhONPH ElMpoY4= X-Google-Smtp-Source: AGHT+IEfC5wjdly2Oi2VTsboD7iJTTa5MEqGX/XpE56Oi78cwJFI7MJEAubiWLgbkwBOanVP+66elg== X-Received: by 2002:a2e:a80a:0:b0:2fa:c014:4b6b with SMTP id 38308e7fff4ca-30009cc80ccmr10990311fa.41.1733217589521; Tue, 03 Dec 2024 01:19:49 -0800 (PST) Received: from [127.0.1.1] (217.97.33.231.ipv4.supernova.orange.pl. [217.97.33.231]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ffdfbb915esm15591811fa.19.2024.12.03.01.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:49 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:29 +0100 Subject: [PATCH 1/9] crypto: qce - fix goto jump in error path Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241203-crypto-qce-refactor-v1-1-c5901d2dd45c@linaro.org> References: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> In-Reply-To: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> To: Thara Gopinath , Herbert Xu , "David S. Miller" , Stanimir Varbanov Cc: linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , stable@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=826; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=YB5a3XXobSonCeqEXm7LbV3WosWHg1/Yxs2aSCuvkxU=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0wYallq8NjSyGqGvvA+foSvpLbFYIrIvrHR woqO06Z3q6JAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMAAKCRARpy6gFHHX cs2+EACJKlJsbURMhP9mtuBKWgdQiwB8DpCV0aASWdjnwswK4VaXJuGoi6yZLhXIOszQAhb5I5M ZuaDUbGbqSyhNXGQJlSGUgnfhfOTTl1BWx8XEfSNSAcCCvrqkBs2s3z3Q538FmOUZOektwppCXY MTYq2BTyXSFM4z/1pOWQ8AJIJIBZCy9SWkRpcWDG0UQbYzwGS7QIEv6JTd6KJIxxYnI8W6/W55G WoOPBOrVx1EOvYhSZlbXb2OlcThLBo05+QYmNKWzgo8cxwyWN+T5IqU1jUXwWBoKYaVjZqhu3l2 BKNq93HrcXUPvLwZRiKZpx3DK5gsnOvFsZmodCB9zS9fkXcphUKCXud7Jukn5Ung7+qpCozp8qQ LX6IxG0WpBdkFoqmK1Av0peZiE7ejVZVuEkmmmpGogqSm3n9WPcE9igdf//67Sea6noR6/VJhlt Gr4Oqm1vcjX1fGg6+/6DjluspbZ0/1aG23TJqVFWhICMmCVtl0BTZ3wBMkyMgVTl450JEtldWlv yXHED3oaixiRzibBBnMvGLsQLl5UWvYkZcsfAbcd2Qq7OfgmPBpXkzjqp3qO7ZiSPjvQShHOjIN k0KPeN8d0bZGesxwudYEmmZRuLwS2U45kfT7oB+ktNm0Bo/i0fz3j5pAYSS6OvvR8IDDe5h5EUX 0iUqsU1PIKPr9fw== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski If qce_check_version() fails, we should jump to err_dma as we already called qce_dma_request() a couple lines before. Cc: stable@vger.kernel.org Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver") Signed-off-by: Bartosz Golaszewski --- drivers/crypto/qce/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index e228a31fe28dc..58ea93220f015 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -247,7 +247,7 @@ static int qce_crypto_probe(struct platform_device *pdev) ret = qce_check_version(qce); if (ret) - goto err_clks; + goto err_dma; spin_lock_init(&qce->lock); tasklet_init(&qce->done_tasklet, qce_tasklet_req_done, From patchwork Tue Dec 3 09:19:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847022 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6BFF17F4F2 for ; Tue, 3 Dec 2024 09:19:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217595; cv=none; b=W9roJ30id+WmVIeP+vZfWJq2nlRdxstzgNS3yWCN9/6WoGbAJvyPYrf1n0DacBzwiGyCTQyLVbxzviCo6738Abn53d8O34FAqGfneOnbIXZhK3Mtyc9JdSRCyMYAwOikXEysERX0jPvSbBVsYIlchtN7njyjiXeS14dbqFytOh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217595; c=relaxed/simple; bh=a/a90MwMNFc+GxsiPvK3hlVi3Cfoeup3Cw0hJE7QZ8c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V7lMeyCvm1H46Z/bHlFc/dbIQNg+LvjkJOlvhz7Lvu7uKpkLoNw6u7mvlz0IdYj9GmW1JK/ZeL4xRg/RrUHleV6efCRJrHXqE/ZvdfklGyoIoV//Er6uaaFI2Ga7q75l/M5tuKAJmjHjxboBg5A7fwD1rV+QQEH39IFnvjx5i94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=YfBIXwfZ; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="YfBIXwfZ" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2ffbf4580cbso54442731fa.2 for ; Tue, 03 Dec 2024 01:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1733217592; x=1733822392; darn=vger.kernel.org; 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=/6k2L140W1gZGlavDo9n9M/YySHsyHY7A8KJtnjO2Uw=; b=YfBIXwfZlUSEijvwE8zS3odGzaIM014MxMPEE/hCidxPwqgTebETz4Hl7zz54xk2pN +0Sl+c7MoWFV1Koqx4q8JMgwjZGZTj9L/E1BiA8iNzVcXz+sv2ENLKT1wmkOFWHuPehe SpTqshBR9n/h1aomqkNsnIHj5U1KODKSu4bcCMlZgEAV1bYy6U5r7fk4Tmh4HNQ+FBzj /cZqLlY3M82qpGK1bZmTEN3EdZ/XyhjOMeOvZu6KC+GJVKEiImx+Xkyihiartsm8cbHV z+c+yf5TAizsJ38PiWp+AKwSf4Z7W8tgvPOHv81/M9IYWpcwQwonKSNIwwSEBRp6MVF+ aD3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217592; x=1733822392; 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=/6k2L140W1gZGlavDo9n9M/YySHsyHY7A8KJtnjO2Uw=; b=V28om7zha/9v3pQCDPOn2DokRdfcFZJRxmcNcJ7aA47rCJYZQ5Kq/EpHF42RNJJBSE 3xTS5G3Nxlp4N4LjsTH0ZEHyqyFtPYwLxzpP/OXlA/5NW8uUtjpx2Pru12u4jV+4VQzM P6VlpQ9UVgP0c13waf69YRB8FFNC6UrXIuPA3wiICwBsAa2iQv6KMj2JN+7oqvEQUd5G 5ZfvMgoH6yHnBaNaeKzK0E9qEPiVYEoHR+m6Jqxdeirl7dtiwpdn5SQIJUAUBrshf8wZ my/0RLfvSiy0L5OqRBUD6SpUC+6ssdMbOOt07Gr73OaQdwRVV7utKu3TZB0rKErbGC0Y VRHw== X-Forwarded-Encrypted: i=1; AJvYcCUyPQxexl1UdcKViQGEoYSaoA0SaeEq1olCByToo/P4ZRPeT+mSEPkxw7V/4YnjVet7mTK8lTiIK65kpdgi@vger.kernel.org X-Gm-Message-State: AOJu0YzzUjHfqGSK55r34W8t094Xm8iuuEdyq3kl0ZH0H2S5AFsZCFrr U5YZypp+pnG77LP1Dtpt4CSBySeQ0LfeHLlg800BW+zrkehjKfEaSLXbS4NThk2OqJOv+dwRK3L lRWU= X-Gm-Gg: ASbGnct7de+k1Jn8KTSeCNKHjIbG35D+r4xXYdjsrMoCU/us0eKV73mKomRVjoIdBCf NwkIxoyN5YIW+3MwzbyBG847WEbEXBc1jf6JEOxa+qX/joLRetyla85Ror+cJ6R0PSstNXJwbDA 0R/HNTitN8XnwGiNQibgHAR7o5kkSoCghGKPT1OQBmVsGewOlHJkbjScm+kz6vjV0rYv4Wcm4I3 tAc0fToIpFaCvywF8FMrNvDYXWdx0rCB54x9ahnBuMPFDW5yaLH1dm8TwobNOpro4R6weSmce1I Hyk2MZs= X-Google-Smtp-Source: AGHT+IEFWbr1zwOKq4r9HKNY4A2niJg6mEKSn2jXVRltpQlBC4u5eKxbX5aii3pqpt8ekqkvMGxP3g== X-Received: by 2002:a05:651c:1605:b0:2fe:fec7:8adf with SMTP id 38308e7fff4ca-30009d29edemr7573921fa.38.1733217591609; Tue, 03 Dec 2024 01:19:51 -0800 (PST) Received: from [127.0.1.1] (217.97.33.231.ipv4.supernova.orange.pl. [217.97.33.231]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ffdfbb915esm15591811fa.19.2024.12.03.01.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:51 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:31 +0100 Subject: [PATCH 3/9] crypto: qce - remove unneeded call to icc_set_bw() in error path Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241203-crypto-qce-refactor-v1-3-c5901d2dd45c@linaro.org> References: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> In-Reply-To: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> To: Thara Gopinath , Herbert Xu , "David S. Miller" , Stanimir Varbanov Cc: linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=990; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=HwsKCoEKlyX+6A6A6vYVvj3FWwSlHH/aqK3VHfeTQ1w=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0xuy13gNwVh4GBpYH/G6g0ZAVf0zKVYlq7s wTi+HyNkFOJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMQAKCRARpy6gFHHX chMKEADPUtJZmkMcMO6clrMtTNe+NsFRTE2wmmxKSzcTh9TAjGJFn9zhkkxNF36L/oTTSLDedai L4Isuj83Fhg8Q1wWyEZKb2hla8S9b5+u0Y00wQWWVp5E3lNuXfWyT6VPd8127CK4G5XwD2ranLD 1GutHcvaz1nZhMOK/ynvp3by2jwM4w0Wt/akhP4vC86J9kNC772AbJL9wmc0ydIKYR3xgMlEvGf kWOm5tfLc+33XpXk1sM/h0As4tYbtcXqTFBKW+debJXjuPNv/zMPUpAQTr6JI3x8usvtprORwKJ 2hfSUXOPoGv6kNCZsHxtcy2m/bPP2+Lzmrf8+NUxuOOLy9yisAu1HPL0dz/FTOEXlzZT7t9OQgJ pMcx/4whGy6nayk10WHlAnubKlLcrj6Jpv99zZG9+a04cthBjmW8NkElKwp0C5TH+IpHo9gK4FT U4RD/So+AzEAZiJ+/2tnpMv60tvBSudwtIvMVCoblOaQhgFUHg4t103OTlWorglDkiGeLUoXQf3 FLbhNKdg6qCze/j0HMMz0slarTwpt3t52dAsFzlMlDR1GY/Q69SJfMAPxMxftorq5rI++wsg7j3 nqXXh1PzjGhM9rCxs+LiIut/dX5+V6lMJiIFTBO4dgt0ryzDeae98BD2VibmKEfBCFbO86VazTM VfO561uDhqz6yjA== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski There's no need to call icc_set_bw(qce->mem_path, 0, 0); in error path as this will already be done in the release path of devm_of_icc_get(). Signed-off-by: Bartosz Golaszewski --- drivers/crypto/qce/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index 848e5e802b92b..f9ff1dfc1defe 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -234,7 +234,7 @@ static int qce_crypto_probe(struct platform_device *pdev) ret = clk_prepare_enable(qce->core); if (ret) - goto err_mem_path_disable; + return ret; ret = clk_prepare_enable(qce->iface); if (ret) @@ -274,8 +274,6 @@ static int qce_crypto_probe(struct platform_device *pdev) clk_disable_unprepare(qce->iface); err_clks_core: clk_disable_unprepare(qce->core); -err_mem_path_disable: - icc_set_bw(qce->mem_path, 0, 0); return ret; } From patchwork Tue Dec 3 09:19:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847021 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 226A51E008C for ; Tue, 3 Dec 2024 09:19:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217598; cv=none; b=LNAqXcPhoUe+QaaOI7FMicokJtZqoDQb9FKnb4P21IHzUTHDgSVryJmSy7Ih0WB5ZcIfF9du9iF0E/QBdMhu2D3raV+tdJGFtRfMEXLneo4tK+6AgJYsTQ+3UrNjtgcDfeSUj+0zmYfzoGOv1uCjTomR53d9QHUm3ZWtqlKLEik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217598; c=relaxed/simple; bh=HD6F12ehGLkQs/vK8YhET8fqt4KkxJlOeNzxTaJtU30=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VmvUsIiaaapflDSYFolEXl+b7eDaYX2pNUhNyVG7sPIBsqf72xnfZ38t/TGxs/xYRcgRIG1UPjcGlaPIRHzPehZcYy8wmxvqw+UUmN0Wb6uxEH+bdcAOXFcvzsto5w5Ug4NHbQ/GyI3PnJovBurO6PFVHndexy+5cS8QuSdw/p0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=yKGKuU/a; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="yKGKuU/a" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2ffe4569fbeso46629521fa.1 for ; Tue, 03 Dec 2024 01:19:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1733217594; x=1733822394; darn=vger.kernel.org; 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=eftVblPKS4gARELZ0p732NX41Z2T9XexDLuwGnyPTVs=; b=yKGKuU/a7xR2mEQL3IbfP9VrkdyWpmGmB+SzgdE1Ebg1TdrNFt7/aunU0yYVhvomPU Qsj50JB/+zZWeroTPWyjMcw5eujWz44yPPaa0urvgBIVgwOTTnQPcUL4k9N2xBHAoLAf jOaQFUL/ndqxKB1jHm3qqXNKEDpub+qsBySHATq/ttVptzTSBoNNgTFbwGAxaeatUqxk gqii1bOrjcOknGadt2gQ/4QT+djC5yAeiynttRR8Ex6dB6aIZtIUfzGFHIOpEjVa0H3k tkkG8ayJ7/FZpeNFpJNfJCtIdGKoEIvhl/J991zrZrj8k80+Vjm8UPZF9t+wRGgDCZZs UW/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217594; x=1733822394; 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=eftVblPKS4gARELZ0p732NX41Z2T9XexDLuwGnyPTVs=; b=tFBkat2Zi8EW4vQVWCL4kem52r7IqtyIkPHVve4j2zPenh46wwz0Pr392C40KfqmOl 7EaBHmmrtA8+yySLEdV45sv/CnbCM27VG3OqRMf5z9fltlLc29qWzxdH4D7nhf/aUw8e lKdH38JfztM7RBe5t0s9GxUQm91MWcBLFZihTgFT96h+h26tnYQX+davhuf8cX57MUVv WxZISQ2KzsC3nTxZJ6D92/FB1hLl2SPMgTM+tXGBPU5VHIbNgjCmfVrHcjNpNynpGjD1 lZR+GbaGIz1/+wUxYFMyKd4zMU4taCvmSUmpmMFY3z7+1k8C6SSUZkf8yfWXJedFlLVM J38A== X-Forwarded-Encrypted: i=1; AJvYcCV2E15mjmTkzHfoMVr7AY6zobltJ2L/BNNGxe5m53IBJDGQLZgo8YpLOPzGQ0j5L/EkS9eDWymGC8A6Zou3@vger.kernel.org X-Gm-Message-State: AOJu0Yxr1PwBaGofqJBX3SaLDlw9a5xuMNhJELm4qnH2TpOpthWVGaVz WKfv54QUcXu7XHbpskWTmmnWVvPcnuyvT++TYb5vVOwr3yHgsAA4CzHDxSKOFa1O9j4U025i+z0 Trds= X-Gm-Gg: ASbGncuYyzlzSgPXFfbrK+LCDW49sHGYWeYFqM+irxzGVQrK1wjfZC34qi4oRBdc+CB DjV4m35VB3TIkzphXXnBlIlZyeKboQHIlbV2a/s7ifFIkxaGGAgYZHXNXVfNBdn3ZVWV96GIFsd Z4gs7h4SyOiQyO+EyZBdwbVOG4C6ZDaElnydyPTew9888+rnHBEgvbt7fAlLlL9A1WGs4eeUvLr 5Zsr/6ixUIkb74Zr7mE4IAJ2q9bvJ+mnKea8NIXDQgeOQp0WAE3WAi5+1j3oBreO7nuttNCH9EO w2syM2E= X-Google-Smtp-Source: AGHT+IEk8thFGeV9xvcpu2/iiVlx4e+FXLk1zP9i6j7DxGvSmKxBpAM9ERT9rQMBPxBN9BOkjqbtDA== X-Received: by 2002:a2e:a542:0:b0:300:8ff:db52 with SMTP id 38308e7fff4ca-3000a2bda42mr6248931fa.19.1733217594013; Tue, 03 Dec 2024 01:19:54 -0800 (PST) Received: from [127.0.1.1] (217.97.33.231.ipv4.supernova.orange.pl. [217.97.33.231]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ffdfbb915esm15591811fa.19.2024.12.03.01.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:53 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:33 +0100 Subject: [PATCH 5/9] crypto: qce - convert qce_dma_request() to use devres Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241203-crypto-qce-refactor-v1-5-c5901d2dd45c@linaro.org> References: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> In-Reply-To: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> To: Thara Gopinath , Herbert Xu , "David S. Miller" , Stanimir Varbanov Cc: linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3759; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=5anFU4gDXPczz4A13V8FA6PEG1xNDqU3mfQG1FqR+pE=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0xDdrcq+p+ikfNKs5QrH/yE5ZsPIYMjGLl2 K2K/QsfD2mJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMQAKCRARpy6gFHHX ctNhD/0Tdpytetrv206QK1MRQTJhRd12RBnkirZ2p7yrQlAjvcgut6iBpLbLDnlBq8ytV4ke6nH De8n7jvThGT5/d5MCp8BFNh/2JzYqhzd9397GADyXHmTdN5kbFNNGQFRsWn6W78IYp34+UqwlBJ QH2rZU/djSLrtW/2SdgNFwLhto0ESKqAO/aVl+gSRy9GyRPaPfSJcvKji621OeqERwHn90ZLFaY CaLlkL1/1Ext4UbWitz0JaHpq65r+n8R1VDb6VIdnOTT7PB7denSYdrUX8zV1BdA0Waw/0SXOp7 SaMRMoG+IYgNU7+ywKeFh5rg2iHjYK0FCTV33L/4Y9xII6bYtVrQT5SC3TXq4XibUuXfMnupd9Q 3d9EGsD1oGl2xTkuOwyM74ouRvPnakYCx2awvAAsZ44ZMEFpb3YjGxeCTwyUueIQSPrYZjhsiot NMeAKJfzSjcALA+cBVRJ+y84yLAX8/5z8VULj9JnJKGPE+A7A47BuwoxPWRIq0V4KAKic4Fqcv4 10132HwVEL76A1PRfIrIJ9NuYRgEs5JGzT8ZBpcpm/MOaoRch4hF1w5SGTk5p88lZfG/UYalZJL D3xccXbuWJ8wQPJCiWkTD8p5KMK5DL0Vj83jKgHGbxhsJfO+NMoJS28fRUAs1oj86bNB7Q6oLQq NmZt+7ppzMChmyw== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Make qce_dma_request() into a managed interface. With this we can simplify the error path in probe() and drop another operations from remove(). Signed-off-by: Bartosz Golaszewski --- drivers/crypto/qce/core.c | 16 +++------------- drivers/crypto/qce/dma.c | 22 +++++++++++++--------- drivers/crypto/qce/dma.h | 3 +-- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index cdcddf8f9f02b..e2cda24960f63 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -232,13 +232,13 @@ static int qce_crypto_probe(struct platform_device *pdev) if (ret) return ret; - ret = qce_dma_request(qce->dev, &qce->dma); + ret = devm_qce_dma_request(qce->dev, &qce->dma); if (ret) return ret; ret = qce_check_version(qce); if (ret) - goto err_dma; + return ret; spin_lock_init(&qce->lock); tasklet_init(&qce->done_tasklet, qce_tasklet_req_done, @@ -248,16 +248,7 @@ static int qce_crypto_probe(struct platform_device *pdev) qce->async_req_enqueue = qce_async_request_enqueue; qce->async_req_done = qce_async_request_done; - ret = qce_register_algs(qce); - if (ret) - goto err_dma; - - return 0; - -err_dma: - qce_dma_release(&qce->dma); - - return ret; + return qce_register_algs(qce); } static void qce_crypto_remove(struct platform_device *pdev) @@ -266,7 +257,6 @@ static void qce_crypto_remove(struct platform_device *pdev) tasklet_kill(&qce->done_tasklet); qce_unregister_algs(qce); - qce_dma_release(&qce->dma); } static const struct of_device_id qce_crypto_of_match[] = { diff --git a/drivers/crypto/qce/dma.c b/drivers/crypto/qce/dma.c index 46db5bf366b44..1dec7aea852dd 100644 --- a/drivers/crypto/qce/dma.c +++ b/drivers/crypto/qce/dma.c @@ -3,12 +3,22 @@ * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. */ +#include #include #include #include "dma.h" -int qce_dma_request(struct device *dev, struct qce_dma_data *dma) +static void qce_dma_release(void *data) +{ + struct qce_dma_data *dma = data; + + dma_release_channel(dma->txchan); + dma_release_channel(dma->rxchan); + kfree(dma->result_buf); +} + +int devm_qce_dma_request(struct device *dev, struct qce_dma_data *dma) { int ret; @@ -31,7 +41,8 @@ int qce_dma_request(struct device *dev, struct qce_dma_data *dma) dma->ignore_buf = dma->result_buf + QCE_RESULT_BUF_SZ; - return 0; + return devm_add_action_or_reset(dev, qce_dma_release, dma); + error_nomem: dma_release_channel(dma->rxchan); error_rx: @@ -39,13 +50,6 @@ int qce_dma_request(struct device *dev, struct qce_dma_data *dma) return ret; } -void qce_dma_release(struct qce_dma_data *dma) -{ - dma_release_channel(dma->txchan); - dma_release_channel(dma->rxchan); - kfree(dma->result_buf); -} - struct scatterlist * qce_sgtable_add(struct sg_table *sgt, struct scatterlist *new_sgl, unsigned int max_len) diff --git a/drivers/crypto/qce/dma.h b/drivers/crypto/qce/dma.h index 7864021693608..31629185000e1 100644 --- a/drivers/crypto/qce/dma.h +++ b/drivers/crypto/qce/dma.h @@ -34,8 +34,7 @@ struct qce_dma_data { void *ignore_buf; }; -int qce_dma_request(struct device *dev, struct qce_dma_data *dma); -void qce_dma_release(struct qce_dma_data *dma); +int devm_qce_dma_request(struct device *dev, struct qce_dma_data *dma); int qce_dma_prep_sgs(struct qce_dma_data *dma, struct scatterlist *sg_in, int in_ents, struct scatterlist *sg_out, int out_ents, dma_async_tx_callback cb, void *cb_param); From patchwork Tue Dec 3 09:19:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847020 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B2891E0B6F for ; Tue, 3 Dec 2024 09:19:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217600; cv=none; b=WJdSk+2E3Vers/ZQ7fotEDLLm03QxqORHosYUA1bsfhTTVOkDxZnynmbYoGu+L7vpMZ3+hlgVjzqa9xlcNSLtqXPsliKasKw4Q+PDeDLhZ9geQvbyCr0z6U8qOOmEth9Uiwg8dwlUzJbeqyqDbJbVnZDinyecbgd+paQ4KIU5Wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217600; c=relaxed/simple; bh=NJcpYWyInZqRALglY6KsrQLHat0Tnpu7cK3AllLDtRY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LTkf1RX1H65jWMafzXGyAkxxwDVQLGNyEe+PCRP1J7ggnntgukueTFvcWPGY8rj/NgXTWNhFHzNUF9k4qHpt2gHn1CVsDW9jIvwhFEFaSgilERHVXbGMh22EFL1h+TXRtZWMRn98hRJ0dPM70SIWDuFpXZVxLnFjJPUCxnBQYGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=0ZD6NoMH; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="0ZD6NoMH" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2ffbfee94d7so43911681fa.3 for ; Tue, 03 Dec 2024 01:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1733217596; x=1733822396; darn=vger.kernel.org; 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=ibyeqRptd4mJK2k4LjBPbRDskyZlzeGNEtvsESQmAbs=; b=0ZD6NoMHMovOPCGOFx4RHwLdaQV98OlTvSemVQlwvJSKrD/ywnN/B49hVUfBrRucfS CIjnv5HLGp+TT1XXcm9tmMrnAjxpUKz1SZ0PWDFdlL1/7uLEpbBEEKNp9hsywaviuGYV +1SkeBuk9t0n7CyREGLfX3lOLLtKiO2+4t955VH5bWJUM9lFMT3Hg36gbpYXz/kEd6fY sNUdaZO61HDLuARAQHC6biH728DntKMoFKcjbUzSAmWy6KxEQtYW4WuSB5wSJp2M8kus Ih/K6V12Khu0CzmfvQRlTlKOS8YlDOJxvGfueKZKYYX9qVAp/wkzyxXsprLusB/IKgMg 5MdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217596; x=1733822396; 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=ibyeqRptd4mJK2k4LjBPbRDskyZlzeGNEtvsESQmAbs=; b=WyoZK+V/zfFGsW8h3KL+OlI+s1yvEHoH641DaGk0VJKk1ImjlbePcYLNN8+bAEUwUZ 78YS4xAH7JR77sZCMhzgNve97j2Y9gWc1wWOe0YAbt6okDCL+wFypMwqvKGR6fsPVZpU VeIIHc303obH5Xg0THZYNr+Ouo09NeDhM9XRKb7m3slEDZ8nsEngwJaQoLAYhs5cRQL8 GboD4KwZTmcDTwCX5H6Br3hppSpgQ3iF3uQw5VEntFaebSoK/7LizcUHywUCou0pMRtq sSXXVtkw3or9zlYvL+H75c5yKn993Lu7A+nivVeFJ3N0zhunx+IANepGx63VpESry3jk rhzA== X-Forwarded-Encrypted: i=1; AJvYcCXdnzqDnIRWymnVwXYStPusPbQDJZlP2Nt6OAT9sJZZ8QD7MSXPQ1PLOvY7xmxOHSFmZXlMpduepExzSZxj@vger.kernel.org X-Gm-Message-State: AOJu0Yye8pMzbcuk6Vwqd6Hx/g7hEV1c3dCTnc+jYNV4rmHUtMZkcG3X FuCLH972svdGOsnnbtV3YTclvM8m2vh+/+rnd1Le8XiHuXfW5YFzAYHosLOgG/udd7YZEqXgZYz 6rqo= X-Gm-Gg: ASbGnctq/1OJ1TY6O3dkqhNrZMBswvaV1LTV3qXKiiQRpwj305mfwKoYvnufEN/tNj5 K5eH3HdTRIM1AXK4Kr4pz3DgwMuG8RXWwfWLDllGBjg/pNAC75ULkAIQtBGPfV0bGsqnAl6jdXt qA3pZ8/mmDx33us0y0xuuM7VfvXRgNyz9XNu7dfFLec3DyJmBoE/BBpKIZEgSOsmZfKO9V3xk6B jGe/CLaCZveLz3EyNezcyns/5hlc68G89DT342EkqkF8vE+YHIzHEwYVz/zTCzX4t2wcSxtOgG6 vOHmKQI= X-Google-Smtp-Source: AGHT+IEefCq+oR7ETFY8rQcEIbWc0+3MFXkcBFau0VlA7vyd8gScWVSJW1iFlI7ZjfJKrqYCJrpmmg== X-Received: by 2002:a2e:a781:0:b0:2fb:407b:1702 with SMTP id 38308e7fff4ca-30009c0b0c7mr4723261fa.20.1733217596110; Tue, 03 Dec 2024 01:19:56 -0800 (PST) Received: from [127.0.1.1] (217.97.33.231.ipv4.supernova.orange.pl. [217.97.33.231]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ffdfbb915esm15591811fa.19.2024.12.03.01.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:55 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:35 +0100 Subject: [PATCH 7/9] crypto: qce - use __free() for a buffer that's always freed Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241203-crypto-qce-refactor-v1-7-c5901d2dd45c@linaro.org> References: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> In-Reply-To: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> To: Thara Gopinath , Herbert Xu , "David S. Miller" , Stanimir Varbanov Cc: linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1535; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=ToF/xAKlSmUpzxuoLyjBFnBG84QwusKuXFLF6zjeK88=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0yLFudVleOu9sAuviRn3AuGtiZibobrk6Sq 9x/HvQyEeyJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMgAKCRARpy6gFHHX cnsxD/9NgrACtnn9VoEEsk2ViZMl50jeio6Co3oFr2jFnYJudvDZ8gaiRH5ZdGFP+AkmV7wqZWD Nq9reMo3oAxIiBOWI+dmcloRKRoPvAk9H0iO+Q9U78UtdyLlToKnxdgNJkorjAjWHqRg2irzp/X 2M74v8NKLmR+SueDHf3u2fLWwnV4aoHzsPbAS+3OWYcJmb+/132mPcPla0cwiIbPU+boQ+MEzy5 fUAf39OLEYbbs+129Twr/hvSK8SgdugoQbalnstV/FzxxeJBLvzphsP7YIR9DY1UfTVnKuNs1Ki bEetE5y5PnfPdIxC6FwMq0cVfBGo27uA8OOIzZpy6pJBlcrFVWyKZzihXtVzArb5Tc73bkvQP1C VFFUKW3kEkKFuOiuPBTA9yysEkHlMgHWRgmolrOfHATfn+EPcEyCuEDikfTKke9fxGGGwn/1PYN XfbSYy0GvrXF+Zf/AIWuC9CAIRvEbwWg28aUR8yFLsnSegJOy6+tZ5EP5hfjjUuXD6ypBpsWpVO fUJOaMUqe739riMXfc1A17NOh17rtt0N4Ciux4C90iLiOMZrDd+toLHICPsj16biPVcetwJGmPF Ls7cq0lmM+Bql964apoYR6+LHhOcle5Bb6/JpydHN3CO9N1WBDH1VUxciXkumZ+/myrsysRcPF8 KFM15RixOoEezYQ== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski The buffer allocated in qce_ahash_hmac_setkey is always freed before returning to use __free() to automate it. Signed-off-by: Bartosz Golaszewski --- drivers/crypto/qce/sha.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index fc72af8aa9a72..916908c04b635 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -3,6 +3,7 @@ * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -336,7 +337,6 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, struct scatterlist sg; unsigned int blocksize; struct crypto_ahash *ahash_tfm; - u8 *buf; int ret; const char *alg_name; @@ -370,7 +370,8 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, crypto_req_done, &wait); crypto_ahash_clear_flags(ahash_tfm, ~0); - buf = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, GFP_KERNEL); + u8 *buf __free(kfree) = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, + GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto err_free_req; @@ -382,7 +383,6 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, ret = crypto_wait_req(crypto_ahash_digest(req), &wait); - kfree(buf); err_free_req: ahash_request_free(req); err_free_ahash: From patchwork Tue Dec 3 09:19:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847019 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EB9C1DFE1D for ; Tue, 3 Dec 2024 09:20:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217602; cv=none; b=LW5YrQyY/UCcPWLVFlrVHiqytDPt54At4dSied2ACgsYSW0AYzY8RiSY8W2sJVE8gOVkSudu9WdsZ0I3fTPS5xXSdGXBKUvCkZeFlHxRtreYnF/lhTh8Q8SyeCv8x6ygLFzDLz8GDEXtZE95kC1AuPZmGk8V2Rj1Z/X/8e4nzxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217602; c=relaxed/simple; bh=Xy5gKbnsBkJc2FKfgIbY/ZU2mcaK2le76I/vIuWL2Mw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=USpRbHjqcKJoPR2bfrBZrivWc1thez+gY4F6XADWfspORaAdYZzMKUrgs8HQJFug0M2pbL1OZUF3C0+EbDbSDnQxH+7u1EqMT4ZgD1xKQW6r6YGqLN+bLad5oZytdnGJiLORHaLtmgtVGVIjiaRT0hd0m2TTqcoY2RES2Jbibuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=MvQxr23w; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="MvQxr23w" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2ffbf4580cbso54444331fa.2 for ; Tue, 03 Dec 2024 01:20:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1733217598; x=1733822398; darn=vger.kernel.org; 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=ISF/64QR6+2FKLNb1nT6CCEwJdkaHvgB/2jCubwzpII=; b=MvQxr23wTkcLN0QffPC5cvSLy+pYRpNCbw+mZCDa6SYWtsC+Za40e01ahOgzRnzSB0 GGCuQTRj7RnNAb0ARHon2/Jx8wtwfR/JvgCmvK0VGnmCr+wG0eUSW2CFj9/viwwOwOFE QYUVpYIBnhvwtII/XFnWSJtVr0PU7Adjf2U5A2OCGnaxhbHqDe43u7dw0fAQSOzgUUfL n7DCBXy8kuVj8n9W795Pw11BwWL6MjvNnBpDZ0lQePJCF69L4yGZDIn7f+Exv1dLw/va UzKVsLChz1cVq7ZYbkKm7zxU7vwejjUXngqaExASLaKKaXAz304u8VWPyH/ECM4hQ5YS sfCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217598; x=1733822398; 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=ISF/64QR6+2FKLNb1nT6CCEwJdkaHvgB/2jCubwzpII=; b=SzxnxdrrmAAMeNB10U7otaBb/xirvVsH8Nu9UR3P8LTqBcKnvFMWW0QKk0UadI2pii K+uIs242gXOTRE1Gzju6jdc9uWgTy2n+fVSsR8y8lm2qQrjKNRmV0NTFe73sC5n/lA+r cnd6Mbgos+/LF2qjUurGTjjmG02B+Zk1uEoSRNiVshTCdH9VBMPax6YnJGvkvWCjQYgX Wia/JzJVVxbM90shzDg0o72Jhi3YLwttCst0pTjiTNZzpyL1h6MHQeiYtj64El8QEnc0 pasqcDD98cXqBzTYZwftMM8W0ipszTTRfczmdHlgz8Q4J0lsM2EZpCsA20jtx+pMarSb vSDg== X-Forwarded-Encrypted: i=1; AJvYcCVxd133ULVm0hkKAmiOTeVOhyzNmEAXvskMhLd1sCzmLPMNzxPESYJiu9sKWlQAikUnFwEXpqNZoLlr/K3u@vger.kernel.org X-Gm-Message-State: AOJu0Yy2Et5nTnxmx7frqDvnAZrPYpJOGqfRUHx+vm81ax5R0Opb3oMH IVX/rCfEGeDtQ1VbzeKK5iNH7+b+cPfcmh/cpDLXrYEudiGh27+3yZbTBSDHZjnG1RpG4L2y3g3 GocY= X-Gm-Gg: ASbGncuSU1SY0bWiVpmRsQlOySLaHrIAWhaUDB4tbS/ieXD7zW+pWXeA2Mr+5EP+0Jr 6rC2kemIoyZwzb0RxFrZZKdHIMIVIeD+ZwDOYYttMcymymFWWJESBYUwoFb/GR3/azlhNyBrxUi Q+PhQ3d8Tx9QCH7RLvK2vSdKxE9w0moIDF5Wv62+czsLk9i5ErkPNoxPvuj7eGW+Tntq3Zivaxt ttb6tSeqy6TpowUcgxJ9b+3TdZmjviXr1iaRY39guCXLVLrk8cBR9XkCx1RapLHSORkNUtev4pr ieUC4fA= X-Google-Smtp-Source: AGHT+IHaBLaSsIJWPu7p7o0yORpSo5yhv3wHRlgSQ3NM1wphPHeKCE2EEMt2FIsSop8RfoJMgXVREQ== X-Received: by 2002:a2e:b8c6:0:b0:2fb:8774:4412 with SMTP id 38308e7fff4ca-30009cb820bmr9003191fa.24.1733217598161; Tue, 03 Dec 2024 01:19:58 -0800 (PST) Received: from [127.0.1.1] (217.97.33.231.ipv4.supernova.orange.pl. [217.97.33.231]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ffdfbb915esm15591811fa.19.2024.12.03.01.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:57 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:37 +0100 Subject: [PATCH 9/9] crypto: qce - switch to using a mutex Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241203-crypto-qce-refactor-v1-9-c5901d2dd45c@linaro.org> References: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> In-Reply-To: <20241203-crypto-qce-refactor-v1-0-c5901d2dd45c@linaro.org> To: Thara Gopinath , Herbert Xu , "David S. Miller" , Stanimir Varbanov Cc: linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3847; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=cnqYifjiBVmCbHFlZxnQbldj5KyaOEJPM6w2WklbSN0=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0zTfWx8MjlbvjYfTHKIJbV7ckw08uVj9nyU UFw0uaad5eJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMwAKCRARpy6gFHHX ctYoD/4vTX+HSBP7ylOm8KAQzmwrakIgaF8n1RYlEZQ1ZT7E9R9zm8GadC/r096lx53eXXeogHT JFdXeYROsiAFqbffm9SbS+Hp8YxSiIWyKHhT5T2zUQ9fIka56dlVAO8wQammqtgYK9iRtRrvrMO 3dhH7RZBdaAJbZ0ytApf1XgkuwMr5Ff7086pNAW/3g3xZLG8JLlccR/bFw09vIbMpq9vDlC/VZS YmRzf1udif7FH+HSUQmlHL7w+Kqj7fG/fDrODnZTxzMQ5VGyQwfx87yytWl5jxQtz/PeL/J2ocj qKlKwEaNzDmEn4krU5vb3AGhpLE7cRzMq8pkzliZRT6q2yvXYyi6l9034KD2sjDGkD1P772Ey5B 2OOGNPvBZFCnYMwTiAhMBXEPwsYKt4NAdccamIvx9p5TIDnYmeQCaEJNgEPFI+eCdQnp4b7+4u4 0mekSkMeUhJF6VpTFLw+pW/BzC5I5evBy7J6hy4NpQPpEieKSNhVja2jzaYGN7eATIrI4N3CU4z i3wDl8k1koACwUcm++fVkTnzDmZ4fLEyNwlNRNE6KjQyb5xBeXZ7k7e6zi9RtqK+zwqMFMWYJGG LS/fsAIzm0ohCcOl3UfQfG+rBiJsBiYjDygEIE1Xb+yLrqTEcTk5gkcqzkTVrhokB11nBt39Cs8 GkJ5YLTMFCBPl/Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Having switched to workqueue from tasklet, we are no longer limited to atomic APIs and can now convert the spinlock to a mutex. This, along with the conversion from tasklet to workqueue grants us ~15% improvement in cryptsetup benchmarks for AES encryption. While at it: use guards to simplify locking code. Signed-off-by: Bartosz Golaszewski --- drivers/crypto/qce/core.c | 46 +++++++++++++++++++++------------------------- drivers/crypto/qce/core.h | 3 ++- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index 6de9f1e23e282..e95e84486d9ae 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -3,6 +3,7 @@ * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -11,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -89,34 +89,28 @@ static int qce_handle_queue(struct qce_device *qce, struct crypto_async_request *req) { struct crypto_async_request *async_req, *backlog; - unsigned long flags; int ret = 0, err; - spin_lock_irqsave(&qce->lock, flags); + scoped_guard(mutex, &qce->lock) { + if (req) + ret = crypto_enqueue_request(&qce->queue, req); - if (req) - ret = crypto_enqueue_request(&qce->queue, req); + /* busy, do not dequeue request */ + if (qce->req) + return ret; - /* busy, do not dequeue request */ - if (qce->req) { - spin_unlock_irqrestore(&qce->lock, flags); - return ret; + backlog = crypto_get_backlog(&qce->queue); + async_req = crypto_dequeue_request(&qce->queue); + if (async_req) + qce->req = async_req; } - backlog = crypto_get_backlog(&qce->queue); - async_req = crypto_dequeue_request(&qce->queue); - if (async_req) - qce->req = async_req; - - spin_unlock_irqrestore(&qce->lock, flags); - if (!async_req) return ret; if (backlog) { - spin_lock_bh(&qce->lock); - crypto_request_complete(backlog, -EINPROGRESS); - spin_unlock_bh(&qce->lock); + scoped_guard(mutex, &qce->lock) + crypto_request_complete(backlog, -EINPROGRESS); } err = qce_handle_request(async_req); @@ -133,12 +127,11 @@ static void qce_req_done_work(struct work_struct *work) struct qce_device *qce = container_of(work, struct qce_device, done_work); struct crypto_async_request *req; - unsigned long flags; - spin_lock_irqsave(&qce->lock, flags); - req = qce->req; - qce->req = NULL; - spin_unlock_irqrestore(&qce->lock, flags); + scoped_guard(mutex, &qce->lock) { + req = qce->req; + qce->req = NULL; + } if (req) crypto_request_complete(req, qce->result); @@ -243,7 +236,10 @@ static int qce_crypto_probe(struct platform_device *pdev) if (ret) return ret; - spin_lock_init(&qce->lock); + ret = devm_mutex_init(qce->dev, &qce->lock); + if (ret) + return ret; + INIT_WORK(&qce->done_work, qce_req_done_work); crypto_init_queue(&qce->queue, QCE_QUEUE_LENGTH); diff --git a/drivers/crypto/qce/core.h b/drivers/crypto/qce/core.h index 39e75a75a4293..eb6fa7a8b64a8 100644 --- a/drivers/crypto/qce/core.h +++ b/drivers/crypto/qce/core.h @@ -6,6 +6,7 @@ #ifndef _CORE_H_ #define _CORE_H_ +#include #include #include "dma.h" @@ -30,7 +31,7 @@ */ struct qce_device { struct crypto_queue queue; - spinlock_t lock; + struct mutex lock; struct work_struct done_work; struct crypto_async_request *req; int result;