From patchwork Wed Aug 28 12:28:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 13781235 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 17881C54FA6 for ; Wed, 28 Aug 2024 12:28:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A47AD6B0092; Wed, 28 Aug 2024 08:28:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F8A26B0096; Wed, 28 Aug 2024 08:28:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 872466B0098; Wed, 28 Aug 2024 08:28:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 69CAC6B0092 for ; Wed, 28 Aug 2024 08:28:58 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CFEBD81FA3 for ; Wed, 28 Aug 2024 12:28:57 +0000 (UTC) X-FDA: 82501583514.24.4600A81 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf11.hostedemail.com (Postfix) with ESMTP id 5F5124002A for ; Wed, 28 Aug 2024 12:28:54 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=EnmRmkZ8; spf=pass (imf11.hostedemail.com: domain of m.szyprowski@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=m.szyprowski@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724848048; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=NSj5vkqYTM3e+hX7IsHJ3VkGf9PQv0mvXnMfgqsUvYw=; b=k7b//zskyQo8AUTYwfhaWUn1gMtmr9oDmSiNJhFYsR+4o4c9yg/zLOrO0doGe8RayXrHDI MHeZO+ZPfplmEXqoDJV6DairSCwEpDmBsHJZKdCk3ohEOPYFRnVKOnqDPwgk9VYg8nR73Y IQHdIEvpatlgvUO/dIjEQZAp8P8liqQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724848048; a=rsa-sha256; cv=none; b=oRyFDtsMrFcCoAjy4htF97HQLahVOit0KPbLhMsNUXziUqPpP6LlVwzdBjNw2Ts3yqdX+/ ZILZKgDBe7GrCD/PnAR7yZOlGGnMtK1hSnvKPL575+f4SQVraRdai+duLeyjC/G/0ZxxeG 6qHoOoWy/TI7kvB9oynp7m6cZlN549w= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=EnmRmkZ8; spf=pass (imf11.hostedemail.com: domain of m.szyprowski@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=m.szyprowski@samsung.com; dmarc=pass (policy=none) header.from=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240828122851euoutp013594c7d1d78562c567f32deaa701c983~v5Dy_Jibk3266932669euoutp01h for ; Wed, 28 Aug 2024 12:28:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240828122851euoutp013594c7d1d78562c567f32deaa701c983~v5Dy_Jibk3266932669euoutp01h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724848131; bh=NSj5vkqYTM3e+hX7IsHJ3VkGf9PQv0mvXnMfgqsUvYw=; h=From:To:Cc:Subject:Date:References:From; b=EnmRmkZ87PTD/BkqOHcMJXWhBxP/ML1mz1TYVJL0mcUUQuj6jRNxLKjjRx4Udx6iO zZ4eyQysgbFw7TUY0mVMiMnTIePZzlWDfApoV4gIKlm1RXcQEwf2k+0Kv3ZemiHWfd PbsDMwb/sjJ8YKD8iQNd1EmkI2G5jbenK70Krjwk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240828122851eucas1p24f8b636bcedfe2f375d14f077fb10763~v5Dyq6FNw1791517915eucas1p2C; Wed, 28 Aug 2024 12:28:51 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BC.98.09620.3081FC66; Wed, 28 Aug 2024 13:28:51 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240828122850eucas1p27f050ad5fb011796b89bb90be353c417~v5DyC29y90037300373eucas1p22; Wed, 28 Aug 2024 12:28:50 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240828122850eusmtrp1115f8a027d7533c68810504c7dbb3b3b~v5DyCRr9W2497624976eusmtrp14; Wed, 28 Aug 2024 12:28:50 +0000 (GMT) X-AuditID: cbfec7f5-d1bff70000002594-5d-66cf18031521 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FA.17.09010.2081FC66; Wed, 28 Aug 2024 13:28:50 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240828122850eusmtip2bc4934e9241c919a63c4619245f27d4a~v5Dxf06m01549815498eusmtip2G; Wed, 28 Aug 2024 12:28:50 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Marek Szyprowski , Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Cristian Ciocaltea , "Liam R . Howlett" Subject: [PATCH] regcache: use map->alloc_flags also for allocating cache Date: Wed, 28 Aug 2024 14:28:34 +0200 Message-Id: <20240828122834.3778031-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIKsWRmVeSWpSXmKPExsWy7djP87rMEufTDN4ckbCY+vAJm8W3Q2cY LZoXr2ez2N7wgN3i8q45bBb31vxntVh75C67xdwvU5kdODx23F3C6LFpVSebx6ZPk9g99s9d w+7x8ektFo++LasYPT5vkgtgj+KySUnNySxLLdK3S+DKeHD2O1PBYcGKa29uszYwvubrYuTk kBAwkVjQPZ8ZxBYSWMEoMXOKdBcjF5D9hVFi77/ZzBDOZ0aJA087WWE6Xh0+wAaRWM4oMWPF ZXa4lqtNZ8BmsQkYSnS97WIDsUWAOrZ3PmUCKWIWmM4ksexADxNIQljAU+Lrtz5GEJtFQFVi 47oD7CA2r4C9xN8fsxgh1slL7D94lhkiLihxcuYTFhCbGSjevBXiPgmBHRwSK7deZINocJH4 /7+bCcIWlnh1fAs7hC0jcXpyDwtEQzujxILf95kgnAmMEg3Pb0Gts5a4c+4X0CQOoBWaEut3 6UOEHSWubdzCAhKWEOCTuPFWEOIIPolJ26YzQ4R5JTrahCCq1SRmHV8Ht/bghUtQJR4Sm4+Y QcI6VmLKtM0sExgVZiH5bBaSz2YhnLCAkXkVo3hqaXFuemqxcV5quV5xYm5xaV66XnJ+7iZG YCo6/e/41x2MK1591DvEyMTBeIhRgoNZSYT3xPGzaUK8KYmVValF+fFFpTmpxYcYpTlYlMR5 VVPkU4UE0hNLUrNTUwtSi2CyTBycUg1MyxfOnTZ9dUa+9POahZ/Ywnvrejb6asRsaN7VJKjV /t/2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sLFfihBo2R5Wku4b+DNgLZLs05zz4t4x8snn/o2dsKR5jXL wv+c4eRd9K5xB8Pp2J/5MXsKDpWvz5D5Zb34MENy1GKuhx+ife/ZmUcK93g/O3RlZcP6uV5s mSZrJk7fK/m22ej9ZOPvD9S2nri4tuqHrP4RgycbWqMnHjiv/oQ72uT504S9b3cwcq799Oif 7WytFTsmvLnS7WzT7Mr4UitKZ+86Be2AIo1OD09tS+FZ7c/djiqxFGckGmoxFxUnAgDMAzSe CgMAAA== X-CMS-MailID: 20240828122850eucas1p27f050ad5fb011796b89bb90be353c417 X-Msg-Generator: CA X-RootMTR: 20240828122850eucas1p27f050ad5fb011796b89bb90be353c417 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240828122850eucas1p27f050ad5fb011796b89bb90be353c417 References: X-Rspamd-Queue-Id: 5F5124002A X-Stat-Signature: ih1wkaeosywr5aic6djpndji6dq1e7wn X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724848134-749763 X-HE-Meta: U2FsdGVkX1+9KToGtNqlNQJ9NvJNtoAO+NRZMqws5Qzt+VpWO08tli5mGM091XDkY7vMG0UqHA4+Dn6dQqY4X2ej90UTLbiOXb3cOy0r2gOfDd9WzyalqlOXOOQ/dTy/ZuqJaeWfMmteNf7mQneyUCSgi49u6lYsd/84tP8Vr0zdDWedc5PWbNfGsqt9gu8HavH1OeOoLcaruO7iS7H6pRirmX1bxEL+MfyFAw0oNvbPYGWPE8KZMry+MtLUsLr9LAI1MTpUG9arsqeirTeoX2owOKwxIMPsN5LpcrJRgoC/r74azyfTbbHLnLXPu6tcYxJv3FX/atzuXyIQY6eqltXq+NZQ6kgqykz+DnOTN/nFWDaNjIxxYfNzqbgtZ2om2e2CfRI0bHylWJBkSlfVmEa6m2gB16CMBGGf6V/7EgXFAyo5sT3VpcOYB4ZBGFVfsPCsZRo0Qw5/1wqoCGLoyxRuOAVHzCxBDCtOnpVEi8KgtnCpERz3cECIivnBHWQaPH5JmVxEJ6cGnNKv8fgni1O94k8ce8JA3AImpuEqCs+zkgS1eQQNtg9cW59u7I2+l/R+sCKG+Ego9N7eZ4QwzoNLCO8wPQ/yuuoSjtJSdP6PrRC4b+5iGrx4duBnHRerZs7wc8+m74d/agAFtaJZcSV8aRu+cHpNZttx+DCfcVagjOgf21tdSzxQ0SBlTKTial5i7GyAnA4RombrFPbiofEvRq4lXIwwcH7ypHEDbBNw4uzz1aY/e4eMH0j5OE55ng5Emw4iRPsfufsvdkKQk+3FKGWxZwmdoHQIsTyFoCel7vUkUMW87K6xGtFMYQ0JNWPMGJ6neG2ACySaLOqSPvzfXd3bxM4mwdzfkuHopqGvNOlCJV3W0MHAFfRWyTYaMfqvSzyvf0aHF5IdCIB8fCRh+zCm54x71SDLjc+Cj7MQa4w/2C/JseEdp9UIc/iEEVKVUtGnp9HLV3NrEJ4 k9GRkd6T M+UduDCK7iImJtHRCEHub6TOh7rDrSAeDnbPat0NQXJOWBeh7SCwNajBIRnnVkAdGo5Poaxg7JYoX7xTLhMTy0YMOFmG71kMyf3wM7lgy5UGNlcn4qqD9v26CcFL+6Zs+ORNqsx51kTrLA78= 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: Commit fd4ebc07b4df ("regmap: Hold the regmap lock when allocating and freeing the cache") introduced a locking around the allocating and freeing a regmap cache, so adjust the memory allocation flags to the ones given in the regmap configuration instead of the hardcoded GFP_KERNEL. This fixes the "BUG: sleeping function called from invalid context" introduced by the mentioned commit. Fixes: fd4ebc07b4df ("regmap: Hold the regmap lock when allocating and freeing the cache") Signed-off-by: Marek Szyprowski --- drivers/base/regmap/regcache-flat.c | 2 +- drivers/base/regmap/regcache-maple.c | 2 +- drivers/base/regmap/regcache-rbtree.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c index 9b17c77dec9d..f36d3618b67c 100644 --- a/drivers/base/regmap/regcache-flat.c +++ b/drivers/base/regmap/regcache-flat.c @@ -27,7 +27,7 @@ static int regcache_flat_init(struct regmap *map) return -EINVAL; map->cache = kcalloc(regcache_flat_get_index(map, map->max_register) - + 1, sizeof(unsigned int), GFP_KERNEL); + + 1, sizeof(unsigned int), map->alloc_flags); if (!map->cache) return -ENOMEM; diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c index 2dea9d259c49..8d27d3653ea3 100644 --- a/drivers/base/regmap/regcache-maple.c +++ b/drivers/base/regmap/regcache-maple.c @@ -348,7 +348,7 @@ static int regcache_maple_init(struct regmap *map) int ret; int range_start; - mt = kmalloc(sizeof(*mt), GFP_KERNEL); + mt = kmalloc(sizeof(*mt), map->alloc_flags); if (!mt) return -ENOMEM; map->cache = mt; diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c index 3db88bbcae0f..188438186589 100644 --- a/drivers/base/regmap/regcache-rbtree.c +++ b/drivers/base/regmap/regcache-rbtree.c @@ -187,7 +187,7 @@ static int regcache_rbtree_init(struct regmap *map) int i; int ret; - map->cache = kmalloc(sizeof *rbtree_ctx, GFP_KERNEL); + map->cache = kmalloc(sizeof *rbtree_ctx, map->alloc_flags); if (!map->cache) return -ENOMEM;