From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 108D62E54AA for ; Fri, 6 Feb 2026 10:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770372884; cv=none; b=VTN0HgiMbR7Dr2ogprk/hY9IRIf6/4sPKLc07lozqS42pLgH9gVSKbzJvjrWsS0rs8JGdbw9ZT2Mx+Xt3LlJiiYm9thLK1T4kWEne5xY/qyEdp5CEDkAsC+VZqT+1w3vnhNUmyFO85MEZyzWYfpJKugTugiL8DBkp2bazzVMwD4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770372884; c=relaxed/simple; bh=S80eEenF23Jlftx8Nb2GoLHh0cNpf0uICWbwA4J24oU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=RBakvgsfFfNjtlLoJDm/nV3UOypS18Wl2sOEOAzaT0FZ4/sENR5fbDrLnXcc1NySVW16tlSE7J8OT6d4PIObGfh+/k2oGzXgiz/nj4gcztkiOt0FawpDM5x6IUcl0CDf5cU+NFZwBU558S+f8/1ReVe1A6leY+1Al+jEmik9OpQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hOCuBbrs; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hOCuBbrs" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c68b97b7316so413900a12.3 for ; Fri, 06 Feb 2026 02:14:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770372883; x=1770977683; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Zs6k6Yg8dxvKjSPzGnO8E07vhqHgQ2Yo/nScR5UofAg=; b=hOCuBbrsdLyflv/pru3Pe2vzNhCKb+u37HwQzKPx0jQIl7OPu5uzDA30ejDWsxqiMc NaZbOpMcfqHjGf7OYlcfxas3LE+Hh/i/6y8mffKx6e4LTxmLLCj2fAIE5/ewmfMeJnVh DoTnLz9Zv8mYbNHH5mQe/rhBcRwZAFvk3qu2gaqmhkioOmLpln1rwP/DCrUaZuu42eOc +hUoDlvENUWIz+KiUxk0k/lSEnmpwIHSDnjVBOVHKXNdUE/ALqdxa6Yp+3HiSOtcGVwM 5SdDBPp4NOYyTMHUZsJwPLtDn+L6RWKk6HAq2U7Cb0wRgW3Q2+HCSSLLbNwEENfLqoS4 uM/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770372883; x=1770977683; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Zs6k6Yg8dxvKjSPzGnO8E07vhqHgQ2Yo/nScR5UofAg=; b=g/SiKtysh9n5XdS7TMSNE30cjYxFQtPV4MrA4NrOpBKQ60OYwQ148GQ8dL1ryN9Sb1 6eQQWGEkDjqmqrCUjxyDDl2zdHg4fGaR42lUnh6ekwZMCBPKC3gMyh2hRRBd8mdW5lje yXS58cwnoToEvyhvX6WIzrXBPwrXHkYURjrR4xLRBmHn5mWa/gQnFF/Kf/hqsyXQYgyn CeeIC5IME1UllDEBf9HM8SPWWbmQgRErN4LaWDz19Z59nBAsCpgXBwPabBITZjX9BvUe NYGpHG4jHoJf8lyUY4wS+K+vHRb8GEaa1vzY4nvzf5g/E5DRUg6u2eImRcYnASmH/PTi /L0g== X-Forwarded-Encrypted: i=1; AJvYcCU1o2U8rfU3BhMXlde57oxkMa2VDtNq1DEt14oH1KT8yqaoe9EJ1VeVcSc1iDtF8IQpRKvDPOwDmvZNos4=@vger.kernel.org X-Gm-Message-State: AOJu0YwfN2Tjmgv6jQVNS1cvaQroSpZG/K4D4jSr9KkjjOHnUvSEvruT Lxb7DdhygmXpaj3pTR2ZKSJnR9BSrUy0ULwPEObpe6Kskh6dl9yU8swo9hhly9dee7yT5PMnd2r 5DRMgp0qFo/xpGyO8t0fYBMMVpg== X-Received: from pguz16.prod.google.com ([2002:a65:6110:0:b0:bd9:a349:94bb]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:2211:b0:35d:5d40:6d79 with SMTP id adf61e73a8af0-393acf58258mr2466129637.12.1770372883313; Fri, 06 Feb 2026 02:14:43 -0800 (PST) Date: Fri, 6 Feb 2026 10:14:40 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.rc2.204.g2597b5adb4-goog Message-ID: <20260206101440.4171445-1-joonwonkang@google.com> Subject: [PATCH v2 2/2] mailbox: Make mbox_send_message() return error code when tx fails From: Joonwon Kang To: jassisinghbrar@gmail.com Cc: joonwonkang@google.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, lee@kernel.org Content-Type: text/plain; charset="UTF-8" When the mailbox controller failed transmitting message, the error code was only passed to the client's tx done handler and not to mbox_send_message(). For this reason, the function could return a false success. This commit resolves the issue by introducing the tx status and checking it before mbox_send_message() returns. Cc: stable@vger.kernel.org Signed-off-by: Joonwon Kang --- v1 -> v2: No major change. drivers/mailbox/mailbox.c | 20 +++++++++++++++----- include/linux/mailbox_controller.h | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 0af2f91132e0..ed1b405a2999 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -26,7 +26,10 @@ static LIST_HEAD(mbox_cons); static DEFINE_MUTEX(con_mutex); -static int add_to_rbuf(struct mbox_chan *chan, void *mssg, struct completion *tx_complete) +static int add_to_rbuf(struct mbox_chan *chan, + void *mssg, + struct completion *tx_complete, + int *tx_status) { int idx; @@ -39,6 +42,7 @@ static int add_to_rbuf(struct mbox_chan *chan, void *mssg, struct completion *tx idx = chan->msg_free; chan->msg_data[idx].data = mssg; chan->msg_data[idx].tx_complete = tx_complete; + chan->msg_data[idx].tx_status = tx_status; chan->msg_count++; if (idx == MBOX_TX_QUEUE_LEN - 1) @@ -96,7 +100,7 @@ static void msg_submit(struct mbox_chan *chan) static void tx_tick(struct mbox_chan *chan, int r, int idx) { - struct mbox_message mssg = {NULL, NULL}; + struct mbox_message mssg = {NULL, NULL, NULL}; scoped_guard(spinlock_irqsave, &chan->lock) { if (idx == MBOX_IDX_NOT_DESIGNATED || idx == chan->active_req) { @@ -107,6 +111,7 @@ static void tx_tick(struct mbox_chan *chan, int r, int idx) } else { chan->msg_data[idx].data = MBOX_DATA_CANCELED; chan->msg_data[idx].tx_complete = NULL; + chan->msg_data[idx].tx_status = NULL; return; } } @@ -121,8 +126,10 @@ static void tx_tick(struct mbox_chan *chan, int r, int idx) if (chan->cl->tx_done) chan->cl->tx_done(chan->cl, mssg.data, r); - if (r != -ETIME && chan->cl->tx_block) + if (r != -ETIME && chan->cl->tx_block) { + *mssg.tx_status = r; complete(mssg.tx_complete); + } } static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer) @@ -268,15 +275,16 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) int t; int idx; struct completion tx_complete; + int tx_status = 0; if (!chan || !chan->cl) return -EINVAL; if (chan->cl->tx_block) { init_completion(&tx_complete); - t = add_to_rbuf(chan, mssg, &tx_complete); + t = add_to_rbuf(chan, mssg, &tx_complete, &tx_status); } else { - t = add_to_rbuf(chan, mssg, NULL); + t = add_to_rbuf(chan, mssg, NULL, NULL); } if (t < 0) { @@ -300,6 +308,8 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) idx = t; t = -ETIME; tx_tick(chan, t, idx); + } else if (tx_status < 0) { + t = tx_status; } } diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index 67e08a440f5f..6929774d3129 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -109,10 +109,12 @@ struct mbox_controller { * struct mbox_message - Internal representation of a mailbox message * @data: Data packet * @tx_complete: Pointer to the transmission completion + * @tx_status: Pointer to the transmission status */ struct mbox_message { void *data; struct completion *tx_complete; + int *tx_status; }; /** -- 2.53.0.rc2.204.g2597b5adb4-goog