From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.132 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796290196; b=2mexFAVzG2OhxV308cjT2tl1K4O+1ZhP5I1qFlHEazSbzWI2JCPhUZktY0nl/tlvz4Rb bWijkz+6MarUMJxYi12Paqbio7LQ/TpNeyInTRFU5A5JGHMSLayvzOSllRpGDNeCdGJTe 4ARrlDvx0zcSt2q8lwi6EST7/5KMI9rJyWSnijTmtYNwj547TL7QHwynKqmW4a/vhl7Z1 BjE66/PsuQ9g5gh8SbfAWMQ9aau8N3+GFzztmZHEsL9uedTrVTgM7h13Sggxd1Nss7jT4 Fl6izREvayTtUK0s1ZmpaS9a4EWk5e2Rpm2rKuyfFY7veIyu5rpXZpftFFLmgDtR8aQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796290196; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=qBWT99gqXk+f05Wrm7TLThHI1vBXy7WT6+5JZ9dRzRY=; b=RdDHBCcIsBX0WoOVT+DC9BZ0rdcrGV2DdVtqog5WRGdZrS51FiAYy9JvyBpX61anP1sE c20xaa/zYNVC0CVhMWygsyCnDrAzt87ZrrxQOtSE+LwdRo9VAMNGhNkMx4Ci2r5Iq3Hy4 IRdohA2zZQCt1EywI3X8UDYViJcyXJioFhZ9gI4V9iaRrDPTQ6qZ1Ee8jkcNI180+W47Y rsKaRo6Sqkzc12aHcvD+RV0fIN8PbFgMdKsBiNiIKxGX2nErZmJoLRGxqBYRedmYHNFry ZY+7aSV08YX/P24YQf7HVvqi68ADaRwMhUgqlP4SymFdu7wJsuVbz1ZCKBzeOyHtqlw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=a3ZfGMlN; arc=none smtp.remote-ip=115.124.30.132 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DA42606A33A; Thu, 3 Dec 2026 09:29:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9DA42606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=a3ZfGMlN DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796290189; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=qBWT99gqXk+f05Wrm7TLThHI1vBXy7WT6+5JZ9dRzRY=; b=a3ZfGMlNjt47KMZR3v6d+CiwUYqB6YT469tFbh44AG09WLk1Fa936eXVeVfqUJiJ9Vqx4gbS21XfMXD3gbK03mqhHFFxc1fAJz2p++OvDyF5GxuKsP1oPtbeFUDGIVxkXED+Hdjt73D+317QYNzqxvRHZwIA30ChHkrk8dyqRDc= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033040069076;MF=jiangtianfeng@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0XGDtz99_1796290179; Received: from h68d07384.sqa.eu95.tbsite.net(mailfrom:jiangtianfeng@linux.alibaba.com fp:SMTPD_---0XGDtz99_1796290179 cluster:ay36) by smtp.aliyun-inc.com; Thu, 03 Dec 2026 17:29:49 +0800 From: Jiangtian Feng To: jassisinghbrar@gmail.com Cc: thierry.reding@kernel.org, jonathanh@nvidia.com, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Jiangtian Feng Subject: [PATCH] mailbox: tegra-hsp: Reuse doorbell slots after failed startup Date: Thu, 3 Dec 2026 17:29:37 +0800 Message-ID: <20261203092937.3428647-1-jiangtianfeng@linux.alibaba.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261203083330.3300442-2-jiangtianfeng@linux.alibaba.com> References: <20261203083330.3300442-2-jiangtianfeng@linux.alibaba.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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