* [PATCH 0/2] mailbox: tegra-hsp: Reject duplicate mailbox clients @ 2026-12-03 8:33 Jiangtian Feng 2026-12-03 8:33 ` [PATCH 1/2] mailbox: tegra-hsp: Reject duplicate doorbell clients Jiangtian Feng 2026-12-03 8:33 ` [PATCH 2/2] mailbox: tegra-hsp: Reject duplicate shared mailbox clients Jiangtian Feng 0 siblings, 2 replies; 4+ messages in thread From: Jiangtian Feng @ 2026-12-03 8:33 UTC (permalink / raw) To: jassisinghbrar Cc: thierry.reding, jonathanh, linux-kernel, linux-tegra, Jiangtian Feng These two small patches prevent a repeated mailbox request from changing the state of an active client. The doorbell patch rejects a duplicate request while chan->cl is live. Using the client pointer rather than the channel pointer alone preserves retries after a failed startup while keeping exclusive ownership during normal use. The shared mailbox patch rejects an occupied channel before changing mb->ops or mb->producer, preserving the original client's direction, width and interrupt mask. The failed-startup channel-slot lifetime issue is pre-existing and is intentionally outside this small series. Validation: - Independent static review found no High/Medium issues. - W=1 tegra-hsp.o builds after each patch. - Complete ARM64 Image build; size 44,833,280 bytes, SHA-256 f972a099b2da6e801c41d25558c3803af604bdbb1113adfdeda931b6e94e0d28. - Fixes tags were verified against full repository history. - Final patches have no checkpatch warnings; only the submitter's DCO sign-off is pending. NOT_RUN: - Repeated client, BPMP, startup failure/rebind and IRQ runtime testing. - NOIRQ suspend/resume and hardware fault injection. Jiangtian Feng (2): mailbox: tegra-hsp: Reject duplicate doorbell clients mailbox: tegra-hsp: Reject duplicate shared mailbox clients drivers/mailbox/tegra-hsp.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.47.3 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] mailbox: tegra-hsp: Reject duplicate doorbell clients 2026-12-03 8:33 [PATCH 0/2] mailbox: tegra-hsp: Reject duplicate mailbox clients Jiangtian Feng @ 2026-12-03 8:33 ` Jiangtian Feng 2026-12-03 9:29 ` [PATCH] mailbox: tegra-hsp: Reuse doorbell slots after failed startup Jiangtian Feng 2026-12-03 8:33 ` [PATCH 2/2] mailbox: tegra-hsp: Reject duplicate shared mailbox clients Jiangtian Feng 1 sibling, 1 reply; 4+ messages in thread From: Jiangtian Feng @ 2026-12-03 8:33 UTC (permalink / raw) To: jassisinghbrar Cc: thierry.reding, jonathanh, linux-kernel, linux-tegra, Jiangtian Feng tegra_hsp_db_xlate() overwrites db->channel.chan for each request. A second client for the same master can replace an active binding, leaving the original client with corrupted IRQ state and allowing callbacks before the new client is installed. Reject requests while the doorbell has a live client. Checking chan->cl rather than the channel pointer alone preserves retries after a failed startup while keeping exclusive ownership during normal use. Qoder, an AI coding assistant, helped analyze the duplicate-binding failure mode and draft this change and description. The submitter reviewed the change and is responsible for final validation. Fixes: 0fe88461a0ec ("mailbox: Add Tegra HSP driver") Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com> --- drivers/mailbox/tegra-hsp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c index 1f6215c7e498..b1ea2beeaf8b 100644 --- a/drivers/mailbox/tegra-hsp.c +++ b/drivers/mailbox/tegra-hsp.c @@ -608,6 +608,12 @@ static struct mbox_chan *tegra_hsp_db_xlate(struct mbox_controller *mbox, spin_lock_irqsave(&hsp->lock, flags); + /* A failed startup has no live client and may be retried. */ + if (channel->chan && channel->chan->cl) { + spin_unlock_irqrestore(&hsp->lock, flags); + return ERR_PTR(-EBUSY); + } + for (i = 0; i < mbox->num_chans; i++) { chan = &mbox->chans[i]; if (!chan->con_priv) { -- 2.47.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] mailbox: tegra-hsp: Reuse doorbell slots after failed startup 2026-12-03 8:33 ` [PATCH 1/2] mailbox: tegra-hsp: Reject duplicate doorbell clients Jiangtian Feng @ 2026-12-03 9:29 ` Jiangtian Feng 0 siblings, 0 replies; 4+ messages in thread From: Jiangtian Feng @ 2026-12-03 9:29 UTC (permalink / raw) To: jassisinghbrar Cc: thierry.reding, jonathanh, linux-kernel, linux-tegra, Jiangtian Feng A failed startup leaves the HSP channel and con_priv bound after mailbox core clears the client. The next xlate skips that stale slot and allocates a new one, so repeated failures can eventually exhaust all 32 doorbell channels. Reuse the existing slot when it has no live client instead of scanning for another one. Active clients are still rejected with -EBUSY, and a slot released by a failed startup or normal free remains available for the next request. Also restore MBOX_TXDONE_BY_ACK during startup. Generic channel cleanup changes ACK to POLL, but doorbell clients expect their original ACK mode and do not initialize polling. Reusing a slot without this restoration would break subsequent message submission and TX-done handling. Qoder, an AI coding assistant, helped analyze the failed-startup slot lifetime and draft this change and description. The submitter reviewed the change and is responsible for final validation. Fixes: 0fe88461a0ec ("mailbox: Add Tegra HSP driver") Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com> --- drivers/mailbox/tegra-hsp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c index 7902af16433c..30688761eff5 100644 --- a/drivers/mailbox/tegra-hsp.c +++ b/drivers/mailbox/tegra-hsp.c @@ -337,6 +337,8 @@ static int tegra_hsp_doorbell_startup(struct mbox_chan *chan) if (tegra_is_silicon() && !tegra_hsp_doorbell_can_ring(db)) return -ENODEV; + chan->txdone_method = MBOX_TXDONE_BY_ACK; + spin_lock_irqsave(&hsp->lock, flags); value = tegra_hsp_channel_readl(&ccplex->channel, HSP_DB_ENABLE); @@ -609,9 +611,14 @@ static struct mbox_chan *tegra_hsp_db_xlate(struct mbox_controller *mbox, spin_lock_irqsave(&hsp->lock, flags); /* A failed startup has no live client and may be retried. */ - if (channel->chan && channel->chan->cl) { - spin_unlock_irqrestore(&hsp->lock, flags); - return ERR_PTR(-EBUSY); + if (channel->chan) { + if (channel->chan->cl) { + spin_unlock_irqrestore(&hsp->lock, flags); + return ERR_PTR(-EBUSY); + } + + chan = channel->chan; + goto out; } for (i = 0; i < mbox->num_chans; i++) { @@ -625,6 +632,7 @@ static struct mbox_chan *tegra_hsp_db_xlate(struct mbox_controller *mbox, chan = NULL; } +out: spin_unlock_irqrestore(&hsp->lock, flags); return chan ?: ERR_PTR(-EBUSY); -- 2.47.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mailbox: tegra-hsp: Reject duplicate shared mailbox clients 2026-12-03 8:33 [PATCH 0/2] mailbox: tegra-hsp: Reject duplicate mailbox clients Jiangtian Feng 2026-12-03 8:33 ` [PATCH 1/2] mailbox: tegra-hsp: Reject duplicate doorbell clients Jiangtian Feng @ 2026-12-03 8:33 ` Jiangtian Feng 1 sibling, 0 replies; 4+ messages in thread From: Jiangtian Feng @ 2026-12-03 8:33 UTC (permalink / raw) To: jassisinghbrar Cc: thierry.reding, jonathanh, linux-kernel, linux-tegra, Jiangtian Feng A repeated request for an occupied shared mailbox changes mb->ops and mb->producer before mailbox core rejects it. The original client can then use the wrong direction or width, and shutdown may mask the wrong interrupt bit. Reject an occupied shared mailbox before changing any of its state. The check is serialized by mailbox core's con_mutex, and a failed or normal release still allows a later request. Qoder, an AI coding assistant, helped analyze the duplicate-binding failure mode and draft this change and description. The submitter reviewed the change and is responsible for final validation. Fixes: 91b1b1c3da8a ("mailbox: tegra-hsp: Add support for shared mailboxes") Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com> --- drivers/mailbox/tegra-hsp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c index b1ea2beeaf8b..7902af16433c 100644 --- a/drivers/mailbox/tegra-hsp.c +++ b/drivers/mailbox/tegra-hsp.c @@ -645,6 +645,9 @@ static struct mbox_chan *tegra_hsp_sm_xlate(struct mbox_controller *mbox, mb = &hsp->mailboxes[index]; + if (mb->channel.chan->cl) + return ERR_PTR(-EBUSY); + if (type & TEGRA_HSP_MBOX_TYPE_SM_128BIT) { if (!hsp->soc->has_128_bit_mb) return ERR_PTR(-ENODEV); -- 2.47.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-03 9:29 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-03 8:33 [PATCH 0/2] mailbox: tegra-hsp: Reject duplicate mailbox clients Jiangtian Feng 2026-12-03 8:33 ` [PATCH 1/2] mailbox: tegra-hsp: Reject duplicate doorbell clients Jiangtian Feng 2026-12-03 9:29 ` [PATCH] mailbox: tegra-hsp: Reuse doorbell slots after failed startup Jiangtian Feng 2026-12-03 8:33 ` [PATCH 2/2] mailbox: tegra-hsp: Reject duplicate shared mailbox clients Jiangtian Feng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox