From nobody Fri May 3 03:22:25 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DC36C76196 for ; Tue, 28 Mar 2023 13:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232979AbjC1NPK (ORCPT ); Tue, 28 Mar 2023 09:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233152AbjC1NOu (ORCPT ); Tue, 28 Mar 2023 09:14:50 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D430AD3C for ; Tue, 28 Mar 2023 06:14:43 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 8F51C424E7; Tue, 28 Mar 2023 13:14:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1680009281; bh=M7BzVw3d+64yIlKTxTOsMPRrEdN40ois41hxCJhxNek=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=yhLrq3a2VSPO6qAAar4w8yMBuoTwqmf6c9lHfCFOeyqPCzzYTVMCCl8kHGb8TpYYf 5N9ZrFREQYfuxQTLdgj1f7hY+7iFdHUe4KRqmGpQu2RmxPA5ZfPuVs0F4kjPdza5pf lm6f4HYnyHTExicoh7tNB1EC/USPBZ+WYDjV5PNPIKKWci504PUx+Aq2YhvlB2HNJ1 r4rOBRcjtibaU406MtKCBAC5tyqepsgQ8mrilPDJ0RUmJ2G5Pxrmh0IoPXV0+hTStU vVRq06BES7HPDwJ6+eNfTcmLVNpterB1yzsxZFodqNsjdjSwfEBFK1kUCXi0ylvmSy wBkbnQ/3+pobA== From: Hector Martin Date: Tue, 28 Mar 2023 22:14:14 +0900 Subject: [PATCH 1/5] soc: apple: rtkit: Get rid of apple_rtkit_send_message_wait MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230328-soc-mailbox-v1-1-3953814532fd@marcan.st> References: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> In-Reply-To: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> To: Sven Peter , Alyssa Rosenzweig , Jassi Brar , Janne Grunau Cc: linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Hector Martin X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2779; i=marcan@marcan.st; h=from:subject:message-id; bh=M7BzVw3d+64yIlKTxTOsMPRrEdN40ois41hxCJhxNek=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhhSlF5arc30WH38iP59FQLWl7b9feMIP52DDW9ULV56O1 jqQ8kqjo5SFQYyDQVZMkaXxRO+pbs/p59RVU6bDzGFlAhnCwMUpABNJu8DIsK2db2X7ohmdi6+c OFY0p+iBxwEmw6S7+/1KZ5z6IV7wq5vhf/J1tqkdvyUiFDmuzgno3RTCvGKa4+Nt927dd/96NWr ZVC4A X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is fundamentally broken and has no users. Just remove it. Signed-off-by: Hector Martin Acked-by: Eric Curtin Acked-by: Neal Gompa --- drivers/soc/apple/rtkit.c | 32 -------------------------------- include/linux/soc/apple/rtkit.h | 18 ------------------ 2 files changed, 50 deletions(-) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index d9f19dc99da5..7c9b9f25bbc1 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -641,38 +641,6 @@ int apple_rtkit_send_message(struct apple_rtkit *rtk, = u8 ep, u64 message, } EXPORT_SYMBOL_GPL(apple_rtkit_send_message); =20 -int apple_rtkit_send_message_wait(struct apple_rtkit *rtk, u8 ep, u64 mess= age, - unsigned long timeout, bool atomic) -{ - DECLARE_COMPLETION_ONSTACK(completion); - int ret; - long t; - - ret =3D apple_rtkit_send_message(rtk, ep, message, &completion, atomic); - if (ret < 0) - return ret; - - if (atomic) { - ret =3D mbox_flush(rtk->mbox_chan, timeout); - if (ret < 0) - return ret; - - if (try_wait_for_completion(&completion)) - return 0; - - return -ETIME; - } else { - t =3D wait_for_completion_interruptible_timeout( - &completion, msecs_to_jiffies(timeout)); - if (t < 0) - return t; - else if (t =3D=3D 0) - return -ETIME; - return 0; - } -} -EXPORT_SYMBOL_GPL(apple_rtkit_send_message_wait); - int apple_rtkit_poll(struct apple_rtkit *rtk) { return mbox_client_peek_data(rtk->mbox_chan); diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtki= t.h index fc456f75c131..8c9ca857ccf6 100644 --- a/include/linux/soc/apple/rtkit.h +++ b/include/linux/soc/apple/rtkit.h @@ -160,24 +160,6 @@ int apple_rtkit_start_ep(struct apple_rtkit *rtk, u8 e= ndpoint); int apple_rtkit_send_message(struct apple_rtkit *rtk, u8 ep, u64 message, struct completion *completion, bool atomic); =20 -/* - * Send a message to the given endpoint and wait until it has been submitt= ed - * to the hardware FIFO. - * Will return zero on success and a negative error code on failure - * (e.g. -ETIME when the message couldn't be written within the given - * timeout) - * - * @rtk: RTKit reference - * @ep: target endpoint - * @message: message to be sent - * @timeout: timeout in milliseconds to allow the message transmiss= ion - * to be completed - * @atomic: if set to true this function can be called from atomic - * context. - */ -int apple_rtkit_send_message_wait(struct apple_rtkit *rtk, u8 ep, u64 mess= age, - unsigned long timeout, bool atomic); - /* * Process incoming messages in atomic context. * This only guarantees that messages arrive as far as the recv_message_ea= rly --=20 2.40.0 From nobody Fri May 3 03:22:25 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 974EBC76196 for ; Tue, 28 Mar 2023 13:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233136AbjC1NPQ (ORCPT ); Tue, 28 Mar 2023 09:15:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbjC1NOw (ORCPT ); Tue, 28 Mar 2023 09:14:52 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E95ADA269 for ; Tue, 28 Mar 2023 06:14:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 40576425BD; Tue, 28 Mar 2023 13:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1680009284; bh=7ZNytj3rXeQBs6gPjD4i3yWkwyH0nFzGUCcQ2o/qxC8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=EVmoJS82Q3iiN9At/Do+rv3pDPq3v+0ZS6eYH8eXLPScwjCahi2OTJ9EXjmY6QcqU vdeoam1wqI9i/KvnJTXv1/XHz2WnEDkGyf5R8+yhNlb9/Djzyk+Qlo92Xh0ILxZJZk crR7TSlRAKwn8C+aeWMFE7YEYY9vQGeZuRrm7j/EAgYwM5xCUqpSEunZWVQqvqHhnb CCl6H+7QhynjChGQCCRsiKphQRc4bu7A9aNZSSrZv7XedBDG4Dg3TKx+M/VW7LkUE/ 6wzLUB3JmTCjQWsfwST2TgE2nviQq/Ox7qQU4kagDp/OOy9Ms7mJA5WQolVKVAgrWf JVGKsAoK5aMLw== From: Hector Martin Date: Tue, 28 Mar 2023 22:14:15 +0900 Subject: [PATCH 2/5] soc: apple: mailbox: Add ASC/M3 mailbox driver MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230328-soc-mailbox-v1-2-3953814532fd@marcan.st> References: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> In-Reply-To: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> To: Sven Peter , Alyssa Rosenzweig , Jassi Brar , Janne Grunau Cc: linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Hector Martin X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=16645; i=marcan@marcan.st; h=from:subject:message-id; bh=7ZNytj3rXeQBs6gPjD4i3yWkwyH0nFzGUCcQ2o/qxC8=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhhSlF1ay65fk7DRQF7z0ONR5QaTElYja9wuvPfujWrnE8 CCrmQVTRykLgxgHg6yYIkvjid5T3Z7Tz6mrpkyHmcPKBDKEgYtTACayfQ8jw+7pTipNdSlTy1bb TSq4YHLlKPO6WWfEi4L6nD6K7n+75gjDX+k1mRx1XnzTP57J0TxRfedrYP87R40mrdu1j339d3p XcwMA X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This new driver is based on the existing apple-mailbox driver, but replaces the usage of the mailbox subsystem with directly exported symbols. As part of this refactor, this adds support for using the hardware FIFOs (not supported in mailbox) and implicitly fixes a bunch of bugs caused by bad interactions with the mailbox subsystem. It also adds runtime-PM support. The new config symbol is APPLE_MBOX, while the module name remains identical ("apple-mailbox"). The configs are mutually exclusive in Kconfig, to avoid conflicts. Signed-off-by: Hector Martin Acked-by: Eric Curtin Acked-by: Neal Gompa --- drivers/soc/apple/Kconfig | 14 ++ drivers/soc/apple/Makefile | 3 + drivers/soc/apple/mailbox.c | 434 ++++++++++++++++++++++++++++++++++++++++= ++++ drivers/soc/apple/mailbox.h | 48 +++++ 4 files changed, 499 insertions(+) diff --git a/drivers/soc/apple/Kconfig b/drivers/soc/apple/Kconfig index a1596fefacff..caa2cf09ff7a 100644 --- a/drivers/soc/apple/Kconfig +++ b/drivers/soc/apple/Kconfig @@ -17,6 +17,20 @@ config APPLE_PMGR_PWRSTATE controls for SoC devices. This driver manages them through the generic power domain framework, and also provides reset support. =20 +config APPLE_MBOX + tristate "Apple SoC mailboxes" + depends on PM + depends on ARCH_APPLE || (64BIT && COMPILE_TEST) + depends on !APPLE_MAILBOX + default ARCH_APPLE + help + Apple SoCs have various co-processors required for certain + peripherals to work (NVMe, display controller, etc.). This + driver adds support for the mailbox controller used to + communicate with those. + + Say Y here if you have an Apple SoC. + config APPLE_RTKIT tristate "Apple RTKit co-processor IPC protocol" depends on MAILBOX diff --git a/drivers/soc/apple/Makefile b/drivers/soc/apple/Makefile index e293770cf66d..e52edf6a73da 100644 --- a/drivers/soc/apple/Makefile +++ b/drivers/soc/apple/Makefile @@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_APPLE_PMGR_PWRSTATE) +=3D apple-pmgr-pwrstate.o =20 +obj-$(CONFIG_APPLE_MBOX) +=3D apple-mailbox.o +apple-mailbox-y =3D mailbox.o + obj-$(CONFIG_APPLE_RTKIT) +=3D apple-rtkit.o apple-rtkit-y =3D rtkit.o rtkit-crashlog.o =20 diff --git a/drivers/soc/apple/mailbox.c b/drivers/soc/apple/mailbox.c new file mode 100644 index 000000000000..7bdebafa6e83 --- /dev/null +++ b/drivers/soc/apple/mailbox.c @@ -0,0 +1,434 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * Apple mailbox driver + * + * Copyright The Asahi Linux Contributors + * + * This driver adds support for two mailbox variants (called ASC and M3 by + * Apple) found in Apple SoCs such as the M1. It consists of two FIFOs use= d to + * exchange 64+32 bit messages between the main CPU and a co-processor. + * Various coprocessors implement different IPC protocols based on these s= imple + * messages and shared memory buffers. + * + * Both the main CPU and the co-processor see the same set of registers but + * the first FIFO (A2I) is always used to transfer messages from the appli= cation + * processor (us) to the I/O processor and the second one (I2A) for the + * other direction. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mailbox.h" + +#define APPLE_ASC_MBOX_CONTROL_FULL BIT(16) +#define APPLE_ASC_MBOX_CONTROL_EMPTY BIT(17) + +#define APPLE_ASC_MBOX_A2I_CONTROL 0x110 +#define APPLE_ASC_MBOX_A2I_SEND0 0x800 +#define APPLE_ASC_MBOX_A2I_SEND1 0x808 +#define APPLE_ASC_MBOX_A2I_RECV0 0x810 +#define APPLE_ASC_MBOX_A2I_RECV1 0x818 + +#define APPLE_ASC_MBOX_I2A_CONTROL 0x114 +#define APPLE_ASC_MBOX_I2A_SEND0 0x820 +#define APPLE_ASC_MBOX_I2A_SEND1 0x828 +#define APPLE_ASC_MBOX_I2A_RECV0 0x830 +#define APPLE_ASC_MBOX_I2A_RECV1 0x838 + +#define APPLE_M3_MBOX_CONTROL_FULL BIT(16) +#define APPLE_M3_MBOX_CONTROL_EMPTY BIT(17) + +#define APPLE_M3_MBOX_A2I_CONTROL 0x50 +#define APPLE_M3_MBOX_A2I_SEND0 0x60 +#define APPLE_M3_MBOX_A2I_SEND1 0x68 +#define APPLE_M3_MBOX_A2I_RECV0 0x70 +#define APPLE_M3_MBOX_A2I_RECV1 0x78 + +#define APPLE_M3_MBOX_I2A_CONTROL 0x80 +#define APPLE_M3_MBOX_I2A_SEND0 0x90 +#define APPLE_M3_MBOX_I2A_SEND1 0x98 +#define APPLE_M3_MBOX_I2A_RECV0 0xa0 +#define APPLE_M3_MBOX_I2A_RECV1 0xa8 + +#define APPLE_M3_MBOX_IRQ_ENABLE 0x48 +#define APPLE_M3_MBOX_IRQ_ACK 0x4c +#define APPLE_M3_MBOX_IRQ_A2I_EMPTY BIT(0) +#define APPLE_M3_MBOX_IRQ_A2I_NOT_EMPTY BIT(1) +#define APPLE_M3_MBOX_IRQ_I2A_EMPTY BIT(2) +#define APPLE_M3_MBOX_IRQ_I2A_NOT_EMPTY BIT(3) + +#define APPLE_MBOX_MSG1_OUTCNT GENMASK(56, 52) +#define APPLE_MBOX_MSG1_INCNT GENMASK(51, 48) +#define APPLE_MBOX_MSG1_OUTPTR GENMASK(47, 44) +#define APPLE_MBOX_MSG1_INPTR GENMASK(43, 40) +#define APPLE_MBOX_MSG1_MSG GENMASK(31, 0) + +#define APPLE_MBOX_TX_TIMEOUT 500 + +struct apple_mbox_hw { + unsigned int control_full; + unsigned int control_empty; + + unsigned int a2i_control; + unsigned int a2i_send0; + unsigned int a2i_send1; + + unsigned int i2a_control; + unsigned int i2a_recv0; + unsigned int i2a_recv1; + + bool has_irq_controls; + unsigned int irq_enable; + unsigned int irq_ack; + unsigned int irq_bit_recv_not_empty; + unsigned int irq_bit_send_empty; +}; + +int apple_mbox_send(struct apple_mbox *mbox, const struct apple_mbox_msg m= sg, + bool atomic) +{ + unsigned long flags; + int ret; + u32 mbox_ctrl; + long t; + + spin_lock_irqsave(&mbox->tx_lock, flags); + mbox_ctrl =3D readl_relaxed(mbox->regs + mbox->hw->a2i_control); + + while (mbox_ctrl & mbox->hw->control_full) { + if (atomic) { + ret =3D readl_poll_timeout_atomic( + mbox->regs + mbox->hw->a2i_control, mbox_ctrl, + !(mbox_ctrl & mbox->hw->control_full), 100, + APPLE_MBOX_TX_TIMEOUT * 1000); + + if (ret) { + spin_unlock_irqrestore(&mbox->tx_lock, flags); + return ret; + } + + break; + } + /* + * The interrupt is level triggered and will keep firing as long as the + * FIFO is empty. It will also keep firing if the FIFO was empty + * at any point in the past until it has been acknowledged at the + * mailbox level. By acknowledging it here we can ensure that we will + * only get the interrupt once the FIFO has been cleared again. + * If the FIFO is already empty before the ack it will fire again + * immediately after the ack. + */ + if (mbox->hw->has_irq_controls) { + writel_relaxed(mbox->hw->irq_bit_send_empty, + mbox->regs + mbox->hw->irq_ack); + } + enable_irq(mbox->irq_send_empty); + reinit_completion(&mbox->tx_empty); + spin_unlock_irqrestore(&mbox->tx_lock, flags); + + t =3D wait_for_completion_interruptible_timeout( + &mbox->tx_empty, + msecs_to_jiffies(APPLE_MBOX_TX_TIMEOUT)); + if (t < 0) + return t; + else if (t =3D=3D 0) + return -ETIMEDOUT; + + spin_lock_irqsave(&mbox->tx_lock, flags); + mbox_ctrl =3D readl_relaxed(mbox->regs + mbox->hw->a2i_control); + } + + writeq_relaxed(msg.msg0, mbox->regs + mbox->hw->a2i_send0); + writeq_relaxed(FIELD_PREP(APPLE_MBOX_MSG1_MSG, msg.msg1), + mbox->regs + mbox->hw->a2i_send1); + + spin_unlock_irqrestore(&mbox->tx_lock, flags); + + return 0; +} +EXPORT_SYMBOL(apple_mbox_send); + +static irqreturn_t apple_mbox_send_empty_irq(int irq, void *data) +{ + struct apple_mbox *mbox =3D data; + + /* + * We don't need to acknowledge the interrupt at the mailbox level + * here even if supported by the hardware. It will keep firing but that + * doesn't matter since it's disabled at the main interrupt controller. + * apple_mbox_send will acknowledge it before enabling + * it at the main controller again. + */ + spin_lock(&mbox->tx_lock); + disable_irq_nosync(mbox->irq_send_empty); + complete(&mbox->tx_empty); + spin_unlock(&mbox->tx_lock); + + return IRQ_HANDLED; +} + +static int apple_mbox_poll_locked(struct apple_mbox *mbox) +{ + struct apple_mbox_msg msg; + int ret =3D 0; + + u32 mbox_ctrl =3D readl_relaxed(mbox->regs + mbox->hw->i2a_control); + + while (!(mbox_ctrl & mbox->hw->control_empty)) { + msg.msg0 =3D readq_relaxed(mbox->regs + mbox->hw->i2a_recv0); + msg.msg1 =3D FIELD_GET( + APPLE_MBOX_MSG1_MSG, + readq_relaxed(mbox->regs + mbox->hw->i2a_recv1)); + + mbox->rx(mbox, msg, mbox->cookie); + ret++; + mbox_ctrl =3D readl_relaxed(mbox->regs + mbox->hw->i2a_control); + } + + /* + * The interrupt will keep firing even if there are no more messages + * unless we also acknowledge it at the mailbox level here. + * There's no race if a message comes in between the check in the while + * loop above and the ack below: If a new messages arrives inbetween + * those two the interrupt will just fire again immediately after the + * ack since it's level triggered. + */ + if (mbox->hw->has_irq_controls) { + writel_relaxed(mbox->hw->irq_bit_recv_not_empty, + mbox->regs + mbox->hw->irq_ack); + } + + return ret; +} + +static irqreturn_t apple_mbox_recv_irq(int irq, void *data) +{ + struct apple_mbox *mbox =3D data; + + spin_lock(&mbox->rx_lock); + apple_mbox_poll_locked(mbox); + spin_unlock(&mbox->rx_lock); + + return IRQ_HANDLED; +} + +int apple_mbox_poll(struct apple_mbox *mbox) +{ + unsigned long flags; + int ret; + + spin_lock_irqsave(&mbox->rx_lock, flags); + ret =3D apple_mbox_poll_locked(mbox); + spin_unlock_irqrestore(&mbox->rx_lock, flags); + + return ret; +} +EXPORT_SYMBOL(apple_mbox_poll); + +int apple_mbox_start(struct apple_mbox *mbox) +{ + int ret; + + if (mbox->active) + return 0; + + ret =3D pm_runtime_resume_and_get(mbox->dev); + if (ret) + return ret; + + /* + * Only some variants of this mailbox HW provide interrupt control + * at the mailbox level. We therefore need to handle enabling/disabling + * interrupts at the main interrupt controller anyway for hardware that + * doesn't. Just always keep the interrupts we care about enabled at + * the mailbox level so that both hardware revisions behave almost + * the same. + */ + if (mbox->hw->has_irq_controls) { + writel_relaxed(mbox->hw->irq_bit_recv_not_empty | + mbox->hw->irq_bit_send_empty, + mbox->regs + mbox->hw->irq_enable); + } + + enable_irq(mbox->irq_recv_not_empty); + mbox->active =3D true; + return 0; +} +EXPORT_SYMBOL(apple_mbox_start); + +void apple_mbox_stop(struct apple_mbox *mbox) +{ + if (!mbox->active) + return; + + mbox->active =3D false; + disable_irq(mbox->irq_recv_not_empty); + pm_runtime_mark_last_busy(mbox->dev); + pm_runtime_put_autosuspend(mbox->dev); +} +EXPORT_SYMBOL(apple_mbox_stop); + +struct apple_mbox *apple_mbox_get(struct device *dev, int index) +{ + struct of_phandle_args args; + struct platform_device *pdev; + struct apple_mbox *mbox; + int ret; + + ret =3D of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells", + index, &args); + if (ret || !args.np) + return ERR_PTR(ret); + + pdev =3D of_find_device_by_node(args.np); + of_node_put(args.np); + + if (!pdev) + return ERR_PTR(EPROBE_DEFER); + + mbox =3D platform_get_drvdata(pdev); + if (!mbox) + return ERR_PTR(EPROBE_DEFER); + + if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER)) + return ERR_PTR(ENODEV); + + return mbox; +} +EXPORT_SYMBOL(apple_mbox_get); + +struct apple_mbox *apple_mbox_get_byname(struct device *dev, const char *n= ame) +{ + int index; + + index =3D of_property_match_string(dev->of_node, "mbox-names", name); + if (index < 0) + return ERR_PTR(index); + + return apple_mbox_get(dev, index); +} +EXPORT_SYMBOL(apple_mbox_get_byname); + +static int apple_mbox_probe(struct platform_device *pdev) +{ + int ret; + char *irqname; + struct apple_mbox *mbox; + struct device *dev =3D &pdev->dev; + + mbox =3D devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); + if (!mbox) + return -ENOMEM; + + mbox->dev =3D &pdev->dev; + mbox->hw =3D of_device_get_match_data(dev); + if (!mbox->hw) + return -EINVAL; + + mbox->regs =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(mbox->regs)) + return PTR_ERR(mbox->regs); + + mbox->irq_recv_not_empty =3D + platform_get_irq_byname(pdev, "recv-not-empty"); + if (mbox->irq_recv_not_empty < 0) + return -ENODEV; + + mbox->irq_send_empty =3D platform_get_irq_byname(pdev, "send-empty"); + if (mbox->irq_send_empty < 0) + return -ENODEV; + + spin_lock_init(&mbox->rx_lock); + spin_lock_init(&mbox->tx_lock); + init_completion(&mbox->tx_empty); + + irqname =3D devm_kasprintf(dev, GFP_KERNEL, "%s-recv", dev_name(dev)); + if (!irqname) + return -ENOMEM; + + ret =3D devm_request_irq(dev, mbox->irq_recv_not_empty, + apple_mbox_recv_irq, + IRQF_NO_AUTOEN | IRQF_NO_SUSPEND, irqname, mbox); + if (ret) + return ret; + + irqname =3D devm_kasprintf(dev, GFP_KERNEL, "%s-send", dev_name(dev)); + if (!irqname) + return -ENOMEM; + + ret =3D devm_request_irq(dev, mbox->irq_send_empty, + apple_mbox_send_empty_irq, + IRQF_NO_AUTOEN | IRQF_NO_SUSPEND, irqname, mbox); + if (ret) + return ret; + + ret =3D devm_pm_runtime_enable(dev); + if (ret) + return ret; + + platform_set_drvdata(pdev, mbox); + return 0; +} + +static const struct apple_mbox_hw apple_mbox_asc_hw =3D { + .control_full =3D APPLE_ASC_MBOX_CONTROL_FULL, + .control_empty =3D APPLE_ASC_MBOX_CONTROL_EMPTY, + + .a2i_control =3D APPLE_ASC_MBOX_A2I_CONTROL, + .a2i_send0 =3D APPLE_ASC_MBOX_A2I_SEND0, + .a2i_send1 =3D APPLE_ASC_MBOX_A2I_SEND1, + + .i2a_control =3D APPLE_ASC_MBOX_I2A_CONTROL, + .i2a_recv0 =3D APPLE_ASC_MBOX_I2A_RECV0, + .i2a_recv1 =3D APPLE_ASC_MBOX_I2A_RECV1, + + .has_irq_controls =3D false, +}; + +static const struct apple_mbox_hw apple_mbox_m3_hw =3D { + .control_full =3D APPLE_M3_MBOX_CONTROL_FULL, + .control_empty =3D APPLE_M3_MBOX_CONTROL_EMPTY, + + .a2i_control =3D APPLE_M3_MBOX_A2I_CONTROL, + .a2i_send0 =3D APPLE_M3_MBOX_A2I_SEND0, + .a2i_send1 =3D APPLE_M3_MBOX_A2I_SEND1, + + .i2a_control =3D APPLE_M3_MBOX_I2A_CONTROL, + .i2a_recv0 =3D APPLE_M3_MBOX_I2A_RECV0, + .i2a_recv1 =3D APPLE_M3_MBOX_I2A_RECV1, + + .has_irq_controls =3D true, + .irq_enable =3D APPLE_M3_MBOX_IRQ_ENABLE, + .irq_ack =3D APPLE_M3_MBOX_IRQ_ACK, + .irq_bit_recv_not_empty =3D APPLE_M3_MBOX_IRQ_I2A_NOT_EMPTY, + .irq_bit_send_empty =3D APPLE_M3_MBOX_IRQ_A2I_EMPTY, +}; + +static const struct of_device_id apple_mbox_of_match[] =3D { + { .compatible =3D "apple,asc-mailbox-v4", .data =3D &apple_mbox_asc_hw }, + { .compatible =3D "apple,m3-mailbox-v2", .data =3D &apple_mbox_m3_hw }, + {} +}; +MODULE_DEVICE_TABLE(of, apple_mbox_of_match); + +static struct platform_driver apple_mbox_driver =3D { + .driver =3D { + .name =3D "apple-mailbox", + .of_match_table =3D apple_mbox_of_match, + }, + .probe =3D apple_mbox_probe, +}; +module_platform_driver(apple_mbox_driver); + +MODULE_LICENSE("Dual MIT/GPL"); +MODULE_AUTHOR("Sven Peter "); +MODULE_DESCRIPTION("Apple Mailbox driver"); diff --git a/drivers/soc/apple/mailbox.h b/drivers/soc/apple/mailbox.h new file mode 100644 index 000000000000..f73a8913da95 --- /dev/null +++ b/drivers/soc/apple/mailbox.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* + * Apple mailbox message format + * + * Copyright The Asahi Linux Contributors + */ + +#ifndef _APPLE_MAILBOX_H_ +#define _APPLE_MAILBOX_H_ + +#include +#include + +/* encodes a single 96bit message sent over the single channel */ +struct apple_mbox_msg { + u64 msg0; + u32 msg1; +}; + +struct apple_mbox { + struct device *dev; + void __iomem *regs; + const struct apple_mbox_hw *hw; + bool active; + + int irq_recv_not_empty; + int irq_send_empty; + + spinlock_t rx_lock; + spinlock_t tx_lock; + + struct completion tx_empty; + + /** Receive callback for incoming messages */ + void (*rx)(struct apple_mbox *mbox, struct apple_mbox_msg msg, void *cook= ie); + void *cookie; +}; + +struct apple_mbox *apple_mbox_get(struct device *dev, int index); +struct apple_mbox *apple_mbox_get_byname(struct device *dev, const char *n= ame); + +int apple_mbox_start(struct apple_mbox *mbox); +void apple_mbox_stop(struct apple_mbox *mbox); +int apple_mbox_poll(struct apple_mbox *mbox); +int apple_mbox_send(struct apple_mbox *mbox, struct apple_mbox_msg msg, + bool atomic); + +#endif --=20 2.40.0 From nobody Fri May 3 03:22:25 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B27F1C6FD18 for ; Tue, 28 Mar 2023 13:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233150AbjC1NP0 (ORCPT ); Tue, 28 Mar 2023 09:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232433AbjC1NO6 (ORCPT ); Tue, 28 Mar 2023 09:14:58 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89D42B463 for ; Tue, 28 Mar 2023 06:14:48 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 12A7C425FF; Tue, 28 Mar 2023 13:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1680009287; bh=7+GJvR9Q7iwdn6RqvrNP3aRb/S8micm1/klhGlkjTQs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hmxYgkrmhKrSMm1gsbnyzuk/Oy5Z9ZH4Yk2doGwr2ElU+dG8ORruuNYMvyZg21x7d ZNe0BhG5knyu2NXY6w8YxOuaUsOLx4aPUaskc659yxlOnmdcVh/pxGbhrIdhh7QDv8 akB+yp2FzyOMUHulOeI+OcUxXBmJcJHEOzCBAcc+wqadjIlNIYabkVZGt35Zd/4wSh EKYjVa8+adiglibmgZGRdFrr6HqqiCTEKuNYW+dQ/IRNpD+Cc7m1cc16OljBeDPPT+ ZDlvaf71ceYRuH1Gu24U8tifqGusHjEbkPzVS024A4nfApJ1d5pEtuaIe461T2ofdE Z61s+TVPw0heA== From: Hector Martin Date: Tue, 28 Mar 2023 22:14:16 +0900 Subject: [PATCH 3/5] soc: apple: rtkit: Port to the internal mailbox driver MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230328-soc-mailbox-v1-3-3953814532fd@marcan.st> References: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> In-Reply-To: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> To: Sven Peter , Alyssa Rosenzweig , Jassi Brar , Janne Grunau Cc: linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Hector Martin X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8077; i=marcan@marcan.st; h=from:subject:message-id; bh=7+GJvR9Q7iwdn6RqvrNP3aRb/S8micm1/klhGlkjTQs=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhhSlF1Z6n1/9W5qvvm3p9Rf3MhJuu679rryuvts9e/vJB sN1bbmXO0pZGMQ4GGTFFFkaT/Se6vacfk5dNWU6zBxWJpAhDFycAjCRA2sYGTZIV3PsWCXqE7zG 6n3dye3KFyxbjykqPX1fdWOpYqylayojw9/IUqY7u04c6pilePWw+uejmgr3ky69OBpS/1+S+cE De1YA X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have a mailbox driver in drivers/soc/apple, port the RTKit code to it. This mostly just entails replacing calls through the mailbox subsystem with direct calls into the driver. Signed-off-by: Hector Martin Acked-by: Eric Curtin Acked-by: Neal Gompa --- drivers/soc/apple/Kconfig | 2 +- drivers/soc/apple/rtkit-internal.h | 8 +-- drivers/soc/apple/rtkit.c | 101 ++++++++++-----------------------= ---- 3 files changed, 31 insertions(+), 80 deletions(-) diff --git a/drivers/soc/apple/Kconfig b/drivers/soc/apple/Kconfig index caa2cf09ff7a..d0e29bbd8c6f 100644 --- a/drivers/soc/apple/Kconfig +++ b/drivers/soc/apple/Kconfig @@ -33,7 +33,7 @@ config APPLE_MBOX =20 config APPLE_RTKIT tristate "Apple RTKit co-processor IPC protocol" - depends on MAILBOX + depends on APPLE_MBOX depends on ARCH_APPLE || COMPILE_TEST default ARCH_APPLE help diff --git a/drivers/soc/apple/rtkit-internal.h b/drivers/soc/apple/rtkit-i= nternal.h index 24bd619ec5e4..27c9fa745fd5 100644 --- a/drivers/soc/apple/rtkit-internal.h +++ b/drivers/soc/apple/rtkit-internal.h @@ -7,18 +7,17 @@ #ifndef _APPLE_RTKIT_INTERAL_H #define _APPLE_RTKIT_INTERAL_H =20 -#include #include #include #include #include #include #include -#include #include #include #include #include +#include "mailbox.h" =20 #define APPLE_RTKIT_APP_ENDPOINT_START 0x20 #define APPLE_RTKIT_MAX_ENDPOINTS 0x100 @@ -28,10 +27,7 @@ struct apple_rtkit { const struct apple_rtkit_ops *ops; struct device *dev; =20 - const char *mbox_name; - int mbox_idx; - struct mbox_client mbox_cl; - struct mbox_chan *mbox_chan; + struct apple_mbox *mbox; =20 struct completion epmap_completion; struct completion iop_pwr_ack_completion; diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index 7c9b9f25bbc1..e6d940292c9f 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -72,11 +72,6 @@ enum { #define APPLE_RTKIT_MIN_SUPPORTED_VERSION 11 #define APPLE_RTKIT_MAX_SUPPORTED_VERSION 12 =20 -struct apple_rtkit_msg { - struct completion *completion; - struct apple_mbox_msg mbox_msg; -}; - struct apple_rtkit_rx_work { struct apple_rtkit *rtk; u8 ep; @@ -550,12 +545,12 @@ static void apple_rtkit_rx_work(struct work_struct *w= ork) kfree(rtk_work); } =20 -static void apple_rtkit_rx(struct mbox_client *cl, void *mssg) +static void apple_rtkit_rx(struct apple_mbox *mbox, struct apple_mbox_msg = msg, + void *cookie) { - struct apple_rtkit *rtk =3D container_of(cl, struct apple_rtkit, mbox_cl); - struct apple_mbox_msg *msg =3D mssg; + struct apple_rtkit *rtk =3D cookie; struct apple_rtkit_rx_work *work; - u8 ep =3D msg->msg1; + u8 ep =3D msg.msg1; =20 /* * The message was read from a MMIO FIFO and we have to make @@ -571,7 +566,7 @@ static void apple_rtkit_rx(struct mbox_client *cl, void= *mssg) =20 if (ep >=3D APPLE_RTKIT_APP_ENDPOINT_START && rtk->ops->recv_message_early && - rtk->ops->recv_message_early(rtk->cookie, ep, msg->msg0)) + rtk->ops->recv_message_early(rtk->cookie, ep, msg.msg0)) return; =20 work =3D kzalloc(sizeof(*work), GFP_ATOMIC); @@ -580,30 +575,18 @@ static void apple_rtkit_rx(struct mbox_client *cl, vo= id *mssg) =20 work->rtk =3D rtk; work->ep =3D ep; - work->msg =3D msg->msg0; + work->msg =3D msg.msg0; INIT_WORK(&work->work, apple_rtkit_rx_work); queue_work(rtk->wq, &work->work); } =20 -static void apple_rtkit_tx_done(struct mbox_client *cl, void *mssg, int r) -{ - struct apple_rtkit_msg *msg =3D - container_of(mssg, struct apple_rtkit_msg, mbox_msg); - - if (r =3D=3D -ETIME) - return; - - if (msg->completion) - complete(msg->completion); - kfree(msg); -} - int apple_rtkit_send_message(struct apple_rtkit *rtk, u8 ep, u64 message, struct completion *completion, bool atomic) { - struct apple_rtkit_msg *msg; - int ret; - gfp_t flags; + struct apple_mbox_msg msg =3D { + .msg0 =3D message, + .msg1 =3D ep, + }; =20 if (rtk->crashed) return -EINVAL; @@ -611,19 +594,6 @@ int apple_rtkit_send_message(struct apple_rtkit *rtk, = u8 ep, u64 message, !apple_rtkit_is_running(rtk)) return -EINVAL; =20 - if (atomic) - flags =3D GFP_ATOMIC; - else - flags =3D GFP_KERNEL; - - msg =3D kzalloc(sizeof(*msg), flags); - if (!msg) - return -ENOMEM; - - msg->mbox_msg.msg0 =3D message; - msg->mbox_msg.msg1 =3D ep; - msg->completion =3D completion; - /* * The message will be sent with a MMIO write. We need the barrier * here to ensure any previous writes to buffers are visible to the @@ -631,19 +601,13 @@ int apple_rtkit_send_message(struct apple_rtkit *rtk,= u8 ep, u64 message, */ dma_wmb(); =20 - ret =3D mbox_send_message(rtk->mbox_chan, &msg->mbox_msg); - if (ret < 0) { - kfree(msg); - return ret; - } - - return 0; + return apple_mbox_send(rtk->mbox, msg, atomic); } EXPORT_SYMBOL_GPL(apple_rtkit_send_message); =20 int apple_rtkit_poll(struct apple_rtkit *rtk) { - return mbox_client_peek_data(rtk->mbox_chan); + return apple_mbox_poll(rtk->mbox); } EXPORT_SYMBOL_GPL(apple_rtkit_poll); =20 @@ -665,20 +629,6 @@ int apple_rtkit_start_ep(struct apple_rtkit *rtk, u8 e= ndpoint) } EXPORT_SYMBOL_GPL(apple_rtkit_start_ep); =20 -static int apple_rtkit_request_mbox_chan(struct apple_rtkit *rtk) -{ - if (rtk->mbox_name) - rtk->mbox_chan =3D mbox_request_channel_byname(&rtk->mbox_cl, - rtk->mbox_name); - else - rtk->mbox_chan =3D - mbox_request_channel(&rtk->mbox_cl, rtk->mbox_idx); - - if (IS_ERR(rtk->mbox_chan)) - return PTR_ERR(rtk->mbox_chan); - return 0; -} - struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, const char *mbox_name, int mbox_idx, const struct apple_rtkit_ops *ops) @@ -704,13 +654,18 @@ struct apple_rtkit *apple_rtkit_init(struct device *d= ev, void *cookie, bitmap_zero(rtk->endpoints, APPLE_RTKIT_MAX_ENDPOINTS); set_bit(APPLE_RTKIT_EP_MGMT, rtk->endpoints); =20 - rtk->mbox_name =3D mbox_name; - rtk->mbox_idx =3D mbox_idx; - rtk->mbox_cl.dev =3D dev; - rtk->mbox_cl.tx_block =3D false; - rtk->mbox_cl.knows_txdone =3D false; - rtk->mbox_cl.rx_callback =3D &apple_rtkit_rx; - rtk->mbox_cl.tx_done =3D &apple_rtkit_tx_done; + if (mbox_name) + rtk->mbox =3D apple_mbox_get_byname(dev, mbox_name); + else + rtk->mbox =3D apple_mbox_get(dev, mbox_idx); + + if (IS_ERR(rtk->mbox)) { + ret =3D PTR_ERR(rtk->mbox); + goto free_rtk; + } + + rtk->mbox->rx =3D apple_rtkit_rx; + rtk->mbox->cookie =3D rtk; =20 rtk->wq =3D alloc_ordered_workqueue("rtkit-%s", WQ_MEM_RECLAIM, dev_name(rtk->dev)); @@ -719,7 +674,7 @@ struct apple_rtkit *apple_rtkit_init(struct device *dev= , void *cookie, goto free_rtk; } =20 - ret =3D apple_rtkit_request_mbox_chan(rtk); + ret =3D apple_mbox_start(rtk->mbox); if (ret) goto destroy_wq; =20 @@ -750,7 +705,7 @@ static int apple_rtkit_wait_for_completion(struct compl= etion *c) int apple_rtkit_reinit(struct apple_rtkit *rtk) { /* make sure we don't handle any messages while reinitializing */ - mbox_free_channel(rtk->mbox_chan); + apple_mbox_stop(rtk->mbox); flush_workqueue(rtk->wq); =20 apple_rtkit_free_buffer(rtk, &rtk->ioreport_buffer); @@ -774,7 +729,7 @@ int apple_rtkit_reinit(struct apple_rtkit *rtk) rtk->iop_power_state =3D APPLE_RTKIT_PWR_STATE_OFF; rtk->ap_power_state =3D APPLE_RTKIT_PWR_STATE_OFF; =20 - return apple_rtkit_request_mbox_chan(rtk); + return apple_mbox_start(rtk->mbox); } EXPORT_SYMBOL_GPL(apple_rtkit_reinit); =20 @@ -930,7 +885,7 @@ EXPORT_SYMBOL_GPL(apple_rtkit_wake); =20 void apple_rtkit_free(struct apple_rtkit *rtk) { - mbox_free_channel(rtk->mbox_chan); + apple_mbox_stop(rtk->mbox); destroy_workqueue(rtk->wq); =20 apple_rtkit_free_buffer(rtk, &rtk->ioreport_buffer); --=20 2.40.0 From nobody Fri May 3 03:22:25 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1F3CC6FD18 for ; Tue, 28 Mar 2023 13:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232890AbjC1NP2 (ORCPT ); Tue, 28 Mar 2023 09:15:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232694AbjC1NO7 (ORCPT ); Tue, 28 Mar 2023 09:14:59 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694229EEE for ; Tue, 28 Mar 2023 06:14:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id A0C5342618; Tue, 28 Mar 2023 13:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1680009289; bh=gX0+H+/vQnX55PjESjX+h3IDdrFj6hdhmYLUgpV640g=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CDaowcFqsiAHyGEhPsbxr7OuQYRTLgtKACQB7/AjXoOgFZkOtXxgmGujiKwi3KEBZ /QPaSokrhFGS8cRQByxBPb1qSGfOV9vw7yeRuM2Gx1bx3+jnIPvOfAgYivfWeCGngB 7WGDrxy7FB3bKG+RqTWxOpUqLUk2yEbKfsqq87BmM1KUdmHOwmGt41vixuFBs+owB1 Uh279Y4CPTdWxGKhIegnpxVZm3VZQZvSc0xTvt/Jx+LrcsoTesadclhPPR/Ct2tFOY MYkVfw7K1cOWId4JGXrOy66gRwTMzoo6+T9084e95YnZ9B7J4PM3p3GkclKkq8sFsE zoUGEHTY0C9/g== From: Hector Martin Date: Tue, 28 Mar 2023 22:14:17 +0900 Subject: [PATCH 4/5] mailbox: apple: Delete driver MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230328-soc-mailbox-v1-4-3953814532fd@marcan.st> References: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> In-Reply-To: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> To: Sven Peter , Alyssa Rosenzweig , Jassi Brar , Janne Grunau Cc: linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Hector Martin X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=16535; i=marcan@marcan.st; h=from:subject:message-id; bh=gX0+H+/vQnX55PjESjX+h3IDdrFj6hdhmYLUgpV640g=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhhSlF9ZPzf+UV+fcKU1XW9eWVrhL7uieD6rzsy+d/fD3Q 6PZ5HLnjlIWBjEOBlkxRZbGE72nuj2nn1NXTZkOM4eVCWQIAxenAEzkVj7DX3HFr88WhPtqa6xu WHBF4+RDwQfLP/DUnvSsTTfasPW+tQIjw7oNxYHnjM9O+iH/J8d3QgDDjk9Ff7Wmn+vWeCCzPva kCBsA X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver is now orphaned and superseded by drivers/soc/apple/mailbox.c. Signed-off-by: Hector Martin Acked-by: Eric Curtin Acked-by: Neal Gompa --- MAINTAINERS | 2 - drivers/mailbox/Kconfig | 12 -- drivers/mailbox/Makefile | 2 - drivers/mailbox/apple-mailbox.c | 441 ------------------------------------= ---- include/linux/apple-mailbox.h | 19 -- 5 files changed, 476 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 8d5bc223f305..c115e0ad41da 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1966,7 +1966,6 @@ F: drivers/i2c/busses/i2c-pasemi-platform.c F: drivers/iommu/apple-dart.c F: drivers/iommu/io-pgtable-dart.c F: drivers/irqchip/irq-apple-aic.c -F: drivers/mailbox/apple-mailbox.c F: drivers/nvme/host/apple.c F: drivers/nvmem/apple-efuses.c F: drivers/pinctrl/pinctrl-apple-gpio.c @@ -1974,7 +1973,6 @@ F: drivers/soc/apple/* F: drivers/watchdog/apple_wdt.c F: include/dt-bindings/interrupt-controller/apple-aic.h F: include/dt-bindings/pinctrl/apple.h -F: include/linux/apple-mailbox.h F: include/linux/soc/apple/* =20 ARM/APPLE MACHINE SOUND DRIVERS diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 1495965bc394..73952108cc52 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -8,18 +8,6 @@ menuconfig MAILBOX =20 if MAILBOX =20 -config APPLE_MAILBOX - tristate "Apple Mailbox driver" - depends on ARCH_APPLE || (ARM64 && COMPILE_TEST) - default ARCH_APPLE - help - Apple SoCs have various co-processors required for certain - peripherals to work (NVMe, display controller, etc.). This - driver adds support for the mailbox controller used to - communicate with those. - - Say Y here if you have a Apple SoC. - config ARM_MHU tristate "ARM MHU Mailbox" depends on ARM_AMBA diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index fc9376117111..18793e6caa2f 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -60,5 +60,3 @@ obj-$(CONFIG_SUN6I_MSGBOX) +=3D sun6i-msgbox.o obj-$(CONFIG_SPRD_MBOX) +=3D sprd-mailbox.o =20 obj-$(CONFIG_QCOM_IPCC) +=3D qcom-ipcc.o - -obj-$(CONFIG_APPLE_MAILBOX) +=3D apple-mailbox.o diff --git a/drivers/mailbox/apple-mailbox.c b/drivers/mailbox/apple-mailbo= x.c deleted file mode 100644 index 2a3e8d8ff8b5..000000000000 --- a/drivers/mailbox/apple-mailbox.c +++ /dev/null @@ -1,441 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only OR MIT -/* - * Apple mailbox driver - * - * Copyright (C) 2021 The Asahi Linux Contributors - * - * This driver adds support for two mailbox variants (called ASC and M3 by - * Apple) found in Apple SoCs such as the M1. It consists of two FIFOs use= d to - * exchange 64+32 bit messages between the main CPU and a co-processor. - * Various coprocessors implement different IPC protocols based on these s= imple - * messages and shared memory buffers. - * - * Both the main CPU and the co-processor see the same set of registers but - * the first FIFO (A2I) is always used to transfer messages from the appli= cation - * processor (us) to the I/O processor and the second one (I2A) for the - * other direction. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define APPLE_ASC_MBOX_CONTROL_FULL BIT(16) -#define APPLE_ASC_MBOX_CONTROL_EMPTY BIT(17) - -#define APPLE_ASC_MBOX_A2I_CONTROL 0x110 -#define APPLE_ASC_MBOX_A2I_SEND0 0x800 -#define APPLE_ASC_MBOX_A2I_SEND1 0x808 -#define APPLE_ASC_MBOX_A2I_RECV0 0x810 -#define APPLE_ASC_MBOX_A2I_RECV1 0x818 - -#define APPLE_ASC_MBOX_I2A_CONTROL 0x114 -#define APPLE_ASC_MBOX_I2A_SEND0 0x820 -#define APPLE_ASC_MBOX_I2A_SEND1 0x828 -#define APPLE_ASC_MBOX_I2A_RECV0 0x830 -#define APPLE_ASC_MBOX_I2A_RECV1 0x838 - -#define APPLE_M3_MBOX_CONTROL_FULL BIT(16) -#define APPLE_M3_MBOX_CONTROL_EMPTY BIT(17) - -#define APPLE_M3_MBOX_A2I_CONTROL 0x50 -#define APPLE_M3_MBOX_A2I_SEND0 0x60 -#define APPLE_M3_MBOX_A2I_SEND1 0x68 -#define APPLE_M3_MBOX_A2I_RECV0 0x70 -#define APPLE_M3_MBOX_A2I_RECV1 0x78 - -#define APPLE_M3_MBOX_I2A_CONTROL 0x80 -#define APPLE_M3_MBOX_I2A_SEND0 0x90 -#define APPLE_M3_MBOX_I2A_SEND1 0x98 -#define APPLE_M3_MBOX_I2A_RECV0 0xa0 -#define APPLE_M3_MBOX_I2A_RECV1 0xa8 - -#define APPLE_M3_MBOX_IRQ_ENABLE 0x48 -#define APPLE_M3_MBOX_IRQ_ACK 0x4c -#define APPLE_M3_MBOX_IRQ_A2I_EMPTY BIT(0) -#define APPLE_M3_MBOX_IRQ_A2I_NOT_EMPTY BIT(1) -#define APPLE_M3_MBOX_IRQ_I2A_EMPTY BIT(2) -#define APPLE_M3_MBOX_IRQ_I2A_NOT_EMPTY BIT(3) - -#define APPLE_MBOX_MSG1_OUTCNT GENMASK(56, 52) -#define APPLE_MBOX_MSG1_INCNT GENMASK(51, 48) -#define APPLE_MBOX_MSG1_OUTPTR GENMASK(47, 44) -#define APPLE_MBOX_MSG1_INPTR GENMASK(43, 40) -#define APPLE_MBOX_MSG1_MSG GENMASK(31, 0) - -struct apple_mbox_hw { - unsigned int control_full; - unsigned int control_empty; - - unsigned int a2i_control; - unsigned int a2i_send0; - unsigned int a2i_send1; - - unsigned int i2a_control; - unsigned int i2a_recv0; - unsigned int i2a_recv1; - - bool has_irq_controls; - unsigned int irq_enable; - unsigned int irq_ack; - unsigned int irq_bit_recv_not_empty; - unsigned int irq_bit_send_empty; -}; - -struct apple_mbox { - void __iomem *regs; - const struct apple_mbox_hw *hw; - - int irq_recv_not_empty; - int irq_send_empty; - - struct mbox_chan chan; - - struct device *dev; - struct mbox_controller controller; - spinlock_t rx_lock; -}; - -static const struct of_device_id apple_mbox_of_match[]; - -static bool apple_mbox_hw_can_send(struct apple_mbox *apple_mbox) -{ - u32 mbox_ctrl =3D - readl_relaxed(apple_mbox->regs + apple_mbox->hw->a2i_control); - - return !(mbox_ctrl & apple_mbox->hw->control_full); -} - -static bool apple_mbox_hw_send_empty(struct apple_mbox *apple_mbox) -{ - u32 mbox_ctrl =3D - readl_relaxed(apple_mbox->regs + apple_mbox->hw->a2i_control); - - return mbox_ctrl & apple_mbox->hw->control_empty; -} - -static int apple_mbox_hw_send(struct apple_mbox *apple_mbox, - struct apple_mbox_msg *msg) -{ - if (!apple_mbox_hw_can_send(apple_mbox)) - return -EBUSY; - - dev_dbg(apple_mbox->dev, "> TX %016llx %08x\n", msg->msg0, msg->msg1); - - writeq_relaxed(msg->msg0, apple_mbox->regs + apple_mbox->hw->a2i_send0); - writeq_relaxed(FIELD_PREP(APPLE_MBOX_MSG1_MSG, msg->msg1), - apple_mbox->regs + apple_mbox->hw->a2i_send1); - - return 0; -} - -static bool apple_mbox_hw_can_recv(struct apple_mbox *apple_mbox) -{ - u32 mbox_ctrl =3D - readl_relaxed(apple_mbox->regs + apple_mbox->hw->i2a_control); - - return !(mbox_ctrl & apple_mbox->hw->control_empty); -} - -static int apple_mbox_hw_recv(struct apple_mbox *apple_mbox, - struct apple_mbox_msg *msg) -{ - if (!apple_mbox_hw_can_recv(apple_mbox)) - return -ENOMSG; - - msg->msg0 =3D readq_relaxed(apple_mbox->regs + apple_mbox->hw->i2a_recv0); - msg->msg1 =3D FIELD_GET( - APPLE_MBOX_MSG1_MSG, - readq_relaxed(apple_mbox->regs + apple_mbox->hw->i2a_recv1)); - - dev_dbg(apple_mbox->dev, "< RX %016llx %08x\n", msg->msg0, msg->msg1); - - return 0; -} - -static int apple_mbox_chan_send_data(struct mbox_chan *chan, void *data) -{ - struct apple_mbox *apple_mbox =3D chan->con_priv; - struct apple_mbox_msg *msg =3D data; - int ret; - - ret =3D apple_mbox_hw_send(apple_mbox, msg); - if (ret) - return ret; - - /* - * The interrupt is level triggered and will keep firing as long as the - * FIFO is empty. It will also keep firing if the FIFO was empty - * at any point in the past until it has been acknowledged at the - * mailbox level. By acknowledging it here we can ensure that we will - * only get the interrupt once the FIFO has been cleared again. - * If the FIFO is already empty before the ack it will fire again - * immediately after the ack. - */ - if (apple_mbox->hw->has_irq_controls) { - writel_relaxed(apple_mbox->hw->irq_bit_send_empty, - apple_mbox->regs + apple_mbox->hw->irq_ack); - } - enable_irq(apple_mbox->irq_send_empty); - - return 0; -} - -static irqreturn_t apple_mbox_send_empty_irq(int irq, void *data) -{ - struct apple_mbox *apple_mbox =3D data; - - /* - * We don't need to acknowledge the interrupt at the mailbox level - * here even if supported by the hardware. It will keep firing but that - * doesn't matter since it's disabled at the main interrupt controller. - * apple_mbox_chan_send_data will acknowledge it before enabling - * it at the main controller again. - */ - disable_irq_nosync(apple_mbox->irq_send_empty); - mbox_chan_txdone(&apple_mbox->chan, 0); - return IRQ_HANDLED; -} - -static int apple_mbox_poll(struct apple_mbox *apple_mbox) -{ - struct apple_mbox_msg msg; - int ret =3D 0; - - while (apple_mbox_hw_recv(apple_mbox, &msg) =3D=3D 0) { - mbox_chan_received_data(&apple_mbox->chan, (void *)&msg); - ret++; - } - - /* - * The interrupt will keep firing even if there are no more messages - * unless we also acknowledge it at the mailbox level here. - * There's no race if a message comes in between the check in the while - * loop above and the ack below: If a new messages arrives inbetween - * those two the interrupt will just fire again immediately after the - * ack since it's level triggered. - */ - if (apple_mbox->hw->has_irq_controls) { - writel_relaxed(apple_mbox->hw->irq_bit_recv_not_empty, - apple_mbox->regs + apple_mbox->hw->irq_ack); - } - - return ret; -} - -static irqreturn_t apple_mbox_recv_irq(int irq, void *data) -{ - struct apple_mbox *apple_mbox =3D data; - - spin_lock(&apple_mbox->rx_lock); - apple_mbox_poll(apple_mbox); - spin_unlock(&apple_mbox->rx_lock); - - return IRQ_HANDLED; -} - -static bool apple_mbox_chan_peek_data(struct mbox_chan *chan) -{ - struct apple_mbox *apple_mbox =3D chan->con_priv; - unsigned long flags; - int ret; - - spin_lock_irqsave(&apple_mbox->rx_lock, flags); - ret =3D apple_mbox_poll(apple_mbox); - spin_unlock_irqrestore(&apple_mbox->rx_lock, flags); - - return ret > 0; -} - -static int apple_mbox_chan_flush(struct mbox_chan *chan, unsigned long tim= eout) -{ - struct apple_mbox *apple_mbox =3D chan->con_priv; - unsigned long deadline =3D jiffies + msecs_to_jiffies(timeout); - - while (time_before(jiffies, deadline)) { - if (apple_mbox_hw_send_empty(apple_mbox)) { - mbox_chan_txdone(&apple_mbox->chan, 0); - return 0; - } - - udelay(1); - } - - return -ETIME; -} - -static int apple_mbox_chan_startup(struct mbox_chan *chan) -{ - struct apple_mbox *apple_mbox =3D chan->con_priv; - - /* - * Only some variants of this mailbox HW provide interrupt control - * at the mailbox level. We therefore need to handle enabling/disabling - * interrupts at the main interrupt controller anyway for hardware that - * doesn't. Just always keep the interrupts we care about enabled at - * the mailbox level so that both hardware revisions behave almost - * the same. - */ - if (apple_mbox->hw->has_irq_controls) { - writel_relaxed(apple_mbox->hw->irq_bit_recv_not_empty | - apple_mbox->hw->irq_bit_send_empty, - apple_mbox->regs + apple_mbox->hw->irq_enable); - } - - enable_irq(apple_mbox->irq_recv_not_empty); - return 0; -} - -static void apple_mbox_chan_shutdown(struct mbox_chan *chan) -{ - struct apple_mbox *apple_mbox =3D chan->con_priv; - - disable_irq(apple_mbox->irq_recv_not_empty); -} - -static const struct mbox_chan_ops apple_mbox_ops =3D { - .send_data =3D apple_mbox_chan_send_data, - .peek_data =3D apple_mbox_chan_peek_data, - .flush =3D apple_mbox_chan_flush, - .startup =3D apple_mbox_chan_startup, - .shutdown =3D apple_mbox_chan_shutdown, -}; - -static struct mbox_chan *apple_mbox_of_xlate(struct mbox_controller *mbox, - const struct of_phandle_args *args) -{ - if (args->args_count !=3D 0) - return ERR_PTR(-EINVAL); - - return &mbox->chans[0]; -} - -static int apple_mbox_probe(struct platform_device *pdev) -{ - int ret; - const struct of_device_id *match; - char *irqname; - struct apple_mbox *mbox; - struct device *dev =3D &pdev->dev; - - match =3D of_match_node(apple_mbox_of_match, pdev->dev.of_node); - if (!match) - return -EINVAL; - if (!match->data) - return -EINVAL; - - mbox =3D devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); - if (!mbox) - return -ENOMEM; - platform_set_drvdata(pdev, mbox); - - mbox->dev =3D dev; - mbox->regs =3D devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(mbox->regs)) - return PTR_ERR(mbox->regs); - - mbox->hw =3D match->data; - mbox->irq_recv_not_empty =3D - platform_get_irq_byname(pdev, "recv-not-empty"); - if (mbox->irq_recv_not_empty < 0) - return -ENODEV; - - mbox->irq_send_empty =3D platform_get_irq_byname(pdev, "send-empty"); - if (mbox->irq_send_empty < 0) - return -ENODEV; - - mbox->controller.dev =3D mbox->dev; - mbox->controller.num_chans =3D 1; - mbox->controller.chans =3D &mbox->chan; - mbox->controller.ops =3D &apple_mbox_ops; - mbox->controller.txdone_irq =3D true; - mbox->controller.of_xlate =3D apple_mbox_of_xlate; - mbox->chan.con_priv =3D mbox; - spin_lock_init(&mbox->rx_lock); - - irqname =3D devm_kasprintf(dev, GFP_KERNEL, "%s-recv", dev_name(dev)); - if (!irqname) - return -ENOMEM; - - ret =3D devm_request_threaded_irq(dev, mbox->irq_recv_not_empty, NULL, - apple_mbox_recv_irq, - IRQF_NO_AUTOEN | IRQF_ONESHOT, irqname, - mbox); - if (ret) - return ret; - - irqname =3D devm_kasprintf(dev, GFP_KERNEL, "%s-send", dev_name(dev)); - if (!irqname) - return -ENOMEM; - - ret =3D devm_request_irq(dev, mbox->irq_send_empty, - apple_mbox_send_empty_irq, IRQF_NO_AUTOEN, - irqname, mbox); - if (ret) - return ret; - - return devm_mbox_controller_register(dev, &mbox->controller); -} - -static const struct apple_mbox_hw apple_mbox_asc_hw =3D { - .control_full =3D APPLE_ASC_MBOX_CONTROL_FULL, - .control_empty =3D APPLE_ASC_MBOX_CONTROL_EMPTY, - - .a2i_control =3D APPLE_ASC_MBOX_A2I_CONTROL, - .a2i_send0 =3D APPLE_ASC_MBOX_A2I_SEND0, - .a2i_send1 =3D APPLE_ASC_MBOX_A2I_SEND1, - - .i2a_control =3D APPLE_ASC_MBOX_I2A_CONTROL, - .i2a_recv0 =3D APPLE_ASC_MBOX_I2A_RECV0, - .i2a_recv1 =3D APPLE_ASC_MBOX_I2A_RECV1, - - .has_irq_controls =3D false, -}; - -static const struct apple_mbox_hw apple_mbox_m3_hw =3D { - .control_full =3D APPLE_M3_MBOX_CONTROL_FULL, - .control_empty =3D APPLE_M3_MBOX_CONTROL_EMPTY, - - .a2i_control =3D APPLE_M3_MBOX_A2I_CONTROL, - .a2i_send0 =3D APPLE_M3_MBOX_A2I_SEND0, - .a2i_send1 =3D APPLE_M3_MBOX_A2I_SEND1, - - .i2a_control =3D APPLE_M3_MBOX_I2A_CONTROL, - .i2a_recv0 =3D APPLE_M3_MBOX_I2A_RECV0, - .i2a_recv1 =3D APPLE_M3_MBOX_I2A_RECV1, - - .has_irq_controls =3D true, - .irq_enable =3D APPLE_M3_MBOX_IRQ_ENABLE, - .irq_ack =3D APPLE_M3_MBOX_IRQ_ACK, - .irq_bit_recv_not_empty =3D APPLE_M3_MBOX_IRQ_I2A_NOT_EMPTY, - .irq_bit_send_empty =3D APPLE_M3_MBOX_IRQ_A2I_EMPTY, -}; - -static const struct of_device_id apple_mbox_of_match[] =3D { - { .compatible =3D "apple,asc-mailbox-v4", .data =3D &apple_mbox_asc_hw }, - { .compatible =3D "apple,m3-mailbox-v2", .data =3D &apple_mbox_m3_hw }, - {} -}; -MODULE_DEVICE_TABLE(of, apple_mbox_of_match); - -static struct platform_driver apple_mbox_driver =3D { - .driver =3D { - .name =3D "apple-mailbox", - .of_match_table =3D apple_mbox_of_match, - }, - .probe =3D apple_mbox_probe, -}; -module_platform_driver(apple_mbox_driver); - -MODULE_LICENSE("Dual MIT/GPL"); -MODULE_AUTHOR("Sven Peter "); -MODULE_DESCRIPTION("Apple Mailbox driver"); diff --git a/include/linux/apple-mailbox.h b/include/linux/apple-mailbox.h deleted file mode 100644 index 720fbb70294a..000000000000 --- a/include/linux/apple-mailbox.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ -/* - * Apple mailbox message format - * - * Copyright (C) 2021 The Asahi Linux Contributors - */ - -#ifndef _LINUX_APPLE_MAILBOX_H_ -#define _LINUX_APPLE_MAILBOX_H_ - -#include - -/* encodes a single 96bit message sent over the single channel */ -struct apple_mbox_msg { - u64 msg0; - u32 msg1; -}; - -#endif --=20 2.40.0 From nobody Fri May 3 03:22:25 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9284CC6FD18 for ; Tue, 28 Mar 2023 13:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233006AbjC1NPc (ORCPT ); Tue, 28 Mar 2023 09:15:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232802AbjC1NPA (ORCPT ); Tue, 28 Mar 2023 09:15:00 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE88FB74B for ; Tue, 28 Mar 2023 06:14:53 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 8717B4249A; Tue, 28 Mar 2023 13:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1680009292; bh=WRbEluBIEV7jHnCWK701TbH9lXJAyLcM/aZGlX67/Kg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hXjfxzmy+bjJP1Fpfh00OxQbjMxbWQlrxsqL63NpIge5jgXFjTRR5wNPyCSeQBcSk wkCjGkpT/0FFpnN9lbfu8Je2zpxtZ0Cdqo4P2ABY/gj3R41LFUJVPELVLWUF6pgzYJ QqKCycYHxvU+wk4BP7mZDWUeZFmSfZlw6IQgqqPpWkYLWc/+w4k1HBP1JcdtkYD1cU Fd8NZmGT4dnuSf2Djb5LPI+vLPAuFaq/QKfmWifiLSkveMz24pmrIzMqxwleDr6tUF jpiUPKv4HZTLGUWsB8SrB9RJfrrwb5Mpe6c980+SSR7rQIerk8ZWshPhil9vABVU4B iK3Rp26CRo4Rw== From: Hector Martin Date: Tue, 28 Mar 2023 22:14:18 +0900 Subject: [PATCH 5/5] soc: apple: mailbox: Rename config symbol to APPLE_MAILBOX MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230328-soc-mailbox-v1-5-3953814532fd@marcan.st> References: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> In-Reply-To: <20230328-soc-mailbox-v1-0-3953814532fd@marcan.st> To: Sven Peter , Alyssa Rosenzweig , Jassi Brar , Janne Grunau Cc: linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Hector Martin X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1768; i=marcan@marcan.st; h=from:subject:message-id; bh=WRbEluBIEV7jHnCWK701TbH9lXJAyLcM/aZGlX67/Kg=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhhSlFzb2Ledid97V2H582/tdDi4XleJzH76YsEH+hFKuc HugRn5ERykLgxgHg6yYIkvjid5T3Z7Tz6mrpkyHmcPKBDKEgYtTACZy2YThn73sX8ktsz/XCmyL WLRiB2/gbKXa6rBd2ucu9+iUh5VG6TMyfJUXW3JaM3k523sF5f0FttfTaqM3fpMyzqpVT/4WtmA jPwA= X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the original owner of APPLE_MAILBOX removed, let's rename the new APPLE_MBOX to the old name. This avoids .config churn for downstream users, and leaves us with an identical config symbol and module name as before. Signed-off-by: Hector Martin Acked-by: Eric Curtin Acked-by: Neal Gompa --- drivers/soc/apple/Kconfig | 5 ++--- drivers/soc/apple/Makefile | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/soc/apple/Kconfig b/drivers/soc/apple/Kconfig index d0e29bbd8c6f..c5203c388bf4 100644 --- a/drivers/soc/apple/Kconfig +++ b/drivers/soc/apple/Kconfig @@ -17,11 +17,10 @@ config APPLE_PMGR_PWRSTATE controls for SoC devices. This driver manages them through the generic power domain framework, and also provides reset support. =20 -config APPLE_MBOX +config APPLE_MAILBOX tristate "Apple SoC mailboxes" depends on PM depends on ARCH_APPLE || (64BIT && COMPILE_TEST) - depends on !APPLE_MAILBOX default ARCH_APPLE help Apple SoCs have various co-processors required for certain @@ -33,7 +32,7 @@ config APPLE_MBOX =20 config APPLE_RTKIT tristate "Apple RTKit co-processor IPC protocol" - depends on APPLE_MBOX + depends on APPLE_MAILBOX depends on ARCH_APPLE || COMPILE_TEST default ARCH_APPLE help diff --git a/drivers/soc/apple/Makefile b/drivers/soc/apple/Makefile index e52edf6a73da..20feee6f3943 100644 --- a/drivers/soc/apple/Makefile +++ b/drivers/soc/apple/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_APPLE_PMGR_PWRSTATE) +=3D apple-pmgr-pwrstate.o =20 -obj-$(CONFIG_APPLE_MBOX) +=3D apple-mailbox.o +obj-$(CONFIG_APPLE_MAILBOX) +=3D apple-mailbox.o apple-mailbox-y =3D mailbox.o =20 obj-$(CONFIG_APPLE_RTKIT) +=3D apple-rtkit.o --=20 2.40.0