From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 48AC8384234 for ; Fri, 8 May 2026 09:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778230955; cv=none; b=dxFvosKg55xn54o1EHqrSThUur1CDilPUF+NfTzUjjVjMCFuN9w1q9/dkgO3Pvw9sCHZOtiRibilU/qc02PL+/EUFVpOQeQ8DybCfrkl1R45PGnAPuO6T+ZJMUFX2OAWcgA45GOVnbEFo1MdkIbEC2jin91/nVSfvSNP/0AsWp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778230955; c=relaxed/simple; bh=XhdFYMV1mZ70jv8QArNcednC0eRLKAZ5Cf5TYJyVSD0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=eQF5gaV5qiwR7peUTgeF/BqAGr3anPwJl6Mmv52voP9ZtnY9f0wZiPQOV1GUDJhGX0IxjnRamE4NHOhd00son/gDUNuZORytvpfdMu0/Av3FuJL/cyN+EIVIfRrp8IxQ1hC/BiPbPrbRANQYoB9bXz0GniPjPvZwow014RcwvUc= 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=wBC3tuZT; arc=none smtp.client-ip=209.85.214.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="wBC3tuZT" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2adef9d486bso6200005ad.2 for ; Fri, 08 May 2026 02:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778230952; x=1778835752; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=PjRSW5+i7ia4uJhUR30COro91E+rzXNQmOTzNGO1JAI=; b=wBC3tuZTPue/2v98jxkYi1kskZLfd0XVSIoSJA/3RVsYE6NFpWaD6BXHp01jUvP0xv vD4SgpuU6C0fU9r/q/aVoZm9dvqWvwLEBAY/dSzsQrOLMEibe0l87nHtDBRzKghhi2bJ hh18AK5WSsafgT4P5DY89q5RZCI6olF/SRcF0CbxJJAlIlMBvKoywKxx38yuRPKqo8JT ThJhXiQZSYT1hg1z66mx28eOG8L8EW0c3iHMT9PmnSw+EThgty0Z8NynJjpHMUFwnTVO XEGIluAP/WmkrFIL0qZIhKUmM/kjmBdu5yBicR6bHCicMyM16jG8vBKnb2Jg6tY6vtHF LyWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778230952; x=1778835752; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PjRSW5+i7ia4uJhUR30COro91E+rzXNQmOTzNGO1JAI=; b=L2ueGL62jr68iKxOXxmQRcazy88G+QyDxTafH+sRnuf95gcMASDWpBGqROOgVBig2m SK+47ZGcemCd0WepAGSXwGWX5LCRIjNxOpyuVQevESbHDWPuuL2pZlCO7h+0d4Kf7ibm CvbmwdE8olwatprq0Uh5VQ1aqBacpyS18deD3OE5qPqwr0akPskGd7On3Q/riXYLH3q8 4hIPJ6vpNg3PRu4y4SngR0CwY2C7g6EC8vT4CB2Fxy3x9KjOGeScYGFbwb/I8+hXLqAV KMOS5/GTwmyOLIJPLNm2GQl9uxZegK92TkU4dtGJlAfSsl1Mw4A9DrWvn28e34ZJY0gF 0kKg== X-Forwarded-Encrypted: i=1; AFNElJ/pRtiGEj5tJoqiw3uwmDYLOVHX9j5swqOTWD1pQnmGFHpoR8RviF83R6QHaC/m8oB3qYIGI8IFP7M77PY=@vger.kernel.org X-Gm-Message-State: AOJu0YxX8sIy593LcB+VaXduUjC87s4BMcdAG8k3HmI2MPraFrSTMR+R Rpyq6/t1t0AiLi0BAwzqzRBq4gV0IzR9NBlPWbw+Fiwks7cN6b1h04M+y6wRl5iut136NTuRIDw MPrG8SuH8ubGbW5qcJYjs0EmebQ== X-Received: from plbmz13.prod.google.com ([2002:a17:903:350d:b0:2b2:5117:a3f]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2844:b0:2b7:ca38:975f with SMTP id d9443c01a7336-2ba792877bdmr87188285ad.23.1778230952448; Fri, 08 May 2026 02:02:32 -0700 (PDT) Date: Fri, 8 May 2026 09:02:28 +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.54.0.563.g4f69b47b94-goog Message-ID: <20260508090228.3796635-1-joonwonkang@google.com> Subject: [PATCH v5] mailbox: Make mbox_send_message() return error code when tx fails From: Joonwon Kang To: jassisinghbrar@gmail.com, sudeep.holla@kernel.org Cc: dianders@chromium.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, joonwonkang@google.com 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() in blocking mode. 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. This commit works with the premise that the multi-threads' access to a channel in blocking mode is serialized by clients, not by the mailbox APIs, since the current mbox_send_message() in blocking mode does not support multi-threads. Cc: stable@vger.kernel.org Signed-off-by: Joonwon Kang Reviewed-by: Sudeep Holla --- v5: Add note to the commit message that the current mailbox APIs in blocking mode do not support multi-threads. v4: Detach it from the previous commit that supports multi-thread in blocking mode and rebase it on the latest for-next branch. v3: No major patch since v1. drivers/mailbox/mailbox.c | 6 +++++- include/linux/mailbox_controller.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index b00f7a32e866..066702e5a46f 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -98,8 +98,10 @@ static void tx_tick(struct mbox_chan *chan, int r) if (chan->cl->tx_done) chan->cl->tx_done(chan->cl, mssg, r); - if (r != -ETIME && chan->cl->tx_block) + if (r != -ETIME && chan->cl->tx_block) { + chan->tx_status = r; complete(&chan->tx_complete); + } } static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer) @@ -295,6 +297,8 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) if (ret == 0) { t = -ETIME; tx_tick(chan, t); + } else if (chan->tx_status < 0) { + t = chan->tx_status; } } diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index dc93287a2a01..26a238a6f941 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -120,6 +120,7 @@ struct mbox_controller { * @txdone_method: Way to detect TXDone chosen by the API * @cl: Pointer to the current owner of this channel * @tx_complete: Transmission completion + * @tx_status: Transmission status * @active_req: Currently active request hook * @msg_count: No. of mssg currently queued * @msg_free: Index of next available mssg slot @@ -132,6 +133,7 @@ struct mbox_chan { unsigned txdone_method; struct mbox_client *cl; struct completion tx_complete; + int tx_status; void *active_req; unsigned msg_count, msg_free; void *msg_data[MBOX_TX_QUEUE_LEN]; -- 2.54.0.563.g4f69b47b94-goog