From patchwork Fri Feb 16 04:08:13 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: 201912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp288636dyb; Thu, 15 Feb 2024 20:17:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWN4ehsuz14pkXyC0tSGGGfPWjNkPdgw+tagwNRxIcEfvu+3ROPdKxFIrwynv2FSe0AYkSj4RZgeFLkbNSC3JjiyNRw0w== X-Google-Smtp-Source: AGHT+IGO5bETN6PFMQ3ssN5JDKtjkK2qyQTOosZKIL5r8lOCph/V/LFP1Ir+RfqMLpFkBEY91eiT X-Received: by 2002:a0c:da82:0:b0:68f:2c72:a76a with SMTP id z2-20020a0cda82000000b0068f2c72a76amr2708786qvj.3.1708057033469; Thu, 15 Feb 2024 20:17:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708057033; cv=pass; d=google.com; s=arc-20160816; b=zeQDXDc8/jdeQa8dUWMYHrWof0b7vxzhRjNFxAhDXKhspu6pPMIVN8r66a0/gkAsn8 ssLB6ilmwArQrSY7IU+O+Oe5FKCAWHQ8bXhU2WgVdiEkqhuaKy7VJE8piAoWrgEdldT8 h0fP8rqINhu1tjA0TAuQ8amHvxKTZJfTVTn8Ey27d0KQsud2nxd10LbgLSvXhiLt15a4 qR3p6iEDi658Dz8/zIqkgioo6sGjtZjxLqlBrIDFqRbRHbYcM/HZpDrwJMQpVL2rmtt1 pIG8okVqc0GMz/JGZvjBwAUaLQuy7qHJ30TJ20JzMyTEt/yfhWyRAwDDnLNjYaDvc15p hEaQ== ARC-Message-Signature: i=2; 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=ip6H/hpmZhzyeEdQqkgVS2/3JYDDw9wfoPqTzf/YhGo=; fh=1Wtaf7mFadLcDYeqk5V/GTRC0kmDSYe3KOZyEXi+pAk=; b=NM0aqbtSoZoJTs1KI78IBl0Bnnl8y+ae6313V8/5PfFlolP5Eez5SyDztEgB3BIwPT 9qB39a2jrutXqgCBDtUNz0PU1lquGozJSTL4R2cogsrHXOVTIckQqHHnkCzfmp2lOxXb 0PDKji8rvRzIIZweC9BU2ojwwxRCmU6H9t0/Her3/nQ96Te2Uz0tWEmLJti3qTgl5sCY U7W9Guim25+Cx3VDVteHR2q9mLBmQUooF+1rlxfcIOPaS3gd6pb+vzKwjcjikP14rPdF 9kezWby8snNG7pvv3wk4HBaijIANdZwfDedmgBLKUHiLTuo3ODEa54GqLK31Rbl3uLbd cvEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="bX8Q/+hS"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-68045-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68045-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pt1-20020a056214048100b0068cc2054432si3116408qvb.495.2024.02.15.20.17.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 20:17:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68045-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="bX8Q/+hS"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-68045-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68045-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 334F71C21648 for ; Fri, 16 Feb 2024 04:17:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 258D3168DA; Fri, 16 Feb 2024 04:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bX8Q/+hS" Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.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 8C59014AA3; Fri, 16 Feb 2024 04:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708056541; cv=none; b=i+NSdS79WWqBkrbuDqNBDRiTjkRMXzzE+8pjV8k5p1yzI0419ZmN3V7vUHwYGpPZWdZdGIE6j1E4mbVYZ9N/xUhBuvX7fbhyL5NFNK5O/Gy+u6oPJsizdxZMPV7xnsZLOEQXa4qQWdXpxlxllHF3nilPVGhk+KVxzschB05G3gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708056541; c=relaxed/simple; bh=dZFmMb0eUSR9kF0J/d1NN2tRjiMEitp/3HXoSB/UdT8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JF7tfInyXcL1lKAMvI2NdapTb6uWrwDHTscMJ2WpFXMD8ql91WemRjq+RTdn/DrRLJgdzFDfbrlRecXJFg68M5IpTsRYJVIT5lOHiwCgEDfyIcED5pACUfp83mdotqMUz4OAeSAqn1SRYOIPVqZnof8Wd3XgbpIloHuEVWfpLEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bX8Q/+hS; arc=none smtp.client-ip=209.85.215.177 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-pg1-f177.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso302285a12.3; Thu, 15 Feb 2024 20:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708056539; x=1708661339; 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=ip6H/hpmZhzyeEdQqkgVS2/3JYDDw9wfoPqTzf/YhGo=; b=bX8Q/+hSMnGLsen8mxLD4KmobJxOgUwi8oAMnRiXC5F/qDs3NlarcXXszXsItFSHmk l887Sk3nbRRXblJR9PSlg4r8ZVWq2sESPiTOyQUWBwt/jnT4188Dt3n5uxdmq7lJUnjA wJtXRpXCyOEUv5MLfQSh8/8k6D48+eHdDMisufx9kYubIqbqVXbjE6iYsCaQ7b+/1Vn+ l2PdscB38C+q9cjPAJtfIqFgQEarlweshfrHJcQIptok/+Aqvba+EUFsYNAtlkaK6DYz +DeGDVMr3vxvLszWyTgtk/3YXeatUfPbDNth9Tard80d0OVtwu6VJO4DDqZ4wpb+LpYL bpig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708056539; x=1708661339; 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=ip6H/hpmZhzyeEdQqkgVS2/3JYDDw9wfoPqTzf/YhGo=; b=YTgp/iOrlGVpKAcRT7U557KXi3p0Jv/X+0wrgrPkUO1H/R2myTl1HHtrWWfyghMWKA MSmuUSBH7//TuMrQIpmFr0OvGKpoloodQACb54HCEIe82GXRjKNqH1BU1g/dwzWgZN8f MixlnGH9pE5dJ2J0g7Sh1yryW7KeIkJOhBhyC8Ifoo7VxW+hZ/6Nga2QAcH1PfFuoxxf N+Ajxu0Fzi7p95WSh8o8XUlXyJk3CZLNnsp4ChaPr+6cuqZFyvMq0kZ1rRKyVRU+J87+ mUWh2BHwcq3qgLGT0+Cbi0AFoo8QkSjneB+Iu2/KuZqD73W3Mco/2d8y7FREYSq27/u1 U7jg== X-Forwarded-Encrypted: i=1; AJvYcCWAbeaIbpXz/Od8vBfKhLXKL2GI+lVmEjcTJdjVwoxRYRDF0BkZ8niG73IyVhfxV91eALemagMV0GTQe5FCJJ9OdyVK7jChcOuqdshmax6U9FIN+Pu+Z9IPjI4tzdQjiLeHaDLzfTFHQP3n X-Gm-Message-State: AOJu0YxhsZCRWxQ6FyJluUOqe+NjGa80AclqRkA6wuvkvN6ZQj6JHwZe jev8JMjSsVG942b136Z45lOVjNm0mkvPA/15F7uLhmRQ/4oZONPv X-Received: by 2002:a05:6a20:9585:b0:19e:3709:f3f9 with SMTP id iu5-20020a056a20958500b0019e3709f3f9mr5626996pzb.2.1708056538819; Thu, 15 Feb 2024 20:08:58 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:f28b:3925:777f:45d4]) by smtp.gmail.com with ESMTPSA id pt12-20020a17090b3d0c00b00298ff26e4c8sm2321393pjb.26.2024.02.15.20.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 20:08:58 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, davem@davemloft.net, hannes@cmpxchg.org, herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, linux-mm@kvack.org, nphamcs@gmail.com, yosryahmed@google.com, zhouchengming@bytedance.com Cc: chriscli@google.com, chrisl@kernel.org, ddstreet@ieee.org, linux-kernel@vger.kernel.org, sjenning@redhat.com, vitaly.wool@konsulko.com, Barry Song Subject: [PATCH v2 1/3] crypto: introduce acomp_is_sleepable to expose if a acomp has a scomp backend Date: Fri, 16 Feb 2024 17:08:13 +1300 Message-Id: <20240216040815.114202-2-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216040815.114202-1-21cnbao@gmail.com> References: <20240216040815.114202-1-21cnbao@gmail.com> 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: 1791027612016370082 X-GMAIL-MSGID: 1791027612016370082 From: Barry Song Almost all CPU-based compressors/decompressors are actually synchronous though they support acomp APIs. While some hardware has 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. Signed-off-by: Barry Song Tested-by: Chengming Zhou --- 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..fa15df394a4c 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_sleepable(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_sleepable); + 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..88ca33532313 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -204,6 +204,15 @@ struct acomp_req *acomp_request_alloc(struct crypto_acomp *tfm); */ void acomp_request_free(struct acomp_req *req); +/** + * acomp_is_sleepable() -- check if an acomp is sleepable + * + * @tfm: ACOMPRESS tfm handle allocated with crypto_alloc_acomp() + * + * Return: true if the acomp is sleepable, otherwise, false + */ +bool acomp_is_sleepable(struct crypto_acomp *tfm); + /** * acomp_request_set_callback() -- Sets an asynchronous callback *