From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=192.198.163.19 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796354153; b=xsw6EcTOfmWgSrW+h4TJe5I57HQFKHJhGRM52AxjbPXa7sWzJ2AGGZtzssyqu3u6DtnK 5G8r2NJEvLLHUImRKmCRoOdNrGbFDzBmEnBz/Tar47szlpYV0E8hfcJS8/emNqwGf4IZ/ nUdZcoUEh/IGW1P79SprDh5l8kEhU613b3yK0DYawgkACmnn/bOSbzROkk4/I+vSUwfzp htHqc/DDNe5BzLtFbSeVDyvtqndFZ9TSS2NjgTOykmFnVMTFjIoW6zfgddLLyKLlshjXT N1nDi876AP+IDpQOjKb+f1OAM8UpxC6hkkpf3hbTXcrShwCBusQcJb56LGqRlLsJivw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796354153; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Received: Received:Received:Received:Date:From:To:CC:Subject:Message-ID: References:Content-Type:Content-Disposition:In-Reply-To: X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-Exchange-RoutingPolicyChecked: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; bh=3SMxvGjnkvAfdaeYQ5SsJjaXYD9BylZr+JFX4JjGs+o=; b=yaThvuijcFNg+lWVBmHGiuw1zO6zP8VkKOnNpvuzjsBTnhiOxCfpBVyo7D+8x4wuXu5/ faAhJ6PWnqM7QwngLqGVvqYxHUDgpXk3Sw2CZkPrjMvzQ5tkuPNw/Fx1kA6ax/rH/0+u1 eJaccKZJot2cDhKfTyv+3CF0+IlNFiRw8kU/YT12BsWYHS4Uq2pwaLE6ReIuf6u69X17X CgFdFLHot2+hf3FZz3LuIF0zXYi5eA499BI0SQ0NKj/p26S3bfBnN0Yfh2+W5M0L1IOcB q+bIXd7jeUZZvZQUFUP21mqrs62vQssGRfr6JHGrfjNbJ0nmVnBGrRE8T972snqWfVg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ZFpt7hcQ; arc=pass header.oldest-pass=0 smtp.remote-ip=192.198.163.19 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BEE4606A332; Fri, 4 Dec 2026 03:15:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2BEE4606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ZFpt7hcQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796354154; x=1827890154; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=3SMxvGjnkvAfdaeYQ5SsJjaXYD9BylZr+JFX4JjGs+o=; b=ZFpt7hcQRvuUJ1mA4n8csDoWtouOSbQclPhJYUO+vtnzuSn87jgfJv0d 0jaa9h+C+2/W6x+0+tRbC6j0daynp+zpJ2zdteO4eo8qsTZ2xtO5XI9+8 Qt3OrvcnXxSslRX7K0PP0oAMBKVFCt/20E6ecdHyeQAIq2/KFqatve8eF CV1uIrLRTrt4T/nKMYKQcsEI8Upw3yNLCifLqSlkzh0T1WWG2dvFiqNiR 8wwF7L1M8Ht33MeWGpx+L9qEAU0qaFPTgCHlcIxpFkrVD6NwXib/Vd/4o /iH/2ZklhVHXstTBkVLHWEGWo82jVhAuKx/D63xWBVRDp09Zk63ES3v+L g==; X-CSE-ConnectionGUID: DUJ67j83QnOySuc44WKd/Q== X-CSE-MsgGUID: MYRsZ6ooTGWAIKCRITm+jA== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5347122" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5347122" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 19:15:53 -0800 X-CSE-ConnectionGUID: QggyuTqsT9K6SDi7ZP3idw== X-CSE-MsgGUID: DNW57dWoR8K2vxTV7jHMHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="14097862" Received: from orsmsx902.amr.corp.intel.com ([10.22.229.24]) by fmviesa008.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 19:15:53 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX902.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 19:15:51 -0800 Received: from ORSEDG901.ED.cps.intel.com (10.7.248.11) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Thu, 3 Dec 2026 19:15:51 -0800 Received: from MW6PR02CU001.outbound.protection.outlook.com (52.101.48.4) by edgegateway.intel.com (134.134.137.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 19:15:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d6OZEQAZjSl6H1KsggtNdVF3Z9xHPPBcSY1x9F6hWzvTYXLTwJEGKV5BTSF6WJDEiDGfstpJYlmeIK03ogWBqw0masAQSIsHuulA6kBO0+ohEYSvJJnpbzqM94oc9uLwvYDm0CH/sjiaVnikqCOSUM2V2//2RrS+wZaU051PzrPDUU+Os2e6imTqAl4BpEa/5VaxgmeKaY1aASen4GK2m9YVINiRLJekrvXPVyV4T478kZiFaq4Cr1cdHW3WbIdTakxFSpdFFCd8N3MIFpvmPKB1YYkcoUhFZaBjMgIF45qygWXrNO7IaRewQGZbQdBpljyJjmuOlX12dSnrvu5yCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3SMxvGjnkvAfdaeYQ5SsJjaXYD9BylZr+JFX4JjGs+o=; b=Eb5rmbhCO1seySo1ze3GXUjgiSG2TxTf3RtlcV3s1S2yI1jaMRgnsftvy3FsRAwcioqgCXgMkehebAKf/2E56GE6X7sVzqxZcDP1y9M73K0i/shAmgtdHbOvU377VqDf4LOZWFT22ZTgzzI53TT+90EGDsDQEWMj2+sXisKi+hY96cDd47x5dx0mQUgovZzhJX6qC4Mxwgm5B2JqCCPT84Z7K1pf6r+fn7nMkozKOFjUno9kVzMtDYAdW310yP2pRKb9oxfWu4fNrkggAFnGbYr7ElqvPgCu8IGMq8rdicLylXGNwS0/gr6TTbAYviXaLIiRyvn8QHyFLSxilE90pA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS4PPF0BAC23327.namprd11.prod.outlook.com (2603:10b6:f:fc02::9) by PH7PR11MB6884.namprd11.prod.outlook.com (2603:10b6:510:203::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Fri, 4 Dec 2026 03:15:43 +0000 Received: from DS4PPF0BAC23327.namprd11.prod.outlook.com ([fe80::a1fc:97e0:329a:4aa7]) by DS4PPF0BAC23327.namprd11.prod.outlook.com ([fe80::a1fc:97e0:329a:4aa7%6]) with mapi id 15.21.0688.011; Fri, 4 Dec 2026 03:15:43 +0000 Date: Thu, 3 Dec 2026 19:15:38 -0800 From: Alison Schofield To: CC: Dave Jiang , , "Davidlohr Bueso" , Jonathan Cameron , Vishal Verma , Ira Weiny , Li Ming , Ben Cheatham , "Alejandro Lucero" , Richard Cheng , , Sashiko Subject: Re: [PATCH v3] cxl/region: Fix self-deadlock when cxl_memdev_attach_region() fails Message-ID: References: <20261204-junhomax-fix-cxl-attach-region-deadlock-v3-1-8008f8f72d4a@xcena.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261204-junhomax-fix-cxl-attach-region-deadlock-v3-1-8008f8f72d4a@xcena.com> X-ClientProxiedBy: SJ0PR05CA0194.namprd05.prod.outlook.com (2603:10b6:a03:330::19) To DS4PPF0BAC23327.namprd11.prod.outlook.com (2603:10b6:f:fc02::9) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS4PPF0BAC23327:EE_|PH7PR11MB6884:EE_ X-MS-Office365-Filtering-Correlation-Id: 1dc16637-eb14-489c-b3e4-08df51b4e183 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|366016|376014|7416014|1800799024|6133799003|22082099003|18002099003|261026140227099003|10067099003|56012099006|11063799006|261028144727099003|261022075727099003|261102130727099003|261021123027099003|261021121427099003|261022113327099003|261102123227099003|261009223027099003|261026121527099003|261022105027099003; X-Microsoft-Antispam-Message-Info: eGfNkLc3RZM+ljhRs8IjAWRpS3r/TZIcKJ019rAH/w5bQUOj48w5M1uKdv7WqxGWx4If9m+M+PGL6Dx68WZPXxtVKCkPeecE2cVXQ+hKd4kOu3cZ72NMQLfOiG47/mix/wNqTuJ8EIRRnX8mrwpcXtqGtTHrFCq+VoxJB1aXWPacUdkkAQISfXG1BnlkOCgXsQqj8YN55wB2BpqscOqzkM5joFtI+s9DNQHul4SnqXrJiMvtcqScqd4hVUFY5zK4BY2coIN+dLwbsXsusAHGoXJ1QBf1VutB2Gf4woH3bVLEQufEH7SV/YGkwZTajW6n0KFUFgcy25X+huf2DKyzJMef+r3fxQxMrR6jEg5P/ETg2NrOPgvMtYq+xX3cTtJEKVjJxbMUIljsDI8lwoRZBPEt7AImb1h2yn7IIQKwbt796CrFg+1MX/3cqGU0HvnsRNNG0vnglSnUn76B0Q7gAvr2g3eD/EfOVi61oyxK5ofNYUltCrxUTKLvsWsUwMLYbsKF+NGovdDbNkZhnTWeCPFcggvvviHLZkbHb216nUbf/J2TOXDnXJikLb2xgtunICwSDTGB0hsbHlAaw22OGnt6sgDfnQ/pcC55mNXS3tI4yGdzUXpJMxjsgHSo4+5/ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS4PPF0BAC23327.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(366016)(376014)(7416014)(1800799024)(6133799003)(22082099003)(18002099003)(261026140227099003)(10067099003)(56012099006)(11063799006)(261028144727099003)(261022075727099003)(261102130727099003)(261021123027099003)(261021121427099003)(261022113327099003)(261102123227099003)(261009223027099003)(261026121527099003)(261022105027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?no0KPMciE+hzhidhTm84JiTsQOkRAqMKV8I5BLhghtFFNNw9XsazxP2iMuO3?= =?us-ascii?Q?J+FDt90FQ/mhvJNR2rKe6zZYVDf2SuOB2VshirKl1iXTGaCrWGTtDfVR4grf?= =?us-ascii?Q?QCm1p3wx+3/Xg3lPsLDldlC+Ik/vMBByGU7BTSJQDuY/fGKC7bsgP0OcL0aH?= =?us-ascii?Q?Y+Nc2E6KGW1PFrbLtIHnM6FrfoTrucLFgedg50lp/abZN/4nJh+xxu64X7cn?= =?us-ascii?Q?xOPCdwfHLPKVTlIvCkq7dXrR6r0PIVXseJ3GcHiDPPstc26EZ3PC+C6lGkpQ?= =?us-ascii?Q?ICxWk+ViJEgynuJbB1IBEfAwAKjVwVu33qFVtLyNK5Ya1Iy4YuEwkrycrcU5?= =?us-ascii?Q?XVN1nQmfpH5XSIQghrKbBLj/6w3rexvLH2Ah4EC0s7GqP9Q/PlcSF80yyxU6?= =?us-ascii?Q?2b7OyPnhLIUQ2TP4Ur0zOrvgX+oMxhGo5CIyJPH4CszFF1YnlQi2WORjbpkC?= =?us-ascii?Q?IrfnXau8SUO5N4cWn3FhraWQaKHDIuiclPyKTyPb/RJsEeydRtL/nCoF7EtI?= =?us-ascii?Q?AyPWghzhuz+DB+8phTA4oZetyijM0EurHs3zCcfgSRvtRPAGrJO0+k2sqMOD?= =?us-ascii?Q?b4uP0SfyVNr/W9eXosw0YZhMAVGoOUe+ua/aTshPT+3/ujx1Ddw/7SFKdzat?= =?us-ascii?Q?gYOPaV9BKmOzibQgqagnhNiNJ6v/LWRGJWZBz1hXfHVdbe2y7Zu8dHNolz+e?= =?us-ascii?Q?gehzWA0TJ+kX+wga9XkV4ldVhgs2nfYhkSu+6PKELEm/Kg5K3uJEhlCrFBAB?= =?us-ascii?Q?z22fCyXN78N4ge7llMlV5zxV9m1yD1N67Qjg0Wtnx4xU3OrkdOx5CWqNFEGx?= =?us-ascii?Q?7pmheZSqWYoTxEhYUKDPQtQYtT9RJlT99uBd/z70J/FuGmAg8gIYnZztNmHD?= =?us-ascii?Q?5f7JGok4qMM2cf0uqvsic5v8C9vquy3sKdo5F5DYRgUzct7S7vVwd+9KJZMy?= =?us-ascii?Q?ZcwUBSJrjEW9i8AQKFUcH8lKc/WJftEMMbBEWbQ0wvHdWG/8qrlNBGMeIiR0?= =?us-ascii?Q?MdSWnPa8wIraTj8q9l0MaD7KduY7j58n0l5yXr/AmNnZu5MIV9NZElgyqVI+?= =?us-ascii?Q?Fi5WtNFNGvAaZaX4VzgSfRZooacx7uBkuvbIabknOZtoF/kPODVH/QjVSRD4?= =?us-ascii?Q?qWYDUqE22sKT5SGnsuw+PGJztFxijM+gV6TIAWaGrJrmQl4Ukn+WdsWSE2JJ?= =?us-ascii?Q?kkLKmTUw8mdMJVy1ie43hiWz4Ko6rS9qVM7B44wEX7qTYPLqRZHBTwpbPgJa?= =?us-ascii?Q?XsF2Hxb/qbaF8ipMjQjWdJ3MMcVY7fjTMbGYJoerjWXQJygvKigN0QADv9ag?= =?us-ascii?Q?8rnOrTDwmajTdPviHmmYE5r/aKkFf8Uv13KEIO84YTt8PgJLX8ReLDPB46j3?= =?us-ascii?Q?lG3uGAhLck+TyUgB1NLU23kHbBlzMp02YEA/igPAtJ/3QGobgYu73sxk1nQw?= =?us-ascii?Q?HyyyQvAMO+QK98G5bgB40LrOyHr4TJVlDpdudj9uJ8fxo1zlsXi1QvPAvJPE?= =?us-ascii?Q?1b9cnI451oQ3Yvm7yZivDYrm0DcnQ9AMhig9vbhod+PEuO1TcVn+vFFAZHIt?= =?us-ascii?Q?532OD51e0lX9DoGFHuKV9ByK56pfQum6UIUB+sXIhXsnT2pmE0OqAeis9lCL?= =?us-ascii?Q?6mbLYgossghmys/tezO4HQtb66CIC+55QX0s9dl+ZRmUqgqMEX0ENGzA/9XK?= =?us-ascii?Q?K9w3flK5wKS8hIvHKeGBs/vO69TSqPV7itZ4lgt7syk9/kOvUQIfFfC4sp3f?= =?us-ascii?Q?G5jLUR5KalR138D+clzM43vyHTTPcu4=3D?= X-Exchange-RoutingPolicyChecked: cY9GIlpPD6OoA3Mmw4mBPnIRs/Izyv5bVoyISF98XvweYPCfP2vNmXLWzYU9bOPAJKODNh9xmyCAwRQv8RKsra2SegxHLTsIOtMvUsxmSSn9mU/poH+zrwbhPqTcNWxsqjY2E+DH12B9y/8m/8zFq/wqjBXsaRCGpZRCEbWC3t2ZHFfv/BzVn0YNj3VcRZ+jXmyfbR3ubUqvklnx41Y3aQqql28DQtAaHW5loyC9bp2Se+C487syX5f4zufQA6/Y0nDsmNsco6W07W2u8Cj/3RWDQ5k9soYDgbq2US+rbEijozo+yY7CNbSD6BNRutxxktLPk+8tc//JI0ktYXJ45g== X-MS-Exchange-CrossTenant-Network-Message-Id: 1dc16637-eb14-489c-b3e4-08df51b4e183 X-MS-Exchange-CrossTenant-AuthSource: DS4PPF0BAC23327.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 03:15:43.2072 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VJA46tdjA7wKnUcHp/d3y7T99g2ArxaCDjmXBsZblR26v4zl+QG+rXlTJnUrahbr0HvV6VU/RHYYt28iOd5iiFVGxwHSjzGEcmYj1taBfHI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6884 X-OriginatorOrg: intel.com On Fri, Dec 04, 2026 at 10:53:26AM +0900, Junho Cha via B4 Relay wrote: > From: Junho Cha > > A devres allocation failure during cxl_mem probe can deadlock the > probing task. devm_add_action_or_reset() then runs > endpoint_unregister_region(), which waits for cxl_rwsem.region for > write while the task holds it for read. The wait is killable, but a > fatal signal can interrupt the detach and leave the decoder attached > to an unregistered region. Lockdep also reports an inversion: the > cleanup takes cxlrd->regions_lock under cxl_rwsem.dpa, while > cxl_add_to_region() takes it before both rwsems. > > Register the action with devm_add_action() while holding both rwsems, > so the region cannot be detached between validation and registration. > If registration fails, release both rwsems before unregistering the > region to avoid the self-deadlock and the lock order inversion. Keep > the endpoint device lock held throughout. > > Tested with cxl_test (type2_test=1), failing the devres allocation > through failslab with the stack filter limited to > cxl_memdev_attach_region(). Probe returned -ENOMEM, the region was > unregistered, and lockdep reported no inversion. Thanks for the updates! Reviewed-by: Alison Schofield In the future, be aware that folks will expect you to reply to the review feedback in the prior revisions email thread. In this case, you did add my name in the changelog and this was very fresh in my mind, so I didn't gripe. However, replies are proper ettiquite, and others (including me) might no be so forgiving next time, so best to set a pattern of doing so. Documentation/process/submitting-patches.rst, line 313. The key passage: "Your patch will almost certainly get comments from reviewers on ways in which the patch can be improved, in the form of a reply to your email. You must respond to those comments; ignoring reviewers is a good way to get ignored in return. You can simply reply to their emails to answer their comments. > > Fixes: d8dcb0b74b04 ("cxl/region: Introduce devm_cxl_probe_mem()") > Reported-by: Sashiko > Link: https://lore.kernel.org/all/20260805080537.7489E1F000E9@smtp.kernel.org/ > Signed-off-by: Junho Cha > --- > Dave pointed at this reset path while reviewing the Type2 multipf > series [1]. This is a standalone fix for the existing code that keeps > the region teardown when registering the action fails. > > [1] https://lore.kernel.org/linux-cxl/6bc33514-8bfb-44d6-8fde-28f45dff5eb9@intel.com/ > --- > Changes in v3: > - Rewrite the commit log as a short summary (Alison). > - Rename the out-parameter to region_out and the caller's variable to > cxlr, and drop the comment before the call (Alison). > - Link to v2: https://patch.msgid.link/20261119-junhomax-fix-cxl-attach-region-deadlock-v2-1-32ddef645e52@xcena.com > > Changes in v2: > - Register the action under both rwsems as before and only run the > unwind after dropping them. v1 left a window where the region could > be detached before the action was registered (Ben). > - Add Reported-by/Link for Sashiko. > - Drop Alejandro's Reviewed-by, since the fix changed. > - Link to v1: https://patch.msgid.link/20261117-junhomax-fix-cxl-attach-region-deadlock-v1-1-f373a135edd2@xcena.com > --- > drivers/cxl/core/region.c | 31 +++++++++++++++++++++++-------- > 1 file changed, 23 insertions(+), 8 deletions(-) > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index 237172b33f55..e22a0e3a4590 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -4437,7 +4437,8 @@ static int first_mapped_decoder(struct device *dev, const void *data) > * Runs in cxl_mem_probe context after successful endpoint probe, assumes the > * simple case of single mapped decoder per memdev. > */ > -int cxl_memdev_attach_region(struct cxl_memdev *cxlmd) > +static int __cxl_memdev_attach_region(struct cxl_memdev *cxlmd, > + struct cxl_region **region_out) > { > struct cxl_attach_region *attach = > container_of(cxlmd->attach, typeof(*attach), attach); > @@ -4446,10 +4447,6 @@ int cxl_memdev_attach_region(struct cxl_memdev *cxlmd) > struct cxl_region *cxlr; > int rc; > > - /* hold endpoint lock to setup autoremove of the region */ > - guard(device)(&endpoint->dev); > - if (!endpoint->dev.driver) > - return -ENXIO; > guard(rwsem_read)(&cxl_rwsem.region); > guard(rwsem_read)(&cxl_rwsem.dpa); > > @@ -4484,10 +4481,11 @@ int cxl_memdev_attach_region(struct cxl_memdev *cxlmd) > > /* Only teardown regions that pass validation, ignore the rest */ > get_device(&cxlr->dev); > - rc = devm_add_action_or_reset(&endpoint->dev, > - endpoint_unregister_region, cxlr); > - if (rc) > + rc = devm_add_action(&endpoint->dev, endpoint_unregister_region, cxlr); > + if (rc) { > + *region_out = cxlr; > return rc; > + } > > attach->hpa_range = (struct range) { > .start = cxlr->params.res->start, > @@ -4495,6 +4493,23 @@ int cxl_memdev_attach_region(struct cxl_memdev *cxlmd) > }; > return 0; > } > + > +int cxl_memdev_attach_region(struct cxl_memdev *cxlmd) > +{ > + struct cxl_port *endpoint = cxlmd->endpoint; > + struct cxl_region *cxlr = NULL; > + int rc; > + > + /* hold endpoint lock to setup autoremove of the region */ > + guard(device)(&endpoint->dev); > + if (!endpoint->dev.driver) > + return -ENXIO; > + > + rc = __cxl_memdev_attach_region(cxlmd, &cxlr); > + if (cxlr) > + endpoint_unregister_region(cxlr); > + return rc; > +} > EXPORT_SYMBOL_FOR_MODULES(cxl_memdev_attach_region, "cxl_mem"); > > /* > > --- > base-commit: 32af7819352bae9c690ebe277a44eceb501d5c68 > change-id: 20261113-junhomax-fix-cxl-attach-region-deadlock-fc0a425f7265 > > Best regards, > -- > Junho Cha > >