From patchwork Wed Jan 3 02:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 184583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4802320dyb; Tue, 2 Jan 2024 18:58:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2CnH6xxruZZFTQ+W0XVY4wO5m+EVN5SUL7/ZtbeAmHRFqO6Y70+lfc1rwev7b9EPrFT6l X-Received: by 2002:a05:6358:784:b0:174:e3e2:4150 with SMTP id n4-20020a056358078400b00174e3e24150mr17034488rwj.0.1704250719568; Tue, 02 Jan 2024 18:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704250719; cv=none; d=google.com; s=arc-20160816; b=h0MXYx9F+1mt00uLOFjVjlClSXl9PaSSlqXgZF0ixZ3Zr6ZZ6AY5jhOxI0H3bisbT4 X3FnMomzqNZzZXUIFQl4tZXjzzhoU6Jn2yPXh86DOLbO7Mfxi9hsC7lsVFLn2uY7M4Vb ypuvXQQ//ZjW3021EG6BVRkIzrFZ2JdrVf6UEBT1gK8DklNy2JxLAh7A8aLZOPLu2Hgh tYx+D0crgh7qrQIjL9jMVeBqSiMsjJkv4iI83wFxOf9a2UQCL/Rczjh5ozQIueovhIgm MFHKWPSqj4W9VzCAHc5S7WnU5p8VfAuq+LQfE5MRj0N+Us0m0L3BfM02toVHIQFy24zf pxyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NIIzA7fbS8s/FhcBsRrFPB1nSchgGWmbbp2yPMvhK/E=; fh=N8BdziGEL67X1CS79Ag9CohCm5DjRRS659nt3Ezwj+A=; b=CH5R1nNfM5SwBAbHjqQgE5nyo2bzejY/2QSqG45NXZtkaZxnKiih6hjVm1ojZxyqqP Z/pfL9B3rrRI3Ckic7REJLQ84H1nW3ZZpx1mhMex6NJXauZAxeL2vvRif2zTHM7SmulG Or+ZTdQhIHyxDOXzUy34jJFvlJTPO7gVb+avEFs9sr4+gakUBas1rrARwI/XFU+JFdpk b+9Ju6teNG8UGff0KZXToxI5p1lZp15LGbbUgYT1UXPMpEW2a3GCPWpy7/kXZzWZJkWG M2kR7QqE3ElJpjhQ5Excu4o+kFJ9kgSrpCty95H/GD8wVBbKk0VaLvBshocJkbMFjWT/ I/+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8jxNEjL; spf=pass (google.com: domain of linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t6-20020a17090ae50600b0028ce966d638si440465pjy.174.2024.01.02.18.58.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 18:58:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8jxNEjL; spf=pass (google.com: domain of linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4E1D1281C73 for ; Wed, 3 Jan 2024 02:58:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47199168BA; Wed, 3 Jan 2024 02:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z8jxNEjL" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (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 59ECA3D6A; Wed, 3 Jan 2024 02:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-2046b2cd2d3so6655698fac.0; Tue, 02 Jan 2024 18:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704250696; x=1704855496; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NIIzA7fbS8s/FhcBsRrFPB1nSchgGWmbbp2yPMvhK/E=; b=Z8jxNEjLZb3IUGGLhfOnGxAi/J6EAdWcyPV2U8lkmWauTyM9C4fkcD5Ol3B7Ez4Pai Dhe3G9EYRPFARHzP0aG6RZANTMMQQMTzqwu96u9of3BdDgVGcmFA80euxjuiTw2zDGwE Of9XANPiJyiCJ2R2yWWKbsfIFO9LpFSSh1ijtxTm06uBpBWtvoU0AYNRrMXsSdTsJm9y EdY+zKLEXkVl9XVZDjt5oQUJYVH7vfb2WiGsHId/SNJQ61Jiub1feldW2FsqYWk5R19+ AwyUbxT5tTxBaK/xMgXGWY648pFI0/OPBjk0vHE5i+25u0cDYE1AXujyN3xLxhti0e+Y gYvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704250696; x=1704855496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NIIzA7fbS8s/FhcBsRrFPB1nSchgGWmbbp2yPMvhK/E=; b=qQyQWLdieq5VyZKGk0iZwntnLf7oICKmbzt2LYGY8MswHEE5oq6RstYoPEoJIxl3P0 O00X/5PTRLy/w3BPyReUPnCnSHJgwNCEJS8s273iqqdpbN944uUT0D/0Vt+q/S5+x3tn 4glYNTkBatcutZ1CdpJnwurorhQiMo+z5OazXGj/sPre/tBlmdmk/5KFe8wDphER9VgK iueY+253UQpVZMsmcCv+pe9bg4ha7hbnDecxlDpVC4Td13+kML/be2jfzj6wAk4eQNMe UM49OMGS4JFGls77MugGbZvFcXMMP/tfxiyp7T2Fm6hA0I48f4IYuKogaxmkUH+YGB/q RjNQ== X-Gm-Message-State: AOJu0Yws1La4jDqdnAxzY7WaQMqK0ngVSyzx+08X/TJ6k8Oz2MTL9OzC ShpbFuzctViXWwUE8VWZgUg= X-Received: by 2002:a05:6870:ad0f:b0:204:9c06:fa91 with SMTP id nt15-20020a056870ad0f00b002049c06fa91mr19005485oab.110.1704250696495; Tue, 02 Jan 2024 18:58:16 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:a7d6:f37a:9130:cd96]) by smtp.gmail.com with ESMTPSA id d6-20020a63fd06000000b005cd8ada89e5sm21168572pgh.70.2024.01.02.18.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 18:58:16 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: herbert@gondor.apana.org.au, davem@davemloft.net, akpm@linux-foundation.org, chriscli@google.com, chrisl@kernel.org, ddstreet@ieee.org, hannes@cmpxchg.org, linux-mm@kvack.org, nphamcs@gmail.com, sjenning@redhat.com, vitaly.wool@konsulko.com, yosryahmed@google.com, zhouchengming@bytedance.com Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Barry Song Subject: [PATCH RFC 1/2] crypto: introduce acomp_is_async to expose if a acomp has a scomp backend Date: Wed, 3 Jan 2024 15:57:57 +1300 Message-Id: <20240103025759.523120-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787036402473674916 X-GMAIL-MSGID: 1787036402473674916 From: Barry Song Almost all CPU-based compressors/decompressors are actually synchronous though they support acomp APIs. While some chips have hardware-based accelerators to offload CPU's work such as hisilicon and intel/qat/, their drivers are working in async mode. Letting acomp's users know exactly if the acomp is really async will help users know if the compression and decompression procedure can sleep and make their decisions accordingly. Signed-off-by: Barry Song --- crypto/acompress.c | 8 ++++++++ include/crypto/acompress.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/crypto/acompress.c b/crypto/acompress.c index 1c682810a484..99118e879a4a 100644 --- a/crypto/acompress.c +++ b/crypto/acompress.c @@ -152,6 +152,14 @@ struct crypto_acomp *crypto_alloc_acomp_node(const char *alg_name, u32 type, } EXPORT_SYMBOL_GPL(crypto_alloc_acomp_node); +bool acomp_is_async(struct crypto_acomp *acomp) +{ + struct crypto_tfm *tfm = crypto_acomp_tfm(acomp); + + return tfm->__crt_alg->cra_type == &crypto_acomp_type; +} +EXPORT_SYMBOL_GPL(acomp_is_async); + struct acomp_req *acomp_request_alloc(struct crypto_acomp *acomp) { struct crypto_tfm *tfm = crypto_acomp_tfm(acomp); diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h index 574cffc90730..5831080479e9 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -195,6 +195,15 @@ static inline int crypto_has_acomp(const char *alg_name, u32 type, u32 mask) */ struct acomp_req *acomp_request_alloc(struct crypto_acomp *tfm); +/** + * acomp_is_async() -- check if an acomp is asynchronous(can sleep) + * + * @tfm: ACOMPRESS tfm handle allocated with crypto_alloc_acomp() + * + * Return: true if the acomp is asynchronous, otherwise, false + */ +bool acomp_is_async(struct crypto_acomp *tfm); + /** * acomp_request_free() -- zeroize and free asynchronous (de)compression * request as well as the output buffer if allocated