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=52.101.85.43 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796230286; b=2yT4o2hNgczSdJqppjSHy0A1Xv+2hprKZyakCXdpMzO8X8P+6fqrekRxzv5OKUmBTAkT 0KWl3eYNLWtGYxx9gTxPGCTOrUrRgDqsBP8jRcwg12IV+Lv+/wEVW52V6fwmynkOyGbpE k7+DhqQNVdSuSdanWMEuJ0S8YxY73CRg7G4H8q7WRA0uw6ZvQO/7X/6MvuFgOd9piXsRK dwAEetlVQBQaZLPVrCQhunLSeXNy7Nm776x8t5IcnZP1NjVlR/UZ+7FNDdWXAsnAF+NLg +wdq8ElgYM9KNZqzqmQ1YkDCDEZJDt48kH1TVwNX5AHaUAfKu5gQq85zk+xreS2GorA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796230286; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-LD-Processed: 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-OriginatorOrg: 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; bh=YNC3FRJcqUoE0vpVfnTd7ARVBXMKBO0DwLpc3Hpcnr4=; b=5mLdHvTGYn48k4p1/i181Spyy5FzAzZo+WUaQ1VubIoC/qiiHkCZGhwnhRWpDXB1i+z9 1/AelVAqYiTpOuiulhjihFB8h+ZHEaZZr/rL/bed/Mo0bHUt4T0tHJN8aAe1mes8fAXFh lHZ4OUrMCiBXtI9wubgzrHP8Gnz8k+9pouwsSoqlMnFp5Hpa2nzn9q9F7vq9fm9G3YkQn NfCOEzXahvToOnoYDaUMsBy7tnJFmkpETkxS74MJB0ubJqnD0NSpGtjUgUMOzU6ULNRqR wu3ZfDe9g3U6hRCgHhvU/2OzP9oLqzQY02/R2AJyAs9POXAw7k4V5MiXhxH79OHlEQA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Qiks1j5r; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.85.43 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010043.outbound.protection.outlook.com [52.101.85.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FB08606A33A; Wed, 2 Dec 2026 16:51:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1FB08606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Qiks1j5r ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ntZbgX1idUtIQlY/EOd1L6mEoacCDjNCi8yPXXYDTMpTCH277rEL1UY6Amu8KVZ7cV8199Xjmp0pD1lP+a7z/y5EwOSfFXkRjeWhgZ1a1c0Xt6TF8mZGDK2F1yDA8zpEWoKDCnyUUotzTnZV9GcLhHAcxupkVP2ZtIUt1jaYJv65W6yFuiLm0HhPg08Bu4gXuViu13ZC18S+yv/ZL/10xqy+M5O7nVd46vHubDOkUnDSElhuFT+ZceXYm0BfL5o6tKYgXIIMclGtbLmIHgVXzp5A7VwgtXuq2XnA+slkqLr2sdw6uUJmLOgSiNGS2GZUrs61AAEing8UFJlOhJ6V8Q== 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=YNC3FRJcqUoE0vpVfnTd7ARVBXMKBO0DwLpc3Hpcnr4=; b=kUFvAM8ucP6qPx2HcYkBi/7qTOPpjfLiy40CKztXenRrg5FtdBSaIYwcxBUALpszjXfPv5ofoIZfCRHkU2tlybtex6YeaEucaxrI1vZ95TinALTGCVV56CcOpG0nLoGDskc4iyaupjV583n7mZQl+370pYtpD2VJ3Kpnd/0t4N3mVfB1jAY3Xlv5mmjBD9lwMEnHSuMyPlmLinFnOiOdPIYdpSeCNb/+CA5hPPTOAQRohJQ8+HH5J4wnYbxas8daO8YtzhN4wvn8gHYouumzxFfY2AZRrhfOEipV3faMcbjchkJDUzhaZCfCHrR+Z9NXjpR+RJtIyGrpC0f9eVwy6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YNC3FRJcqUoE0vpVfnTd7ARVBXMKBO0DwLpc3Hpcnr4=; b=Qiks1j5rfidumIeWlI/iSS6FX1m8EA53AaJ2XurUvJnqVmsQ/Ow1a9hFErDGtJuPNHhw/tXPJDbC13d53kn7qm3XS/D+udadouP/Utm46z+6xeWWRfe1wrZXcfFdjWxjIhdR5pA1dRPWkxDTh3vWC+1SpYSv5KBX3MeDigHTavI= Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CY1PR12MB9697.namprd12.prod.outlook.com (2603:10b6:930:107::6) by CH9PR12MB917979.namprd12.prod.outlook.com (2603:10b6:610:333::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.11; Wed, 2 Dec 2026 16:51:19 +0000 Received: from CY1PR12MB9697.namprd12.prod.outlook.com ([fe80::3a41:55a0:8203:596d]) by CY1PR12MB9697.namprd12.prod.outlook.com ([fe80::3a41:55a0:8203:596d%4]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 16:51:19 +0000 Message-ID: <890ceb8d-cbc2-4ef8-a8e0-5b3d242dfbb1@amd.com> Date: Wed, 2 Dec 2026 22:21:08 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/3] edac: Add Xilinx XilSEM error monitoring driver To: Rama devi Veggalam , bp@alien8.de, tony.luck@intel.com, michal.simek@amd.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, devicetree@vger.kernel.org, james.morse@arm.com, mchehab@kernel.org, rric@kernel.org, git@amd.com References: <1795313124-2138932-1-git-send-email-rama.devi.veggalam@amd.com> <1795313124-2138932-4-git-send-email-rama.devi.veggalam@amd.com> Content-Language: en-US From: "Pandey, Radhey Shyam" In-Reply-To: <1795313124-2138932-4-git-send-email-rama.devi.veggalam@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN5P287CA0043.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:25f::15) To CY1PR12MB9697.namprd12.prod.outlook.com (2603:10b6:930:107::6) X-Mailing-List: linux-edac@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: CY1PR12MB9697:EE_|CH9PR12MB917979:EE_ X-MS-Office365-Filtering-Correlation-Id: ec79aa0b-8fca-4163-c748-08df50947cb5 X-LD-Processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|366016|1800799024|7416014|376014|22082099003|18002099003|10067099003|56012099006|261102123227099003|261028144727099003|261021121427099003|261022075727099003|261022105027099003|261021123027099003|261022113327099003|261021130227099003|261026121527099003|261022115727099003|261026140227099003|261009223027099003|4143699003|5023799004|11063799006|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: 5Xns/uSPcdvaSDZaUhu3aCU/8Vgrzfw7F1NrYl1sWw+gUBgffpO3HihyjAlQoHvJGzc1Y6HXk2Ymf4Cuz2ecw2tFLtwNIE3vVCdyJdGTaqss+M7Z/wK8D3+26FdtImPuZUkXzs0CUpW889HQcHFsEBznSsr0HHM43E0+Kl2+RiS19pz9oMlG8PvMBFHF4Sl+gHZZxwttj37JC2vsvGzR0eP+JWxsvF7D96nw8FlH1FE5ITz9+n7czBjBeg89RmLBJ1YYr3O+pXRUmdjoZ09oSb32ky/N9I7hD0DEb6b27TBQVv6GkDxfRqDSqy27j1vbqiXLTZYlFnI0dJSLzPRccCwdG95ahilWh64Kr6OWTUc8NE1vqzwtfVsITtxu21ftP/DhO9BX1aAs43RnhHo5gWZ1e2DdnLpU8rwXeKwcuDA7lePGrQKN1cr77iprHU1zBMu0RGWWM7PXyITOkyMvM7kE3J/fDHCeK/RFKa5b3bTEmXaURNBpMivKyv2uELRJlSU9YCuw9jS5pHBMYfN52EPfiNF4SHoQ7xP/Lta/9xbsXRj9xTe/SRuFUztMiy9Yq4EShyHRcCfykp3VFwB3ykjFKHpI1eFfOG6ghEI8sghXxNs6geP8AVnJuW7SDGHofg7gn0PzwbA34icd1y5S4aviG33vlJTYqMHxvY8wxEg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY1PR12MB9697.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(366016)(1800799024)(7416014)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(261102123227099003)(261028144727099003)(261021121427099003)(261022075727099003)(261022105027099003)(261021123027099003)(261022113327099003)(261021130227099003)(261026121527099003)(261022115727099003)(261026140227099003)(261009223027099003)(4143699003)(5023799004)(11063799006)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eU54SlRmbEZyZWlnUDVEcG1lN0RCYno0WDk1SWhxRXdsODZhZ3hnRFFxSnZ2?= =?utf-8?B?cGxTMkUyWGtCVEdBVGpsTGE3WndLNXVVSi9nY1BTZVM5WDhWYUYxWTloZUU1?= =?utf-8?B?TlhzSjZFNStQTHYxZ2V3UjZHc2lkdkJ6VTN5NnV1cjUyU3JTdEt5QXhxam9m?= =?utf-8?B?WlpHN3VGcDNtM0U0c3U4dzBBQ21XZjJwaDREN0ZUUE9YalA4MVAzc2huVVpK?= =?utf-8?B?eUt6K2ZWeDBuYlN3SFZSSTVUK0ZmM0I5aGxOS0tTQ05MLzBTOWZzT2xseEs5?= =?utf-8?B?S1NTNk1ZdFVKZjQ2Uk1sR0VLN1BsZHlSYzNBRkdHeDRXR1YwN2Era3JKSmRp?= =?utf-8?B?MVlseVo0UUhndVREWVd1WE0wcWFLdWdpeERrakc5ZkF5eSsvdmNWK3lnanFz?= =?utf-8?B?QnF2MnVqVkxOWVlkU2dlSENtUnRzeWt2RDgzT2NqS2dhTWh4N2YvL2Z4Mkc0?= =?utf-8?B?K2cvZnVWQzRnOUxkMVJFVFI1dEMvWVo2c2VLbkx4UTNiR0NKWmJqWjVJb3pl?= =?utf-8?B?ekpFOTVYaXZhQXM4YmQ3dXhZRDdVcS9ZRTdOVkUzTVlyaENjRUhtRUVCSHZ1?= =?utf-8?B?Y2JXMHBITmg0TXdtdW9nb3p1U3BYbU1LN1hzM0hkSDBaODJlNXJMbkM1WFJy?= =?utf-8?B?NlgyMzE5dVEybEhvRDZ1YW9XVVBaRXVQZjBxekVHc2JlOTRPUExBKzNSc3ZJ?= =?utf-8?B?b3BOS0phV0R5ZVpEZjB0LytSK0ZUV0Q2aVFUY3QzeTc4eTVGMXJ4SWdncU9l?= =?utf-8?B?aDV3YmcvRHFTOGowbHVUM1JDcUw5U1hJUzRRU1JGWW9nK2hsaVBLYWxDQzhQ?= =?utf-8?B?REU1ZUpVSEFVTjlEZXF1YWJPZzF5aEpSQUdWN2VwYmhIQ1pXQnBuV3puMHBt?= =?utf-8?B?c2ZtYWpUaEdOZXBaZWVtTDRoSzFWcStnSmV0U0ZwSU0zMmwyaE9INGF5ejhF?= =?utf-8?B?SGxsS0hqVVdFdm9nR1BqMmgvTG5UVkpHQzFaQnRqRXU0N1FSQTl6cUtCcUJl?= =?utf-8?B?V0hPTVJjZk9VSE1Kb3ZtQVFtVHF5d0JFYTJQemszcW1wL3QwRnNoNjdpcjZ0?= =?utf-8?B?eU1sK1FJdGVScFNjRlpZYmpnaUJOSjBzKzlSMnpzMkhSdGxCYy94L0RHL25z?= =?utf-8?B?Nlg3am9zczRnZWhHMERVMENtVHNJTStjdHl3dm5QLzZMUklQczRCYVpEY0tR?= =?utf-8?B?ZVVIUFYzdDR1eDNBdVlCWWdSVmM0L2I4ZTFZbUlXck5BWmkrKy9qNGlrNUZ0?= =?utf-8?B?VUovYUFXeEh3VXE3VkZGQk16dnl5UU1IYTBIUlBqNHVhcUVieW11ZWRJNTgr?= =?utf-8?B?b21keHJidS93MlFydGE3empJdVYwU0hTb2Rmd0lPTDBXVkxFZFdDbys1VmFN?= =?utf-8?B?V3BOSFZ3azVvUzhpVUtuZlg4S1N4WVd2QTc3RlRDUlB1WnJUKzBHOElhVk0y?= =?utf-8?B?bTRuZk15UEQ0ZHVIME5NSUFEMjYxdHQrNTNEOEhnTFU0blEvNm9OR2F3b2ha?= =?utf-8?B?N2dtVjk1UzdZbXF4dW5UbExIZFBpYkFMTjVtemc3QTlKVk55KyswWWZKUWpt?= =?utf-8?B?NUpqVlBsdVNOYXhqTzdyNGpKOW1hN1ArSmY0T25SUG1yVFkrYzJJWDlQK1Iw?= =?utf-8?B?ZnZYSVNWSnRZeFZ2NXVWbUtyZXl0dTFxZnc3dHFyR3VwdzNxNjVZa2JlMFh2?= =?utf-8?B?QllDTURpSVFwcHpkMWl3Z1ZxU0tmQS9GWUdhaE5QTjBlQytUTXg4VVpUS0lU?= =?utf-8?B?S3hzOEx1em5oS3k0emFLLzVRQlhTdGVUby9CYlZTa09Ccnp3ejdCdFlxaHRz?= =?utf-8?B?UFdDUHVLL2g2cGdvVVdyMDI4bU84WG1jbW9RYXVkV25ja2ltWWJYNEdHZ0Z6?= =?utf-8?B?Yk01SEtUMWNETkNVZE8yQzBSRUN3RFg1a0ExMTdVR3plTnBiTG1QRFBlQmx3?= =?utf-8?B?bWZmZEt5cVJxV0Z4aWlJN1RnT2ZhanhaQmE3Q01tQ1laTWJ4MW5zWnhjOU5h?= =?utf-8?B?aEVNYW84YWVxWS8yUGxVQURWWk5jVGpGQlJKZjBaRk5GNVN3S0k5S1M4NDVL?= =?utf-8?B?UFFPclovYmE0cEVlNmZpQmt1bXBMTnJ5NzRQQlJBQ1hldWFoQXNybHRqeGNO?= =?utf-8?B?anF6eEF6SVozMnBzWm1NQmhUdE9aTG1Hc0Eyb1d3RUR4eEgrbDZROTZwMVRZ?= =?utf-8?B?SzV6aWlEZWYwN3BLUjY5UXdDb2lObDhkMjA5cEhBdCtzaTFsbjQxYTEwakJV?= =?utf-8?B?TEhKZmpWVitYYXZLWGZ0U05Lcjc5dXJUYnI4MUxOY0ZuM0lRclloVmxybFRy?= =?utf-8?Q?5wEFUkhfJrflmBDQID?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec79aa0b-8fca-4163-c748-08df50947cb5 X-MS-Exchange-CrossTenant-AuthSource: CY1PR12MB9697.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 16:51:19.3503 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TVfee0pH2MDUcBl84iJBB8WewRPOjpZk+ZCXFxq8u0S+Tks/ue7GmY1FBlQELU3B X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH9PR12MB917979 On 11/22/2026 7:35 AM, Rama devi Veggalam wrote: Use EDAC/ as prefix. > Add an EDAC driver for the Xilinx Soft Error Mitigation (XilSEM) block > on Versal and Versal NET devices. It reports correctable and > uncorrectable CRAM and NPI errors, received through the firmware event > notification interface, to the EDAC core, and provides sysfs attributes > under /sys/devices/system/edac/xilsem/ to control the scans, inject Not needed to explain path in commit description. > CRAM errors and read the status. > > Only monolithic (single-SLR) devices are supported. The driver cannot Explain single SLR device. > tell at probe time whether a device has more than one SLR, because the > firmware interface has no query for it, so this is stated in the > binding and the ABI and is not checked by the driver. > > The PLM raises one event per corrected CRAM frame, which can hold up to > four CEs, and it can merge events raised back to back. The driver > therefore reports the CEs from the CE count register, which gives the > number of new CEs, and reads their locations from the PLM log, which > keeps the last seven. A bitstream reload clears the count, and the > driver detects it when the new count is below the saved one. It cannot > detect a reload once the count has reached the saved value, as the RTCA > has no reload indicator. > > The XilSEM interfaces are exposed through sysfs rather than debugfs > because they are intended for runtime use on production systems and are > not limited to debugging. They allow applications to initiate on-demand > CRAM scans, retrieve scan status, configuration, and frame ECC > information, and inject CRAM errors to verify the scan and > error-reporting paths while the system is running. > > The result of the most recent request is maintained per device and > returned on the subsequent read of the corresponding file. Concurrent > users are responsible for serializing access, as documented in the ABI > file. from where is this limitation coming and can't it be fixed? > > Add the EDAC_XILSEM Kconfig option, the Makefile entry, the ABI > documentation and a MAINTAINERS entry. Trim the commit description. > > Signed-off-by: Rama devi Veggalam > --- > Changes in v5: > - Made XilSEM a separate driver, xilsem_edac, instead of an additional > EDAC device in versal_edac. > - Made Kconfig depend on ZYNQMP_FIRMWARE && XLNX_EVENT_MANAGER. > - Dropped the SLR ID from the sysfs output. > - Removed the duplicate command enum and unused counters and fields. > - Rejected extra values in written input, and accepted repeated spaces > and tabs. > - Reported every CRAM CE since the last event, each with its own > location. > - Stopped printing unused data for CRAM uncorrectable errors. > - Moved the error event registration to the end of probe. > - Updated the ABI: -EIO on firmware errors, corrected frame ECC > example. > - Documented that only monolithic devices are supported, and why the > interfaces use sysfs. A general feedback- there are comments spanning multiple lines. Please make it concise in next version. > > Changes in v4: > - Registered a second, independent EDAC device for XilSEM alongside > the existing DDRMC device, under the same driver module. > - Added drivers/edac/xsem_edac.h with XilSEM register/structure > definitions. > - Added xsem_edac_probe()/xsem_edac_remove() and 8 xsem_* sysfs > attributes, with matching ABI docs in sysfs-devices-versal-edac > (same commit). > - Updated Kconfig help text and MAINTAINERS for the new files/ > maintainer. > > Changes in v3: > - Merged Versal XilSem edac with Versal edac > > Changes in v2: > - Patch created on top of dependent patch series > "enhance zynqmp_pm_get_family_info()" > - Fixed maximum length warning in patch description > - Added details for eprobe_defer conditions > - Updated copyright information > - Removed ARCH_ZYNQMP in dependent list of XilSEM Kconfig > - Added error code for invalid versal device type > - Removed redundant sysfs details in function headers > - Included MAINTAINERS to this patch > - Added more description in commit message > - Removed print for probe success > - Removed function comments for xsem_edac_remove() > --- > .../ABI/testing/sysfs-devices-xilsem-edac | 188 +++++ > MAINTAINERS | 12 + > drivers/edac/Kconfig | 16 + > drivers/edac/Makefile | 1 + > drivers/edac/xilsem_edac.c | 859 +++++++++++++++++++++ > drivers/edac/xilsem_edac.h | 131 ++++ > 6 files changed, 1207 insertions(+) > create mode 100644 Documentation/ABI/testing/sysfs-devices-xilsem-edac > create mode 100644 drivers/edac/xilsem_edac.c > create mode 100644 drivers/edac/xilsem_edac.h > > diff --git a/Documentation/ABI/testing/sysfs-devices-xilsem-edac b/Documentation/ABI/testing/sysfs-devices-xilsem-edac > new file mode 100644 > index 0000000..2677215 > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-devices-xilsem-edac > @@ -0,0 +1,188 @@ > +What: /sys/devices/system/edac/xilsem/xsem_scan_control_ops > +Date: November 2026 > +Contact: rama.devi.veggalam@amd.com > +Description: > + It is a read/write file. > + Writing to this file causes the software to initiate a > + request to the firmware for doing requested scan operation in > + Configuration RAM (CRAM) or NPI of Versal and Versal NET monolithic devices. > + User needs to provide the scan operation id (init, start, > + stop). > + Write format: , in decimal or 0x-prefixed > + hex. Extra values are rejected with -EINVAL. > + The scan operation id values are as given below: > + 1 - Initialize the scan > + 2 - Start CRAM scan > + 3 - Stop CRAM scan > + 5 - Start NPI scan > + 6 - Stop NPI scan > + 7 - Inject NPI error in first descriptor > + Id 4 (CRAM error injection) is reserved for the separate > + xsem_cram_injecterr attribute below; writing 4, or any other value not > + listed above, returns -EINVAL. > + > + When read, it shows the current scan status with error code. > + The format is [header][error code][status word 1] > + [status word 2][status word 3], where header is > + (0x10300 | operation Id) and the three trailing status words > + are additional firmware status data returned alongside the > + error code. > + The different error codes are as given below: > + ========== ===== > + Error Code Cause > + ========== ===== > + 0x0 Scan operation success > + 0x1 Failure in NPI scan > + 0x80 Calibration timeout > + 0x2000 Internal error > + 0x500000 CRAM initialization not yet done > + 0x600000 Start scan failed > + 0x700000 Stop scan failed > + 0xF00000 Active CRC/UE error > + 0x1000000 ECC/CRC error detected during calibration > + ========== ===== > + > + Note: the result read back is that of the last command the > + firmware executed for this attribute, held in state shared by > + every opener of this file, not per-caller state. If the firmware > + call itself fails, the stored result is cleared and reads back as > + all zeros, including the header. A valid result always has a non-zero > + header. A request that the driver rejects (invalid input) leaves the > + previous result unchanged. Concurrent writers must serialize their > + own access if they need a guaranteed request/response pairing. > + A write fails with -EIO if the firmware reports an error for the > + request; the error code can then be read back from this file. > + > +What: /sys/devices/system/edac/xilsem/xsem_cram_injecterr > +Date: November 2026 > +Contact: rama.devi.veggalam@amd.com > +Description: > + It is a read/write file. > + Writing to this file causes the software to initiate a > + request to the firmware for doing error injection in > + Configuration RAM (CRAM) of Versal and Versal NET monolithic devices. > + User needs to provide the location details of CRAM > + (frame, qword, bit number, row number) to inject the error. > + Write format: , > + space-separated, each value in decimal or 0x-prefixed hex. > + Extra values are rejected with -EINVAL. > + The row number must be in the range 0 to 4; a larger value returns > + -EINVAL. > + When read, it shows the current error injection status. The > + format is [header][error code]. > + Example: [0x10304][0x0] > + The different error codes are as given below: > + ========== ===== > + Error Code Cause > + ========== ===== > + 0x0 Error injection success > + 0x2000 Internal NULL pointer error > + 0x500000 CRAM initialization not yet done > + 0x800000 Invalid row > + 0x900000 Invalid qword > + 0xA00000 Invalid bit > + 0xB00000 Invalid frame address > + 0xC00000 Unexpected bits flipped > + 0xD00000 Masked bit > + 0xE00000 Invalid block type > + 0xF00000 Active CRC/UE error in CRAM > + ========== ===== > + > + Note: the result read back is that of the last command the > + firmware executed for this attribute, held in state shared by > + every opener of this file, not per-caller state. If the firmware > + call itself fails, the stored result is cleared and reads back as > + all zeros, including the header. A valid result always has a non-zero > + header. A request that the driver rejects (invalid input) leaves the > + previous result unchanged. Concurrent writers must serialize their > + own access if they need a guaranteed request/response pairing. > + A write fails with -EIO if the firmware reports an error for the > + request; the error code can then be read back from this file. > + > +What: /sys/devices/system/edac/xilsem/xsem_cram_framecc_read > +Date: November 2026 > +Contact: rama.devi.veggalam@amd.com > +Description: > + It is a read/write file. > + Writing to this file causes the software to initiate a > + request to the firmware for reading frame ECC values in > + Configuration RAM (CRAM) of Versal and Versal NET monolithic devices. > + User needs to provide the location details of CRAM > + (frame, row number) to read the ECC values. > + Write format: , space-separated, each > + value in decimal or 0x-prefixed hex. Extra values are rejected with > + -EINVAL. > + The row number must be in the range 0 to 4; a larger value returns > + -EINVAL. > + When read, it shows the ECC values for the requested frame. > + The format is
> + Example: > + Read Frame ECC Cmd: [0x3030b] > + Frame ECC Word_0: [0x52f245] > + Frame ECC Word_1: [0x7c5a6b] > + Cmd Status: [0x0] > + > + Note: the result read back is that of the last command the > + firmware executed for this attribute, held in state shared by > + every opener of this file, not per-caller state. If the firmware > + call itself fails, the stored result is cleared and reads back as > + all zeros, including the header. A valid result always has a non-zero > + header. A request that the driver rejects (invalid input) leaves the > + previous result unchanged. Concurrent writers must serialize their > + own access if they need a guaranteed request/response pairing. > + A write fails with -EIO if the firmware reports an error for the > + request; the error code can then be read back from this file. > + > +What: /sys/devices/system/edac/xilsem/xsem_read_config > +Date: November 2026 > +Contact: rama.devi.veggalam@amd.com > +Description: > + It is a read/write file. > + Writing to this file causes the software to initiate a > + request to the firmware for reading Xilsem configuration. > + Any value written triggers the read; the value is ignored. > + When read, it shows the CRAM and NPI scan configuration. > + The format is
> + Example: Read Config Cmd: [0x30309] > + CRAM Scan Config: [0x2e] > + NPI Scan Config: [0x5016] > + Cmd Status: [0x0] > + > + Note: the result read back is that of the last command the > + firmware executed for this attribute, held in state shared by > + every opener of this file, not per-caller state. If the firmware > + call itself fails, the stored result is cleared and reads back as > + all zeros, including the header. A valid result always has a non-zero > + header. A request that the driver rejects (invalid input) leaves the > + previous result unchanged. Concurrent writers must serialize their > + own access if they need a guaranteed request/response pairing. > + A write fails with -EIO if the firmware reports an error for the > + request; the error code can then be read back from this file. > + > +What: /sys/devices/system/edac/xilsem/xsem_read_status > +Date: November 2026 > +Contact: rama.devi.veggalam@amd.com > +Description: > + It is a read/write file. > + Writing to this file causes the software to initiate a > + request to read the Xilsem status. User needs to provide > + the module id for status. The module id values are as given below: > + 1 - CRAM scan > + 2 - NPI scan > + Write format: , in decimal or 0x-prefixed hex. Any other > + value returns -EINVAL. > + When read, it shows the status of the requested module. The > + format is always [value 0][value 1][value 2]. > + For CRAM: value 0 is status, value 1 is CE count, value 2 is > + always 0 (unused for this module). > + Example: [0x10005][0x0][0x0] > + For NPI: value 0 is status, value 1 is scan count, value 2 is > + heartbeat count. > + Example: [0xA01][0x10][0x1] > + > + Note: the result read back is that of the last status read for this > + attribute, held in state shared by every opener of this file, not > + per-caller state. A request that the driver rejects (invalid module > + id) leaves the previous result unchanged. Concurrent writers must > + serialize their own access if they need a guaranteed > + request/response pairing. > diff --git a/MAINTAINERS b/MAINTAINERS > index 3ed1991..71aa9d0 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -30817,6 +30817,18 @@ F: drivers/dma/xilinx/xdma.c > F: include/linux/dma/amd_xdma.h > F: include/linux/platform_data/amd_xdma.h > > +XILINX XILSEM EDAC DRIVER > +M: Rama devi Veggalam > +R: Radhey Shyam Pandey > +L: linux-edac@vger.kernel.org > +S: Maintained > +F: Documentation/ABI/testing/sysfs-devices-xilsem-edac > +F: Documentation/devicetree/bindings/edac/xlnx,xilsem.yaml > +F: drivers/edac/xilsem_edac.c > +F: drivers/edac/xilsem_edac.h > +F: drivers/firmware/xilinx/zynqmp-sem.c > +F: include/linux/firmware/xlnx-zynqmp-sem.h > + > XILINX ZYNQMP DPDMA DRIVER > M: Laurent Pinchart > L: dmaengine@vger.kernel.org > diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig > index 4c70729..a066c87 100644 > --- a/drivers/edac/Kconfig > +++ b/drivers/edac/Kconfig > @@ -569,6 +569,22 @@ config EDAC_VERSAL > Support injecting both correctable and uncorrectable errors > for debugging purposes. > > +config EDAC_XILSEM > + tristate "Xilinx XilSEM (Soft Error Mitigation)" > + depends on (ZYNQMP_FIRMWARE && XLNX_EVENT_MANAGER) || COMPILE_TEST > + help > + Support for monitoring the XilSEM (Soft Error Mitigation) soft-error > + detection and correction block on Xilinx Versal and Versal NET, which covers > + configuration memory in the programmable logic (PL) fabric and the > + NoC Programming Interface (NPI) interconnect. > + > + Report correctable and uncorrectable CRAM and NPI errors, and > + support injecting both error types, which user applications can use > + to run on-demand CRAM scan tests and which also help with debugging. > + > + Only monolithic Versal and Versal NET devices are supported; > + multi-SLR (SSIT) devices are not. > + > config EDAC_LOONGSON > tristate "Loongson Memory Controller" > depends on LOONGARCH && ACPI > diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile > index 4020ea6..8f14990 100644 > --- a/drivers/edac/Makefile > +++ b/drivers/edac/Makefile > @@ -90,6 +90,7 @@ obj-$(CONFIG_EDAC_DMC520) += dmc520_edac.o > obj-$(CONFIG_EDAC_NPCM) += npcm_edac.o > obj-$(CONFIG_EDAC_ZYNQMP) += zynqmp_edac.o > obj-$(CONFIG_EDAC_VERSAL) += versal_edac.o > +obj-$(CONFIG_EDAC_XILSEM) += xilsem_edac.o > obj-$(CONFIG_EDAC_LOONGSON) += loongson_edac.o > obj-$(CONFIG_EDAC_VERSALNET) += versalnet_edac.o > obj-$(CONFIG_EDAC_CORTEX_A72) += a72_edac.o > diff --git a/drivers/edac/xilsem_edac.c b/drivers/edac/xilsem_edac.c > new file mode 100644 > index 0000000..c71ddee > --- /dev/null > +++ b/drivers/edac/xilsem_edac.c > @@ -0,0 +1,859 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Xilinx XilSEM EDAC driver > + * Copyright (C) 2023 - 2026, Advanced Micro Devices, Inc. > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "edac_module.h" > +#include "xilsem_edac.h" > + > +#define EDAC_DEVICE "Xilsem" > + > +/** > + * xsem_scan_control_show - Shows scan control operation status > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * > + * Shows the scan control operations status > + * Return: Number of bytes copied. > + */ > +static ssize_t xsem_scan_control_show(struct edac_device_ctl_info *dci, char *data) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + int ret; > + > + mutex_lock(&priv->lock); > + ret = scnprintf(data, PAGE_SIZE, "[0x%x][0x%x][0x%x][0x%x][0x%x]\n", > + priv->scan_ctrl_status.hdr, priv->scan_ctrl_status.status, > + priv->scan_ctrl_status.status1, priv->scan_ctrl_status.status2, > + priv->scan_ctrl_status.status3); > + mutex_unlock(&priv->lock); > + > + return ret; > +} > + > +/** > + * xsem_store_prep - Copy a sysfs store() write into a kernel buffer > + * @data: Pointer to user data > + * @count: Number of bytes written > + * > + * Return: Pointer to a NUL-terminated kernel copy of data, to be freed by > + * the caller with kfree(), or NULL on allocation failure. > + */ > +static char *xsem_store_prep(const char *data, size_t count) > +{ > + char *kern_buff; > + > + /* > + * Allocate one extra byte for the NUL terminator: strscpy() copies at > + * most (size-1) bytes from data and always writes the terminator at > + * kern_buff[size-1]. A "count"-sized buffer would silently drop the > + * last byte of a full, non-newline-terminated "count"-byte write. > + */ > + kern_buff = kzalloc(count + 1, GFP_KERNEL); > + if (!kern_buff) > + return NULL; > + > + strscpy(kern_buff, data, count + 1); > + > + return kern_buff; > +} > + > +/** > + * xsem_parse_token - Parse the next space- or tab-separated token as an unsigned int > + * @inbuf: Pointer to the remaining unparsed buffer, advanced past the > + * consumed token > + * @val: Output value > + * > + * Sequences of spaces and tabs between tokens are skipped. > + * > + * Return: 0 on success, -EINVAL if there is no token left or it is not a > + * valid unsigned integer. > + */ > +static int xsem_parse_token(char **inbuf, u32 *val) > +{ > + char *tok; > + > + do { > + tok = strsep(inbuf, " \t"); > + } while (tok && !*tok); > + > + if (!tok) > + return -EINVAL; > + > + if (kstrtouint(tok, 0, val)) > + return -EINVAL; > + > + return 0; > +} > + > +/** > + * xsem_parse_end - Check that no unparsed input is left > + * @inbuf: Remaining unparsed buffer, as left by xsem_parse_token() > + * > + * Return: 0 if only whitespace is left, -EINVAL if there are extra values. > + */ > +static int xsem_parse_end(char *inbuf) > +{ > + if (!inbuf) > + return 0; > + > + return *skip_spaces(inbuf) ? -EINVAL : 0; > +} > + > +/** > + * xsem_scan_control_store - Set scan control operation > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * @count: read the size bytes from buffer > + * > + * User-space interface for doing Xilsem scan operations > + * (initialization, start, stop) > + * Return: count argument if request succeeds, else error code > + */ > +static ssize_t xsem_scan_control_store(struct edac_device_ctl_info *dci, > + const char *data, size_t count) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + char *kern_buff, *inbuf; > + u32 cmd; > + int ret; > + > + kern_buff = xsem_store_prep(data, count); > + if (!kern_buff) > + return -ENOMEM; > + > + inbuf = kern_buff; > + > + /* Read Scan command */ > + ret = xsem_parse_token(&inbuf, &cmd); > + if (ret) > + goto err; > + > + ret = xsem_parse_end(inbuf); > + if (ret) > + goto err; > + > + mutex_lock(&priv->lock); > + ret = zynqmp_pm_xilsem_cntrl_ops(cmd, 0, &priv->scan_ctrl_status); > + mutex_unlock(&priv->lock); > +err: > + kfree(kern_buff); > + > + if (ret) > + return ret; > + > + return count; > +} > + > +/** > + * xsem_cram_injecterr_show - Shows CRAM error injection status > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * > + * Shows CRAM error injection status > + * Return: Number of bytes copied. > + */ > +static ssize_t xsem_cram_injecterr_show(struct edac_device_ctl_info *dci, char *data) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + int ret; > + > + mutex_lock(&priv->lock); > + ret = scnprintf(data, PAGE_SIZE, "[0x%x][0x%x]\n", priv->cram_errinj_status.hdr, > + priv->cram_errinj_status.status); > + mutex_unlock(&priv->lock); > + > + return ret; > +} > + > +/** > + * xsem_cram_injecterr_store - Start error injection > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * @count: read the size bytes from buffer > + * > + * User-space interface for doing CRAM error injection > + * Return: count argument if request succeeds, else error code > + */ > +static ssize_t xsem_cram_injecterr_store(struct edac_device_ctl_info *dci, > + const char *data, size_t count) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + char *kern_buff, *inbuf; > + u32 row, frame, qword, bitloc; > + int ret; > + > + kern_buff = xsem_store_prep(data, count); > + if (!kern_buff) > + return -ENOMEM; > + > + inbuf = kern_buff; > + > + /* Read Frame number */ > + ret = xsem_parse_token(&inbuf, &frame); > + if (ret) > + goto err; > + > + /* Read Qword number */ > + ret = xsem_parse_token(&inbuf, &qword); > + if (ret) > + goto err; > + > + /* Read Bit location */ > + ret = xsem_parse_token(&inbuf, &bitloc); > + if (ret) > + goto err; > + > + /* Read Row number */ > + ret = xsem_parse_token(&inbuf, &row); > + if (ret) > + goto err; > + > + ret = xsem_parse_end(inbuf); > + if (ret) > + goto err; > + > + if (row > MAX_CFRAME_ROW_ID) { > + ret = -EINVAL; > + goto err; > + } > + > + mutex_lock(&priv->lock); > + ret = zynqmp_pm_xilsem_cram_err_inj(0, frame, qword, bitloc, row, > + &priv->cram_errinj_status); > + mutex_unlock(&priv->lock); > +err: > + kfree(kern_buff); > + > + if (ret) > + return ret; > + > + return count; > +} > + > +/** > + * xsem_cram_framecc_read_show - Shows CRAM Frame ECC > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * > + * Shows CRAM Frame ECC value > + * Return: Number of bytes copied. > + */ > +static ssize_t xsem_cram_framecc_read_show(struct edac_device_ctl_info *dci, > + char *data) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + int offset = 0; > + > + mutex_lock(&priv->lock); > + offset += scnprintf(data + offset, PAGE_SIZE - offset, > + "Read Frame ECC Cmd: [0x%x]\n", priv->cram_frame_ecc.hdr); > + offset += scnprintf(data + offset, PAGE_SIZE - offset, > + "Frame ECC Word_0: [0x%x]\n", priv->cram_frame_ecc.ecc0); > + offset += scnprintf(data + offset, PAGE_SIZE - offset, > + "Frame ECC Word_1: [0x%x]\n", priv->cram_frame_ecc.ecc1); > + offset += scnprintf(data + offset, PAGE_SIZE - offset, > + "Cmd Status: [0x%x]\n", priv->cram_frame_ecc.status); > + mutex_unlock(&priv->lock); > + > + return offset; > +} > + > +/** > + * xsem_cram_framecc_read_store - Read CRAM Frame ECC > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * @count: read the size bytes from buffer > + * > + * User-space interface for reading CRAM frame ECC > + * Return: count argument if request succeeds, else error code > + */ > +static ssize_t xsem_cram_framecc_read_store(struct edac_device_ctl_info *dci, > + const char *data, size_t count) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + char *kern_buff, *inbuf; > + u32 frameaddr, row; > + int ret; > + > + kern_buff = xsem_store_prep(data, count); > + if (!kern_buff) > + return -ENOMEM; > + > + inbuf = kern_buff; > + > + /* Read Frame address */ > + ret = xsem_parse_token(&inbuf, &frameaddr); > + if (ret) > + goto err; > + > + /* Read Row number */ > + ret = xsem_parse_token(&inbuf, &row); > + if (ret) > + goto err; > + > + ret = xsem_parse_end(inbuf); > + if (ret) > + goto err; > + > + if (row > MAX_CFRAME_ROW_ID) { > + ret = -EINVAL; > + goto err; > + } > + > + mutex_lock(&priv->lock); > + ret = zynqmp_pm_xilsem_cram_read_ecc(0, frameaddr, row, &priv->cram_frame_ecc); > + mutex_unlock(&priv->lock); > +err: > + kfree(kern_buff); > + > + if (ret) > + return ret; > + > + return count; > +} > + > +/** > + * xsem_read_status_show - Shows CRAM & NPI scan status > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * > + * Shows CRAM & NPI scan status > + * Return: Number of bytes copied. > + */ > +static ssize_t xsem_read_status_show(struct edac_device_ctl_info *dci, char *data) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + int ret; > + > + mutex_lock(&priv->lock); > + ret = scnprintf(data, PAGE_SIZE, "[0x%x][0x%x][0x%x]\n", > + priv->xilsem_status[0], priv->xilsem_status[1], > + priv->xilsem_status[2]); > + mutex_unlock(&priv->lock); > + > + return ret; > +} > + > +/** > + * xsem_read_status_store - Read CRAM & NPI scan status > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * @count: read the size bytes from buffer > + * > + * User-space interface for reading Xilsem status > + * Return: count argument if read succeeds, else error code > + */ > +static ssize_t xsem_read_status_store(struct edac_device_ctl_info *dci, > + const char *data, size_t count) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + unsigned long flags; > + u32 module; > + > + if (kstrtouint(data, 0, &module)) > + return -EINVAL; > + > + if (module != CRAM_MOD_ID && module != NPI_MOD_ID) { > + edac_printk(KERN_ERR, EDAC_DEVICE, "Invalid module %u\n", module); > + return -EINVAL; > + } > + > + mutex_lock(&priv->lock); > + /* > + * CRAM_STS_INFO_OFFSET/CRAM_CE_COUNT_OFFSET (CRAM_MOD_ID) and > + * priv->baseaddr's base register (NPI_MOD_ID) are also read from > + * hardirq context by xsem_geterror_info() via xsem_err_callback(). > + * priv->lock is a mutex and provides no protection against that IRQ > + * preempting this critical section on the same CPU, so take the > + * same irq-safe cnt_lock xsem_err_callback() holds around its MMIO > + * reads to keep this snapshot consistent. > + */ > + raw_spin_lock_irqsave(&priv->cnt_lock, flags); > + if (module == CRAM_MOD_ID) { > + priv->xilsem_status[0] = readl(priv->baseaddr + CRAM_STS_INFO_OFFSET); > + priv->xilsem_status[1] = readl(priv->baseaddr + CRAM_CE_COUNT_OFFSET); > + priv->xilsem_status[2] = 0; > + } else { > + priv->xilsem_status[0] = readl(priv->baseaddr); > + priv->xilsem_status[1] = readl(priv->baseaddr + NPI_SCAN_COUNT); > + priv->xilsem_status[2] = readl(priv->baseaddr + NPI_SCAN_HB_COUNT); > + } > + raw_spin_unlock_irqrestore(&priv->cnt_lock, flags); > + mutex_unlock(&priv->lock); > + > + return count; > +} > + > +/** > + * xsem_read_config_show - Shows CRAM & NPI configuration > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * > + * Shows CRAM & NPI configuration > + * Return: Number of bytes copied. > + */ > +static ssize_t xsem_read_config_show(struct edac_device_ctl_info *dci, char *data) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + int offset = 0; > + > + mutex_lock(&priv->lock); > + offset += scnprintf(data + offset, PAGE_SIZE - offset, "Read Config Cmd: [0x%x]\n", > + priv->xilsem_cfg.hdr); > + offset += scnprintf(data + offset, PAGE_SIZE - offset, "CRAM Scan Config: [0x%x]\n", > + priv->xilsem_cfg.cram_cfg); > + offset += scnprintf(data + offset, PAGE_SIZE - offset, "NPI Scan Config: [0x%x]\n", > + priv->xilsem_cfg.npi_cfg); > + offset += scnprintf(data + offset, PAGE_SIZE - offset, "Cmd Status: [0x%x]\n", > + priv->xilsem_cfg.status); > + mutex_unlock(&priv->lock); > + > + return offset; > +} > + > +/** > + * xsem_read_config_store - Read CRAM & NPI configuration > + * @dci: Pointer to the edac device struct > + * @data: Pointer to user data > + * @count: read the size bytes from buffer > + * > + * User-space interface for reading Xilsem configuration > + * Return: count argument if request succeeds, else error code > + */ > +static ssize_t xsem_read_config_store(struct edac_device_ctl_info *dci, > + const char *data, size_t count) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + int ret; > + > + mutex_lock(&priv->lock); > + ret = zynqmp_pm_xilsem_read_cfg(0, &priv->xilsem_cfg); > + mutex_unlock(&priv->lock); > + > + if (ret) > + return ret; > + > + return count; > +} > + > +/** > + * xsem_handle_error - Handle XilSem error types CE and UE > + * @dci: Pointer to the edac device controller instance > + * @p: Pointer to the xilsem error status structure > + * > + * Handles the correctable and uncorrectable error. > + */ > +static void xsem_handle_error(struct edac_device_ctl_info *dci, struct xsem_error_status *p) > +{ > + struct xsem_ecc_error_info *pinf; > + char message[XILSEM_EDAC_MSG_SIZE]; > + u32 i; > + > + for (i = 0; i < p->ce_located; i++) { > + pinf = &p->ceinfo[i]; > + snprintf(message, XILSEM_EDAC_MSG_SIZE, > + "\nXILSEM CRAM error type :%s\n" > + "\nFrame_Addr: [0x%X]\t Row_num: [0x%X]\t Bit_loc: [0x%X]\t Qword: [0x%X]\n", > + "CE", pinf->frame_addr, pinf->row_id, > + pinf->bit_loc, pinf->qword); > + edac_device_handle_ce(dci, 0, 0, message); > + } > + > + if (p->ce_unlocated) { > + snprintf(message, XILSEM_EDAC_MSG_SIZE, > + "\nXILSEM CRAM error type :%s\n" > + "\nLocation not available, log overwritten\n", "CE"); > + edac_device_handle_ce_count(dci, p->ce_unlocated, 0, 0, message); > + } > + > + /* > + * CRAM and NPI UEs are tracked in separate info structs (not one > + * shared field) and reported independently, so a callback that sees > + * both at once still reports both instead of one silently > + * overwriting the other. > + */ > + if (p->cram_ue) { > + pinf = &p->cram_ueinfo; > + snprintf(message, XILSEM_EDAC_MSG_SIZE, > + "\nXILSEM error type :%s\nstatus: [0x%X]", > + "UE (CRAM)", pinf->status); > + edac_device_handle_ue(dci, 0, 0, message); > + } > + > + if (p->npi_ue) { > + pinf = &p->npi_ueinfo; > + snprintf(message, XILSEM_EDAC_MSG_SIZE, > + "\nXILSEM error type :%s\n" > + "status: [0x%X]\nError_Info0: [0x%X]\n" > + "Error_Info1: [0x%X]", > + "UE (NPI)", pinf->status, pinf->data0, pinf->data1); > + edac_device_handle_ue(dci, 0, 0, message); > + } > +} > + > +/** > + * xsem_read_ce_log - Read one entry of the PLM correctable error log > + * @priv: Pointer to the xilsem private data > + * @slot: Log slot, 0 to XILSEM_MAX_CE_LOG_CNT - 1 > + * @info: Output error information > + */ > +static void xsem_read_ce_log(struct xsem_edac_priv *priv, u32 slot, > + struct xsem_ecc_error_info *info) > +{ > + u32 error_word_0, error_word_1; > + > + error_word_0 = readl(priv->baseaddr + CRAM_CE_ADDRL0_OFFSET + (slot * 8U)); > + error_word_1 = readl(priv->baseaddr + CRAM_CE_ADDRH0_OFFSET + (slot * 8U)); > + > + /* Frame is at 22:0 bits of SEM_CRAMERR_ADDRH0 reg */ > + info->frame_addr = FIELD_GET(CRAM_ERR_FRAME_MASK, error_word_1); > + > + /* row is at 26:23 bits of SEM_CRAMERR_ADDRH0 reg */ > + info->row_id = FIELD_GET(CRAM_ERR_ROW_MASK, error_word_1); > + > + /* bit is at 22:16 bits of SEM_CRAMERR_ADDRL0 reg */ > + info->bit_loc = FIELD_GET(CRAM_ERR_BIT_MASK, error_word_0); > + > + /* Qword is at 27:23 bits of SEM_CRAMERR_ADDRL0 reg */ > + info->qword = FIELD_GET(CRAM_ERR_QWRD_MASK, error_word_0); > +} > + > +/** > + * xsem_geterror_info - Get the current ecc error info > + * @dci: Pointer to the edac device controller instance > + * @p: Pointer to the Xilsem error status structure > + * @mask: mask indicates the error type > + * > + * Determines there is any ecc error or not > + */ > +static void xsem_geterror_info(struct edac_device_ctl_info *dci, struct xsem_error_status *p, > + u32 mask) > +{ > + struct xsem_edac_priv *priv = dci->pvt_info; > + u32 ce_total, ce_unreported, slot, i; > + > + if (mask & priv->cram_ce_mask) { > + /* Read CRAM total correctable error count */ > + ce_total = readl(priv->baseaddr + CRAM_CE_COUNT_OFFSET); > + > + /* > + * The PLM raises an event after it has updated the CE count, > + * and keeps the locations of the last XILSEM_MAX_CE_LOG_CNT > + * CEs in a circular log. One event can stand for several CEs: > + * the PLM raises one event per corrected frame, which can hold > + * up to four CEs, and it can merge events raised back to back. > + * A callback can also run after more CEs have happened. So > + * report every CE since the last report, taken from the count, > + * and report nothing if the count has not changed. > + * > + * The PLM clears the XilSEM RTCA, including the count and the > + * log, when a new bitstream is loaded, so a count below the > + * last one means the count started again from zero. A reload > + * is not detected if the count has already reached the last > + * one when the callback runs, as the RTCA has no reload > + * counter to tell it. > + */ > + if (ce_total < priv->ce_total_reported) > + ce_unreported = ce_total; > + else > + ce_unreported = ce_total - priv->ce_total_reported; > + priv->ce_total_reported = ce_total; > + > + /* Locations older than the log size have been overwritten */ > + if (ce_unreported > XILSEM_MAX_CE_LOG_CNT) { > + p->ce_unlocated = ce_unreported - XILSEM_MAX_CE_LOG_CNT; > + ce_unreported = XILSEM_MAX_CE_LOG_CNT; > + } > + > + /* CE number n (counting from 1) is logged in slot (n - 1) % log size */ > + for (i = 0; i < ce_unreported; i++) { > + slot = (ce_total - ce_unreported + i) % XILSEM_MAX_CE_LOG_CNT; > + xsem_read_ce_log(priv, slot, &p->ceinfo[i]); > + } > + p->ce_located = ce_unreported; > + } > + > + /* > + * The event manager invokes this callback once per event bit, so > + * @mask normally has a single CE or UE bit set. Each UE source keeps > + * its own cram_ueinfo/npi_ueinfo, so xsem_handle_error() reports them > + * separately even if more than one bit is set. > + */ > + if (mask & priv->cram_ue_mask) { > + p->cram_ue = true; > + p->cram_ueinfo.status = readl(priv->baseaddr + CRAM_STS_INFO_OFFSET); > + } > + if (mask & priv->npi_ue_mask) { > + p->npi_ue = true; > + p->npi_ueinfo.data0 = readl(priv->baseaddr + NPI_ERR0_INFO_OFFSET); > + p->npi_ueinfo.data1 = readl(priv->baseaddr + NPI_ERR1_INFO_OFFSET); > + p->npi_ueinfo.status = readl(priv->baseaddr); > + } > + > + if (!(mask & (priv->cram_ce_mask | priv->cram_ue_mask | priv->npi_ue_mask))) > + edac_printk(KERN_ERR, EDAC_DEVICE, "Invalid Event received %x\n", mask); > +} > + > +/** > + * xsem_err_callback - Handle Correctable and Uncorrectable errors. > + * @payload: payload data. > + * @data: controller data. > + * > + * Handles ECC correctable and uncorrectable errors. > + */ > +static void xsem_err_callback(const u32 *payload, void *data) > +{ > + struct edac_device_ctl_info *dci = (struct edac_device_ctl_info *)data; > + struct xsem_error_status stat; > + struct xsem_edac_priv *priv; > + unsigned long flags; > + u32 event; > + > + priv = dci->pvt_info; > + memset(&stat, 0, sizeof(stat)); > + /* Read payload to get the event type */ > + event = payload[2]; > + edac_printk(KERN_INFO, EDAC_DEVICE, "Event received %x\n", event); > + > + /* > + * CRAM and NPI events can invoke this callback concurrently on > + * multiple CPUs. xsem_geterror_info() reads MMIO registers that > + * xsem_read_status_store() also reads in process context. priv->lock > + * is a mutex and cannot exclude this hardirq callback, so both paths > + * take the irq-safe cnt_lock around those register reads. > + * > + * cnt_lock is also held across xsem_handle_error(). That serializes > + * the calls to edac_device_handle_ce()/ue(), which update non-atomic > + * u32 counters in the shared EDAC device info, and prevents lost > + * updates when callbacks run concurrently on multiple CPUs. > + */ > + raw_spin_lock_irqsave(&priv->cnt_lock, flags); > + xsem_geterror_info(dci, &stat, event); > + xsem_handle_error(dci, &stat); > + raw_spin_unlock_irqrestore(&priv->cnt_lock, flags); > +} > + > +static const struct edac_dev_sysfs_attribute xsem_edac_sysfs_attributes[] = { > + { > + .attr = { > + .name = "xsem_scan_control_ops", > + .mode = (0644) > + }, > + .show = xsem_scan_control_show, > + .store = xsem_scan_control_store}, > + { > + .attr = { > + .name = "xsem_cram_injecterr", > + .mode = (0644) > + }, > + .show = xsem_cram_injecterr_show, > + .store = xsem_cram_injecterr_store}, > + { > + .attr = { > + .name = "xsem_cram_framecc_read", > + .mode = (0644) > + }, > + .show = xsem_cram_framecc_read_show, > + .store = xsem_cram_framecc_read_store}, > + { > + .attr = { > + .name = "xsem_read_status", > + .mode = (0644) > + }, > + .show = xsem_read_status_show, > + .store = xsem_read_status_store}, > + { > + .attr = { > + .name = "xsem_read_config", > + .mode = (0644) > + }, > + .show = xsem_read_config_show, > + .store = xsem_read_config_store}, > + { > + .attr = {.name = NULL} > + } > +}; > + > +/** > + * xsem_edac_probe - Check controller and bind driver. > + * @pdev: platform device. > + * > + * Probe a specific controller instance for binding with the driver. > + * > + * Return: 0 if the controller instance was successfully bound to the > + * driver; otherwise, < 0 on error. > + */ > +static int xsem_edac_probe(struct platform_device *pdev) > +{ > + struct xsem_edac_priv *priv; > + void __iomem *plmrtca_baseaddr; > + struct edac_device_ctl_info *dci; > + u32 family_code; > + int rc; Follow reverse xmas style. > + > + plmrtca_baseaddr = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(plmrtca_baseaddr)) > + return PTR_ERR(plmrtca_baseaddr); > + > + dci = edac_device_alloc_ctl_info(sizeof(*priv), XILSEM_EDAC_STRNG, > + 1, XILSEM_EDAC_STRNG, 1, 0, > + edac_device_alloc_index()); > + if (!dci) { > + edac_printk(KERN_ERR, EDAC_DEVICE, "Unable to allocate EDAC device\n"); > + return -ENOMEM; > + } > + > + priv = dci->pvt_info; > + platform_set_drvdata(pdev, dci); > + dci->dev = &pdev->dev; > + priv->baseaddr = plmrtca_baseaddr; > + dci->mod_name = "xilsem_edac"; > + dci->ctl_name = XILSEM_EDAC_STRNG; > + dci->dev_name = dev_name(&pdev->dev); > + > + mutex_init(&priv->lock); > + raw_spin_lock_init(&priv->cnt_lock); > + > + /* > + * Only Versal and Versal NET monolithic devices are supported. The > + * firmware interface has no way to report the device topology, so this > + * cannot be checked here; it is documented in the binding and the ABI. > + */ > + rc = zynqmp_pm_get_family_info(&family_code); > + if (rc) { > + /* > + * -ENODEV means the firmware driver hasn't registered yet on > + * a real ARCH_ZYNQMP build - defer and retry. On a > + * COMPILE_TEST build without CONFIG_ZYNQMP_FIRMWARE reachable > + * the stub always returns -ENODEV, so deferring would retry > + * forever for no reason; let it fail outright there instead. > + */ > + if (rc == -ENODEV && IS_REACHABLE(CONFIG_ZYNQMP_FIRMWARE)) > + rc = -EPROBE_DEFER; > + goto free_dev_ctl; > + } > + > + if (family_code == PM_VERSAL_NET_FAMILY_CODE) { > + priv->sw_event_node_id = VERSAL_NET_EVENT_ERROR_SW_ERR; > + priv->cram_ce_mask = XPM_VERSAL_NET_EVENT_ERROR_MASK_XSEM_CRAM_CE; > + priv->cram_ue_mask = XPM_VERSAL_NET_EVENT_ERROR_MASK_XSEM_CRAM_UE; > + priv->npi_ue_mask = XPM_VERSAL_NET_EVENT_ERROR_MASK_XSEM_NPI_UE; > + } else if (family_code == PM_VERSAL_FAMILY_CODE) { > + priv->sw_event_node_id = VERSAL_EVENT_ERROR_SW_ERR; > + priv->cram_ce_mask = XPM_VERSAL_EVENT_ERROR_MASK_XSEM_CRAM_CE_5; > + priv->cram_ue_mask = XPM_VERSAL_EVENT_ERROR_MASK_XSEM_CRAM_UE_6; > + priv->npi_ue_mask = XPM_VERSAL_EVENT_ERROR_MASK_XSEM_NPI_UE_7; > + } else { > + /* > + * Bail out here instead of continuing to register an event > + * with a zero node id/mask (what edac_device_alloc_ctl_info() > + * leaves in priv) for a family we don't recognize. > + */ > + edac_printk(KERN_ERR, EDAC_DEVICE, "Invalid Device family code %u\n", > + family_code); > + rc = -ENODEV; > + goto free_dev_ctl; > + } > + /* > + * Report only CEs that happen from now on. Read the baseline before the > + * sysfs attributes appear, so that a CE injected through them is not > + * folded into it. A CE before the event is registered is reported with > + * the next event. > + */ > + priv->ce_total_reported = readl(priv->baseaddr + CRAM_CE_COUNT_OFFSET); > + > + /* > + * Publish the sysfs attributes only once the per-family event > + * constants are resolved, otherwise a write from userspace during probe > + * could start hardware scanning before this state exists. > + */ > + dci->sysfs_attributes = xsem_edac_sysfs_attributes; > + rc = edac_device_add_device(dci); > + if (rc) { > + /* edac_device_add_device() returns a bare 1 on failure, not a negative errno */ > + rc = -ENODEV; > + goto free_dev_ctl; > + } > + > + /* > + * Register the error event as the last step, so that nothing can fail > + * after the callback is live and dci is never freed while the callback > + * is registered on the probe path. > + */ > + rc = xlnx_register_event(PM_NOTIFY_CB, priv->sw_event_node_id, > + priv->cram_ce_mask | priv->cram_ue_mask | priv->npi_ue_mask, > + false, xsem_err_callback, dci); > + if (rc) { > + /* > + * xlnx_register_event() returns -EACCES if the event manager > + * driver is not probed yet. In this case, defer > + * xsem_edac_probe(). > + */ > + if (rc == -EACCES) > + rc = -EPROBE_DEFER; > + goto del_dev; > + } > + > + return 0; > + > +del_dev: > + edac_device_del_device(&pdev->dev); > +free_dev_ctl: > + edac_device_free_ctl_info(dci); > + > + return rc; > +} > + > +/** > + * xsem_edac_remove - Unbind driver from controller. > + * @pdev: Platform device. > + */ > +static void xsem_edac_remove(struct platform_device *pdev) > +{ > + struct edac_device_ctl_info *dci = platform_get_drvdata(pdev); > + struct xsem_edac_priv *priv = dci->pvt_info; > + > + /* > + * On failure the callback is already gone: the event manager was > + * removed and dropped it, or only the firmware unregistration failed > + * after the callback was removed. > + */ > + xlnx_unregister_event(PM_NOTIFY_CB, priv->sw_event_node_id, > + priv->cram_ce_mask | priv->cram_ue_mask | priv->npi_ue_mask, > + xsem_err_callback, dci); > + edac_device_del_device(&pdev->dev); > + edac_device_free_ctl_info(dci); > +} > + > +static const struct of_device_id xsem_edac_match[] = { > + { .compatible = "xlnx,xilsem" }, > + { /* end of table */ } > +}; > +MODULE_DEVICE_TABLE(of, xsem_edac_match); > + > +static struct platform_driver xilinx_xilsem_edac_driver = { > + .driver = { > + .name = "xilsem-edac", > + .of_match_table = xsem_edac_match, > + }, > + .probe = xsem_edac_probe, > + .remove = xsem_edac_remove, > +}; > + > +module_platform_driver(xilinx_xilsem_edac_driver); > + > +MODULE_AUTHOR("Advanced Micro Devices, Inc."); > +MODULE_DESCRIPTION("Xilinx XilSEM EDAC driver"); > +MODULE_LICENSE("GPL"); > diff --git a/drivers/edac/xilsem_edac.h b/drivers/edac/xilsem_edac.h > new file mode 100644 > index 0000000..bd08665 > --- /dev/null > +++ b/drivers/edac/xilsem_edac.h > @@ -0,0 +1,131 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Xilinx XilSEM (Soft Error Mitigation) EDAC definitions > + * Copyright (C) 2023 - 2026, Advanced Micro Devices, Inc. > + * > + * Constants and data structures for the XilSEM EDAC driver (xilsem_edac.c): > + * the "xlnx,xilsem" compatible, xsem_edac_probe(), xsem_edac_remove() and > + * the xsem_* sysfs attributes. > + * > + */ > +#ifndef _XILSEM_EDAC_H > +#define _XILSEM_EDAC_H > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define XILSEM_EDAC_MSG_SIZE 256 > +#define XILSEM_EDAC_STRNG "xilsem" > + > +/* XilSem CE Error log count */ > +#define XILSEM_MAX_CE_LOG_CNT 7 > + > +/* Maximum CFRAME row number */ > +#define MAX_CFRAME_ROW_ID 4 > + > +/* XilSem_CRAM scan error info registers */ > +#define CRAM_STS_INFO_OFFSET 0x34 > +#define CRAM_CE_ADDRL0_OFFSET 0x38 > +#define CRAM_CE_ADDRH0_OFFSET 0x3C > +#define CRAM_CE_COUNT_OFFSET 0x70 > + > +/* XilSem_NPI_Scan uncorrectable error info registers */ > +#define NPI_SCAN_COUNT 0x24 > +#define NPI_SCAN_HB_COUNT 0x28 > +#define NPI_ERR0_INFO_OFFSET 0x2C > +#define NPI_ERR1_INFO_OFFSET 0x30 > + > +/* XilSem bit masks for extracting error details */ > +#define CRAM_ERR_ROW_MASK GENMASK(26, 23) > +#define CRAM_ERR_BIT_MASK GENMASK(22, 16) > +#define CRAM_ERR_QWRD_MASK GENMASK(27, 23) > +#define CRAM_ERR_FRAME_MASK GENMASK(22, 0) > + > +/* XilSem Module IDs */ > +#define CRAM_MOD_ID 0x1 > +#define NPI_MOD_ID 0x2 > + > +/** > + * struct xsem_ecc_error_info - ECC error log information > + * @status: CRAM/NPI scan error status > + * @data0: Checksum of the error descriptor (NPI UE only) > + * @data1: Index of the error descriptor (NPI UE only) > + * @frame_addr: Frame location at which error occurred > + * @row_id: Row number > + * @bit_loc: Bit position in the Qword > + * @qword: Qword location in the frame > + */ > +struct xsem_ecc_error_info { > + u32 status; > + u32 data0; > + u32 data1; > + u32 frame_addr; > + u8 row_id; > + u8 bit_loc; > + u8 qword; > +}; > + > +/** > + * struct xsem_error_status - ECC status information to report > + * @ce_located: Number of correctable errors with a location in @ceinfo > + * @ce_unlocated: Correctable errors whose location was overwritten in the PLM log > + * before it was read > + * @cram_ue: True if a CRAM UE was seen in this callback > + * @npi_ue: True if an NPI UE was seen in this callback > + * @ceinfo: Correctable error log information, oldest first > + * @cram_ueinfo: CRAM uncorrectable error log information > + * @npi_ueinfo: NPI uncorrectable error log information > + */ > +struct xsem_error_status { > + u32 ce_located; > + u32 ce_unlocated; > + bool cram_ue; > + bool npi_ue; > + struct xsem_ecc_error_info ceinfo[XILSEM_MAX_CE_LOG_CNT]; > + struct xsem_ecc_error_info cram_ueinfo; > + struct xsem_ecc_error_info npi_ueinfo; > +}; > + > +/** > + * struct xsem_edac_priv - Xilsem private instance data > + * @baseaddr: Base address of the XilSem PLM RTCA module > + * @cram_errinj_status: Buffer for CRAM error injection > + * @scan_ctrl_status: Buffer for scan ctrl commands > + * @cram_frame_ecc: Buffer for CRAM frame ECC > + * @xilsem_status: Buffer for CRAM & NPI status > + * @xilsem_cfg: Buffer for CRAM & NPI configuration > + * @sw_event_node_id: Error event node Id > + * @cram_ce_mask: Event bit mask for CRAM correctable error > + * @cram_ue_mask: Event bit mask for CRAM uncorrectable error > + * @npi_ue_mask: Event bit mask for NPI uncorrectable error > + * @ce_total_reported: Total CRAM correctable error count at the last report, protected > + * by cnt_lock > + * @lock: Serializes sysfs show/store access to the buffers above, > + * which are shared between all xsem_* sysfs callbacks. > + * @cnt_lock: irq-safe lock protecting the CRAM/NPI status MMIO registers, > + * which are read from both xsem_err_callback() (hardirq) and > + * xsem_read_status_store() (process context), where priv->lock, a > + * mutex, cannot be used. Also held across xsem_handle_error() to > + * serialize the calls into the EDAC core. > + */ > +struct xsem_edac_priv { > + void __iomem *baseaddr; > + struct xsem_cram_errinj_response cram_errinj_status; > + struct xsem_cntrl_ops_response scan_ctrl_status; > + struct xsem_cram_readecc_response cram_frame_ecc; > + u32 xilsem_status[3]; > + struct xsem_read_cfg_response xilsem_cfg; > + u32 sw_event_node_id; > + u32 cram_ce_mask; > + u32 cram_ue_mask; > + u32 npi_ue_mask; > + u32 ce_total_reported; > + struct mutex lock; /* protects the status fields above, read from sysfs show() */ > + raw_spinlock_t cnt_lock; /* protects CRAM/NPI status regs */ > +}; > + > +#endif /* _XILSEM_EDAC_H */