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.16 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796269628; b=VELkLFQHSH75bV9N8teXGEbHI8quKuxO1ye/7t4nuERFfbXf3uiJFU4Gk8ul75cW1ENG 3K0ERP7lzJllYM1ZmweaQ+mS0t1Ft+WEq4lJeBqBuAeCdwZPN5TF6UFHxeyKLK+kNvQ6Y kIll0ECI0Gt/FowgOqcLG3IyftuTFAKYZBHWkCrDA+vRbIfaZ+jknvX3knQrQXVdHpu79 KFay+W9VFkChERopw/+dUZZHNpQCuj6b6IIrmRhoQDvPnsDnBBq6elFU+LRgPy/SOroXT tay49kJ3GBa4Bn2dboadtMPNZIwtjq51EnWQ/1c2+JB3qF+SwTQsLiJSqxh5GYOM5MQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796269628; 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=6TsseOO0/rD20au9oQfO2aR2OyW5kbV5+PCYRx2F91c=; b=YDpmWGoIrJFc20aGPaXW/9RmPUv/BAb4pgPynP4x5nt76iOshEUmZEly0PHq0iWYU+Cd MksVkf5swnD0aWJ+TXpifEn0tvaQXaFEM1dOdn5G4to3aFXwROCq4sIZdKUihOcBpE3Tp m6tjDYnTk3M4LxTebJAgHyyVcN8C/4qTWAvRJakFhPCh7AABKz+awtvTBDejINUUtM6P/ LM666S/24o/OTQcxiSiurp9x1+hh0VcaJd1m2pIQoWM9Iw+VYdMMGkCcfwRWsxtZ5xytH DV1KOb8MKnGTp0QBWFV8u1EnXokWUqacUDH5iEQEfQON6mLVmQU8pfdq5p4sDbuWedA== 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=BHAzM1dL; arc=pass header.oldest-pass=0 smtp.remote-ip=192.198.163.16 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 12925606A322; Thu, 3 Dec 2026 03:47:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 12925606A322 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=BHAzM1dL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796269628; x=1827805628; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=6TsseOO0/rD20au9oQfO2aR2OyW5kbV5+PCYRx2F91c=; b=BHAzM1dLbA7yQSByBV/1wqOX2gDwde4Um5rL/dO+L5oZIgMrQNuu9mQd HclYN70/XLZJ/BZYQ1t1aHWwCxGUn+IYlAj0rgVy4KFIhRgAz7KM5NY0J TVaHyj+agjaypsVg1hpKOybLHOyrQc8UYFRsexg71+xYNVunNxoqwQq9O IbJVZ1Zi10pOgPg24nYE9HiI683bRC0v1hzpGMstOTEQKlIkE/zzqzIEU XkjEJBFA2SyGwcCOYkwyfM3qXNxVK/yaeyfPgn72VW6EMIm37I4LMXmqj ozLZYBy02E1W892UDaoYVXYHuIHCHhnATHML724xybnvuF9NONlc4F5gm g==; X-CSE-ConnectionGUID: wLbcaTqFSgiy3R+H/5TwTw== X-CSE-MsgGUID: LtnbMXCVRiO+sKhpoQrcpQ== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5218577" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5218577" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 19:47:07 -0800 X-CSE-ConnectionGUID: CNPpUjNzRcKuCb+3FNI+3w== X-CSE-MsgGUID: qvTIHSFNSl2x8NSohAVnhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13495441" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 19:47:07 -0800 Received: from FMSMSX903.amr.corp.intel.com (10.18.126.92) by fmsmsx901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 19:47:06 -0800 Received: from fmsedg902.ED.cps.intel.com (10.1.192.144) by FMSMSX903.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 19:47:06 -0800 Received: from CH4PR04CU002.outbound.protection.outlook.com (40.107.201.60) by edgegateway.intel.com (192.55.55.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 19:47:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UO0ccN9ydIJQuQ/4czj9xNIr/NijplfKgITeCSbEWAVij6/54neYIpHOjXNoq+HHSjE+Vqp6zxRNozqCDMT9rwii9pYIq/dO7LSSOIaC2sxzGEQROLRHR3vixF2TiYou0OikvUJkR46XcoPU9+m0wZuKm67s9X5/eGjRRNokB0YLLUAQOhlaK0u7w/w7Qe7SY/Be3rc9BlKeBxny7f48DSscajuTzBrvrQfQOmwDfAP8iyryw0QOqQHhUnJz8pqA98f5QEI1yg1iY5qdwqih4kjMiQG5Fa+AzOg1xXLKYqIDRBxsXpJ311oPIA4b85QkPozx73qVd42NyYRT3HC/HA== 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=6TsseOO0/rD20au9oQfO2aR2OyW5kbV5+PCYRx2F91c=; b=jPzUAhAoa0pbf7G7VrJaBfXpaMzEbaxlbtKdym5SSALWgF5DzhioJmcP+aPgV+nDrP0Kk6N6LOxjGHzX1I90+pCtSgDJTyvd0TUjdv/k5kIDjm+TmLIGXMslEh3TgjBngtQxN2OLi2t6eX6mOrDNNdCPBT7egcNtvQkiiD3/+8nqC5sGVz8rDBPCMdQl3brSNchsCzQNcQKSe4G6I5kWUfYDEEr2m7srQqOTzZU77ljDW10cqdEFTQYYDq5Qtm8kp9olzrToHdGmrRtSdPU5d82Of60vcxPOFGsbBOjVZVFLpdUpvd8aVWE+Ak72SU59T/nLWPpr0zl40xvFDzTGLw== 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 IA4PR11MB8891.namprd11.prod.outlook.com (2603:10b6:208:56d::20) by MN2PR11MB4663.namprd11.prod.outlook.com (2603:10b6:208:26f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.11; Thu, 3 Dec 2026 03:47:03 +0000 Received: from IA4PR11MB8891.namprd11.prod.outlook.com ([fe80::1128:c90e:54:e8f1]) by IA4PR11MB8891.namprd11.prod.outlook.com ([fe80::1128:c90e:54:e8f1%4]) with mapi id 15.21.0688.009; Thu, 3 Dec 2026 03:47:03 +0000 Date: Wed, 2 Dec 2026 19:46:58 -0800 From: Alison Schofield To: Yongxin Yang CC: Dave Jiang , Jonathan Cameron , Davidlohr Bueso , Vishal Verma , Dan Williams , Rafael J.Wysocki , "Tony Luck" , Borislav Petkov , Hanjun Guo , Mauro Carvalho Chehab , Shuai Xue , Ira Weiny , Li Ming , Len Brown , , , Subject: Re: [PATCH v8] cxl/core: Create EINJ debugfs files when EINJ is initialized Message-ID: References: <179550361711.991197.13876815308672111616@kylinos.cn> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <179550361711.991197.13876815308672111616@kylinos.cn> X-ClientProxiedBy: MW4PR03CA0326.namprd03.prod.outlook.com (2603:10b6:303:dd::31) To IA4PR11MB8891.namprd11.prod.outlook.com (2603:10b6:208:56d::20) 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: IA4PR11MB8891:EE_|MN2PR11MB4663:EE_ X-MS-Office365-Filtering-Correlation-Id: b6a08594-0838-4e64-a9bd-08df50f017f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|23010399003|11063799006|5023799004|6133799003|22082099003|18002099003|3023799007|10067099003|56012099006|261028144727099003|261102123227099003|261102130727099003|261021123027099003|261021121427099003|261022105027099003|261026121527099003|261026140227099003|261009223027099003; X-Microsoft-Antispam-Message-Info: kbQu9H0VoyJlCr+kMAMmcH9IaHwsaJE+jRPNuKVqwFgdApRF2ygJR+9Dab0eO7aKBw6XZ8P2m8mXQpEEBcPpVcCvG9NmGskbRikUgpgQAamjSRHF+OGn/c3CFrvEVOonvHPy3lXYPbM583/G4ut/hLvZ5cJwBzJ1KYZ78f4S066/IURyWlHfKaIJPMG9qygO/Umo837pCM1w7e49B5Q/nwNYj6UJfZmAXNlZiIGKP43innachHsjzajMJnaI8fEZQO5lreHOdKbIBJB01IY4Rx9a467n/uDuLAKJvX2HkwNy37AHVHGMD8y6XeXwmO2ux9xNeEScdo/82zXgm/1KZliemZFSN4wDDSrLeqENKD2iEZ0Xq548kPnz8ETzs37L/6QbijSnEaSk3mktZccmyA2aRGsN7cyrnXSbjuYH0CN+ik6GES2OQnLZEzIsGnP5/j4gr/+JX3E0oQW9wTezwG5709enQ55FjSa9WiNk2mebhkRhC9QGDgoOOLGJHtkhUCZqo5H2vhY7zqhUo58nEWK58JOhBSqiJcwekKXwOXeHQnG/hD7FYvFY2M4zxOhD8ELHf8e0tNcw0sW3t0wpAsTg3LpYo5YCy9i2hZUgrJyfv1/XLxxmMZqtpCwf7QLX X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA4PR11MB8891.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(23010399003)(11063799006)(5023799004)(6133799003)(22082099003)(18002099003)(3023799007)(10067099003)(56012099006)(261028144727099003)(261102123227099003)(261102130727099003)(261021123027099003)(261021121427099003)(261022105027099003)(261026121527099003)(261026140227099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LwSLsuXyv7pl1qNX5zddeWhC3cCs5uqJcRzQ8d9G5pvfmaio4RE/Q27OxieB?= =?us-ascii?Q?h6IOW7/QvwGAKO0YvwYfaNRggNqQcNceesfqwp+tdfQIB1TwAscjR5KqvQZu?= =?us-ascii?Q?bAxjYgGVkpBRXeZA0vaaxHGYf43KMgWxGi0uZcpd3753PWrgJYePJJV+MsDF?= =?us-ascii?Q?OXiQKZ27cI4g9gVUz0aYbqBfzRJrwL4UxllYVJWd0UQzrqwnSPvescd5Zzme?= =?us-ascii?Q?6o9+BU39DGAUYhBrSRsWZ+eOpJWmgD5+cyN/04dWQDxhBPLleSme6cm18196?= =?us-ascii?Q?Pr/utvdaL3HDiQAgHjIXH75EdLeQWrH9Q7g4kM8rVlyBbexOT4tgP3aaBIry?= =?us-ascii?Q?+X1CmdEZIuvegxvy4VnhnPDFyQ6WhzrT0eMoSSLCkU9KJmn2/1/luUXqo/dC?= =?us-ascii?Q?p/hY73Zl2VHb/zAUNd9nT6b+R9ZIjjDpzMyrSvSYGkVwAVUgXVgAy8jqdmyJ?= =?us-ascii?Q?IxBKLzQhnRMHq+Wjw1+JMMrRFL9D9DYo8oBrpoXi2fcwnwdDT3Lvuiruj8CH?= =?us-ascii?Q?hMWvTbc9mOQJR+1xgDntsVnowLxltMooNJrMbQdo3ykUlutuFhheesC3GPyU?= =?us-ascii?Q?qb9V9UhPqX2cq7WfjPlO4mziugJELb8wSYRy+Q6J5D+0duvrh8s2UQjCJVoI?= =?us-ascii?Q?iokwx1T79msLHrF3ArXmr/agIZru3m3rP33Pnfo269jLIHG1kChqgsOqKZjS?= =?us-ascii?Q?IUILLzPSxFjD/kcU5pJycWVizOSKE4nAB8/VL27GK55UVP91Hh6o9Jh+As5d?= =?us-ascii?Q?1ivyCZcC9Wft8vyvzSDuO6hbaR7eEJEadmK3qmY9BEgEz7mPNVSeY8ykCKco?= =?us-ascii?Q?GgizP4WjI1IxlnxTKcNlEL7TIg8LyKWlG6IqsToik/ocwI3TXIStfBE19BCC?= =?us-ascii?Q?8G8KOT/9NclfAWQECOnbFdSmc2D64KuI9DTz9m0drhmL01Ub28HDqcWrb1wO?= =?us-ascii?Q?36ChWoUlrwvO4jjCmHI6a1bEzcNwbha5/oA13qOEphyxCVzsz59Yyc1hX0yp?= =?us-ascii?Q?5h6pDobNJ8nt9n7o1gO/R6GpCTqPxbmD/RBjQ0wS+hn/e0LTubedz/TKcmKw?= =?us-ascii?Q?6hziQ5ttq4UNNXrKGOtJXSiC/D8iq5FdH0x9xkJw5iIaVuEGqjrZz5h+fb/5?= =?us-ascii?Q?Ow5ckDw6MYENQIw8b422W/gX+tS+ka2JrSgJNIS3t1ttbchdlHH0NskIWvSS?= =?us-ascii?Q?PcofK1U8gk8WA8X9yzZZJrr9lDN5BIzA64RNqhTsK+F45F1fQdNnTJ1toMRS?= =?us-ascii?Q?dzEjLFSRaoq7VsBdAxD2e5y346bCHegqwS8Jgp+g/y4WRtIkOxTCokYWylT2?= =?us-ascii?Q?/G1Zu2oEAhWRRG3ZRKFyTrmcEbEao04qB5C+tCCz62pTN1CQZC2XErpiDyRr?= =?us-ascii?Q?L2fXSOuacADKmrb/qdG8j3O/01Yq3uDRD/e5odkGZIBrfv1tMNA16maL/slQ?= =?us-ascii?Q?SeJaL3x4qFweePovfCCdLVqhJpvJNghdz3K/sTN+vopGcan9Qs8rulWlsb9x?= =?us-ascii?Q?grczCyEiB3bQGwnbFXwUk3wjRgJUDklVM4/HYGCWkV+W6gbn5MGId0ybv6co?= =?us-ascii?Q?Eyh051mH2HWqpXw/sHZcmkA44psrg5vAuzA8zLWlKDUEeEEE5L+5cEWznf+E?= =?us-ascii?Q?37A/OhOI6gMBCijxgiX70Rvf8j1LDnVUPDsrVByUrO8Fi34S7u9GZJYBnGJs?= =?us-ascii?Q?5SKX5012vw4kGGLmSkKk9cNg+lo5j5dmNDTurImpvOof5IFBazgcjMvSmpOO?= =?us-ascii?Q?P6tBAxPICzcrmfcpIWARytDfoMUI9Vc=3D?= X-Exchange-RoutingPolicyChecked: S4XPS72XUIxfiLuUJQ0kYQOPq8U7VokCvbF9o2Gf6KUWE67b2st5bJ6qOrd5A1qSh7/VKwdVSk5lfnTR1kgej08brZ4kl0K3xLf+7rbEMw5bjL2JYs59XbdbeYGeRNCZS6sMjX9JLI4m7y5KZm7U9neTGG/Ljviqdd446XoNWg5hBjK807SeRGpsJ0jruoQXXPmZmoBljyFDqj1DCXelG8BnFlIFlAZ+9tqY8MdYeRMyyaFeoNImQCKnl7U68mJ8C49Gu73lZZbZE++tqd8sQwgPRsGFzTaFV4fdlDRCeJKYOeoSBii2aF4IQG5+wc6BR+d7yDHKb4192qPFm+3xQw== X-MS-Exchange-CrossTenant-Network-Message-Id: b6a08594-0838-4e64-a9bd-08df50f017f2 X-MS-Exchange-CrossTenant-AuthSource: IA4PR11MB8891.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 03:47:03.5659 (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: NrNAhbdubfmV4dqTDgeGoph8Z0HfO1jWrFlqvG6sdrGVAWi0WU0jN6T04l0Lo5Uw3WEIgsUUbdyupbKfmU0CsuknsoLF7Ea+xI8Z0aoMJEE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4663 X-OriginatorOrg: intel.com On Tue, Nov 24, 2026 at 03:00:17PM +0800, Yongxin Yang wrote: > einj_types under /sys/kernel/debug/cxl/ and the per-port einj_inject files > are how ndctl learns that CXL protocol error injection is available, so > they must exist where it works and stay absent where it does not. > > With cxl_core built in, cxl_core_init() runs at subsys_initcall and > einj_init() at device_initcall, so the is_initialized() check there > always reads false and einj_types is never created. Register > cxl_einj_debugfs_setup() with einj_cxl_register_ready_cb(); EINJ invokes > it from einj_cxl_notify_ready() once it is up, which creates einj_types > and the dport directories skipped before that point. The three helpers > check einj_cxl_is_initialized() and return -ENODEV until then. > > Test on a host with an EINJ table. With CONFIG_CXL_BUS=y and > CONFIG_ACPI_APEI_EINJ=y (CONFIG_ACPI_APEI_EINJ_CXL defaults to y), > einj_types and the dport directories are missing before the change and > appear after it, and writing a type from einj_types to a port's > einj_inject reaches the dport path. With both set to m, cxl_core depends > on einj, so einj comes up first and the files appear when cxl_core loads. > On a host without an EINJ table neither file appears. > > Link: https://lore.kernel.org/all/20261104061256.1449275-1-yangyongxin@kylinos.cn/ > Fixes: 8039804cfa73 ("cxl/core: Add CXL EINJ debugfs files") > Signed-off-by: Yongxin Yang > --- Hi Yongxin, Thanks for the update and for the 'other' reply where you explained what you were planning for v8. I still though need a changelog here, the list of changes from v7->v8. -- Alison > drivers/acpi/apei/apei-internal.h | 7 ++++ > drivers/acpi/apei/einj-core.c | 4 +- > drivers/acpi/apei/einj-cxl.c | 38 +++++++++++++++++ > drivers/cxl/core/port.c | 70 ++++++++++++++++++++++++++++--- > include/cxl/einj.h | 3 ++ > 5 files changed, 115 insertions(+), 7 deletions(-) > > diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h > index 77c10a7a7a9f..5fb28cb4c7aa 100644 > --- a/drivers/acpi/apei/apei-internal.h > +++ b/drivers/acpi/apei/apei-internal.h > @@ -137,6 +137,13 @@ int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, > int einj_cxl_rch_error_inject(u32 type, u32 flags, u64 param1, u64 param2, > u64 param3, u64 param4); > bool einj_is_cxl_error_type(u64 type); > + > +/* Notified from einj_init() once the CXL side may set up its debugfs */ > +#if IS_ENABLED(CONFIG_ACPI_APEI_EINJ_CXL) > +void einj_cxl_notify_ready(void); > +#else > +static inline void einj_cxl_notify_ready(void) { } > +#endif > int einj_validate_error_type(u64 type); > > #ifndef ACPI_EINJ_CXL_CACHE_CORRECTABLE > diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c > index 1f3fa2278584..a3e7185f1e5a 100644 > --- a/drivers/acpi/apei/einj-core.c > +++ b/drivers/acpi/apei/einj-core.c > @@ -1187,8 +1187,10 @@ static int __init einj_init(void) > > einj_dev = faux_device_create("acpi-einj", NULL, &einj_device_ops); > > - if (einj_dev) > + if (einj_dev) { > einj_initialized = true; > + einj_cxl_notify_ready(); > + } > > return 0; > } > diff --git a/drivers/acpi/apei/einj-cxl.c b/drivers/acpi/apei/einj-cxl.c > index e70a416ec925..93003fe4527e 100644 > --- a/drivers/acpi/apei/einj-cxl.c > +++ b/drivers/acpi/apei/einj-cxl.c > @@ -30,6 +30,9 @@ int einj_cxl_available_error_type_show(struct seq_file *m, void *v) > int cxl_err, rc; > u32 available_error_type = 0; > > + if (!einj_cxl_is_initialized()) > + return -ENODEV; > + > rc = einj_get_available_error_type(&available_error_type, ACPI_EINJ_GET_ERROR_TYPE); > if (rc) > return rc; > @@ -72,6 +75,9 @@ int einj_cxl_inject_rch_error(u64 rcrb, u64 type) > { > int rc; > > + if (!einj_cxl_is_initialized()) > + return -ENODEV; > + > /* Only CXL error types can be specified */ > if (!einj_is_cxl_error_type(type)) > return -EINVAL; > @@ -90,6 +96,9 @@ int einj_cxl_inject_error(struct pci_dev *dport, u64 type) > u64 param4 = 0; > int rc; > > + if (!einj_cxl_is_initialized()) > + return -ENODEV; > + > /* Only CXL error types can be specified */ > if (!einj_is_cxl_error_type(type)) > return -EINVAL; > @@ -111,3 +120,32 @@ bool einj_cxl_is_initialized(void) > return einj_initialized; > } > EXPORT_SYMBOL_NS_GPL(einj_cxl_is_initialized, "CXL"); > + > +static void (*einj_cxl_ready_cb)(void); > + > +/** > + * einj_cxl_register_ready_cb - run a callback once EINJ is initialized > + * @cb: callback to invoke, or NULL to cancel a pending registration > + * > + * cxl_core cannot tell at init time whether EINJ will come up. If EINJ is > + * already initialized, @cb runs immediately. > + */ > +void einj_cxl_register_ready_cb(void (*cb)(void)) > +{ > + if (cb && einj_cxl_is_initialized()) { > + cb(); > + return; > + } > + > + einj_cxl_ready_cb = cb; > +} > +EXPORT_SYMBOL_NS_GPL(einj_cxl_register_ready_cb, "CXL"); > + > +void einj_cxl_notify_ready(void) > +{ > + void (*cb)(void) = einj_cxl_ready_cb; > + > + einj_cxl_ready_cb = NULL; > + if (cb) > + cb(); > +} > diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c > index 625e4aa427db..4f6137651ca4 100644 > --- a/drivers/cxl/core/port.c > +++ b/drivers/cxl/core/port.c > @@ -802,6 +802,8 @@ static int cxl_dport_setup_regs(struct device *host, struct cxl_dport *dport, > > DEFINE_SHOW_ATTRIBUTE(einj_cxl_available_error_type); > > +static struct dentry *cxl_debugfs; > + > static int cxl_einj_inject(void *data, u64 type) > { > struct cxl_dport *dport = data; > @@ -822,6 +824,17 @@ static void cxl_debugfs_create_dport_dir(struct cxl_dport *dport) > if (!einj_cxl_is_initialized()) > return; > > + /* > + * Skip dports that already got a directory when they came up. The > + * lookup returns an ERR_PTR when CONFIG_DEBUG_FS is off, so it must > + * not be handed to dput() unchecked. > + */ > + dir = debugfs_lookup(dev_name(dport->dport_dev), cxl_debugfs); > + if (!IS_ERR_OR_NULL(dir)) { > + dput(dir); > + return; > + } > + > /* > * Protocol error injection is only available for CXL 2.0+ root ports > * and CXL 1.1 downstream ports > @@ -836,6 +849,54 @@ static void cxl_debugfs_create_dport_dir(struct cxl_dport *dport) > &cxl_einj_inject_fops); > } > > +static struct dentry *einj_types_dentry; > + > +/* > + * einj_types cannot be created from cxl_core_init(): EINJ is not up yet at > + * that point, so create it once EINJ reports it is initialized. > + */ > +static void cxl_einj_debugfs_add_types(void) > +{ > + if (einj_types_dentry) > + return; > + > + if (!einj_cxl_is_initialized()) > + return; > + > + einj_types_dentry = debugfs_create_file("einj_types", 0400, cxl_debugfs, > + NULL, > + &einj_cxl_available_error_type_fops); > +} > + > +static int cxl_einj_debugfs_create_dport_dirs(struct device *dev, void *data) > +{ > + struct cxl_dport *dport; > + struct cxl_port *port; > + unsigned long index; > + > + if (!is_cxl_port(dev)) > + return 0; > + > + port = to_cxl_port(dev); > + > + guard(device)(dev); > + xa_for_each(&port->dports, index, dport) > + cxl_debugfs_create_dport_dir(dport); > + > + return 0; > +} > + > +/* > + * Called from einj_cxl_notify_ready(), or directly from > + * einj_cxl_register_ready_cb() when EINJ is already up. > + */ > +static void cxl_einj_debugfs_setup(void) > +{ > + cxl_einj_debugfs_add_types(); > + bus_for_each_dev(&cxl_bus_type, NULL, NULL, > + cxl_einj_debugfs_create_dport_dirs); > +} > + > static int cxl_port_add(struct cxl_port *port, > resource_size_t component_reg_phys, > struct cxl_dport *parent_dport) > @@ -2501,8 +2562,6 @@ const struct bus_type cxl_bus_type = { > }; > EXPORT_SYMBOL_NS_GPL(cxl_bus_type, "CXL"); > > -static struct dentry *cxl_debugfs; > - > struct dentry *cxl_debugfs_create_dir(const char *dir) > { > return debugfs_create_dir(dir, cxl_debugfs); > @@ -2515,10 +2574,6 @@ static __init int cxl_core_init(void) > > cxl_debugfs = debugfs_create_dir("cxl", NULL); > > - if (einj_cxl_is_initialized()) > - debugfs_create_file("einj_types", 0400, cxl_debugfs, NULL, > - &einj_cxl_available_error_type_fops); > - > cxl_mbox_init(); > > rc = cxl_memdev_init(); > @@ -2541,6 +2596,8 @@ static __init int cxl_core_init(void) > > cxl_ras_init(); > > + einj_cxl_register_ready_cb(cxl_einj_debugfs_setup); > + > return 0; > > err_region: > @@ -2554,6 +2611,7 @@ static __init int cxl_core_init(void) > > static void cxl_core_exit(void) > { > + einj_cxl_register_ready_cb(NULL); > cxl_ras_exit(); > cxl_region_exit(); > bus_unregister(&cxl_bus_type); > diff --git a/include/cxl/einj.h b/include/cxl/einj.h > index 624ff6ff41f9..af2af62c8eaa 100644 > --- a/include/cxl/einj.h > +++ b/include/cxl/einj.h > @@ -21,6 +21,7 @@ int einj_cxl_available_error_type_show(struct seq_file *m, void *v); > int einj_cxl_inject_error(struct pci_dev *dport_dev, u64 type); > int einj_cxl_inject_rch_error(u64 rcrb, u64 type); > bool einj_cxl_is_initialized(void); > +void einj_cxl_register_ready_cb(void (*cb)(void)); > #else /* !IS_ENABLED(CONFIG_ACPI_APEI_EINJ_CXL) */ > static inline int einj_cxl_available_error_type_show(struct seq_file *m, > void *v) > @@ -39,6 +40,8 @@ static inline int einj_cxl_inject_rch_error(u64 rcrb, u64 type) > } > > static inline bool einj_cxl_is_initialized(void) { return false; } > + > +static inline void einj_cxl_register_ready_cb(void (*cb)(void)) { } > #endif /* CONFIG_ACPI_APEI_EINJ_CXL */ > > #endif /* EINJ_CXL_H */ > > base-commit: bc35965f6940a9bf834d54187b6088b8eb09206d > -- > 2.25.1 > > >