From patchwork Wed Jun 15 09:02:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12881958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60E61C433EF for ; Wed, 15 Jun 2022 09:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=uLfbfk6W0Wx0KYPVo+vtrzrabHCTybRHq9rqpzZQ8FU=; b=Zf9Elz6XiNS9Ul ZIp8j8iXbJ1vZuvUD8OYJRqq0Tw9mzMhROIvhTjHwx7yU0hk2fiPcSVb+F1I5ae5bSzTMoZ1lh9kX 17rcqHVzDtjQtu0G9ihJFFqhR/gEkTWhJ4j/3wEgkxf2kPyRCSlsSPEMikJmxl7cWIJLK3WJLoH9G U2JSGS/QRmNLNPuQe/n9XlCpe/096+LCFCUmhH7cIfA2TH00Ii/nQdkm2iFd+mhRBmXykHqi4KaM7 /zJmYoyTZPpJDX5dihjLaWvelshR9Een0lzMidEvrylU8N1rnkSt6HftRZngk/kLxn9syFXNlMBgZ lunnc/Z8WG/bC8sBtEJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1Ow7-00DOoR-2I; Wed, 15 Jun 2022 09:03:39 +0000 Received: from mail-mw2nam04on20704.outbound.protection.outlook.com ([2a01:111:f400:7e8c::704] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1Ow2-00DOnb-Jo for linux-arm-kernel@lists.infradead.org; Wed, 15 Jun 2022 09:03:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W6ixYa2Ax+n4USEPyFFfokiqQhzojpMgEaTMVdybd0KnhQLBM4e7u4ag56usajjL+1TyyflPpuNHwhtCskJwGXEIYSNGuuk4nq417KoO0HR9znEykzejNCTf5hWYxf0dII/YTx5oBUMiyU6skyN5vHCfbtQBLInPoDQvIe3PBfRcWBkEIsP73wRD3W2Ujwc0f0ZzlFHa2k31IgSaKckm0mRhgIaQAmlkpWVO/9CrRrsY6MWRi79fgrWZrTuJnMz0+9F8NEafrVmsXWVjnelEUFOAfbj2yD7jWrnYdNTz0vyH5HKc2Oc1KCGB/UNpj8C6TNrdS0G5DWUx4FLWBLMgIg== 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=k5ILu6O5pGyOSenTp8GHVVJzY8VeQWIjZHgAYpoOAto=; b=M8E/AoN66A1WI/4+IPQYKCZZleDBs1azfqc/xhb3d4Bd9sygR2PU8hCFh9AyVFfVTVM2QW3gFS7248wQcmCUNhUCEQIojDB4tY2KBeU5j/+5PhR5IDMuKWm4EyfYsMuv7rXLu7RFOmj1SxKuOgyjn3kqUButdoWp6Q3gMvrELLwoCszlgzgLJIRtGxWr6MYKb3OU+0ncXLI6AqP4BlMkLe83MtTeEcnLfGdNXqmguT8PoMjMuRZGiVqgTnOdgM0CoTh1sCFKeYTKnaoJr+5BEyaZ8rPq7LWDityN+LBkBCzcPbfupZ0bIWlQCb6sWtn3K881P5GOT7TceBWWqtu51A== 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=k5ILu6O5pGyOSenTp8GHVVJzY8VeQWIjZHgAYpoOAto=; b=A3rw1DSb54jYMdNJXvrRGrYLi49msDqMHQcQXXb+XMjxXFoe+F+R4D+skI+DsSnD93nX7Sf4F/F8IMoJKI/RB7f8vMmXZUrTcgBw+7tsCxV7gffn/EgmTuguzUYtGKqA7rjJ8/ipJ3W+RMfSlTTi75plPn6+hdE+M+LjpPXG4q8= 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 DM5PR01MB2666.prod.exchangelabs.com (2603:10b6:3:ff::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Wed, 15 Jun 2022 09:03:27 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::7535:773:f979:893e]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::7535:773:f979:893e%7]) with mapi id 15.20.5332.020; Wed, 15 Jun 2022 09:03:26 +0000 From: Quan Nguyen To: Quan Nguyen , Corey Minyard , Rob Herring , Krzysztof Kozlowski , Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andrew Jeffery , Wolfram Sang , openipmi-developer@lists.sourceforge.net, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v8 0/3] Add SSIF BMC driver Date: Wed, 15 Jun 2022 16:02:56 +0700 Message-Id: <20220615090259.1121405-1-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86ba64fe-ffe4-41c9-db81-08da4eade872 X-MS-TrafficTypeDiagnostic: DM5PR01MB2666: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: FI+s2EsmWtl0JVpWuuG63f/RH1IUlRY2c7K99+/jrjK2j9qrvxJluY2xead9WOs8wisntYJOXXnxDtxZDjC4084BAK3Kqh7A9SKSE0eu8qWgllWnL6kMYS05MFO2PJxji9YvDzRiAfhxL2fgpnaDpKAjFG7zrDlxUh149iAU3GLCGuaztvGhdQP/yjWFfSWvLsEMS22/C0H79JQ+4ZhErZjYYDH9wPkXxEq+LrZGFH4NNUDwFMhVZOho2rP6LWtubuO+Ux7yomMZ7IpTnnIaTIugpGWerBzPgxetsd1lCqCiK/HanN6TpJOq4dR7lq4g4l2okxrljmXnUTTcXtOIgJ7ukaoQ8LLP1AaPA4eOa8MY2xy0Y1MYREYStEH8j72Ykx5rg6GT+oZvTEpYsH3vxlC6uppbd9x8Vu1ro779qEmRbE8X8bEyT7+01OTLiGStBimt29PydWSYfd2XA6mxjY6rLUhcLSF4cKIlS301Z/57pgPIG0+pCn9Xe918QLaGzM2GYGAQZrix1IkKAtJVqTdwF5hxJiKZNVjfoY+AUBo75Jt586kyQ1Qu6LBHH+QhARSwQie//uk5X/bryEAEW439+fukITt3MVpvU7cPy8OMJRNy2viHkBe7+qY++kFi8+Wfn/0W+9zcj78ItSRp8OlFMpnhGqeOlYdoRfxwuOz/Wkxep+cJBJsQ0LoXdtg7qWmGBPEvdl/65ROWDFX9sYszxGfClohGVEgps1VAHOZnVSUTlJONBibuCW/uI7YjU0j0klU1JJM+Gw6MVslJoC4Du6Uy0wUJulJ5BDwcEhiAyXXp1dYjDyZGQcDR4VWc 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:(13230016)(4636009)(366004)(7416002)(8936002)(107886003)(5660300002)(26005)(52116002)(6512007)(6666004)(6506007)(508600001)(2616005)(921005)(38100700002)(2906002)(38350700002)(186003)(83380400001)(86362001)(966005)(6486002)(1076003)(316002)(4326008)(54906003)(8676002)(66476007)(110136005)(66946007)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WK084hNYKVsV92t7eC7p8XCkRzs8MjfvMtWUYCiuus737+TwIpmukKF6ltDGU4CBaAr2/rtP3OodqeyBfn0aLiyd/ryozOdhJchFvvSMLokEcWT5CtL1ETXRmwr9Kr2jiVusOQRxF6W2KSlZYs7P0rGiwtJg359Xmqjo6BetlhSPoEqkCYN+Jq2VBc2ktVYSAznVFS11lguOoIbZoJhtK2sRqcGOA0fsvTeVGqeDIwxvSX0od/zj9Yx7qGvC8MoEapdM5mWvFRJXPt2e9LjYEJ89AWs+4/vJFxk7UcdTDjDsI7a/s2357ROgUBsEruMe0YQdQFubv7FToIhDox2FzjanKrrwq2CcZFIJG8BakyuBfATJaVveDxE3EUwJNEDEO3gth82Wqlz4wy3bhrE5y4fnX+rpM9E1yilICTmzIYg687i2W95Mspzrlv0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BHPfV+bH5SVRohHPAB5xnl3O7Jh67EJP93RvJh+z2gtF/CBZgrC1HgPLqt3hvAL2RcUEzdyYlJddJQ3wk/xKSonsCoWhHyyeXY7HDb82wYOOyGmu/zx7neuBbpyLhLWsIE/Ho2G1tLgcMqE0CqtJsPjFAGJ1u0Y6BFtOWUv3Gbxrw3pIHetSo3JXORcbAb0MbNRQXktqd6KMbwlch/TrwdkTgNENkSOBYTc074SnG0wP15tPh2YXGgBw2Lax9Nou1r0yrRwpMe36lqggJyS0rNX6B8xbC X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86ba64fe-ffe4-41c9-db81-08da4eade872 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2022 09:03:26.7509 (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: 7Rfdniy5KGFaMAhJ+4b4luAEuSvLVta9oyVB75WaSHRIVkYygELBcElPEpPgQ616Sp7un9AzfphDi7mGKF2UFC1gYn7PHJCnVyxH3GIyL6E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR01MB2666 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220615_020334_898237_B2D77E7F X-CRM114-Status: GOOD ( 17.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series add support the SSIF BMC driver which is to perform in-band IPMI communication with their host in management (BMC) side. SSIF BMC driver in this series is tested with Aspeed AST2500. Discussion for v7: https://lkml.org/lkml/2022/4/22/4 v8: + Dropped ssif_bmc.h file and move its content to ssif_bmc.c [Corey] + Add struct ipmi_ssif_msg to include/uapi/linux/ipmi_ssif_bmc.h header file [Corey] + Use unsigned int for len field in struct ipmi_ssif_msg [Corey] + Avoid using packed structure [Corey] + Add comment to clarify the logic flow [Corey] + Fix multipart read end with len=0 issue [Corey] + Refactor code handle the too big request message [Corey] + Fix code indentation issue [Corey] + Clean buffer before receiving request to avoid garbage [Quan] + Fix the license to SPDX-License-Identifier: GPL-2.0-only [Quan] v7: + Remove unnecessary del_timer() in response_timeout() [Corey] + Change compatible string from "ampere,ssif-bmc" to "ssif-bmc" [Jae] + Dropped the use of ssif_msg_len() macro, use the len directly [Quan] + Solve possible issue if both response timer and ssif_bmc_write() occurred at the same time [Corey] + Fix wrong return type of ssif_bmc_poll() [kernel robot test] + Refactor and introduce ssif_part_buffer struct to replace the response_buf to manage each send/receive part of ssif [Quan] + Change SSIF_BAD_SMBUS state to SSIF_ABORTING state [Corey] + Support abort feature to skip the current bad request/response and wait until next new request [Corey] + Refactor the PEC calculation to avoid the re-calculate the PEC on each I2C_SLAVE_WRITE_RECEIVED event [Quan] + Fix the use of error-proned idx [Corey] + Defer the test for valid SMBus command until the read/write part is determined [Quan] + Change/split unsupported_smbus_cmd() to supported_[write|read]_cmd() [Corey] + Abort the request if somehow its size exceeded 255 bytes [Quan] v6: + Drop the use of slave_enable() [Wolfram] + Make i2c-aspeed to issue RxCmdLast command on all I2C_SLAVE_WRITE_REQUESTED event to assert NAK when slave busy [Quan] + Make i2c slave to return -EBUSY when it's busy [Quan] + Drop the aborting feature as return Completion Code 0xFF may stop host to retry and make ipmi_ssif.so fails to load [Quan] + Add timer to recover slave from busy state when no response [Quan] + Clean request/response buffer appropriately [Quan] + Add some minor change on error and warning messages [Quan] v5: + Correct the patches order to fix the bisect issue found by kernel build robot v4: + Fix recursive spinlock [Graeme] + Send response with Completion code 0xFF when aborting [Quan] + Fix warning with dt_binding_check [Rob] + Change aspeed-ssif-bmc.yaml to ssif-bmc.yaml [Quan] + Added bounding check on SMBus writes and the whole request [Dan] + Moved buffer to end of struct ssif_bmc_ctx to avoid context corruption if somehow buffer is written past the end [Dan] + Return -EINVAL if userspace buffer too small, don't silence truncate [Corey, Joel] + Not necessary to check NONBLOCK in lock [Corey] + Enforce one user at a time [Joel] + Reject write with invalid response length from userspace [Corey] + Add state machines for better ssif bmc state handling [Quan] + Drop ssif_bmc_aspeed.c and make ssif_bmc.c is generic SSIF BMC driver [Quan] + Change compatible string "aspeed,ast2500-ssif-bmc" to "ampere,ssif-bmc" [Quan] + Toggle Slave enable in i2c-aspeed to turn on/off slave mode [Ryan] + Added slave_enable() to struct i2c_algorithm to control slave mode and to address the recursive spinlock [Graeme, Ryan] + Abort current request with invalid SMBus write or invalid command [Quan] + Abort all request if there is pending response [Quan] + Changed validate_pec() to validate_request() [Quan] + Add unsupported_smbus_cmd() to handle unknown SMBus command [Quan] + Print internal state string for ease investigating issue [Quan] + Move to READY state on SLAVE_STOP event [Quan] + Change initilize_transfer() to process_smbus_cmd() [Quan] + Introduce functions for each slave event [Quan] v3: + Switched binding doc to use DT schema format [Rob] + Splited into generic ssif_bmc and aspeed-specific [Corey, Joel] + Removed redundant license info [Joel] + Switched to use traditional if-else [Joel] + Removed unused ssif_bmc_ioctl() [Joel] + Made handle_request()/complete_response() to return void [Joel] + Refactored send_ssif_bmc_response() and receive_ssif_bmc_request() [Corey] + Remove mutex [Corey] + Use spin_lock/unlock_irqsave/restore in callback [Corey] + Removed the unnecessary memset [Corey] + Switch to use dev_err() [Corey] + Combine mask/unmask two interrupts together [Corey] + Fixed unhandled Tx done with NAK [Quan] + Late ack'ed Tx done w/wo Ack irq [Quan] + Use aspeed-specific exported aspeed_set_slave_busy() when slave busy to fix the deadlock [Graeme, Philipp, Quan] + Clean buffer for last multipart read [Quan] + Handle unknown incoming command [Quan] v2: + Fixed compiling error with COMPILE_TEST for arc Quan Nguyen (3): ipmi: ssif_bmc: Add SSIF BMC driver bindings: ipmi: Add binding for SSIF BMC driver i2c: aspeed: Assert NAK when slave is busy .../devicetree/bindings/ipmi/ssif-bmc.yaml | 38 + drivers/char/ipmi/Kconfig | 11 + drivers/char/ipmi/Makefile | 1 + drivers/char/ipmi/ssif_bmc.c | 880 ++++++++++++++++++ drivers/i2c/busses/i2c-aspeed.c | 5 +- include/uapi/linux/ipmi_ssif_bmc.h | 16 + 6 files changed, 950 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/ipmi/ssif-bmc.yaml create mode 100644 drivers/char/ipmi/ssif_bmc.c create mode 100644 include/uapi/linux/ipmi_ssif_bmc.h