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: 13891994 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 Reviewed-by: Neil Armstrong --- 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:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13891995 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 AAAEC1DF243 for ; Tue, 3 Dec 2024 09:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217594; cv=none; b=TVaLOU7AtOpEcdSfUCRHSqycXeAGms2BTzXRtxWpVoVkw9/X3a3mGJ6KeheazfBL7osQp1j+x+rHamDzxVNvNgGFck3nSDNsaQYqcJOPcYXlN4KxiB2h3U50Fywf1VNyDRYqUKd/GRjzfH1s6Uvoi/ff1PIyHZY6cqS9mMsyFX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217594; c=relaxed/simple; bh=eYuNbK80WRaAXbQTcnKblv8sx0lo50Hxsz+fIFYIPBs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WO5WXO5JnCGwfoYCvDrtbwGx5NbmnfUKaNPwdTq6EY69P9I+EwKx0dOfW6FmIKZNqE9ZUv64Py/LmFFYRnFT2r91ZyZd8BvmBJiiqT+7VdeTMPkKpCMcRzAMhEElb12jZiE8jQzcGshSRConTZBWOzYzNqmWVS8MQEZ7ikjFP60= 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=tuRcgEr9; arc=none smtp.client-ip=209.85.208.174 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="tuRcgEr9" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2ffc1009a06so77010871fa.2 for ; Tue, 03 Dec 2024 01:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1733217591; x=1733822391; 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=8/FxCq/D+ZrwlBd1hxrnw2bJ03+PvBK8Cp4qmHys6u8=; b=tuRcgEr9b3IchxC9FKSVGgv26qwo7cZ+VCvbhv8sBx61MPlvwfgPL9zjaN9TB4UVo6 eFCN1SNkAzUxTx5hH3dW7439AXzmda+i5C1ZCBWLvpj5CgInBZ2scNSyo/waexhDcqJm qQ81PEK0S+De3w72bPk9TU/0n0ueFp6UbWs0HiSuNw1sONnxXrPklPMAQ51mBKI89Qmv 0oGHwcE7DIlBWvdV72UtKU5GuaUOLebmeZuWhEJOWFQFSVLUomACVgDrLwp8qTexProG ObxLDzlZKX6RUkTwSb4Sq//IQV/eSZLgEPrfnV/MFjMXPJfjUytmEwKTbhlxGjbaAOHw clJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217591; x=1733822391; 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=8/FxCq/D+ZrwlBd1hxrnw2bJ03+PvBK8Cp4qmHys6u8=; b=ThIChjHzX9tRTMOEtlh7jgHAVG4+lqjFtOGo1We5FzRqG/Xn63Wxpp2hADQeWKqG0M FMULclBYuze6y0SjvfoncHO15ITm1jHoVP37ERSCyRjmEQTsLe61JkJa8s4jJ2cuIQUQ FNeiUkAtOPEtvYpvowjnz28y+5z+LX709uuFykiXs2DPRrKh1yE46b9h3GDNxI1Kf67C aoKPpQTjyJHCqn6617ToNBLzBZsszMKMaDvEqr9/oCJQ7hPzffKUnu8eg8EuEbtQrYjX qMS2Bc/5GeVdg0adGFP+ocu5urfj2IkzsAt0c6458qYIUuREyW2GccQMoz3IRtukbjCb RjTw== X-Forwarded-Encrypted: i=1; AJvYcCWK6i6oFYW9UphZSgm7qMfuHmyHyTkGvU5Z51Q5bhCXFpF2oDweoikyB1iHc4EQkd+0S+vdMzlIY8qNxKWr@vger.kernel.org X-Gm-Message-State: AOJu0YxQ4IGGl3LdtuFdw7Nwcw1+v2WI7BRPc/NU/XACseBKOEMw42jA jUVrY+S5rhzXm1iXFU2E4cL/wRvMdxZDPnry7P34DzpWQsYZtR0ptdG1eQIa2jYImn90g7Gn7OS WYfA= X-Gm-Gg: ASbGnctLiRLBH6GKJPZpbrlEnnjz7+raqtype0O4VlvmF1ZY/9ynF6W9VIYZDSdwRme QwgpFgxwSjVFQsVje45WmzMF5GHyhmQR/S/D2G/iU0qxmhPyjFgK9zM74TGFchj9YPSBu8pVIJa eXve5hQtIFQgYwb1uU1N1uueXIaQnIAadwpH3iSVkKfnxyPxVbYYgiqNAZLW4eMsv08UwELajz/ HEOY/YvHzXnoBNCRk9Q8PhsisF9vykUU328oZZwxb1xXxh2hUv3PWhtVf4t0CCs2/MsK8sX/+zZ JPv6KGs= X-Google-Smtp-Source: AGHT+IEfXdjC8Yy7o9RHZ+7NgaXen0b0wo8Kg4Qe17WVjeTIs6uDHz7DGadVEYSDMKcH/M4MKy5dSA== X-Received: by 2002:a2e:a9a4:0:b0:2ff:5c17:d57d with SMTP id 38308e7fff4ca-30009c46730mr14340111fa.2.1733217590598; Tue, 03 Dec 2024 01:19:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:50 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:30 +0100 Subject: [PATCH 2/9] crypto: qce - unregister previously registered algos 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-2-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=1343; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=AfbQb2BovfoohKrly7MBshyETjFSgtG70aWbcVS1ssU=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0w6LMZ4oCMoqdYSOCLYwhUym1VRGdxxsqzH 49+cG0An+aJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMAAKCRARpy6gFHHX crPMD/9LzRflfe82BvLf9MYfTWI3o+kFii09BTKW8IgEonlmbp5zrkjC2hAw1b93i2amJozgvK2 /FHV7gZWxOnB12uKkpsZ4csxUxaDSmXGzP31RGwjaBZmK7nKfaO75mqWR7KKwKvMIabAgtWg2LQ UZqJ5dGd173VgDzctd5VrfOq+97489FaIu2wIuYSzMDOgLIagFZL4jcQBDsGl/9bujZPVeVFnVc GTz+8a+oYXDoC49AHHPjq2+t+HMX0CAhuGoqdmdD0Wn8TLP4zxZjXXmPR9H4jvH7x4xJAMl2MNH EGosLof58L7Zcvj4mbmyHsATV6B2pcv/znjfQoVWIIEFwBSlblaHcg9RQ76ndR88Oo09SEN3ECr Z8wssjPr2NPDeIC31PtjdA9GDGVl2YS4osgsGx6DM5TduXNkjXCHrPyssKD2EJuiMMcMgwrmmFZ TOVnOWnWRc8uXmhrmxJfPS2z5IDq+RZa3E3krJPRskqMUJgvbvG1tjc1UAu0QBMA1qydxotqleO 4k/DlSRU3PYjFFdFjoTePtfTszKuME+yO1JZKv0JqaWwCaoObhpwazXDgVpdKRk2IbhEpAtb7eG 8NpRB/zzb/gx1yd3gVXiOuzPYVMIjU72ZzGjKMzDVOJN47kZ5V7zWBgoAVoHo6JZGmsai7YvP+D wfWmRBvsBLW0ppQ== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski If we encounter an error when registering alorithms with the crypto framework, we just bail out and don't unregister the ones we successfully registered in prior iterations of the loop. Add code that goes back over the algos and unregisters them before returning an error from qce_register_algs(). Cc: stable@vger.kernel.org Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver") Signed-off-by: Bartosz Golaszewski Reviewed-by: Neil Armstrong --- drivers/crypto/qce/core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index 58ea93220f015..848e5e802b92b 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -51,16 +51,19 @@ static void qce_unregister_algs(struct qce_device *qce) static int qce_register_algs(struct qce_device *qce) { const struct qce_algo_ops *ops; - int i, ret = -ENODEV; + int i, j, ret = -ENODEV; for (i = 0; i < ARRAY_SIZE(qce_ops); i++) { ops = qce_ops[i]; ret = ops->register_algs(qce); - if (ret) - break; + if (ret) { + for (j = i - 1; j >= 0; j--) + ops->unregister_algs(qce); + return ret; + } } - return ret; + return 0; } static int qce_handle_request(struct crypto_async_request *async_req) 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: 13891996 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 Reviewed-by: Neil Armstrong --- 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:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13891997 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 B07CA1DFE08 for ; Tue, 3 Dec 2024 09:19:54 +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=1733217596; cv=none; b=kNuHRysOWrGW9lfDuqQTVqhm2OZPhr7R36cLY+oXZpm7//JmCUUPFBAXjDN8Rcg3VOcdFe0n12JRWe5+l7MQVO4sBbfIALhCNccUpHXdCon8WcWTuosbwi751+imUYhNE0iW68+033Wjx+zPY+y6Bx2yr3c6Y83R0BybhTjIpVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217596; c=relaxed/simple; bh=Z0GfOAYJP0APAwF1wT1qA4iA1Irs0ALfopxV0Gc5vhk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FYS3rjpdI9ahyqHtll4IDqQGYoD9aA23e3QbrkiwgLpkBh5u5f+PzpJZblzZXqWVnslfpFfpkwHlE88SjWk43HPjOSDRKGbKdmeQZOzmRcsneHPvWvbb/Te0Z6DMq3LaxgWjpq/9LwjnpAAdnL6nBzb0YxWzkppuJkm36mh0FSs= 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=WIaEaolD; 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="WIaEaolD" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2ffc80318c9so54600771fa.2 for ; Tue, 03 Dec 2024 01:19:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1733217593; x=1733822393; 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=iEmSL8+sddZC5U8u8rKhuAs5pRnLG1giY8wKLfUZTPU=; b=WIaEaolDa75fs0BdG35+jVfiy6QxWkPGdvNRQeBDYhsor3OJDtWoRhIcEv+dZRgDFW bmrbbymuJvCDWNeTnjnRhdxKrAJI4KM6yJ5sXWVQAf2QVGOu8Lb8UKkBB2Sb3tunXeL3 VSRSimFamjVQmSJ6rL26CKyvYa01ZRhl7GMJ0CEfDohbgzstJiv6TH8UHKtrEsm6oP9X T07Ni7we6UBS7crXqQueIwJLWcFDDRmmm5x6aIJ7SRFpIAF0rcjskT5qOyGMV36fASJE DhLwFxchBoEm75zbFRCUcBS3iP9TcB8Ox2xozLPD9BZE9JCEJsC25m6IPje/IwdfXdbC b7mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217593; x=1733822393; 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=iEmSL8+sddZC5U8u8rKhuAs5pRnLG1giY8wKLfUZTPU=; b=tQLr3xEkJnoj5oK1K7YA9P3F649/CMN5m5xMN14dDByogZ0MkJ+fkJ4zaHfyHTHteY LmEW0+ZVJlfZ4rYjO67dfaZ17QkVMFXoIMzLUEjWOxcpauRf7pyTF1a4ONYGYDj9HOZJ 5JLU2oWh0e9DkIwJ0yZAmFP+Q74T2ofMrCQ3wI+3qBR+lFAiGaPF/wCNMSI7YiW6HXXx gKtKpjLC5RgX+764m8A5ZHzteCLdvkttES3o8DrbmhHRopVFLuFNpeHinWG/s1M6Vf6E fmhtq/W/IDNjnwvrFgF0FaH4vApJgP5OdStOsHnJXZY+Ae7eXJ7vcd84sX/XXWZYixrc HaSA== X-Forwarded-Encrypted: i=1; AJvYcCWnMon0pkKvVt7S/nr4VU/yQbwyj70ZKrnQ84JF4qRrJFDjPoyuBvM9U4PP1CBDA51fldWVTp3bzaIHCaHz@vger.kernel.org X-Gm-Message-State: AOJu0YxTI8Y/MBQgY5DuQTeM1EnjQ8W3BI9eZY2dNJ23+TfaEq0LYwWu xI1d7ppPVLB1OMCIAMiP09OF3f5foeyROkkzuH632LDKShMDCMtanJE28KS7sW1XNySUlfeoPVt KPCQ= X-Gm-Gg: ASbGncu9OW4iuqjjQ8nJFkFSYDl7nd5Ro3v6DJ7oU5cnIf5LSXZ/338Iydn3etn7AMF QgYUOPoubQ1X3dqMZ8jKxC9Aua5r1t71cErOom0zSSsyo4ChB0VQLbey2GtbjAARyEWcfbLjN8q HG0AI4jhNPH1tu9o6tiwPKu6NHF41FIUcJ3eEOS03ZSUCKgb3neKuI4BMl0Om1rIoMgIzn694Ab HIqZoVUYD5W/k8Gnt/DJVFwYDUxSSTLnS8AMmNnAEHhcDkM8CuKj8dIhdIRLX7/GjL3sED+A3vv T7nr5Bc= X-Google-Smtp-Source: AGHT+IFaQWa086WdWD9OtF9i2iKTP732rCIE9XHL/J0c9FQlcUMT62QhRdBnv2a/4N1LumlA4FOHtw== X-Received: by 2002:a05:651c:502:b0:2ff:c7a2:c1d6 with SMTP id 38308e7fff4ca-30009c057c3mr8280531fa.18.1733217592650; Tue, 03 Dec 2024 01:19:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:52 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:32 +0100 Subject: [PATCH 4/9] crypto: qce - shrink code with devres clk helpers 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-4-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=2343; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=jgSsdDqzauWGl9p/3YUK4kLf/M4okM3HyzfRntFUc+A=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0xTaehQqNa27XHs5bjGiXp2naG2ecW3xkgW AKW+YPfj5WJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMQAKCRARpy6gFHHX cl+HEADczNfVm8CvOEoleQLzgRmkmCOt5Nz9PMJkhwwrNkkoJBb10kEy3TIxG7CbRHZA+QzH90E z69lQIixv/Xmej+XgRyExKRdd93diL1LROvwefA8e57C4uwW69NAop6lij0cscTo908L4M9BVnA ow7vH5SI9oOL/gvvKEuw7l9umaIQlEQZgoiyh+JVfA8MZ7ea/Vqmz/SYMY4nJYEnwejF50Ugg6O Yuzo8UfTOu1pqXMLv3eUHYWEq9Ct1PAKvee2zCcQA63+oPbEJPFcTbyBsYhX65cmuUEt6Wpswj5 xbL41GGzHPWaLUDSfLs9mIbeoc41T2MdxQe/s6HobVEhCEA1XB1cF/dNggaqT2dE8s3cmKsoW75 bOpe/35/LwUeqbOuSV2/IljVJbWpZKahbY8g/J2Qr8ZU7t9hwaTbPtNcJDk/HOdImkMSxl19nc1 StWDwLhtkGBNJtv1+RAJ236pIO1O/jqLaXhoc8FM536voiG2l6p1odVsKyWRyKNJOzhwadO6E/b Mddk3dl//lHu7ZQ1tMN76wMexck4It5ODrN9iCwf7QS2xCBXuBMIG44xO3wBEDHYDv7sp2SUsQU b+2hoD8K3pN+FZuwvPyxLiv7JlUZtdYOFdvcAfrU32Yj3/cblVT62hlkRSwTp6SGeC47YS27SAg 4T4ZTEytGksdNbg== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Use devm_clk_get_optional_enabled() to avoid having to enable the clocks separately as well as putting the clocks in error path and the remove() callback. Signed-off-by: Bartosz Golaszewski Reviewed-by: Neil Armstrong --- drivers/crypto/qce/core.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index f9ff1dfc1defe..cdcddf8f9f02b 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -212,15 +212,15 @@ static int qce_crypto_probe(struct platform_device *pdev) if (ret < 0) return ret; - qce->core = devm_clk_get_optional(qce->dev, "core"); + qce->core = devm_clk_get_optional_enabled(qce->dev, "core"); if (IS_ERR(qce->core)) return PTR_ERR(qce->core); - qce->iface = devm_clk_get_optional(qce->dev, "iface"); + qce->iface = devm_clk_get_optional_enabled(qce->dev, "iface"); if (IS_ERR(qce->iface)) return PTR_ERR(qce->iface); - qce->bus = devm_clk_get_optional(qce->dev, "bus"); + qce->bus = devm_clk_get_optional_enabled(qce->dev, "bus"); if (IS_ERR(qce->bus)) return PTR_ERR(qce->bus); @@ -232,21 +232,9 @@ static int qce_crypto_probe(struct platform_device *pdev) if (ret) return ret; - ret = clk_prepare_enable(qce->core); - if (ret) - return ret; - - ret = clk_prepare_enable(qce->iface); - if (ret) - goto err_clks_core; - - ret = clk_prepare_enable(qce->bus); - if (ret) - goto err_clks_iface; - ret = qce_dma_request(qce->dev, &qce->dma); if (ret) - goto err_clks; + return ret; ret = qce_check_version(qce); if (ret) @@ -268,12 +256,6 @@ static int qce_crypto_probe(struct platform_device *pdev) err_dma: qce_dma_release(&qce->dma); -err_clks: - clk_disable_unprepare(qce->bus); -err_clks_iface: - clk_disable_unprepare(qce->iface); -err_clks_core: - clk_disable_unprepare(qce->core); return ret; } @@ -285,9 +267,6 @@ static void qce_crypto_remove(struct platform_device *pdev) tasklet_kill(&qce->done_tasklet); qce_unregister_algs(qce); qce_dma_release(&qce->dma); - clk_disable_unprepare(qce->bus); - clk_disable_unprepare(qce->iface); - clk_disable_unprepare(qce->core); } static const struct of_device_id qce_crypto_of_match[] = { 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: 13891998 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 Reviewed-by: Neil Armstrong --- 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:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13891999 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 489FF1DFE1D for ; Tue, 3 Dec 2024 09:19:57 +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=1733217599; cv=none; b=WpCB1D2DKccKYr0HvB5AvyW2XnG4KYPFspsAFWaS9m9JK+cpUS4xaKIQKYyG0Y9ZugbyIRTQK5ekKFZhiH0QcitIhLSEUw6fbyv8MJ/XlUVvMd8W+nHJbgkgze+DHmp/NGlfe6v/wydm6d91Msa4SINNNbeiKw56FpIT5G/kNH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217599; c=relaxed/simple; bh=+VpEigVc6lxA9LKBiAOInc8aR+tM26asXGWOiNd0c8s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oaSkIZFXXfNb124zFZVmhVk1EqEIbNjve2Ce7is0RFd9bCjALsjqnpvpxj9WLNPhHhxAUrubWBgiMJHIDz9sBJOjUWXNmM/FG9Rt8S7EtJYqv5JiluB8zbfenixuQu8POhilhwSts/4DxtepKzFSzZN7lAlgavrlJoIXivosdcA= 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=t1Ik/Gsh; 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="t1Ik/Gsh" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-3000b64fbe9so3594821fa.1 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=1733217595; x=1733822395; 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=8j8u3Wa3a2CyIsUGNm4RzXAyNu0/dvUGsIrzSdp+VkQ=; b=t1Ik/GshkkyNCt1kIu2A9r8cEdVHmXfxzmBJZKC9bssCx9hQaUGsFPlAYKfy/ma//L rMB+kzp1cGUghRUxRDskGTAF972pQbk9URNOcF+GXylIZ6fyJpADVmV5ouAWdS0WuD5O GoI5mD4l4Wk4wLk1mH11k5sc4wkAumLun9G25tkqMbUvob9VNR1SFUqhVPOSys37LL08 5U4msGUFm3nHM0W7J1iZnFxcbyIdWJ8+wXhoyTJtN8BbfN3AZCfniGkBZfww9jbjobhR fAjZlQcDvNfFdr3WZbFMAjWIRfcv4wNH7T2tVSefJzDoAA18nDGQ0wMhluiFcZJQDCIK bgMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217595; x=1733822395; 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=8j8u3Wa3a2CyIsUGNm4RzXAyNu0/dvUGsIrzSdp+VkQ=; b=DXXmOSdOv2wM27dbhWK832ud46Oj4pa4Us9cq2KwerdeJVk6IsJXyjA/0R8Vf+fLuj FtanAnG3sa3mIWcMtqmeH87sDVBc9NT8XDWQheSlcM0xRn4S0lqZsxggAAOvNj7TJ3AU ISNo5LGHkL8OSBPMoma0YP3lL1TbvCflwIn6OQ6jnrW6VuK19zGw58moFwc0B5UIIZcV Ygauua4cQsveXtxOBYP/z4WiswpDpDQpJN48xxdZYK5cnPEKPvuGzvgQ8AVe19SM6cep wWhzq6tJn4xex9GxROeZ18kbmSQTTl7TIc35WlKUUbUKm2ZACI6PhKWtmkLFB4wtiLvr RAJQ== X-Forwarded-Encrypted: i=1; AJvYcCU+Wj0F01SoD67pzfj+4jdBZ1C6NJPl+HS7hBM6UFc43Xs+o8VbAuoelAZGwxg/szeLY7pb8ZTu1L7rXBXM@vger.kernel.org X-Gm-Message-State: AOJu0YyDqIZ0Qol0a6s70SWaBvYvaYqb2Q3Wi2vz+baRpNv4Kby2gf20 4GWYCnzWDwmXiq5M7td8X8VtWRxsfmISkzm7FDPqQKt+ngdMi+coh5120oUdni41dU1MCTVTx8U 0xgU= X-Gm-Gg: ASbGncukhTCBzPqAyaSJmlGLMUU2tjT9V0D8LG7eYH7eVxWgpl4HRfaSSDeL9gO8h/M PlwKwTlLtm+suxSNGWEGDWuwaHIYlD8x48S9G/UM5gkxSn3/1pt3x+/8GHdrudiSu8Uge/BEADJ h3J/tPmJ0nl2zPVkUPhaO7G/5GeLGZB7dumC++Lpff2AbBUEFhZHN1PtlH878PA88b/ZG65WSL8 JGyeYlyL/+R3TfhDqfEVP+8sJI9xtmwwzvFA5ijCJdxu9HgaW7+0ajqKWSDJQ6h7N4dTlte1892 NL3uhMY= X-Google-Smtp-Source: AGHT+IGTRPHLzsa+Od2O+5Vq5r0Q0wNcJxcWkB+oMesKwMmytxjH29mLGq29QHRwrq5YMCpTL1tlZA== X-Received: by 2002:a2e:be88:0:b0:2fa:cc50:41b with SMTP id 38308e7fff4ca-30009bf6023mr9288611fa.5.1733217595149; Tue, 03 Dec 2024 01:19:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:54 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:34 +0100 Subject: [PATCH 6/9] crypto: qce - make qce_register_algs() a managed interface 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-6-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=2091; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=nbVED4dd7+CBe0Mn4liIw0K/JKHlGMvh5/n4LZbE1tw=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0yY2lAugX/APXTAaiXr52sczuy5mBqSvOr1 A1zuRZ7nQKJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMgAKCRARpy6gFHHX ctp3D/4kRDqo7ceRU5VTbMDu5cHGuKvEQk4HFWugzwXQIkoWKFUvh4YLEBDGEKm2JRgijn4vvzV Bk6TxrOGczusyAdIZFdL/LvedFKBH4XsalF2V+qYROSB5sRBhPXWgpVfq+cLNyYZ/LECMmvRXYv U+qtM8FgrfNqwrVqon2EJ0GD3hEdEatVif+iS53g4nsWqVQvjPA+yzzQ6V96AkWYvyjyyEkuPHg sa2TnC73M0z4QK0fOFIvFoKT/39vqqpqHnkNXHziHTpv75xGKayrLSwYEUToXQ2UEeMwC35DV8S bMSXFOMKN14JbV8Bn2k3oXjTyuomyPmjI0EWuirUxfdeME3f/MCJWM3amBQKrNlaEDlS59Eg3dZ 95gBOvNQzESMkHSYvMq8tbgshlhOybXbUTQZ6RCyxToP5uWqODoBuf4HuL9mbL+MIlEef48qcb3 Qs6tvUFi0XS9Mwrq4IsefHGwvlmiPxsxRc628xwXJ9KtfTPmbXV/ryZPRm9idByg3EhDiAmA5eU KiEJR0jEHxQOHQTbHH+HtcZxiQeY5LwbHSRRtAqe44shWSqhH78uK25Kr0je2CDp7GqVKwKsWAA LcYTuBQxy8qfHhG4UjMHKOmlyCmotumyOhKMKfXFVZKG0vtR5bPu0XUzAXpv0FBAoPsuMArabad B7KdDGSu8v83r9Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Make qce_register_algs() a managed interface. This allows us to further simplify the remove() callback. Signed-off-by: Bartosz Golaszewski Reviewed-by: Neil Armstrong --- drivers/crypto/qce/core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index e2cda24960f63..5e21754c7f822 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -37,9 +38,10 @@ static const struct qce_algo_ops *qce_ops[] = { #endif }; -static void qce_unregister_algs(struct qce_device *qce) +static void qce_unregister_algs(void *data) { const struct qce_algo_ops *ops; + struct qce_device *qce = data; int i; for (i = 0; i < ARRAY_SIZE(qce_ops); i++) { @@ -48,7 +50,7 @@ static void qce_unregister_algs(struct qce_device *qce) } } -static int qce_register_algs(struct qce_device *qce) +static int devm_qce_register_algs(struct qce_device *qce) { const struct qce_algo_ops *ops; int i, j, ret = -ENODEV; @@ -63,7 +65,7 @@ static int qce_register_algs(struct qce_device *qce) } } - return 0; + return devm_add_action_or_reset(qce->dev, qce_unregister_algs, qce); } static int qce_handle_request(struct crypto_async_request *async_req) @@ -248,7 +250,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; - return qce_register_algs(qce); + return devm_qce_register_algs(qce); } static void qce_crypto_remove(struct platform_device *pdev) @@ -256,7 +258,6 @@ static void qce_crypto_remove(struct platform_device *pdev) struct qce_device *qce = platform_get_drvdata(pdev); tasklet_kill(&qce->done_tasklet); - qce_unregister_algs(qce); } static const struct of_device_id qce_crypto_of_match[] = { 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: 13892000 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 Reviewed-by: Neil Armstrong --- 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:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13892001 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 582061E0B99 for ; Tue, 3 Dec 2024 09:19:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217601; cv=none; b=KBA5ouKe+7FK84FWpuSv3X4B0mxwNIwyYMPuVzUFvA4U1zyyYpyzfOR4cEWSnjS80W2ybw7EWxTzwTGPftfI/Vk4m1nn7vG+hXbjccJzZLNFRYgdznrEXlHawQ76ElpsGKpSGl5G9MtUjyQ9YHyjVaHPTXPJvJdKdkSrZH7oDQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733217601; c=relaxed/simple; bh=v36RVXGvlTlE5sonbFp2YQfvFCSumnQSXer1pNGWy18=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b1LrfHMgRXI2D/rzJSyhIN372vzcirXRWK62iruQ2+X5uPSxG0Zwq4koPYiDkcgkVGHv9q2o/FDb91sxFVUkXmD2rKGtMtNSnpA/dARS/DJ4gc3TyfGeY671BXr8rcHtxYWzIJKJkkx2RQhWWi3vm5ic23812aF6Ajdba/2x4lI= 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=XtisRaYY; arc=none smtp.client-ip=209.85.208.172 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="XtisRaYY" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2ffc1f72a5bso53775761fa.1 for ; Tue, 03 Dec 2024 01:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1733217597; x=1733822397; 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=LRH6cj3Zv8oaIGQjdTXxz7Bjv+j+MCyGC3Pj/yHr73E=; b=XtisRaYYgyhnxc3gwkcsw30NTSoF6RBvVNHu+HKfN02hC+dCyXuxn0fkZJRwqvJRlx JMyyDjdMX4juz2flVicS2macLirGcefaCmsoWQO4ipEm8Q7k69awHUcqOCQDYbj9RLTL o7CedU0Cg36FiJTIzpywIpd3F5dM5VlNQ/DShekc9Hbqj3cVi4nNUFGfkpI6kDdr4cMP orCovM2LFaRnQPJXiOpKR8km0uNd6Iw4BfgZVjAobQSnVePBaprUB0HXS8hqzljZmXC1 viF68Vvu+V1r425w6i5d7egn0Ra5jNrmiUt8Ljk97pInM+CXfwRuDTc8d8dCyrtuhXIJ WHqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733217597; x=1733822397; 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=LRH6cj3Zv8oaIGQjdTXxz7Bjv+j+MCyGC3Pj/yHr73E=; b=UW8hjjf7svT5p5hhWqYS4vf8W29sspI3/jiMueYe0aqcZEvx+fWAguFENNOYLxhq3o gIhrQ7sPsk8757rXAhHVJu6JUhLCd82YWigmwZWmxIpKfVPiHK8tCsgajdw4s/9lgoaA 4mq7ss7aKbZAETSf1eDArX3mcBpS1DQP9s6KDwR8Cj8pscF6PDQfQB6bU6O0XcwU2j0e 9KKdtOwm3q6PvXM9QAAhBkPj4bqD6f4Mw9equykPVOOdtSWMxM6swE1XxqcGxcGtgKQb xpBwdACw/FT45p/A+0PHR3WUBPBgqcAiYZoiBTw9/m3cfDAQuOcNP0uP+rNuzIIRD+aL GNrw== X-Forwarded-Encrypted: i=1; AJvYcCWg3etbXRNtco7b1slDn01tC8VlB0tjqiSLVPCOg3A/0oPT8J1wel1IwziU7pkCLGDya0jl+r8DG0GGTYJh@vger.kernel.org X-Gm-Message-State: AOJu0YxGHJskUN4cz6G8H9zGMhx0ILKobaJ5IB+cFWI9A03POo1Kf1Df 8TEyrDmPOcigdj74WdU8fw+4BSsE2jUiVScElvU4yFJLxGh3+jCzctnFPjVcsZRp7HNMs3ZOS6r bsJE= X-Gm-Gg: ASbGncvhJi1fphEifA922xTZS6F23tNaLHt64SsfCevU9Krvfw5jXmDfANM2wYdUnpM icJJtm5ZoTmZ3hoht96acjxgGBpW6r7kV1EoPo/0j3YYHP6xWPOd9Ox+rRftcSzsRB80OAGnKCw o2kdw/kxt3/Si4sinOUBNj6RS5FNxYGJDiomXXeEGDxq2DMujaPhQ3kYmNnar07VydQmuhiD9Fq lpwKKwc10RZx3uoujirxve9c1R71ULT9ykv12yCbY25lVaXz3TJVb8J5pF/LNr2un9PoFY8ChRC yW4RGzk= X-Google-Smtp-Source: AGHT+IEwQO/Tj+5na6vVlqf2KeawHQpVSNxOc1OX2QKgNgIzhPI5EiWxtK24ZF8BHykiFaKddauGmg== X-Received: by 2002:a2e:a98a:0:b0:2fb:5a42:da45 with SMTP id 38308e7fff4ca-2ffde23e531mr75703801fa.16.1733217597191; Tue, 03 Dec 2024 01:19:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 01:19:56 -0800 (PST) From: Bartosz Golaszewski Date: Tue, 03 Dec 2024 10:19:36 +0100 Subject: [PATCH 8/9] crypto: qce - convert tasklet to workqueue 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-8-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=3375; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=bX/So5owe8asnIGgm+prnF/cLGwAYLG//DR0NWiAu7o=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnTs0ybBYqgSqrqtV+nWWBjSFG4iZy8W0KJW9i7 snficeCg22JAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZ07NMgAKCRARpy6gFHHX ckoTEAC/aYy5y66Se3hGIFX7dhzL9YSeLFKDk28WP24GKvN8fuYnDYupADG3wSgLOePVz5E3NUu krZWznJMKjOFgtwtk48FdqZLOoP9+vck+xqBQ8p7dcedyRqnnERZa4xZBJBdHOqb0/Q3FVoDpiZ QTaSt2n9flTMhiaU8ltUkXSSgV7yc9I/9+7YXNoTsAHvnZ60MRtTcDv3OA25+AR/ET9C9863eC1 Dri7s86tK9M5zrj01TyStIUp/51YctfejFIczenhXHFW3/P+ts8l52OjvKXQSu5GkLITJasOxlM iHg2L71MfkleKyUZy+iFDIb+cbdnBizsV1VBj6jwEBBpYlLMN1esVskhj+zgBegtF0gwuxBDmIi V09vulaShhs8/sUEXx2LmgmvxgXNQRpnZJekiRhywTcIj2/0d0ARJ1QVSTMrpB/MWm43NP3PVPw Uhe0RAiGGMec5MXtFjs193sy4YF55Zp8vBjZiKiqe+qLnqsm5YcZ43Lv9HUoO2UypLhwufnf0wo 2BKFQ/TQi3ZvEhljuy0NGlAhQ/rc730clVFbRSN2qKKXHV/7Cqu3VJhlDx0dUAxISury/FdVn8k 8VtWB6so1T7EHCG7P5Oi/Khnjuz4BXGmG/9lhxD350vBYtNbLGOLOPgF8dznQIzod2p8UsGgFPC vo4rYQb0RrNBHmg== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski There's nothing about the qce driver that requires running from a tasklet. Switch to using the system workqueue. Signed-off-by: Bartosz Golaszewski Reviewed-by: Neil Armstrong --- drivers/crypto/qce/core.c | 20 ++++++-------------- drivers/crypto/qce/core.h | 6 ++++-- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index 5e21754c7f822..6de9f1e23e282 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -122,15 +122,16 @@ static int qce_handle_queue(struct qce_device *qce, err = qce_handle_request(async_req); if (err) { qce->result = err; - tasklet_schedule(&qce->done_tasklet); + schedule_work(&qce->done_work); } return ret; } -static void qce_tasklet_req_done(unsigned long data) +static void qce_req_done_work(struct work_struct *work) { - struct qce_device *qce = (struct qce_device *)data; + struct qce_device *qce = container_of(work, struct qce_device, + done_work); struct crypto_async_request *req; unsigned long flags; @@ -154,7 +155,7 @@ static int qce_async_request_enqueue(struct qce_device *qce, static void qce_async_request_done(struct qce_device *qce, int ret) { qce->result = ret; - tasklet_schedule(&qce->done_tasklet); + schedule_work(&qce->done_work); } static int qce_check_version(struct qce_device *qce) @@ -243,8 +244,7 @@ static int qce_crypto_probe(struct platform_device *pdev) return ret; spin_lock_init(&qce->lock); - tasklet_init(&qce->done_tasklet, qce_tasklet_req_done, - (unsigned long)qce); + INIT_WORK(&qce->done_work, qce_req_done_work); crypto_init_queue(&qce->queue, QCE_QUEUE_LENGTH); qce->async_req_enqueue = qce_async_request_enqueue; @@ -253,13 +253,6 @@ static int qce_crypto_probe(struct platform_device *pdev) return devm_qce_register_algs(qce); } -static void qce_crypto_remove(struct platform_device *pdev) -{ - struct qce_device *qce = platform_get_drvdata(pdev); - - tasklet_kill(&qce->done_tasklet); -} - static const struct of_device_id qce_crypto_of_match[] = { { .compatible = "qcom,crypto-v5.1", }, { .compatible = "qcom,crypto-v5.4", }, @@ -270,7 +263,6 @@ MODULE_DEVICE_TABLE(of, qce_crypto_of_match); static struct platform_driver qce_crypto_driver = { .probe = qce_crypto_probe, - .remove = qce_crypto_remove, .driver = { .name = KBUILD_MODNAME, .of_match_table = qce_crypto_of_match, diff --git a/drivers/crypto/qce/core.h b/drivers/crypto/qce/core.h index 228fcd69ec511..39e75a75a4293 100644 --- a/drivers/crypto/qce/core.h +++ b/drivers/crypto/qce/core.h @@ -6,13 +6,15 @@ #ifndef _CORE_H_ #define _CORE_H_ +#include + #include "dma.h" /** * struct qce_device - crypto engine device structure * @queue: crypto request queue * @lock: the lock protects queue and req - * @done_tasklet: done tasklet object + * @done_work: workqueue context * @req: current active request * @result: result of current transform * @base: virtual IO base @@ -29,7 +31,7 @@ struct qce_device { struct crypto_queue queue; spinlock_t lock; - struct tasklet_struct done_tasklet; + struct work_struct done_work; struct crypto_async_request *req; int result; void __iomem *base; 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: 13892002 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 Reviewed-by: Neil Armstrong --- 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;