From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387217; b=FkBpVAEDmRrVUcn/kxkj3WJyoz+g2vBILEkJtzni3q/ASHg32NSUvKLKfxW6b96/3lVW ybau9i1uNSsj1dKNc+IDERGymaKSVwvdHqApspRW9+hYOe/o6akKm0W80Nn+P0UGIQDyA aYePpFwsJVq/+CZqt62PUyzx0tmIQe5RgSphFKCcegiS+PEZVrhNG1L9urGAQwYrZgZ+j 2PiaJ3eJDkKX9XmrY74n0b3n0g400LpUtBT7ZYylwmidyAwAElpsxxRjgThuwdZDVFq5k lb9PUVrq5SxrKRMVEQYUF8fyjstbQ6DVBqguxoGhgNBO4h27m7PkGJsbyTLBGsRXQow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387217; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=C8u5CHUmBMsQjI1nq7aHi+YamPn0iN7inViVWgVsZEY=; b=13wFxi5OZiA0tcH0zLYZsDsaHupHOsHjddETMR7Ktd1gyBQEMXACJ6lnSsOTO3qUB6de oUt9FohAa2eLIeARKHgUOYTQekYV4JQTJZpRooO2RUeDIDpMA3n1o40t5rZLjo3naIYCe kchRWYblXTgUCKq9TK7NofYb0xLyZiA67k07xH8ok1zYLt7qumHgGLys9LlpAQ3Zlvrg3 4P8hSPcbPTasim/uGSgx/NLKB+xjtz7G6geDhB2NRflEZIL+q+z6VH3AALNDLVZdQ18bU KZJJobEKl3FLsSMnsSoO98opByV1Nb6rejj+5jLW1rPcQ+otMi0WKYtNo2a8IRq5p8A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fd3InPTX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3739B606A322 for ; Fri, 4 Dec 2026 12:26:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fd3InPTX Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCDBF1F00897; Fri, 4 Dec 2026 12:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796387216; bh=C8u5CHUmBMsQjI1nq7aHi+YamPn0iN7inViVWgVsZEY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Fd3InPTXcKqePfdSFrlpevAWMDOUe5jX8Tfi/jku3Av0JLjXZHlqxk0QlSESRz3+6 YqUdYUl9K8YGeh7401fyG3WTUJRzL29njHSpbtstUyx4K/H3E69WyGGUTvuDTTvJ42 OvIDEKRbviOn3sVRmFJ+6u1/TxSfsWYRru+DYnoRaGEApjwS75OnktEHXuPTI+CyW+ /o5Zo5Nf+Ht4XGP3ylCmFjZRkuxxLGsEoKhOP7fhnUWBMt+Ee60c7Byo0hJB9pM9dt b/EdsyxO1j6hKmSuiRp3nv2b3Clnf1F2eQRshEeP0rp+bKv30/9fCYn7K8pqps++7G 8JoEuxoIjCW/g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 3/5] mailbox: add direct synchronous transmit API Reply-To: sashiko-reviews@lists.linux.dev To: "Anup Patel" Cc: linux-clk@vger.kernel.org In-Reply-To: <20261204111504.3362889-4-anup.patel@oss.qualcomm.com> References: <20261204111504.3362889-1-anup.patel@oss.qualcomm.com> <20261204111504.3362889-4-anup.patel@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 12:26:56 +0000 X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] mailbox: appending sync_caps bloats struct mbox_chan and causes false sharing - [Low] mailbox: struct mbox_client kernel-doc omits tx_prepare and tx_done - [Low] mailbox: lockdep_assert_not_held() false positive on PREEMPT_RT hardirq -- commit 710773999a3f8b3a62dd32451d8d433420cb359f Author: Jassi Brar mailbox: add direct synchronous transmit API This commit adds an opt-in per-channel direct synchronous transmit path (mbox_send_message_sync() and mbox_send_message_sync_sleepable()) that bypasses the queued TX ring buffer and txdone state machine. > diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c > index efacd24a085d1..0cc7d2eed7cff 100644 > --- a/drivers/mailbox/mailbox.c > +++ b/drivers/mailbox/mailbox.c [ ... ] > @@ -308,6 +328,78 @@ int mbox_send_message(struct mbox_chan *chan, void *= mssg) > } > EXPORT_SYMBOL_GPL(mbox_send_message); > =20 > +/** > + * mbox_send_message_sync - directly transmit a message from atomic cont= ext > + * @chan: Mailbox channel assigned to this client. > + * @mssg: Client specific message typecasted. > + * > + * Directly invoke the controller's atomic-safe synchronous transmit > + * operation. The operation runs in the caller's context, without > + * chan->lock and without touching the queued state machine, and returns > + * the controller's per-call result. This function does not sleep and m= ay > + * be called from any context in which the controller's send_data_sync() > + * operation is safe, including hardirq context. > + * > + * The message buffer must remain valid until this function returns; the > + * controller must not retain it afterwards. The caller is responsible = for > + * serializing this call against mbox_free_channel() and driver removal. > + * > + * Return: 0 on success, -EINVAL for invalid arguments, -EOPNOTSUPP if t= he > + * channel does not support atomic-safe direct transmit, or another > + * negative errno from the controller. > + */ > +int mbox_send_message_sync(struct mbox_chan *chan, void *mssg) > +{ > + if (!chan || !READ_ONCE(chan->cl) || mssg =3D=3D MBOX_NO_MSG) > + return -EINVAL; > + > + lockdep_assert_not_held(&chan->lock); [Severity: Low] Can lockdep_assert_not_held(&chan->lock) trigger a false-positive WARN_ON on CONFIG_PREEMPT_RT when called from hardirq context? mbox_seq_show() takes chan->lock with spin_lock_irqsave() on every channel, including active direct channels. Because chan->lock is a spinlock_t, spin_lock_irqsave() maps to rt_spin_lock() on PREEMPT_RT and leaves hardware interrupts enabled while chan->lock is recorded in current->held_locks: mbox_seq_show() spin_lock_irqsave(&chan->lock) (PREEMPT_RT: IRQs stay enabled) mbox_send_message_sync(chan, ...) lockdep_assert_not_held(&chan->lock) <-- false-positive WARN_ON __lock_is_held() checks current->held_locks without filtering by irq_context, so a hardirq preempting mbox_seq_show() on the same CPU hits a spurious lockdep splat (and panics under panic_on_warn). [ ... ] > diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_clien= t.h > index e5997120f45cf..49b778aa4b9ab 100644 > --- a/include/linux/mailbox_client.h > +++ b/include/linux/mailbox_client.h > @@ -16,11 +16,13 @@ struct mbox_chan; > * struct mbox_client - User of a mailbox > * @dev: The client device > * @tx_block: If the mbox_send_message should block until data is > - * transmitted. > - * @tx_tout: Max block period in ms before TX is assumed failure > + * transmitted. Ignored on direct channels. > + * @tx_tout: Max block period in ms before TX is assumed failure. > + * Ignored on direct channels. > * @knows_txdone: If the client could run the TX state machine. Usually > * if the client receives some ACK packet for transmission. > * Unused if the controller already has TX_Done/RTR IRQ. > + * Ignored on direct channels. > * @rx_callback: Atomic callback to provide client the data received > * @tx_prepare: Atomic callback to ask client to prepare the payload > * before initiating the transmission if required. [Severity: Low] Should @tx_prepare and @tx_done (just below in struct mbox_client) also be documented as ignored on direct channels? Neither mbox_send_message_sync() nor mbox_send_message_sync_sleepable() invokes tx_prepare() or tx_done(). Marking @tx_block, @tx_tout, and @knows_txdone as ignored while leaving @tx_prepare and @tx_done unannotated suggests they are still called like @rx_callback. [ ... ] > diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_c= ontroller.h > index 26a238a6f941c..34724bfc683d7 100644 > --- a/include/linux/mailbox_controller.h > +++ b/include/linux/mailbox_controller.h [ ... ] > @@ -127,6 +157,8 @@ struct mbox_controller { > * @msg_data: Hook for data packet > * @lock: Serialise access to the channel > * @con_priv: Hook for controller driver to attach private data > + * @sync_caps: Per-channel direct transmit capabilities, immutable > + * after registration. Zero means a queued channel. > */ > struct mbox_chan { > struct mbox_controller *mbox; > @@ -139,8 +171,14 @@ struct mbox_chan { > void *msg_data[MBOX_TX_QUEUE_LEN]; > spinlock_t lock; /* Serialise access to the channel */ > void *con_priv; > + unsigned int sync_caps; /* MBOX_CHAN_CAP_SYNC_* */ > }; [Severity: Medium] Can appending sync_caps here grow struct mbox_chan from 256 to 264 bytes on 64-bit SMP and introduce cross-channel false sharing? Every queued and direct transmit or txdone hot path reads chan->sync_caps alongside chan->mbox and chan->cl. Putting sync_caps at the end puts it on a fifth cacheline, and in contiguous mbox->chans[] arrays (such as in tegra_hsp_probe()) the 264-byte stride breaks 64-byte channel alignment so chans[i].lock shares a cacheline with chans[i + 1]'s mbox and cl fields. Moving sync_caps directly after txdone_method fills an existing 4-byte padding hole on cacheline 0, keeping sizeof(struct mbox_chan) at 256 bytes and avoiding both the extra cacheline load and cross-channel bouncing. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204111504.3362= 889-1-anup.patel@oss.qualcomm.com?part=3D3