Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp940961pxb; Fri, 22 Apr 2022 14:56:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAD9TSSbzm8X3VDfqNxKDXJERZnTSUxWtggD+8FPlXQWPI5i5GRuo8Olzx4CGf06Amf5CM X-Received: by 2002:a17:902:8306:b0:158:ea27:307d with SMTP id bd6-20020a170902830600b00158ea27307dmr6464568plb.164.1650664564231; Fri, 22 Apr 2022 14:56:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650664564; cv=pass; d=google.com; s=arc-20160816; b=imWKQxZ1jW+CDTfG/Mn4zW3TBvHWuTl3hChf30obc7WSbGHqXkfIKDV4rpjzyyYtoH 5G0xUtlgR4wFh2vahD30Xesx8BsM7U799YYwi6lS7oi7kNO1JZFID2Gjj9aFGNStNsXs 6/05gci6Mnm7prM4yMx2y9MJCqH3e4F/dOuUyqQGXizlzDSJhbreDP07emkqH0OWklYQ /zUiA4iEsd88WRD4qkffWphStrybL2ed04tIHkVzYU4408wpbIRQl7n+VMAzqh2qIG53 aki3dVkMeZudJU3eoRcXe6RYlkMnM5ZSCLfQ1Qb01KHjtGvtz/d8AcrEkO2U1f6G8clE U6og== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:content-language:references:cc:to:subject:from :user-agent:date:message-id:dkim-signature; bh=PSn8Y4P4Khb8BRAqlK8NOwjMVQof/7Ko7tYNp2j5s+o=; b=i+fuSthbtU6TvzzMHvhbL8xjmRoTsa5JarNFJVwqMmP0Aj8I31rYfossJApN+QcDNx TzkBWratxnNzIDfkUi/pSDpHCwZcgJEtd+e165vS7R4CMqfBdEH6bCB4ugj8pCgq0GIW MhAEsgr2fzyUAi222Hf5FgrmWnzHb2Ep8NpHbM/dHA2algN4UKGWLM1kE8/E3t23eb4L dRTynP+dexec1agpEuN4dfjp7lz1kNBOZOzEWBcuYX3zPvTODzoZU0KTvtgAhLD3dcbz EbeJSIbc41e5HBk5LghQRxZV7ygzizjGrunNteHZcy5iR6Ec+7dpVPmxUGyDKlYPwJnr UuAA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=N5+DdCyt; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b17-20020a056a000a9100b00505b3204852si10374237pfl.270.2022.04.22.14.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 14:56:04 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=N5+DdCyt; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0F93F35E60C; Fri, 22 Apr 2022 13:03:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1448845AbiDVOq7 (ORCPT + 99 others); Fri, 22 Apr 2022 10:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237708AbiDVOq5 (ORCPT ); Fri, 22 Apr 2022 10:46:57 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2117.outbound.protection.outlook.com [40.107.94.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C577F5BE5D; Fri, 22 Apr 2022 07:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QfNxX23rl9aLqQezA5Qj4NEo/vrfhgD8o83ftOfzxQnwSsUtQko1bc1eT1NFbRPsIHIvxbi8fbrRvYZm3phIHc8cXzZNj2J29eoIXVFKWT2Z9p/XK2o7FJ234ws7957mR8tyZ7jelmZ3i0I/yEUIyXuL0DLybsq11eTWSvbXdMICpqrfIj7ht7tMHr8czbvLgxzxDM644M4tvXnNZouQpZsgyMJLTYYlj6NuNWfgHTLeeIA5+404W+A4MD63uuYdAzb7iU+O828jVJ3OUoPXa3CL71iUW1vGBBMUXL1y7JdRXyhuzFdWVFbneaHfe2z0mRihE+FQ4Ez/VytNP9JMGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=PSn8Y4P4Khb8BRAqlK8NOwjMVQof/7Ko7tYNp2j5s+o=; b=cr2VbnGT3lLIJgXali6k9NBdoYHrP1L42F/NMVZPbxNdiHZBohcrHCfmkveRlMZPr5P/gq5THB/WwHdj5bn/U6CfX/cvTotnOIP4v19Qqj/kOicXcT6AMkQSA/mwI2Dzg4IiLEeK24NAkR0/W2WI1gNyPVHPLiaBsWuN3HpnQLVHtwc1rB1PExQ613md/13JHXIiyoK1dZgezvrttTf5we9j7gf807k7pvF/NIIwTBr1TNMoOcLub+lAyWvmezJrqtR15so7aJrUi8F5lCENblEVOW8lvCskvoy+nZvxOaTfjhyEgnSFQ/IFT35J1+rAdPnzY+bB4xQmYsSRAsM2MQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PSn8Y4P4Khb8BRAqlK8NOwjMVQof/7Ko7tYNp2j5s+o=; b=N5+DdCytwxX3UT0LxggJUMy/YWNDafFZBU2K0tQXwcb5DE/w3En3XuungocdgJnjPOQHwT5wo24Ri7B7dafP6kAI+8S4wjN8lrDVU4/ranyY7CBh12UAexZGpgup1FMba9WZLOLlSpQ70/hmQBugB4WQh3iDg1RSvuXCXVXU1h4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by MN0PR01MB7634.prod.exchangelabs.com (2603:10b6:208:376::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Fri, 22 Apr 2022 14:43:59 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::319b:4612:e6f4:f22c]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::319b:4612:e6f4:f22c%3]) with mapi id 15.20.5186.015; Fri, 22 Apr 2022 14:43:58 +0000 Message-ID: <82a6452a-965b-7fbe-eba2-919f0a6ed73a@os.amperecomputing.com> Date: Fri, 22 Apr 2022 21:43:39 +0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 From: Quan Nguyen Subject: Re: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver To: Greg Kroah-Hartman Cc: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Thu Nguyen , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, OpenBMC Maillist , Open Source Submission , Phong Vo , "Thang Q . Nguyen" References: <20220422024653.2199489-1-quan@os.amperecomputing.com> <20220422024653.2199489-4-quan@os.amperecomputing.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SI2PR06CA0008.apcprd06.prod.outlook.com (2603:1096:4:186::23) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fb17792-00a2-4a9a-8c57-08da246e886a X-MS-TrafficTypeDiagnostic: MN0PR01MB7634:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: We2D1rBZ2n/10BR78IERRvP3XbwOHio0+Wj7ql6TARq5v6cf8ePjgUkT4+wBz+H9eGSG0/HBnUCmm+k4rzQrCJKGf+CSKW7dc8Q+6nN75UniOaFcnb79QYeDtNNVPVnNl1+6KHgBXtLUnaNf3Mrn8EgmWBpzKeU9IL7q7yzdBgkTTuxpctvqUmfq4i0xvWgonaZfjoNIbglz8kj7Rid5dDdHnQBT45PKyxg+KwgM+eyzk7RZJ08d5Os+GlzxtdYeJoQjYVwVlZyhU15iwQkNpjhFdrbJVxDj9g1YxZ6PUF+KrfWDZj/8tSVB1FCo6J+KJeRBgsVCVwlTH3FtgI1VIXMWq5E5wo+prRznM0Uq1ZSa0hweH75EH3Bcf80KxaL95fRxKBeUWA5pU4jPG2/JeduJbt7RJ0eFH04MV+xcric0Skd6klsGhYWH9WYyTwQo4//AYA5uwb+ZttGOPtOdmabBe4D4VJnStiKZbyQPOHN+r9lYw59WEDEbttBpNkQby4vJGJa1fDl82JS+deEgUGQEu/lDZ45IDJrjdOk5eGZzXxMhGl3PXqjZqh4uyKwu0KvYFQrq1tEm9+w01AYkEU9YV4pKcJ4tOMtbvnlpNX8UfXmcb3cNSDXicTrvs+BS0rh+f6Du1avNe/E88f4Imnvy6rFONKmr74ERiSOvfRl+BjpQtjOPrZ/Gfiqgqo/p2DXcXzfr6laZkyxrQ3e/r/yQW5rStmMtbnDflp/E9nSvD0KmeWSwJL48Zr374rZdzO0ZxFEglGciWf43117evc2sg+tQg+HzdVzbtR1xEyvJEcuEsbdlNgFVoNyeMBGk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(30864003)(52116002)(6666004)(6506007)(26005)(107886003)(508600001)(86362001)(316002)(966005)(6486002)(31686004)(6512007)(2616005)(53546011)(6916009)(54906003)(4326008)(8676002)(186003)(2906002)(31696002)(38350700002)(38100700002)(8936002)(5660300002)(66556008)(66946007)(66476007)(7416002)(83380400001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aUdwbEF1MmgzdjExR0dkUnBXVkhTSUZCWUgxbDFqOGs1dUEydHdZQW9zVTRj?= =?utf-8?B?SjJVS0FzRW9JOHZvalZnVW90anJFMUt1ZWludkp2b2lxUTZaYVVOYjBNU2ov?= =?ut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VVhGVkVnZlUxWGNXWkQrMlJ3cmN5b05qMXpTYVdzVGoweDM3?= =?utf-8?B?bTV2MERwR3FKQy9nVjdpV1gwbVpnbTZYYkZYNVNKTVVvN1RrdXQxaDE3RjVU?= =?utf-8?B?aXVtNmplY2huQWtSaURsamsrSkJsTFF2YzI5UHlRdWFqWExwT2kvak55YzZW?= =?utf-8?B?TFlQZmJSWW1XNThjeUVwc3NqTTc5TW5vRnpyb1UwY24xWU5tTFlkMGtMVzJM?= =?utf-8?B?OHBGVEtOZXlVdVFLMXJ1UlVQOVVRZTNTRkIxR2NKUU1tY05GRm50aGxFS1dw?= =?utf-8?B?OUlsczJrd1lwY3R6V0Q5dmhLSkQ4UG9Sd3E5SkYwWWtNTmY0U2xEYkJVd2xF?= =?utf-8?B?ZWV0Zy9PWnhTUGNoTlk1Vis5Q2hVa0NUV01JazFoTDhiVGVmME5mRXVOa0s3?= =?utf-8?B?cE9LUG5TNzZJbzMyYWxPRE9PWG9sZ24wRUhPT0szSzMxQjJYRElMVVBncjJ2?= =?utf-8?Q?+7aG9F0IGuIxj9KzkRq8L/lxYlg1ccxzx2j0S?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fb17792-00a2-4a9a-8c57-08da246e886a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2022 14:43:58.3795 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2kupJeZy/rkHWGE9DYUx4Yqu5JFHwdsaC112GTlXH2ovrTiKSRt/BqD87csskquvTWR76aIPg+39vL/SiEiLRq5cGIUrZ7i2lfd2M7fArXI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR01MB7634 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/04/2022 13:20, Greg Kroah-Hartman wrote: > On Fri, Apr 22, 2022 at 09:46:47AM +0700, Quan Nguyen wrote: >> This commit adds Ampere's SMpro error monitor driver for monitoring >> and reporting RAS-related errors as reported by SMpro co-processor >> found on Ampere's Altra processor family. >> >> Signed-off-by: Quan Nguyen >> --- >> Changes in v8: >> + Update wording for SMPRO_ERRMON on Kconfig file [Quan] >> + Avoid uninitialized variable use [kernel test robot] >> + Switch to use sysfs_emit() [Greg] >> + Make sysfs to return single value [Greg] >> + Change errors_* sysfs to error_* [Quan] >> + Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report >> overflow status of each type of HW errors [Quan] >> + Add some minor refactor [Quan] >> >> Changes in v7: >> + Remove regmap_acquire/release_lock(), read_i2c_block_data() [Quan] >> + Use regmap_noinc_read() instead of errmon_read_block() [Quan] >> + Validate number of errors before read [Quan] >> + Fix wrong return type of *_show() function [kernel test robot] >> + Adjust patch order to avoid dependence with smpro-mfd [Lee Jones] >> + Use pointer instead of stack memory [Quan] >> >> Changes in v6: >> + First introduced in v6 [Quan] >> >> drivers/misc/Kconfig | 12 + >> drivers/misc/Makefile | 1 + >> drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++++++++++++++++++++ >> 3 files changed, 490 insertions(+) >> create mode 100644 drivers/misc/smpro-errmon.c >> >> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig >> index 41d2bb0ae23a..9fbe6797c440 100644 >> --- a/drivers/misc/Kconfig >> +++ b/drivers/misc/Kconfig >> @@ -176,6 +176,18 @@ config SGI_XP >> this feature will allow for direct communication between SSIs >> based on a network adapter and DMA messaging. >> >> +config SMPRO_ERRMON >> + tristate "Ampere Computing SMPro error monitor driver" >> + depends on MFD_SMPRO || COMPILE_TEST >> + help >> + Say Y here to get support for the SMpro error monitor function >> + provided by Ampere Computing's Altra and Altra Max SoCs. Upon >> + loading, the driver creates sysfs files which can be use to gather >> + multiple HW error data reported via read and write system calls. >> + >> + To compile this driver as a module, say M here. The driver will be >> + called smpro-errmon. >> + >> config CS5535_MFGPT >> tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" >> depends on MFD_CS5535 >> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile >> index 70e800e9127f..483308a6e113 100644 >> --- a/drivers/misc/Makefile >> +++ b/drivers/misc/Makefile >> @@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o >> obj-$(CONFIG_KGDB_TESTS) += kgdbts.o >> obj-$(CONFIG_SGI_XP) += sgi-xp/ >> obj-$(CONFIG_SGI_GRU) += sgi-gru/ >> +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o >> obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o >> obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o >> obj-$(CONFIG_HP_ILO) += hpilo.o >> diff --git a/drivers/misc/smpro-errmon.c b/drivers/misc/smpro-errmon.c >> new file mode 100644 >> index 000000000000..df7d8fc4ff3f >> --- /dev/null >> +++ b/drivers/misc/smpro-errmon.c >> @@ -0,0 +1,477 @@ >> +// SPDX-License-Identifier: GPL-2.0+ > > Are you sure you mean "or any later version"? I have to ask. > Thank Greg for the review. Will change all to SPDX-License-Identifier: GPL-2.0-or-later in next version. >> +static struct smpro_int_error_hdr list_smpro_int_error_hdr[2] = { >> + { >> + ERR_SMPRO_TYPE, >> + ERR_SMPRO_INFO_LO, ERR_SMPRO_INFO_HI, >> + ERR_SMPRO_DATA_LO, ERR_SMPRO_DATA_HI, >> + WARN_SMPRO_INFO_LO, WARN_SMPRO_INFO_HI >> + }, >> + { >> + ERR_PMPRO_TYPE, >> + ERR_PMPRO_INFO_LO, ERR_PMPRO_INFO_HI, >> + ERR_PMPRO_DATA_LO, ERR_PMPRO_DATA_HI, >> + WARN_PMPRO_INFO_LO, WARN_PMPRO_INFO_HI >> + }, > > Odd indentation, checkpatch did not complain? > No, checkpatch.pl did not complain. But let me check to see if there is better indentation. >> +static ssize_t smpro_event_data_read(struct device *dev, >> + struct device_attribute *da, char *buf, >> + int channel) >> +{ >> + struct smpro_errmon *errmon = dev_get_drvdata(dev); >> + s32 event_data; >> + int ret; >> + >> + ret = regmap_read(errmon->regmap, smpro_event_table[channel], &event_data); >> + if (ret) >> + goto done; > > Just return the error here. > Will fix in next version >> + >> + ret = sysfs_emit(buf, "%02x%04x\n", channel, event_data); > > sysfs rules are one value per file. You know this. > Yes, I will address this in my next version. The "channel" could be removed as the sysfs file name itself is enough to identify the channel. >> + /* Clear event after read */ >> + if (event_data != 0) > > Why would it be 0? Isn't 0 a valid value? > > 0 means it is good and there is no event, but if it is not 0, that mean there is an event and need to be written back to clear that event. >> + regmap_write(errmon->regmap, smpro_event_table[channel], event_data); >> +done: >> + return ret; >> +} >> + >> +static ssize_t smpro_overflow_data_read(struct device *dev, struct device_attribute *da, >> + char *buf, int channel) >> +{ >> + struct smpro_errmon *errmon = dev_get_drvdata(dev); >> + struct smpro_error_hdr *err_info; >> + s32 err_count; >> + int ret; >> + >> + err_info = &smpro_error_table[channel]; >> + >> + ret = regmap_read(errmon->regmap, err_info->err_count, &err_count); >> + if (ret) >> + return ret; >> + >> + /* Bit 8 indicates the overflow status */ >> + return sysfs_emit(buf, "%d\n", (err_count & BIT(8)) ? 1 : 0); >> +} >> + >> +static ssize_t smpro_error_data_read(struct device *dev, struct device_attribute *da, >> + char *buf, int channel) >> +{ >> + struct smpro_errmon *errmon = dev_get_drvdata(dev); >> + unsigned char err_data[MAX_READ_BLOCK_LENGTH]; >> + struct smpro_error_hdr *err_info; >> + s32 err_count, err_length; >> + int count = 0; >> + int ret; >> + >> + err_info = &smpro_error_table[channel]; >> + >> + ret = regmap_read(errmon->regmap, err_info->err_count, &err_count); >> + /* Error count is the low byte */ >> + err_count &= 0xff; >> + if (ret || !err_count || err_count > err_info->max_err_cnt) >> + goto done; > > Just return the error. > Will fix in next version. >> + >> + ret = regmap_read(errmon->regmap, err_info->err_len, &err_length); >> + if (ret || err_length <= 0) >> + goto done; > > return the error. > > Wait, you could return 0 here, are you sure about that? > Yes, that is our intention. If ret != 0 then return the error Otherwise, if ret == 0 then return 0 if there is no error and/or err_length invalid. >> + >> + if (err_length > MAX_READ_BLOCK_LENGTH) >> + err_length = MAX_READ_BLOCK_LENGTH; >> + >> + memset(err_data, 0x00, MAX_READ_BLOCK_LENGTH); >> + ret = regmap_noinc_read(errmon->regmap, err_info->err_data, err_data, err_length); >> + if (ret < 0) >> + goto done; > > return the error, no need for a goto in this function. > Agree, will fix this and any other places as well. >> + >> + /* >> + * The output of Core/Memory/PCIe/Others UE/CE errors follows below format: >> + * \ >> + * >> + * Where: >> + * + Error Type: The hardwares cause the errors. (1 byte) >> + * + SubType: Sub type of error in the specified hardware error. (1 byte) >> + * + Instance: Combination of the socket, channel, >> + * slot cause the error. (2 bytes) >> + * + Error Status: Encode of error status. (4 bytes) >> + * + Error Address: The address in device causes the errors. (8 bytes) >> + * + Error Misc 0/1/2/3: Addition info about the errors. (8 bytes for each) >> + * Reference Altra SOC BMC Interface specification. >> + */ >> + count = sysfs_emit(buf, "%02x%02x%04x%08x%016llx%016llx%016llx%016llx%016llx\n", >> + err_data[0], err_data[1], *(u16 *)&err_data[2], >> + *(u32 *)&err_data[4], *(u64 *)&err_data[8], >> + *(u64 *)&err_data[16], *(u64 *)&err_data[24], >> + *(u64 *)&err_data[32], *(u64 *)&err_data[40]); >> + >> + /* go to next error */ >> + ret = regmap_write(errmon->regmap, err_info->err_count, 0x100); >> +done: >> + return ret ? ret : count; >> +} >> + >> +/* >> + * Output format: >> + * >> + * Where: >> + * + errType: SCP Error Type (3 bits) >> + * 1: Warning >> + * 2: Error >> + * 4: Error with data >> + * + image: SCP Image Code (8 bits) >> + * + dir: Direction (1 bit) >> + * 0: Enter >> + * 1: Exit >> + * + location: SCP Module Location Code (8 bits) >> + * + errorCode: SCP Error Code (16 bits) >> + * + data : Extensive data (32 bits) >> + * All bits are 0 when errType is warning or error. >> + */ >> +static ssize_t smpro_internal_err_read(struct device *dev, struct device_attribute *da, >> + char *buf, int channel) >> +{ >> + struct smpro_errmon *errmon = dev_get_drvdata(dev); >> + struct smpro_int_error_hdr *err_info; >> + unsigned int data_lo = 0, data_hi = 0; >> + unsigned int ret_hi, ret_lo; >> + unsigned int err_type; >> + unsigned int value; >> + int count = 0; >> + int ret; >> + >> + /* read error status */ >> + ret = regmap_read(errmon->regmap, GPI_RAS_ERR, &value); >> + if (ret) >> + goto done; > > Same mess here, just return the error. > Yes. will do. >> + >> + if (!((channel == RAS_SMPRO_ERRS && (value & BIT(0))) || >> + (channel == RAS_PMPRO_ERRS && (value & BIT(1))))) >> + goto done; > > No error? Are you sure? > Yes, no error, but let me try to make this a bit simpler in next version. >> + >> + err_info = &list_smpro_int_error_hdr[channel]; >> + ret = regmap_read(errmon->regmap, err_info->err_type, &err_type); >> + if (ret) >> + goto done; >> + >> + ret = regmap_read(errmon->regmap, err_info->err_info_low, &ret_lo); >> + if (ret) >> + goto done; >> + >> + ret = regmap_read(errmon->regmap, err_info->err_info_high, &ret_hi); >> + if (ret) >> + goto done; >> + >> + if (err_type & BIT(2)) { >> + /* Error with data type */ >> + ret = regmap_read(errmon->regmap, err_info->err_data_low, &data_lo); >> + if (ret) >> + goto done; >> + >> + ret = regmap_read(errmon->regmap, err_info->err_data_high, &data_hi); >> + if (ret) >> + goto done; >> + >> + count = sysfs_emit(buf, "%01x%02x%01x%02x%04x%04x%04x\n", >> + 4, (ret_hi & 0xf000) >> 12, (ret_hi & 0x0800) >> 11, >> + ret_hi & 0xff, ret_lo, data_hi, data_lo); >> + /* clear the read errors */ >> + ret = regmap_write(errmon->regmap, err_info->err_type, BIT(2)); >> + >> + } else if (err_type & BIT(1)) { >> + /* Error type */ >> + count = sysfs_emit(buf, "%01x%02x%01x%02x%04x%04x%04x\n", >> + 2, (ret_hi & 0xf000) >> 12, (ret_hi & 0x0800) >> 11, >> + ret_hi & 0xff, ret_lo, data_hi, data_lo); >> + /* clear the read errors */ >> + ret = regmap_write(errmon->regmap, err_info->err_type, BIT(1)); >> + >> + } else if (err_type & BIT(0)) { >> + /* Warning type */ >> + count = sysfs_emit(buf, "%01x%02x%01x%02x%04x%04x%04x\n", >> + 1, (ret_hi & 0xf000) >> 12, (ret_hi & 0x0800) >> 11, >> + ret_hi & 0xff, ret_lo, data_hi, data_lo); >> + /* clear the read errors */ >> + ret = regmap_write(errmon->regmap, err_info->err_type, BIT(0)); >> + } >> +done: >> + return ret ? ret : count; >> +} >> + >> +#define ERROR_OVERFLOW_RO(_error, _index) \ >> + static ssize_t overflow_##_error##_show(struct device *dev, \ >> + struct device_attribute *da, \ >> + char *buf) \ >> + { \ >> + return smpro_overflow_data_read(dev, da, buf, _index); \ >> + } \ >> + static DEVICE_ATTR_RO(overflow_##_error) >> + >> +ERROR_OVERFLOW_RO(core_ce, CORE_CE_ERRS); >> +ERROR_OVERFLOW_RO(core_ue, CORE_UE_ERRS); >> +ERROR_OVERFLOW_RO(mem_ce, MEM_CE_ERRS); >> +ERROR_OVERFLOW_RO(mem_ue, MEM_UE_ERRS); >> +ERROR_OVERFLOW_RO(pcie_ce, PCIE_CE_ERRS); >> +ERROR_OVERFLOW_RO(pcie_ue, PCIE_UE_ERRS); >> +ERROR_OVERFLOW_RO(other_ce, OTHER_CE_ERRS); >> +ERROR_OVERFLOW_RO(other_ue, OTHER_UE_ERRS); >> + >> +#define ERROR_RO(_error, _index) \ >> + static ssize_t error_##_error##_show(struct device *dev, \ >> + struct device_attribute *da, \ >> + char *buf) \ >> + { \ >> + return smpro_error_data_read(dev, da, buf, _index); \ >> + } \ >> + static DEVICE_ATTR_RO(error_##_error) >> + >> +ERROR_RO(core_ce, CORE_CE_ERRS); >> +ERROR_RO(core_ue, CORE_UE_ERRS); >> +ERROR_RO(mem_ce, MEM_CE_ERRS); >> +ERROR_RO(mem_ue, MEM_UE_ERRS); >> +ERROR_RO(pcie_ce, PCIE_CE_ERRS); >> +ERROR_RO(pcie_ue, PCIE_UE_ERRS); >> +ERROR_RO(other_ce, OTHER_CE_ERRS); >> +ERROR_RO(other_ue, OTHER_UE_ERRS); >> + >> +static ssize_t error_smpro_show(struct device *dev, struct device_attribute *da, char *buf) >> +{ >> + return smpro_internal_err_read(dev, da, buf, RAS_SMPRO_ERRS); >> +} >> +static DEVICE_ATTR_RO(error_smpro); >> + >> +static ssize_t error_pmpro_show(struct device *dev, struct device_attribute *da, char *buf) >> +{ >> + return smpro_internal_err_read(dev, da, buf, RAS_PMPRO_ERRS); >> +} >> +static DEVICE_ATTR_RO(error_pmpro); >> + >> +#define EVENT_RO(_event, _index) \ >> + static ssize_t event_##_event##_show(struct device *dev, \ >> + struct device_attribute *da, \ >> + char *buf) \ >> + { \ >> + return smpro_event_data_read(dev, da, buf, _index); \ >> + } \ >> + static DEVICE_ATTR_RO(event_##_event) >> + >> +EVENT_RO(vrd_warn_fault, VRD_WARN_FAULT_EVENTS); >> +EVENT_RO(vrd_hot, VRD_HOT_EVENTS); >> +EVENT_RO(dimm_hot, DIMM_HOT_EVENTS); >> + >> +static struct attribute *smpro_errmon_attrs[] = { >> + &dev_attr_overflow_core_ce.attr, >> + &dev_attr_overflow_core_ue.attr, >> + &dev_attr_overflow_mem_ce.attr, >> + &dev_attr_overflow_mem_ue.attr, >> + &dev_attr_overflow_pcie_ce.attr, >> + &dev_attr_overflow_pcie_ue.attr, >> + &dev_attr_overflow_other_ce.attr, >> + &dev_attr_overflow_other_ue.attr, >> + &dev_attr_error_core_ce.attr, >> + &dev_attr_error_core_ue.attr, >> + &dev_attr_error_mem_ce.attr, >> + &dev_attr_error_mem_ue.attr, >> + &dev_attr_error_pcie_ce.attr, >> + &dev_attr_error_pcie_ue.attr, >> + &dev_attr_error_other_ce.attr, >> + &dev_attr_error_other_ue.attr, >> + &dev_attr_error_smpro.attr, >> + &dev_attr_error_pmpro.attr, >> + &dev_attr_event_vrd_warn_fault.attr, >> + &dev_attr_event_vrd_hot.attr, >> + &dev_attr_event_dimm_hot.attr, >> + NULL >> +}; >> + >> +static const struct attribute_group smpro_errmon_attr_group = { >> + .attrs = smpro_errmon_attrs >> +}; > > ATTRIBUTE_GROUPS()? > > Will use this macro in next version. >> + >> +static int smpro_errmon_probe(struct platform_device *pdev) >> +{ >> + struct smpro_errmon *errmon; >> + int ret; >> + >> + errmon = devm_kzalloc(&pdev->dev, sizeof(struct smpro_errmon), GFP_KERNEL); >> + if (!errmon) >> + return -ENOMEM; >> + >> + platform_set_drvdata(pdev, errmon); >> + >> + errmon->regmap = dev_get_regmap(pdev->dev.parent, NULL); >> + if (!errmon->regmap) >> + return -ENODEV; >> + >> + ret = sysfs_create_group(&pdev->dev.kobj, &smpro_errmon_attr_group); > > You just raced with userspace and lost :( > > Always use the default groups of the platform driver for this. That way > you do not have to do anything special and your files will be created > properly. > And will switch to use .dev_groups follow your article at https://lwn.net/Articles/793061/ >> + if (ret) >> + dev_err(&pdev->dev, "SMPro errmon sysfs registration failed\n"); >> + >> + return 0; >> +} >> + >> +static int smpro_errmon_remove(struct platform_device *pdev) >> +{ >> + sysfs_remove_group(&pdev->dev.kobj, &smpro_errmon_attr_group); >> + pr_info("SMPro errmon sysfs entries removed"); > > Drivers are quiet when all is working properly. > > If you set the pointer properly as asked above, you do not have to > remove the group on your own. > > Huge hint, if you ever call sysfs_* from a driver, something is probably > wrong. > > Same goes for the other drivers in this series, please fix them all up > this way. > Thanks for pointing out. Will apply all other places where applicable. Thank you for the review, -- Quan