mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
To: jassisinghbrar@gmail.com
Cc: thierry.reding@kernel.org, jonathanh@nvidia.com,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
Subject: [PATCH] mailbox: tegra-hsp: Reuse doorbell slots after failed startup
Date: Thu,  3 Dec 2026 17:29:37 +0800	[thread overview]
Message-ID: <20261203092937.3428647-1-jiangtianfeng@linux.alibaba.com> (raw)
In-Reply-To: <20261203083330.3300442-2-jiangtianfeng@linux.alibaba.com>

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


  reply	other threads:[~2026-12-03  9:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Jiangtian Feng [this message]
2026-12-03  8:33 ` [PATCH 2/2] mailbox: tegra-hsp: Reject duplicate shared mailbox clients Jiangtian Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203092937.3428647-1-jiangtianfeng@linux.alibaba.com \
    --to=jiangtianfeng@linux.alibaba.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®