From patchwork Fri Mar 19 06:19:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 12150089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AF2CC433E0 for ; Fri, 19 Mar 2021 06:22:30 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B673464F42 for ; Fri, 19 Mar 2021 06:22:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B673464F42 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=7Xg7kBM4oGthYkD0nuUaiwjPxq3B4+khjls6UGUv2w8=; b=Nrfw0KORe4Ba2ZYaYHjGEhn4rB kssh3Z7dNKMiA5UvNxtXIQUo8YJ6BopS2qJ1ipv7ZChb5pvhiawGR+t2EoIU5n2pfnPjW+1TcsdQg zJzRWAzzU4gjxNguwNbrpP2gxl5Fuqh5x/lbPfyxjiv6O/EcEtIZ7Xv+fb0kxzIX9CoaLiuA76fbq IzyUGEMA+uWH1XizHMximQ95nznlopjw3A58S9Z29Mn9nyBsgecbyrphpR+bFweeWuALGpZXd69Rl HrTIoOq8UmfDxZAED7x8ZKjs4FyGzSPdQVntjp/kke9SzrVcnfSsZ9KiX4m+0anmItxdGBHLHXo45 5k8lhRwQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lN8VA-006cuO-A9; Fri, 19 Mar 2021 06:20:52 +0000 Received: from new4-smtp.messagingengine.com ([66.111.4.230]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lN8V3-006ctU-GP for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 06:20:49 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 9C2E3580A7A; Fri, 19 Mar 2021 02:20:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 19 Mar 2021 02:20:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=DQ0e988igZ7sIe0ymg68c1lDju Q6xtIxXzAGPLSh1nI=; b=iUz/zNDta8Y4JVXEyCbmxRcBFb5BonujfrZcF74o1l Lq9sUqDmc7QhyS25xjwdSc17BL7nsG8FJ4BqoJw+cVF9k/Bs6A4Y2pSY+mpRdzd8 uDzMOQCJgIixT0HWC947AfbzNVGU9TXK1fJoIHykU9K/neeKvT2/V55RjotrPW3f 0bdAYas6+ipiflJbLSUZmDhU3tm4wBe22TJKRzLjUIfgoEqNIX6SMmA+bw6KHLWQ ViwTslmqAoZFFa54qdeXE6XEVlD6bGKBhFv2lAr8lGBUkUU09vn0CQ8xApEzHE8K xImiHcEUDKCI5mJDACqyPD5b7ZnF5SV9V8CCgXxdloww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=DQ0e988igZ7sIe0ym g68c1lDjuQ6xtIxXzAGPLSh1nI=; b=p9WxThGyse3NLP1n85Tefdn9wRP9DroOd Wt4kI5kWTS9qWGNJ6qXYJiCqAu1jViYKt6ai6060xTok9QaR6A2uG41/j3n6XWei KwmirTXI9Fs8k2iLrMqeORuUb/qm9poyfrkF2CJgatKUpHa2lVCaguTZCQQnaB5J dlg+6OAztW+KgVz0QhCOjn7XkihFW7ZTO38WqYp80YrpKWcyWbyinNAMZ6zcY27y GjqYzHpI7jZ9UYJx1sdBtBpfnXt9NMjm26cJWiT3CwhOALYTwSd70Ai3L8tyrIfg XLDPhVc00BNGyJsWvdwZf84J43/u+LFALGXA/tJ4HUXpHq1Vl4zkg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefjedgleegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegrjhdr ihgurdgruheqnecuggftrfgrthhtvghrnhepieelfedtfeetveffgeetteetveeitefhke etvdefteevledvheekveeihfekffefnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghdp ihhnthgvlhdrtghomhdpghhithhhuhgsrdgtohhmpdgumhhtfhdrohhrghenucfkphepud dukedrvddutddrudekuddrheehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomheprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: from localhost.localdomain (ppp118-210-181-55.adl-adc-lon-bras34.tpg.internode.on.net [118.210.181.55]) by mail.messagingengine.com (Postfix) with ESMTPA id 3FD8C1080057; Fri, 19 Mar 2021 02:20:31 -0400 (EDT) From: Andrew Jeffery To: openipmi-developer@lists.sourceforge.net, openbmc@lists.ozlabs.org, minyard@acm.org Cc: joel@jms.id.au, ryan_chen@aspeedtech.com, devicetree@vger.kernel.org, tmaimon77@gmail.com, linux-aspeed@lists.ozlabs.org, linux-gpio@vger.kernel.org, avifishman70@gmail.com, venture@google.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, tali.perry1@gmail.com, robh+dt@kernel.org, lee.jones@linaro.org, chiawei_wang@aspeedtech.com, linux-arm-kernel@lists.infradead.org, benjaminfair@google.com Subject: [PATCH v2 00/21] ipmi: Allow raw access to KCS devices Date: Fri, 19 Mar 2021 16:49:30 +1030 Message-Id: <20210319061952.145040-1-andrew@aj.id.au> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_062046_235686_E193EA35 X-CRM114-Status: GOOD ( 26.00 ) 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 Hello, This series is a bit of a mix of things, but its primary purpose is to expose BMC KCS IPMI devices to userspace in a way that enables userspace to talk to host firmware using protocols that are not IPMI. v1 can be found here: https://lore.kernel.org/openbmc/20210219142523.3464540-1-andrew@aj.id.au/ Changes in v2 include: * A rebase onto v5.12-rc2 * Incorporation of off-list feedback on SerIRQ configuration from Chiawei * Further validation on hardware for ASPEED KCS devices 2, 3 and 4 * Lifting the existing single-open constraint of the IPMI chardev * Fixes addressing Rob's feedback on the conversion of the ASPEED KCS binding to dt-schema * Fixes addressing Rob's feedback on the new aspeed,lpc-interrupts property definition for the ASPEED KCS binding A new chardev device is added whose implementation exposes the Input Data Register (IDR), Output Data Register (ODR) and Status Register (STR) via read() and write(), and implements poll() for event monitoring. The existing /dev/ipmi-kcs* chardev interface exposes the KCS devices in a way which encoded the IPMI protocol in its behaviour. However, as LPC[0] KCS devices give us bi-directional interrupts between the host and a BMC with both a data and status byte, they are useful for purposes beyond IPMI. As a concrete example, libmctp[1] implements a vendor-defined MCTP[2] binding using a combination of LPC Firmware cycles for bulk data transfer and a KCS device via LPC IO cycles for out-of-band protocol control messages[3]. This gives a throughput improvement over the standard KCS binding[4] while continuing to exploit the ease of setup of the LPC bus for early boot firmware on the host processor. The series takes a bit of a winding path to achieve its aim: 1. It begins with patches 1-5 put together by Chia-Wei, which I've rebased on v5.12-rc2. These fix the ASPEED LPC bindings and other non-KCS LPC-related ASPEED device drivers in a way that enables the SerIRQ patches at the end of the series. With Joel's review I'm hoping these 5 can go through the aspeed tree, and that the rest can go through the IPMI tree. 2. Next, patches 6-13 fairly heavily refactor the KCS support in the IPMI part of the tree, re-architecting things such that it's possible to support multiple chardev implementations sitting on top of the ASPEED and Nuvoton device drivers. However, the KCS code didn't really have great separation of concerns as it stood, so even if we disregard the multiple-chardev support I think the cleanups are worthwhile. 3. Patch 14 adds some interrupt management capabilities to the KCS device drivers in preparation for patch 16, which introduces the new "raw" KCS device interface. I'm not stoked about the device name/path, so if people are looking to bikeshed something then feel free to lay into that. 4. The remaining patches switch the ASPEED KCS devicetree binding to dt-schema, add a new interrupt property to describe the SerIRQ behaviour of the device and finally clean up Serial IRQ support in the ASPEED KCS driver. Rob: The dt-binding patches still come before the relevant driver changes, I tried to keep the two close together in the series, hence the bindings changes not being patches 1 and 2. I've exercised the series under qemu with the rainier-bmc machine plus additional patches for KCS support[5]. I've also substituted this series in place of a hacky out-of-tree driver that we've been using for the libmctp stack and successfully booted the host processor under our internal full-platform simulation tools for a Rainier system. Note that this work touches the Nuvoton driver as well as ASPEED's, but I don't have the capability to test those changes or the IPMI chardev path. Tested-by tags would be much appreciated if you can exercise one or both. Please review! Andrew [0] https://www.intel.com/content/dam/www/program/design/us/en/documents/low-pin-count-interface-specification.pdf [1] https://github.com/openbmc/libmctp/ [2] https://www.dmtf.org/sites/default/files/standards/documents/DSP0236_1.3.1.pdf [3] https://github.com/openbmc/libmctp/blob/master/docs/bindings/vendor-astlpc.md [4] https://www.dmtf.org/sites/default/files/standards/documents/DSP0254_1.0.0.pdf [5] https://lore.kernel.org/qemu-devel/20210309131641.2709380-1-clg@kaod.org/ Andrew Jeffery (16): ipmi: kcs_bmc_aspeed: Use of match data to extract KCS properties ipmi: kcs_bmc: Make status update atomic ipmi: kcs_bmc: Rename {read,write}_{status,data}() functions ipmi: kcs_bmc: Split out kcs_bmc_cdev_ipmi ipmi: kcs_bmc: Turn the driver data-structures inside-out ipmi: kcs_bmc: Split headers into device and client ipmi: kcs_bmc: Strip private client data from struct kcs_bmc ipmi: kcs_bmc: Decouple the IPMI chardev from the core ipmi: kcs_bmc: Allow clients to control KCS IRQ state ipmi: kcs_bmc: Don't enforce single-open policy in the kernel ipmi: kcs_bmc: Add a "raw" character device interface dt-bindings: ipmi: Convert ASPEED KCS binding to schema dt-bindings: ipmi: Add optional SerIRQ property to ASPEED KCS devices ipmi: kcs_bmc_aspeed: Implement KCS SerIRQ configuration ipmi: kcs_bmc_aspeed: Fix IBFIE typo from datasheet ipmi: kcs_bmc_aspeed: Optionally apply status address Chia-Wei, Wang (5): dt-bindings: aspeed-lpc: Remove LPC partitioning ARM: dts: Remove LPC BMC and Host partitions ipmi: kcs: aspeed: Adapt to new LPC DTS layout pinctrl: aspeed-g5: Adapt to new LPC device tree layout soc: aspeed: Adapt to new LPC device tree layout Documentation/ABI/testing/dev-raw-kcs | 25 + .../bindings/ipmi/aspeed,ast2400-kcs-bmc.yaml | 106 +++ .../bindings/ipmi/aspeed-kcs-bmc.txt | 33 - .../devicetree/bindings/mfd/aspeed-lpc.txt | 100 +-- arch/arm/boot/dts/aspeed-g4.dtsi | 70 +- arch/arm/boot/dts/aspeed-g5.dtsi | 121 ++-- arch/arm/boot/dts/aspeed-g6.dtsi | 123 ++-- drivers/char/ipmi/Kconfig | 30 + drivers/char/ipmi/Makefile | 2 + drivers/char/ipmi/kcs_bmc.c | 534 ++++---------- drivers/char/ipmi/kcs_bmc.h | 94 +-- drivers/char/ipmi/kcs_bmc_aspeed.c | 663 +++++++++++++----- drivers/char/ipmi/kcs_bmc_cdev_ipmi.c | 570 +++++++++++++++ drivers/char/ipmi/kcs_bmc_cdev_raw.c | 443 ++++++++++++ drivers/char/ipmi/kcs_bmc_client.h | 47 ++ drivers/char/ipmi/kcs_bmc_device.h | 20 + drivers/char/ipmi/kcs_bmc_npcm7xx.c | 97 ++- drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 17 +- drivers/soc/aspeed/aspeed-lpc-ctrl.c | 20 +- drivers/soc/aspeed/aspeed-lpc-snoop.c | 23 +- 20 files changed, 2132 insertions(+), 1006 deletions(-) create mode 100644 Documentation/ABI/testing/dev-raw-kcs create mode 100644 Documentation/devicetree/bindings/ipmi/aspeed,ast2400-kcs-bmc.yaml delete mode 100644 Documentation/devicetree/bindings/ipmi/aspeed-kcs-bmc.txt create mode 100644 drivers/char/ipmi/kcs_bmc_cdev_ipmi.c create mode 100644 drivers/char/ipmi/kcs_bmc_cdev_raw.c create mode 100644 drivers/char/ipmi/kcs_bmc_client.h create mode 100644 drivers/char/ipmi/kcs_bmc_device.h Tested-by: Zev Weiss