From patchwork Thu Aug 22 19:13:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13774107 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 6B15BC52D7C for ; Thu, 22 Aug 2024 19:15:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B68086B0291; Thu, 22 Aug 2024 15:15:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AEF5C6B0296; Thu, 22 Aug 2024 15:15:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96A876B0293; Thu, 22 Aug 2024 15:15:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6FBC780049 for ; Thu, 22 Aug 2024 15:15:49 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D8B2616193E for ; Thu, 22 Aug 2024 19:15:48 +0000 (UTC) X-FDA: 82480835976.18.F87CF53 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id A7E2640021 for ; Thu, 22 Aug 2024 19:15:45 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kPW2vXZ6; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724354055; 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:in-reply-to:references:references:dkim-signature; bh=cGETG2RaQVscMgcFw3YXYL/FYRARYQdM9V5nkXie6Ec=; b=DfPDkSMH2EXv9xC3E2MRsnPnb2KkLuNgU4vcJKqCTdwipPAjVNcNBFEqRG5PcDf1e6LV0b cc8D3YdvIoZcW+cyjcNNQFzQ5J68gigO+dEVDhMgWg6jw+eS0z3sb1AYHOAoBaAovwzuFu 6Ycgz1Gr/5d0/LShDYmkgdMmRUQnPIQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724354055; a=rsa-sha256; cv=none; b=Hpg/3rRWK6r34v4oXQWT+jiuQNrT3OtsOD3cswa+SuGSeXvAvBIwYJfodk/vgxDAciAxjF XN+q0Kdduay7eYc9g/2Us05LUHwLtHPC94l7/WYx4i+McSxNWH1xgnnJNvLGwf0WlWcKc0 mvEaVHx3JRVr3Rrne4WPWQ1s/yBLFWc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kPW2vXZ6; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5A5E2CE1044; Thu, 22 Aug 2024 19:15:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A8F0C4AF0B; Thu, 22 Aug 2024 19:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724354141; bh=Gqu8IKz5ZDmSH1qLlC/PQjAsOLa/MoeoFtoKJgAk1OU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kPW2vXZ6T4WX6SqcSVvQ87sShPfOSoI3xRmeRX74DLMs9qD3/ERN716bUlNvLJbLr keuF0jio2tPcQXDawasMd4lbqUVeiojs2KnNGabvua3cBVUH89haltHTNbBamjRnms rx6sCuG0bGgV2774klnzMYZ1H6LhEgI1RBvRxVUzR15XOmAn0/vnPRXabJCcyvWqwz gPl1bix1AkeNi8qPG/yQIZxnw1rkRSPprIaXrklH8n+rLYbrSKWh0u00P1N4xtzZlN symNkSXDWJ0bWyVo5H1AxcxrTKW7fInileEOZ9eVq8l8ZHlpyoD4fHirU08zLT6s2L SCKB7rYyHT4Vg== From: Mark Brown Date: Thu, 22 Aug 2024 20:13:35 +0100 Subject: [PATCH 1/5] maple_tree: Allow external locks to be configured with their map MIME-Version: 1.0 Message-Id: <20240822-b4-regmap-maple-nolock-v1-1-d5e6dbae3396@kernel.org> References: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> In-Reply-To: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> To: "Liam R. Howlett" Cc: Cristian Ciocaltea , maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1230; i=broonie@kernel.org; h=from:subject:message-id; bh=Gqu8IKz5ZDmSH1qLlC/PQjAsOLa/MoeoFtoKJgAk1OU=; b=owGbwMvMwMWocq27KDak/QLjabUkhrTjfWFP1/QxPVx18BDrR8NLM3vXH4uPO2je4NJyyy9G1 9nlG7tEJ6MRCwMjF4OsmCLL2mcZq9LDJbbOfzT/FcwgViaQKQxcnAIwkXvK7J/ZbVd+TOs9tNrn NYuW9dq1MxNdTXtOagm7KpxbXsdbK3ju2pKreZsUWSVjitr/hWlPsQ+2XPS5iSuz3uBasud3c9l 1D60lzV9/2mWzTETFxnnR1lU1Yt+s0iNjuPdE8G04WqI+4ZhmxW62HzLrZe/7RV2yYqy4V/Cg/K W9/88TGvy9mkd+qQvwRu7pKC1k6rtTva0iPdV7w1mHn5NOyk6NTlbpnRbgIX7FN1hQgo+TU+aqy calQrVf2ebdWyqr0nBrYQQXT8MWj2kG7ofXWXwpkOw4xec/R3PXPLZAhS38bDKBhQVPf9Qmsp7l 01WYIO46PU9jp9rZ4lIWjxfOHQs6KhhV9VTuCMw6dRgA X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A7E2640021 X-Stat-Signature: 5m7iueugb957196bcc6phkk3ox4p5p49 X-Rspam-User: X-HE-Tag: 1724354145-183086 X-HE-Meta: U2FsdGVkX1+4F3YXjK4YRQsAeZg+GfK4ZgS7Nl9wp7BbCJ0+VPYFDyhcNprbi/m1tRxo0BTNiJhWbaDNxgikWKIG2Ol29dD/YiH5CTmnHockXEndqTjy9/TNFOqqQaQUopgcLsWgvKY1eNrvciYRZ+hY2gwTX5GItbAT5HwwsrRWEXgWGY83scJmI9wLGhSM3i+CiU+WG5Oq/ajFoGNvreB80iforiEyioBa/APBme81/h25MWwdZ2fG7p21D7FRlHrzKRa3k47t1L8MKrdnrZolgjEwCfDnCuQgyzOpM0om8bGWHM5EIQG5k9Fw9yprM0ffMa4r+KUdCBxrTPLxv99ZNpDLfVikeExyNfsPotQjvFXlfdf0m7OnRpBM6ut9mqpcCjPCXTrwOi6X6S4Pb+JIzQT3K1/wTHiuDRQc9kwUl4qoGaBCcGC/gutvdtVzV1u5VXcNOGOOs42AcsuqRyMKH7g8LRmpQRhs8fXjsgf5Qb7yMuslUA69yzQMTFsHsEGTM1LOJM2IGg5WaEid/EGjo5wDFsFYEPJSDCROY6QwMOxIECwHTtBOISFrbTYHRjyDmtETzYJ8eHtARN7d5t/BSp01+M4QnNjUf/4VaxkrdZVzjidXc1nI0NG6kE0hDNJcoVicaBi2w30auSAwktKuhnLOqs7A0KYakmAEDWYqRU8ytL/141TICPfMrIm8toB5KpqL5lYa7VQx9RSg4NH9X6eaexWkqUCujYlqXK/uomOP5XEapHkZ9dHqwvKXmZyY/sIJIkYyesQ/XQPPlchi0vQorBCw99KTA1xQoAVMyKe16MemGHvowGSx9eB5mgZSOb/xMwI6qWY0BaD5D5L95TW7lMKJyDDMh435AwfMKQWclJs45DRR8ox5lSQNtajtJvQTWXX+KYX+q4xukkb0LVM45O271vJn4Gkdl4m1YyxvhXzWQOx2AfGdG8rmc3NcE5w5nBfqZ8AZb+u ObFHhq5V ynv+kN44TUleQT2UPdEppyMQMzf+hmV8tFDP5nz3EkxO4C+K1TEqkL/FJ8Rh6MO4ErMQPvHbSKJvhPHi5eaaWLjzsUWnU5TBXoN4wvGcvmZyZW1Vux8QhCV4ulTaWnHsWpjxQxxmy+zonb3c0tPi+SyHK0ggKg7WadP0iEHig7tA4xUhFM/C9i3SyycUo+sYioA3yPn7+OZqi3D5cl55d91/wTsIPfgum+3YdeHVo1164RCtQtMwa3B2FAUqmJmwqu6Y1IF229MABl7Mf9qXiwE0H3IB+S0T3cIA/ZQLy6/QfNeY= 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: Currently the maple tree code allows external locks to be configured by passing the lock itself. This is generally helpful and convenient but is not ideal for situations like the regmap maple tree cache where we support configurable locking at the regmap level and don't have the lock type when we are configuring the maple tree. Add a helper that allows us to pass the dep map directly to help with these situations. Since such code is already peering at the lockdep internals enough to be looking at the map no stub is provided. Signed-off-by: Mark Brown --- include/linux/maple_tree.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index a53ad4dabd7e..bdc6b133abdc 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -193,6 +193,9 @@ typedef struct lockdep_map *lockdep_map_p; #define mt_set_external_lock(mt, lock) \ (mt)->ma_external_lock = &(lock)->dep_map +#define mt_set_external_lock_dep_map(mt, dep_map) \ + (mt)->ma_external_lock = dep_map + #define mt_on_stack(mt) (mt).ma_external_lock = NULL #else typedef struct { /* nothing */ } lockdep_map_p; From patchwork Thu Aug 22 19:13:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13776844 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 C095BC5320E for ; Sun, 25 Aug 2024 17:21:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 059C08D0006; Sun, 25 Aug 2024 13:21:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F270C8D0002; Sun, 25 Aug 2024 13:21:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEF648D0006; Sun, 25 Aug 2024 13:21:50 -0400 (EDT) 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 C0DE58D0002 for ; Sun, 25 Aug 2024 13:21:50 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 39F5AC073A for ; Sun, 25 Aug 2024 17:21:50 +0000 (UTC) X-FDA: 82491435180.10.2AD922B Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf13.hostedemail.com (Postfix) with ESMTP id 72AED2000D for ; Sun, 25 Aug 2024 17:21:48 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=a8HEkCZK; spf=pass (imf13.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724606423; 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:in-reply-to:references:references:dkim-signature; bh=orGDuveXyQKqNHpXrAjI40khDlMlKDPWgf1ImloLjs8=; b=nNKmzDpXP32aqFpdGafIDRnRJiLuoISFFI3nfwB6ChwXt+D372WE6G7nwSJ/7AMw4I8CW9 vsIhdRtIhh+GwxQaTVyivhM5+kgRfSR0wUueuIdUF7hjY3fnsFPO2Ge7GCRVBHfp98dHVv EdKXcnIo1CJGj/8woLso3e6m1HRpoHY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724606423; a=rsa-sha256; cv=none; b=BYGbVZTX1FMeyycy7jmnRDr3zxr7xNNrlwKueJxuXZ/NR+shaZSwiS3Gk2hpwl+HJiJ2lr nr/+Yl+l4wxkoDaE/mI7fNY1fe8q1o3s9nIuxLJxxBZV4Hb3LBM/tBc1yLMuJP1rymcif5 BrndnWVaqsCesBv9S8VVSHG27W4++tA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=a8HEkCZK; spf=pass (imf13.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id E901DA41399; Thu, 22 Aug 2024 19:15:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04B2AC4AF12; Thu, 22 Aug 2024 19:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724354143; bh=HqTvO4EXWR9m8S4knK2OhOF8g7vD7aNMIK2A6uNJAO8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=a8HEkCZKnKXnymobpVWtAm4avgezgATDH2uSDC/fqFclh/7AwmwSQiwL/dEuW3oY8 3UtIQ2KUfb7EjB8W/WuyZ1z23awOIEarRePcINmkUSjh0DMtbnxMFpy1mBeAYinWpp 8/NJeni7ZoxLfzbDVs9Dozm4WPgmsIsbhg1DsHRzea6PL3uTgtlsqTYPB/xZskTWOL OOdF7roGhhi2Mf+kQfp0I/ulmuL/rltSGxMaESwTnZYxzPTwohXwqkhi+vpzX0Da3a Hyw9GRXbwqrPQhY8FKARJjylxxTCVWjjzEfyl248uxNq7XROy2463GDs/ORWoPmys2 cHIOQH+EYdfYg== From: Mark Brown Date: Thu, 22 Aug 2024 20:13:36 +0100 Subject: [PATCH 2/5] regmap: Hold the regmap lock when allocating and freeing the cache MIME-Version: 1.0 Message-Id: <20240822-b4-regmap-maple-nolock-v1-2-d5e6dbae3396@kernel.org> References: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> In-Reply-To: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> To: "Liam R. Howlett" Cc: Cristian Ciocaltea , maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1507; i=broonie@kernel.org; h=from:subject:message-id; bh=HqTvO4EXWR9m8S4knK2OhOF8g7vD7aNMIK2A6uNJAO8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmx45W7hwqN8635GlhniM9IzBeNxeV+mEbT9v4O hPc/8CuTsWJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZseOVgAKCRAk1otyXVSH 0EOTB/wNrSyae31JmMwCaXdCreGvDhp2iBzo39oKF/d+fEx6wa5Bi1u3nZhgDhj/tZfP+nEjirv WEJdY7o4yBWI4lu9+lSSF9w8sAfo7cmjmQJFGJYnqhBVBQOLtd57WU+unlf60Aj17RxD5VoO6U4 OvF75iSafkKRm5ADTxMPZMdjtKdtNeIwmxZiC9LvhLl4Bx+taoiodUVyIY0GGOtF7uT4joZQKdo QYdy1bY44VKxvI13LI1MFNh6Z7iMxvD1ATfbRmA/dpjcCRDyb/qicbzJ+pO3moKGSIXhENto0cF 4Mbmi9s3Sk1Kq85eRfgJLbtHlMEVPAIS9QjMOAybBqufyqJM X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 72AED2000D X-Stat-Signature: q6td8qxnqs4qzpjb9tf9ieapqiocfuy3 X-HE-Tag: 1724606508-159914 X-HE-Meta: U2FsdGVkX1/6ubcOqh7y6Yovkc3C447GrWhnahpAsX9LTS1xlew9ISuNweyKZE5TDvojOiUu4oEb9dptyClPwtEWGKG6jmCAEo1hzesbP2okHjLw6pcdQVXfauqIQjY1JabqAUIzZh4CJbOjKzHb010SudCuMiVgNxuvY4Awr71c5zyr5zg2ZIBCWdsqHj2itzLl9vHlypw1voVcY96bvaYqH6+Yk1WAIVDg0/z9NA0Nof2nQOmYR+JVMbmqnnF+SMxC7d2al1Nuicph4WtevDUvcxVZulq3kK064AM8S6B2YnbEBDqGgA8DTA8od+0tyl1yvxisqdvyQjYtVso/AK01uavJr/P3WShIEpUShuK4XQiOWthsXJqVkuNUY+q2WAsn2Xnfa71d0FqEZDgYTC7fPMbwH1lWWlrHD/JPjVrvtbZgE/iKkNSSTqoy6Ns6DLi9Oy5lvTVVGftzdQHAjeD9U95AoZT6F5kC6zSzxYMPuHPCzbrAXXtsBrbL4WSpt+YXkxzPiQFF5+MHdj+F7nDDrBKV7DYCGZ5jqjRzL5xCB385y1rr+UVyPlMdbh8XcxhTW91GzPRsD5IWTB6Loqm83BIc8O+69Wp2wWXZpWYnoNueGBt/yW62/3C6QsPOCRBAMWdatcUv77f3MkZG6fyOJnqLEF2Fcp0SXbQmkOV/fmepIga75lWTNtVPWlOnMCGyKNvHZEEwh29pY3AmEjehBnM0vYurK2AfHkejdYc9SXTZNNpvzrI1XBkN5vSaadoYpNeS0jM95MmdIB427fOtB9ScHw4nIv9ibYAVBzWiXev3iJYqX3Woncgs3sUalei1vsD+jv+of4FRwt2kMyY0X43v2bXlWw+KsYZNwlUYfkA9tupcTzps5OqHitfGRrXpwzRZSna6iWwn9ZN+gN5JFKkyG3dxMjSRgDvBWxm8lgU0TJJmTJFlFoimP/Mt4MUY8fRr3EGILSocKvY Ens1wpG1 uQwZYNQ/sF0XdbPXstPSoXgjbVHSiQL1YuI5uEhwpLz/p125m14DNylDaiiqt8BanvJqAuEURHB6fl+05sAWPqwFH/kNLnwnnAJeV/Kukauy0Qol0UQbCjA/RrOX6i32MQ6SMeV/5+BqRXg1ah9evkHtn1+dWYAwiVueo7C6WPmhJfgw7fGL+AEjbXMA1vZK7hJNG2HHof3e1EBkIwoKxyP/BQ7MVKEhdSC/IF3mJb33vbfGqiEpx7O7N9BSLKhc23XMKmQnnSIPNBHD4AbsOuKRHF8sTgNobKRDL 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: For the benefit of the maple tree's lockdep checking hold the lock while creating and exiting the cache. Signed-off-by: Mark Brown --- drivers/base/regmap/regcache.c | 4 ++++ drivers/base/regmap/regmap.c | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 7ec1ec605335..d3659ba3cc11 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -195,7 +195,9 @@ int regcache_init(struct regmap *map, const struct regmap_config *config) if (map->cache_ops->init) { dev_dbg(map->dev, "Initializing %s cache\n", map->cache_ops->name); + map->lock(map->lock_arg); ret = map->cache_ops->init(map); + map->unlock(map->lock_arg); if (ret) goto err_free; } @@ -223,7 +225,9 @@ void regcache_exit(struct regmap *map) if (map->cache_ops->exit) { dev_dbg(map->dev, "Destroying %s cache\n", map->cache_ops->name); + map->lock(map->lock_arg); map->cache_ops->exit(map); + map->unlock(map->lock_arg); } } diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index bfc6bc1eb3a4..9ed842d17642 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1445,6 +1445,7 @@ void regmap_exit(struct regmap *map) struct regmap_async *async; regcache_exit(map); + regmap_debugfs_exit(map); regmap_range_exit(map); if (map->bus && map->bus->free_context) From patchwork Thu Aug 22 19:13:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13776869 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 0F1FBC5321E for ; Sun, 25 Aug 2024 18:31:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 873088D002B; Sun, 25 Aug 2024 14:31:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54FC38D0029; Sun, 25 Aug 2024 14:31:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 179A68D002A; Sun, 25 Aug 2024 14:31:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 903118D002B for ; Sun, 25 Aug 2024 14:31:49 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 38E2D1207F7 for ; Sun, 25 Aug 2024 18:31:49 +0000 (UTC) X-FDA: 82491611538.16.8B9D9A8 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf29.hostedemail.com (Postfix) with ESMTP id 7B786120013 for ; Sun, 25 Aug 2024 18:31:47 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FrGKfggg; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724610638; a=rsa-sha256; cv=none; b=BGffpTDchqibpiC36P2TfODBbTWxXI2dML/+LCejyWO51a9VkR74ipI6d6JdNbzRRFrD0X ycggO/J1tlekgAiUrCLZDGB4DWDyc4M/7iMZ3pOsDMldcBufQf1gf6bzCONV4pmGjq5JcL cCbZF/skiO7UsZfm9k/9RkRJX0n7Eb8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FrGKfggg; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724610638; 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:in-reply-to:references:references:dkim-signature; bh=brLKthUFIpP0KWCCLeFdVVost5s8cP7DqtPefpuxJMM=; b=E1FIiud/z+KBUpBF11rHxLoHNurECPfORp+GAT/UFvGbsJ846NHhxKHYUiPfueJ/ihKlTg qxwcdkCaWS6IRqnPS+B60MfYA3N2YjhKX6EjRAD3Ovky8LDeqdZg504zBuxX0wBwmnEf59 o/brJg/dpZ7mvs0RbFVu6vU6GKU52w4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 0335AA4139C; Thu, 22 Aug 2024 19:15:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1D39C4AF15; Thu, 22 Aug 2024 19:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724354145; bh=nMY1SpzGoP8oeW0CCyhb2py/IKmlVcolBjcNTRB94bo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FrGKfggg0RqKGEADj8upTbVV2vULhc0wuFAIt/NeFlYJCquWifB9+wRiU9uN/Or/e H8suP8YWjg/dQ8M3h82wzChv8r8hdh19M74U6a0k0kRGcR7uxf+ypA16/X+h7v9u8n maqMtaP/o014NIs2SJDABM97eTFoK9RpMD/OBME4cZ95KF26ktf8fMXLgaplVMchVb gYS+EYtPdGyr1Aj/sFeFKmW8qFGVmArgBP6Pi1Af0jJdyUJ2f/40dPlDo0i7GcMKag MrBxCTPRahoFCRbHSOKXDH/LlqZp90Gk6fqi9dSzEp7+vh5PUqnhzer+/YHkiXys9I K3mldEPj0y3gQ== From: Mark Brown Date: Thu, 22 Aug 2024 20:13:37 +0100 Subject: [PATCH 3/5] regmap: Use locking during kunit tests MIME-Version: 1.0 Message-Id: <20240822-b4-regmap-maple-nolock-v1-3-d5e6dbae3396@kernel.org> References: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> In-Reply-To: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> To: "Liam R. Howlett" Cc: Cristian Ciocaltea , maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=809; i=broonie@kernel.org; h=from:subject:message-id; bh=nMY1SpzGoP8oeW0CCyhb2py/IKmlVcolBjcNTRB94bo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmx45Xnb0AO+klDAfjuZTanNIr2Sl1IK78oEHoi RHupP7GFl6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZseOVwAKCRAk1otyXVSH 0IlNB/4sujDfssqMAFFVfGMlBY+P/eYdMxzxMqDsvPLXwk3B833qyVPbfKLsdHOCTifxPs29bGU QJOKU4qA5e37G6FnS9t0lTuMjknafH4bdES+sj/FehZQyO7M728TP+F4M9Ata9jS/4RAseCJpSL KZzbTcbYrnSQ/6DVo8c0HoKOeQDMkK/HQajxOBKjMlBsJ0zTDbtG6GGXsKacR04pIrwMQ8f0566 nKG5TQK6lg7jATjGGcxrpcnjvxvaIBXEewIjWFpO92q2mkQODWLzXzFGRUyuZxflsWNSIYntiXs m/br6Oh07fOuV7sDTJx2hiAL/srD4GQfZIXl6MUFj5dhB/t3 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7B786120013 X-Stat-Signature: q6wo1nbix4ieqz666k3kdjqiqa9baphz X-Rspam-User: X-HE-Tag: 1724610707-491322 X-HE-Meta: U2FsdGVkX19o+PeF7mYpu6jKyQRbdKlrC2nGqDvaBpB08KH73+IqmSQqM8AGzlsUJDl1r9uKTsqXn7+if31ed/6BhzyxB4FcASH4t+lgPTg9sRS/J1gc9HeeSTGY8jMTJq2iIJUK7N57q/GVO/yMFBDZ38ZKtrw/ug8sxKUpiuX0Pb2ol6vfPo0T0QvfJ5vykH2BsyXZGZdy1UeasFaI2tKyon+kMgE873gp6jbG4a5hJWygUL8RmQPmu4b/xE5hMLC6U3IcPFNUaRx/yvOrWFO1xMnaWrt4abpqWF/OEXTq+yvEpUP5Xrj8Wm2UBpABwO7C+PfgW0/bPHr31Eo1N/D7Rhav3ie8x5ROPcl0vIECJqFpGeFmUB3p5kjX+Ga5mnhJZNAc4geVFvsb6dtbCENEjsi0tSS1yOrJtAG2ZiRsC0G3yE5byp1J5lx+T2szs/UxRAEvG3YXZv5DtK2ai06KbNjXLY7raBz/b2nBiyqTF7uz/QQsJ5tOadM84deEZIcZkidFT7qq5wgILuITP/sGygTcOU/vElg2vsYaB70cDMxEqLP5Ls42wDITtgObCRuF5McHdfTgE5atc00CA4FRRVNMzQqgNekNkG+eqn+lxN9xH1U9k3TDeovXXmkOR5C2Kug66YzKS7kNounwo8bsI0l/f9njPFeYZLvItXMqj4tE5ho0pLryeW4J4rLrGxjod8x3Aq8V+4ye3ekE70Ge4nux88cG7puD0MFiClHelQAVtASBmGh89xHvwGIzcJsVTFlZ/CBTFIcLFHfEQSQzw3agEgTNEdRpbe3rOPDZMV4nKsYigU6kCT0CCx4UWWkbSyX6wJgxa1ej74ygc8+bp8u8UdrqYUU6PkqWC8im0yUROqa4W/21gM9yhZoiuPHiESxEX6hNV7wq9TJ6EOmz+vy55NGNQQO9VIjGzvm+sulDJBqitHKzg+GyVHG1tNstdp3mygD7KVresIT ZytzxuPw nTVfmQzZsDfPw92Sx5qcDroa+ycH4jgEAEzoEq2bZg4/SS0FNP8Cpj99XSQbYfXeyc23s2pOb83/KHdH4edjn5sXuVdbZoriaocIRskPgU41HlzVFaQDwyUuiVexb19WetkG2xGPh7aHsx8S/fblviVSg7s25J/QW5aVjOqHnSeGbLoUdTwdva26Z195C5azTgrkKYTs7qMfPf/En9W6CiNUdHgOhN9Y3eNhQJcdrX9lVNoptYkhFYBvTHF3kWLu3Rx9w1DVkLe4NzyV6Y/t5VfGTrieNApBAzfyZ 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: There is no reason to bypass the locking when running the kunit tests, leave it enabled as standard. Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-kunit.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c index d790c7df5cac..b80b447c87a2 100644 --- a/drivers/base/regmap/regmap-kunit.c +++ b/drivers/base/regmap/regmap-kunit.c @@ -151,8 +151,6 @@ static struct regmap *gen_regmap(struct kunit *test, struct reg_default *defaults; config->cache_type = param->cache; - config->disable_locking = config->cache_type == REGCACHE_RBTREE || - config->cache_type == REGCACHE_MAPLE; if (config->max_register == 0) { config->max_register = param->from_reg; From patchwork Thu Aug 22 19:13:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13774108 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 575E0C3DA4A for ; Thu, 22 Aug 2024 19:15:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D15136B029D; Thu, 22 Aug 2024 15:15:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C75A76B029E; Thu, 22 Aug 2024 15:15:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF05F6B029F; Thu, 22 Aug 2024 15:15:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 87C456B029D for ; Thu, 22 Aug 2024 15:15:53 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 35AA6121468 for ; Thu, 22 Aug 2024 19:15:53 +0000 (UTC) X-FDA: 82480836186.12.0A58C5A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id B71DCA0037 for ; Thu, 22 Aug 2024 19:15:50 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eQ4qPlhC; spf=pass (imf15.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724354110; a=rsa-sha256; cv=none; b=H/fO0L/4dXxbhoW9J8pj4ln0TAw1WOys0QlB5HlaILtdCgn12WVHxg24uHEZkqeyNtwVLw e5IjVkUHTroNAUpu2l7xUcG17IQc4b8aCDXTrRMv8qRhgYcov43JDxXhI7xPEgO2ji+E0X ZfltjhDaZwI+vIcSPXv9SosRgOMWA7I= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eQ4qPlhC; spf=pass (imf15.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724354110; 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:in-reply-to:references:references:dkim-signature; bh=sxy/y6Rwq+r4k6Toyu+9jWODJ9zeQW7BlpEjw7HxNDQ=; b=E8Lg5Lb/dyg5LrWl0Oao4+UmxTzp+CZpyxerQNh5+gw/8DnlIj8pwG2DoYJN1dpGQd669C s1wagIv7NllzkgGu21vPnU013B19NqhPzadny7IxCjetKozaANhBfWZVTNWiVElCX4Ylpz /GzuMQ0LsJ+mSDzJ9/+etcW7hY+bqQA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B4703CE105F; Thu, 22 Aug 2024 19:15:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 023A0C4AF0C; Thu, 22 Aug 2024 19:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724354147; bh=OBqVs0rQ1CiMM5qFzO+/1VLNqF3w4XsS2CGy4hdAxGo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eQ4qPlhCEF5YOCmpS0UQxZkWeNJnWOrGyMTUxRDoGMV1K/l8JrhpiL6AifpkVLFxS zbAmo4PxMIeb2WCG60SI2idnnmpWISI8RVAnAS473bn258XmFMpcCxpM/abZAhM9xI RBPWYvWEyc1U/dqLTram27k6u6sGyVCZlHqdh3oVmmAk4ykUCT2IOTicjVZWvC6Xz6 3HiBR1FfmhbN6l/M+yOxjKBk3fbyOLaFg4B5svWlWkxjrBnLMbZSrSFL4NFp29Yqgp tgO2RxxGsOhCxACfahu28n2ttUOOYI+lKrPEk0r0Rj9XoizMPmmQUT7Mrn+qzeBHHo xwMQOijbW3JGw== From: Mark Brown Date: Thu, 22 Aug 2024 20:13:38 +0100 Subject: [PATCH 4/5] regmap: Wrap maple tree locking MIME-Version: 1.0 Message-Id: <20240822-b4-regmap-maple-nolock-v1-4-d5e6dbae3396@kernel.org> References: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> In-Reply-To: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> To: "Liam R. Howlett" Cc: Cristian Ciocaltea , maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=3250; i=broonie@kernel.org; h=from:subject:message-id; bh=OBqVs0rQ1CiMM5qFzO+/1VLNqF3w4XsS2CGy4hdAxGo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmx45Yne4Rw9lYzvkFQau2dor1n8Sxe2Cwjon6K vB1crJHzDmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZseOWAAKCRAk1otyXVSH 0FcvB/4iyrhgWnvNVoQrKpcsLNdus42nmx8ZEdApoeflQqenqNixTVrspLKArPh6dm2ctgbXD5H sfEYxli/gChtp9Lyt9ruD+Gxlqd9pM3b3UhLz/xDCHjL15rOI3+WRBt/IdBm3n/a/mHC/2Zx5Kl wEiC7L5gZ9/qoHwYCnYpY+csxYn8hqOcUTdMdQeNLsC9OXfugWH40RTCy1L45wtDBx2kzOXVoLp s6o5oDhR5CF/utYgzqwlI/P0JD/7D/FQDFbxxCeUitdy/qA0IrHHJXpUwBX/DnBedPB73k25yYr lGAf0F+jW5wpaKlKp06AfsSyRqT38pQHFZPR01nPyEwLgWK2 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Stat-Signature: ok965sqcti86h9w5xu4g96wjmup8ik9p X-Rspamd-Queue-Id: B71DCA0037 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724354150-640520 X-HE-Meta: U2FsdGVkX18HkuTPMA/0y/fzQX6pgg0Xnbh0b1ynMjW0R01+5ijIsgOz92+CcHr2EgjjXggOBjX5s4u+4rG9ZFxwNegMTzDaUcGHZHZcf4IGTT7klwAanHAoZ/siBO3NqWIFqryfySHUnpAzwU+L3QFNWtRHmm3IgRHpr15B6kKrBPzQrKcxXih9ekx+ebLIV04l9eexW366CQiLX37Lh2fKEC6KBNRddXs8ia2fGa82BtpCzyFEdyKe5H5T86IGi5WSJSLBBTy4v22qJ73vBTsh1g/NTqusQgMzYD68yVMLVSHcD6yo2echiTANVU+Mb4+6+reTpYpdjOGWOU3kqsCiq68shrW29wBLwzAMzYKm/qiJ+4tVTExc27kr6TohSUxuZHgFAr4tiRyOppdy7g9dXee+WdakVYQ5btmuzlzGDYGRCoGs25XfJPUl3SmggcDFGGq1eX9WtWJhsw0JApe5rphPc8euyrKIYBORkBqEIxRqQm3YrG7WcOL2Jmai5nDwuUP0AJY+JSN3/raDXTcvz1A/tOyu9/N1BQKmlY7S9LUcDZT0AcvwmQTjagXSfxbaZ8xeXhlD0b9GgidZgnp0OGPtRJYHrTuO3AIc5f7TyzmYVyCEQi87/0Yu99eq4k40kfxPCLA+zQmPaStJu6NryWlgSEaDh6Qvrf3Sk17RWfkke2zVVXtR9qqTChu5ZdwKbZqOoVoWmGi9/v+PYCtfjeMKqUkoPgZJiIs3PiAzu8wzMdTdyNlY9kdvZY/+d3R8uhbd0VWYdTtVTmTzkDZtykBtbfC24D2elj3e+53eRJ3Vi4yDlurMimu3/uEDDiuvMqmXCeNnr80NZptIl+FVZ15W2Ypvve8nhLpE5FiPvRVnFduF6F9cHFciOty8Z5Hi8OD76sBRB/lbeCtMVl25tF9EZb1uNq39kCJXrESvZl/xUAPzAhLbjExfKQDLlcY+aQoLfr6Ja1mkr8n 7zGbHtsU SI4jeC2/nCQ+ARmhj0KNur6dGCU4JEFcW/E10nWN9nudbsDetdh7Rpw9vLPNCQB7jVqIs4jX6pHPw+rQ5TaM0dHUxO+e9SGe9fwYzfdERAkLcFmt9PjlOSrPLqMYLqwNKFlWO2khtq0S8w664TH1ABbe/8rN4y6NIHxaLAhio+LLkBCEF0XZot8baB+1lrxw+e3Ttp77/Aa0YKcyyBN8zxd9xitc+lkMM7VjrxZSEop5s0clgVSO+7l08lA== 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: In preparation for using the regmap lock when available with the maple tree lock wrap all the maple tree locking with some local functions and only do the maple tree locking if the maple tree has it's own lock. Signed-off-by: Mark Brown --- drivers/base/regmap/regcache-maple.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c index 2dea9d259c49..d2de3eba1646 100644 --- a/drivers/base/regmap/regcache-maple.c +++ b/drivers/base/regmap/regcache-maple.c @@ -13,6 +13,18 @@ #include "internal.h" +static inline void regmap_mas_lock(struct ma_state *mas) +{ + if (!mt_external_lock(mas->tree)) + mas_lock(mas); +} + +static inline void regmap_mas_unlock(struct ma_state *mas) +{ + if (!mt_external_lock(mas->tree)) + mas_unlock(mas); +} + static int regcache_maple_read(struct regmap *map, unsigned int reg, unsigned int *value) { @@ -89,12 +101,12 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg, * is redundant, but we need to take it due to lockdep asserts * in the maple tree code. */ - mas_lock(&mas); + regmap_mas_lock(&mas); mas_set_range(&mas, index, last); ret = mas_store_gfp(&mas, entry, map->alloc_flags); - mas_unlock(&mas); + regmap_mas_unlock(&mas); if (ret == 0) { kfree(lower); @@ -118,7 +130,7 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min, lower = NULL; upper = NULL; - mas_lock(&mas); + regmap_mas_lock(&mas); mas_for_each(&mas, entry, max) { /* @@ -126,7 +138,7 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min, * Maple lock is redundant, but we need to take it due * to lockdep asserts in the maple tree code. */ - mas_unlock(&mas); + regmap_mas_unlock(&mas); /* Do we need to save any of this entry? */ if (mas.index < min) { @@ -156,7 +168,7 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min, } kfree(entry); - mas_lock(&mas); + regmap_mas_lock(&mas); mas_erase(&mas); /* Insert new nodes with the saved data */ @@ -178,7 +190,7 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min, } out: - mas_unlock(&mas); + regmap_mas_unlock(&mas); out_unlocked: kfree(lower); kfree(upper); @@ -300,11 +312,11 @@ static int regcache_maple_exit(struct regmap *map) if (!mt) return 0; - mas_lock(&mas); + regmap_mas_lock(&mas); mas_for_each(&mas, entry, UINT_MAX) kfree(entry); __mt_destroy(mt); - mas_unlock(&mas); + regmap_mas_unlock(&mas); kfree(mt); map->cache = NULL; @@ -327,13 +339,13 @@ static int regcache_maple_insert_block(struct regmap *map, int first, for (i = 0; i < last - first + 1; i++) entry[i] = map->reg_defaults[first + i].def; - mas_lock(&mas); + regmap_mas_lock(&mas); mas_set_range(&mas, map->reg_defaults[first].reg, map->reg_defaults[last].reg); ret = mas_store_gfp(&mas, entry, map->alloc_flags); - mas_unlock(&mas); + regmap_mas_unlock(&mas); if (ret) kfree(entry); From patchwork Thu Aug 22 19:13:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13776868 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 B706AC5320E for ; Sun, 25 Aug 2024 18:31:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D51B8D002A; Sun, 25 Aug 2024 14:31:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 327F88D002D; Sun, 25 Aug 2024 14:31:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1004A8D0029; Sun, 25 Aug 2024 14:31:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 835358D002A for ; Sun, 25 Aug 2024 14:31:49 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 388B9A0850 for ; Sun, 25 Aug 2024 18:31:49 +0000 (UTC) X-FDA: 82491611538.15.B7EC620 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf27.hostedemail.com (Postfix) with ESMTP id 76C5D40008 for ; Sun, 25 Aug 2024 18:31:47 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U5b70VjH; spf=pass (imf27.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724610688; 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:in-reply-to:references:references:dkim-signature; bh=N6X1Khho36JaLXCuq0P+l/ItnC82nH13pAouozhEhbM=; b=7arDKi1VzML42bnbB1R9BI6UgvubJ9HIGu3J9K0vHZq9P1BLLewaPcXzFGl1thV5Fwz8s7 wEEkUTHNOBiEb1oDJB4lLCV4YjDi7XthBvMeC27tYsKobAfdyBgdRUX3NH8lcWKSbbNibR GZsJXgjfp0Ho/KsIQuXEWpVPjIF3Ed8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U5b70VjH; spf=pass (imf27.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724610688; a=rsa-sha256; cv=none; b=iJfeOV1+eKnoY+R90KIgtWCcIYlBotxmMFR6cfkcTjdkXKjEGMrmAr7etEMyRu9L+X0NSv RjKZoAu3Ic3cBilnsOZMKZk1+5tUWzrVf0GqJO3RAOIucjq0Xoa64fCKr7/re0m9WED9hf BL+tJdpj3WNfjrTV6TNZkA821Km0oUg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 2DF9EA413F5; Thu, 22 Aug 2024 19:15:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC970C4AF12; Thu, 22 Aug 2024 19:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724354149; bh=3IkVv+qB4U5hLvXfbSxIYJIDDH95Yvi/JvCEmYiEG0s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=U5b70VjHfQEHCBxGcuJkIaZuR3G/OzNuKadvdXSUyLMPsPPYw5KHYR5RNmZ4R81tr 5U8hq/bgBfqVHmd4RaNTTKLmhWpSIvhs+1HVg8J1r/gN6M/3bfDFx72BPrAIH+F2J8 4BkKW8CP6RYQfXgOngDOsBcq+HnW0dwSD18fvTwkJkAGiZGm1MZgZmVALySIF/io43 R2C3c+1d0mhm0rVhN/thZ5ybKAn9TgKp8m3R/iYdStDyD0ngzF01dzgsCyra/Gg9xY R+7frdyONZQ9KZxnVDe+vfQ++8bueNVc1Mcj44MPYyu6FQWlWFx2JgQyNRuaXtiYaN BWxE0XEfNPTjQ== From: Mark Brown Date: Thu, 22 Aug 2024 20:13:39 +0100 Subject: [PATCH 5/5] regmap: Don't double lock maple cache when using a regmap provided lock MIME-Version: 1.0 Message-Id: <20240822-b4-regmap-maple-nolock-v1-5-d5e6dbae3396@kernel.org> References: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> In-Reply-To: <20240822-b4-regmap-maple-nolock-v1-0-d5e6dbae3396@kernel.org> To: "Liam R. Howlett" Cc: Cristian Ciocaltea , maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=3508; i=broonie@kernel.org; h=from:subject:message-id; bh=3IkVv+qB4U5hLvXfbSxIYJIDDH95Yvi/JvCEmYiEG0s=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmx45Z28y0ReLetC9q+2YdjmiA9bBTW+merSGJe 7fXi8QJgY+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZseOWQAKCRAk1otyXVSH 0CHEB/4su90f4gO7Qt9qNpuaveRhDVSkPq+70sBLqnd/TbhsYX1jIHDW1A9Qfz5h+u8gLoJJflf jdGXYJ1a+pR5vDp3krO/QpawNW3lwaI6acc1SqbGzseANmX/sVpWjOb6l8plm/vFCdoJVjgVzP2 IHtmE7JEwMP5ldgQAu+610rCQRFeW3Oqr02p1fDApahKnw1hVNOrAWfFWrrmutoQuOYKGceqyo6 Y6dbwEs0nrrGzWyFNSB4C1q8z8eUd5DJw2Jgprqv6mKRiq1ASMR2SWEXlQEfXmTram5pkcbY/3y Me6usgkEUE3WhqMjVulp0qD/k/vxWmd4oAo+/jj9U9jckyf9 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Stat-Signature: ggwheq845mted6dj3m8nprkrm665uoxb X-Rspamd-Queue-Id: 76C5D40008 X-Rspamd-Server: rspam11 X-HE-Tag: 1724610707-607901 X-HE-Meta: U2FsdGVkX18IiMLokN7fZJnmsqZPs64kgxBgN39m6zxFnEeORykVc3RQTSq8Em5Kv+3816XOpkkqXWNp5FOi9JNETSywSIsPVu3EaqhCQU5u4Mxuo/ru7F55YnVRzGKXqICGNm8Hlho5ZdDdtMZxD0hcQ9IZtJ6weOvmGikTIXk+vXO75s82EdhPNhZ9AGrjH9wB1jQ+r9Mm3SRH+GKHDLa6ModcRRi/J1lydpagV/ErzDqCRw1mFI/urPOPfIU3KBiFXrewDedUcSqTJqvcV363SjiXZQszyO3XfkB+eAfThRS8v5OkGl66gYcrUOwsOhjlqCKWwe5vkruKjr1CUrQO8KpEpvffVg/lqGWSW/S/KdVsMkFIYDtoapMUXqfBS0DRZM3wdu42iqrv3zCbtpbL0eN8OXxQHyw7RpZIk5WhKM6s/Hzjj5+f1z2i7HVC79EbIFWebV70UEuE5VGduLNRE2xYt9IQvK4lg0RkDTwjoRI9n7D9axOJ6nf60O6UzUtwjvO4Psi12HgC14aAKc0V5LDjekMjp0Y7zqS3kjS+Zp/itHkAOi3S3qE/Xgdnl/Ex8eozztltqm4BWirWP/O8skRClm/1JBbZiIXQMECz4wY7/WFK2u6n3iwxIf8mbEhq0MsZTnDlfGjPS8c3gyllxERzIXHcH5govVfUZpUu49pmPM+PsrlLvgD5AFgKGk9+7tDbiF36yy5tS7uonc4fkR8GC2b1BPTvfVeLrrMesBIMlnaHYV63WhImdSyn7MFRxV3pAEIidSARKMtQ3aor3O3Fh2kF/kmXsEK/ebKa/J8t2oAicA6hN6JdcXJ+A8vdDRfuqQv4o+5GE/Xwik1OVz+QR03g8Jao+8z1L4CbKzt9J1f7/+gDK7yUj87eQw6k9L3wPYfuYShW0zyFngCxAz+pnPvpgJWFDq0nFmvDqA8HfHtQwIrh0CWnWkwNrZntRnKNZz/HKJOHzZg 5961fLAo PAywTES0E14ZlIM0AT6nik3gUqd2D2FmAHmkzTGZqzF/6mGUPO11RxVtdAd1BJPqPZRWDQVdcAMZ1TAUkNou3cP7PuN4Edu7PK15kHOSYXjMeQpws+SXlnh/pOxdF2jLc2RvzPeTwE7NZt+OawblLBlRFKTyXLI/vBKQu+J4AQX7JCHNN7gDLi9ustF1dYoK9A3t4s6QbJo2eUYTRaQqVrUc0DJZamSk9bV5AMAFqG+TkcP68SR+XZWOqOmKOkwd3tw4Hk4qQ0r4uBKG1rC86AKE8Qex+cKL9MY/I 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: It is not possible to use the maple tree without holding a lock of some kind, by default the maple tree incorporates a lock but it does have support for registering an external lock which will be asserted against instead. At present regmap uses the maple tree's internal lock which is unfortunate since there is also regmap level locking above the cache which protects the cache data structure and things like read/modify/write operations. Let's reduce the overhead here by telling the maple tree about the regmap level lock for cases where regmap does it's own locking. We also support external and custom locking for regmap, neither of which will benefit from this, but this will cover the vast majority of users. Signed-off-by: Mark Brown --- drivers/base/regmap/internal.h | 12 ++++++++++++ drivers/base/regmap/regcache-maple.c | 9 +++++++++ drivers/base/regmap/regmap.c | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 83acccdc1008..a5fe052a70ce 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@ -59,6 +59,9 @@ struct regmap { unsigned long raw_spinlock_flags; }; }; +#ifdef CONFIG_LOCKDEP + struct lockdep_map *lockdep; +#endif regmap_lock lock; regmap_unlock unlock; void *lock_arg; /* This is passed to lock/unlock functions */ @@ -344,4 +347,13 @@ struct regmap *__regmap_init_raw_ram(struct device *dev, #define regmap_init_raw_ram(dev, config, data) \ __regmap_lockdep_wrapper(__regmap_init_raw_ram, #dev, dev, config, data) +#ifdef CONFIG_LOCKDEP +static inline void regmap_set_lockdep(struct regmap *m, struct lockdep_map *l) +{ + m->lockdep = l; +} +#else +#define regmap_set_lockdep(m, l) +#endif + #endif diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c index d2de3eba1646..1247ff3ae397 100644 --- a/drivers/base/regmap/regcache-maple.c +++ b/drivers/base/regmap/regcache-maple.c @@ -365,7 +365,16 @@ static int regcache_maple_init(struct regmap *map) return -ENOMEM; map->cache = mt; +#ifdef CONFIG_LOCKDEP + if (map->lockdep) { + mt_init_flags(mt, MT_FLAGS_LOCK_EXTERN); + mt_set_external_lock_dep_map(mt, map->lockdep); + } else { + mt_init(mt); + } +#else mt_init(mt); +#endif if (!map->num_reg_defaults) return 0; diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 9ed842d17642..f66b5ef56cf8 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -729,12 +729,15 @@ struct regmap *__regmap_init(struct device *dev, map->unlock = regmap_unlock_raw_spinlock; lockdep_set_class_and_name(&map->raw_spinlock, lock_key, lock_name); + regmap_set_lockdep(map, + &map->raw_spinlock.dep_map); } else { spin_lock_init(&map->spinlock); map->lock = regmap_lock_spinlock; map->unlock = regmap_unlock_spinlock; lockdep_set_class_and_name(&map->spinlock, lock_key, lock_name); + regmap_set_lockdep(map, &map->spinlock.dep_map); } } else { mutex_init(&map->mutex); @@ -743,6 +746,7 @@ struct regmap *__regmap_init(struct device *dev, map->can_sleep = true; lockdep_set_class_and_name(&map->mutex, lock_key, lock_name); + regmap_set_lockdep(map, &map->mutex.dep_map); } map->lock_arg = map; }