From patchwork Sat Dec 21 22:07:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchana P Sridhar X-Patchwork-Id: 13917945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B09EBE7718B for ; Sat, 21 Dec 2024 22:07:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09BB56B0082; Sat, 21 Dec 2024 17:07:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 04BA26B0083; Sat, 21 Dec 2024 17:07:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2E196B0085; Sat, 21 Dec 2024 17:07:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C5BD16B0082 for ; Sat, 21 Dec 2024 17:07:11 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3D169A01DA for ; Sat, 21 Dec 2024 22:07:11 +0000 (UTC) X-FDA: 82920352242.02.38BDB07 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by imf17.hostedemail.com (Postfix) with ESMTP id 4C15240003 for ; Sat, 21 Dec 2024 22:06:41 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=TcsRObY5; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf17.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.19 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734818813; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=wqsdQWXFynjFPbw6C3JDeV4YUttojmAZTLwr7/US0aE=; b=Jn20QCbgDhFYw3NB4pE6AkurOYmrOiYRjvJizyM8E2s+1UgxAJpX16bsBl7lCq9KjEYNaF dh4fIJi1FU40J4br1jNgVwlQ5ifudJNrI68G4L/lAEJ4LTedk/dOSrD518NhS0IBzVVTmm jtTP2cEZ41/89W4yTK3im8Zaz7sPNxE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734818813; a=rsa-sha256; cv=none; b=eLFN4KJK1kKKKiwwsW6UG2SJQRZZbxgXO/c7AkZNvaP8autSzZGKNVLQScEsM1M41c0PlW NjUQTdKXeuqnSJpCdJtOh3suWNmukiYMMD0ma5u+Ih00MYxNyG5YpIOioOHB020v8zDhlL XweoHRAGsohuho1Ro/RlvfxzCg6xEyA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=TcsRObY5; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf17.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.19 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734818829; x=1766354829; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=qBpqDxtQZmWTwsyge+1MB2GaW3j+inOdG1CYjVrmhyI=; b=TcsRObY5GW42hmvFeFGOM/n3A2twuaGevE0UBhX4V6OLVkRS376MVQgq M0NEgaH2ku2xdo/wBrmVTfqcB5MkHBNfHp/Rh/pI4sdO/Gqo8yIWCvfn6 Z1GBLPKvDbfCjr4g9SDpzfmMGQgZk8BshN4FVnCjkRp2kVp0WzkLAQ6e2 ficHHwepy5zgBMEByzBghcBSu4TIHUKgLfkFReY8iE0Q1JozxJcRHv7AN 9lXLfvFvKNF1dIorsVXCR1pzbvMsnUWtwdyTIHIs0P4a/9yxH/sKQFS+a LnOVkVIgkx4F/A9mW1RZVIzVByBWJdzVTCNaCchPUOhZWDozoHkDmtrfi Q==; X-CSE-ConnectionGUID: nA7ypLGuSAGoGG1dCDbZQg== X-CSE-MsgGUID: p36RR/xRSxyj+qeoecJFWg== X-IronPort-AV: E=McAfee;i="6700,10204,11293"; a="34610608" X-IronPort-AV: E=Sophos;i="6.12,254,1728975600"; d="scan'208";a="34610608" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2024 14:07:07 -0800 X-CSE-ConnectionGUID: Th2+ROGySKSpWL+iLdgN4Q== X-CSE-MsgGUID: KSMy3ubyRI6+LFwilYiqXw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="98683889" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.115]) by orviesa010.jf.intel.com with ESMTP; 21 Dec 2024 14:07:07 -0800 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, ryan.roberts@arm.com, 21cnbao@gmail.com, akpm@linux-foundation.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, clabbe@baylibre.com, ardb@kernel.org, ebiggers@google.com, surenb@google.com, kristen.c.accardi@intel.com Cc: wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v1] crypto: iaa - Fix IAA disabling that occurs when sync_mode is set to 'async'. Date: Sat, 21 Dec 2024 14:07:07 -0800 Message-Id: <20241221220707.7050-1-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Stat-Signature: d5whb3z7fjp8fn7kd6om7nxukzpody88 X-Rspamd-Queue-Id: 4C15240003 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734818801-343867 X-HE-Meta: U2FsdGVkX1/GeTNuulf73icg9mbVmA0caQV9pEmRUk9k0GOZGBIhiHYjlkP+zmbSChmO5vjGayuEKrkN+uZMB7l7fSj9csDnwDUKWW8/dQ+GXiw8IM1zKe3vCVN+PJ8ESY1Yu5pJEA6AVTbn3+Gx/Fs0u/wzxF8x3gZUvmS07+3N7dV3bnCn8xDct/QQgetuEq/y//E9ldHasbTMZeQGaXHEUziuw4IpiKajggNKTIk/57VXc1+/asbMFGgD+Zxf85mHc/l1Qpq60zEElUTtvJlcM/zcgTtHFFjNOu1/M9CNF/7W3Kz7G5gWZPUfmTURG3b2cMD8KGzQsM514MFlDWr+ZOQ7VpLk8dZhL30gRxOaWBZ136vRBmJWZtDJ/MVb6XQPPdn5eu0cjo28xn3KiG/J0t0F7NdTL3lkl/OuhJvSgvd+01MgQ1kNmK3SlcjQm/CpmxRgQ+aVa+Ns64It8+FeNybJxCAf3jahlA8JaGMPYzFnxEDbazShsNxJ+v0vBEKzKVjjgCQx82WDcWAFXEgjd1UPxI7YQ04rwJk1Rlm9D+I425S8t6ulpuwfG/rKVVj4/Z3WXZe9VO9ZBcdH92JM5oBUlYi/zGnHXAzyYcdFVaXxaC/81hgpncyN6SfjLVDBW+I6GDLnAcBVHoBadx/99qDV8OyskhA+iDWTpClPbSbxg/MzLA145Un8/wkm6mQNhdSlv4avON2D5rfyf3zhFwgCAvX5xXzRi9wEXCUDsCx0WtVJC6MrEilEnd64qosgPYq9EDC7WDNSUNvi+Ah9Fm8eC/i7kh4jkTLwZ452psv9o/VmDYkJBfOe9VBic2fs0V8sOu9izfX0NcAObkd2sJXJ/ePJ4g2mXUdiDOcT1CrieIXNN3MzHg8faPXY4t8Efpeki/2+ZKmXc8XmeSFd2xmbFxteJSM7KjSBqAL7edhjZd0t3H0mO7y/48lLFoFgZgYZMSOIIJ9/XDg lO2OGU4W +RfaLVNhcLyXesSTafpE95tRfWjojmoFP1PS4eWR4y6awJwFGtVEEf7n91jwTBxQwWX6CiA2ra36hW0nWPlmxfeLMTKdx5krIQfew5LFs7SkpN3/kUXhnoXcciP2ObzWcvj0owuwrc0vJ6WVTPL5Hx6tmNFVglfRorm+Q8WEcqbx9Md2AwfjHB7DUkYgiD1pUqpgmAhBSXJ5BQgYmm+RDYh8ztArR9nclK7ofWHZOAN67SBDDnXrLXX3dloABw1dnWSNh X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: With the latest mm-unstable, setting the iaa_crypto sync_mode to 'async' causes crypto testmgr.c test_acomp() failure and dmesg call traces, and zswap being unable to use 'deflate-iaa' as a compressor: echo async > /sys/bus/dsa/drivers/crypto/sync_mode [ 255.271030] zswap: compressor deflate-iaa not available [ 369.960673] INFO: task cryptomgr_test:4889 blocked for more than 122 seconds. [ 369.970127] Not tainted 6.13.0-rc1-mm-unstable-12-16-2024+ #324 [ 369.977411] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 369.986246] task:cryptomgr_test state:D stack:0 pid:4889 tgid:4889 ppid:2 flags:0x00004000 [ 369.986253] Call Trace: [ 369.986256] [ 369.986260] __schedule+0x45c/0xfa0 [ 369.986273] schedule+0x2e/0xb0 [ 369.986277] schedule_timeout+0xe7/0x100 [ 369.986284] ? __prepare_to_swait+0x4e/0x70 [ 369.986290] wait_for_completion+0x8d/0x120 [ 369.986293] test_acomp+0x284/0x670 [ 369.986305] ? __pfx_cryptomgr_test+0x10/0x10 [ 369.986312] alg_test_comp+0x263/0x440 [ 369.986315] ? sched_balance_newidle+0x259/0x430 [ 369.986320] ? __pfx_cryptomgr_test+0x10/0x10 [ 369.986323] alg_test.part.27+0x103/0x410 [ 369.986326] ? __schedule+0x464/0xfa0 [ 369.986330] ? __pfx_cryptomgr_test+0x10/0x10 [ 369.986333] cryptomgr_test+0x20/0x40 [ 369.986336] kthread+0xda/0x110 [ 369.986344] ? __pfx_kthread+0x10/0x10 [ 369.986346] ret_from_fork+0x2d/0x40 [ 369.986355] ? __pfx_kthread+0x10/0x10 [ 369.986358] ret_from_fork_asm+0x1a/0x30 [ 369.986365] This happens because the only async polling without interrupts that iaa_crypto currently implements is with the 'sync' mode. With 'async', iaa_crypto calls to compress/decompress submit the descriptor and return -EINPROGRESS, without any mechanism in the driver to poll for completions. Hence callers such as test_acomp() in crypto/testmgr.c or zswap, that wrap the calls to crypto_acomp_compress() and crypto_acomp_decompress() in synchronous wrappers, will block indefinitely. Even before zswap can notice this problem, the crypto testmgr.c's test_acomp() will fail and prevent registration of "deflate-iaa" as a valid crypto acomp algorithm, thereby disallowing the use of "deflate-iaa" as a zswap compress (zswap will fall-back to the default compressor in this case). To fix this issue, this patch modifies the iaa_crypto sync_mode set function to treat 'async' equivalent to 'sync', so that the correct and only supported driver async polling without interrupts implementation is enabled, and zswap can use 'deflate-iaa' as the compressor. Hence, with this patch, this is what will happen: echo async > /sys/bus/dsa/drivers/crypto/sync_mode cat /sys/bus/dsa/drivers/crypto/sync_mode sync There are no crypto/testmgr.c test_acomp() errors, no call traces and zswap can use 'deflate-iaa' without any errors. The iaa_crypto documentation has also been updated to mention this caveat with 'async' and what to expect with this fix. True iaa_crypto async polling without interrupts is enabled in patch "crypto: iaa - Implement batch_compress(), batch_decompress() API in iaa_crypto." [1] which is under review as part of the "zswap IAA compress batching" patch-series [2]. Until this is merged, we would appreciate it if this current patch can be considered for a hotfix. [1]: https://patchwork.kernel.org/project/linux-mm/patch/20241221063119.29140-5-kanchana.p.sridhar@intel.com/ [2]: https://patchwork.kernel.org/project/linux-mm/list/?series=920084 Fixes: 09646c98d ("crypto: iaa - Add irq support for the crypto async interface") Signed-off-by: Kanchana P Sridhar --- Documentation/driver-api/crypto/iaa/iaa-crypto.rst | 9 ++++++++- drivers/crypto/intel/iaa/iaa_crypto_main.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) base-commit: 13d127a82b5c70061560c65fb083e30e79363874 diff --git a/Documentation/driver-api/crypto/iaa/iaa-crypto.rst b/Documentation/driver-api/crypto/iaa/iaa-crypto.rst index bba40158dd5c..8e50b900d51c 100644 --- a/Documentation/driver-api/crypto/iaa/iaa-crypto.rst +++ b/Documentation/driver-api/crypto/iaa/iaa-crypto.rst @@ -272,7 +272,7 @@ The available attributes are: echo async_irq > /sys/bus/dsa/drivers/crypto/sync_mode Async mode without interrupts (caller must poll) can be enabled by - writing 'async' to it:: + writing 'async' to it (please see Caveat):: echo async > /sys/bus/dsa/drivers/crypto/sync_mode @@ -283,6 +283,13 @@ The available attributes are: The default mode is 'sync'. + Caveat: since the only mechanism that iaa_crypto currently implements + for async polling without interrupts is via the 'sync' mode as + described earlier, writing 'async' to + '/sys/bus/dsa/drivers/crypto/sync_mode' will internally enable the + 'sync' mode. This is to ensure correct iaa_crypto behavior until true + async polling without interrupts is enabled in iaa_crypto. + .. _iaa_default_config: IAA Default Configuration diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c index 9e557649e5d0..c3776b0de51d 100644 --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c @@ -173,7 +173,7 @@ static int set_iaa_sync_mode(const char *name) async_mode = false; use_irq = false; } else if (sysfs_streq(name, "async")) { - async_mode = true; + async_mode = false; use_irq = false; } else if (sysfs_streq(name, "async_irq")) { async_mode = true;