{"id":2219255,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2219255/?format=json","project":{"id":21,"url":"http://patchwork.ozlabs.org/api/1.0/projects/21/?format=json","name":"Linux Tegra Development","link_name":"linux-tegra","list_id":"linux-tegra.vger.kernel.org","list_email":"linux-tegra@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260402170641.2082547-3-joonwonkang@google.com>","date":"2026-04-02T17:06:41","name":"[v3,2/2] mailbox: Make mbox_send_message() return error code when tx fails","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5bf4f8e3a2c51508cebd8afc28ebada9dcd1700d","submitter":{"id":91088,"url":"http://patchwork.ozlabs.org/api/1.0/people/91088/?format=json","name":"Joonwon Kang","email":"joonwonkang@google.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-tegra/patch/20260402170641.2082547-3-joonwonkang@google.com/mbox/","series":[{"id":498517,"url":"http://patchwork.ozlabs.org/api/1.0/series/498517/?format=json","date":"2026-04-02T17:06:41","name":"mailbox: Fix wrong completion order and improper send result in the blocking mode send API","version":3,"mbox":"http://patchwork.ozlabs.org/series/498517/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219255/checks/","tags":{},"headers":{"Return-Path":"\n <linux-tegra+bounces-13543-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-tegra@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256\n header.s=20251104 header.b=REuD9243;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-tegra+bounces-13543-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=\"REuD9243\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.215.202","smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmpN937GWz1yGJ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 04:13:29 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 2890030D01D2\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  2 Apr 2026 17:07:56 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id ACD4D3E0242;\n\tThu,  2 Apr 2026 17:07:55 +0000 (UTC)","from mail-pg1-f202.google.com (mail-pg1-f202.google.com\n [209.85.215.202])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A3C8E3CBE6B\n\tfor <linux-tegra@vger.kernel.org>; Thu,  2 Apr 2026 17:07:48 +0000 (UTC)","by mail-pg1-f202.google.com with SMTP id\n 41be03b00d2f7-c6e24ee93a6so1316822a12.0\n        for <linux-tegra@vger.kernel.org>;\n Thu, 02 Apr 2026 10:07:48 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775149673; cv=none;\n b=Tkyaa2zXPtHpGMNIRS1RiFmJjKK3ZjyR5jeUwgTCJE8gAUfqLFwGjhmirVk+M0LqytzLkHK8rvv0ix3xWDxTlkaGmNwIlIGdly4bAl8g56srU0zDyG7gkY87TtLQiAjy2jr8Filw37S13B8xliO2IpUKJY8PCvlWzFL6AlT6gTc=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775149673; c=relaxed/simple;\n\tbh=RX9yNp5j1OE/PaC+hIPLZ/izItPwEBkRp9rXwgexlsk=;\n\th=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From:\n\t To:Cc:Content-Type;\n b=BenrlNCr5OENs1OgOCQ2gq/dEIUv19hQwYfJ/rDD55jxOCDLGxzanigyLZ3ZPxkk19Rk9p+Zs2GkrQTVSCWZlPw9uhjqrZEfgUAjH6iRruYq366WxFpBMLjxRsMfy3iU+zal/leJzPXLxqSWCyLkeLdPcxV6gaNehsO+uWJCJMQ=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com;\n spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com;\n dkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=REuD9243; arc=none smtp.client-ip=209.85.215.202","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=google.com; s=20251104; t=1775149667; x=1775754467;\n darn=vger.kernel.org;\n        h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n         :date:from:to:cc:subject:date:message-id:reply-to;\n        bh=xtS1OkkhTmC+kJWduMT9+PxAc4KJJ2D34QZmfUPxalo=;\n        b=REuD9243C1mcz2hU0ovnEFQt1Ye0+vC8eA9W2m7Tn8/z5W9zo6oQRPQdcAfmkaCkCJ\n         Wmi7Tl5kRQr1Fkj1JDfgVNmJYoWjOdl+MwgveAxlq6saEvGao27pbx4sEApuZBbrK2pc\n         36RtfJ10W7EusQlLIFw0fxk62uYiNEw3qEUx3SbGkB81l/KxoguSikkEDgKG0WqBgkcq\n         qUF4/D0gL0iqQSJB4HhE5d5ryZBe6yUCiKl3FBoHqv8WyWy//h50m8qNmTi6krgUmd6k\n         B/NbAwdHMKGf0CA5aBP7sQCY3w16tNeDgbO1Q+MQ0Vi9O63Y1HO+sx5vqjrhh7GcZUcK\n         IbOw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1775149667; x=1775754467;\n        h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n         :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n        bh=xtS1OkkhTmC+kJWduMT9+PxAc4KJJ2D34QZmfUPxalo=;\n        b=l5xS+5yjOz09+lobM6ykNsj9Dk8VUmkr2KW78ACl4fvpziFo9hXZait+YQgXBY1rE6\n         hVuKm+w424iA8D5MdJ2QJ7vPnqoJchaKsgZug7zvvUqAX0BIegpS02NCtgCNO6yu78gR\n         liGS1Ye/s8Jt8x333DNUBHv/fs8hj1p1Q+t9+v606Kjcjyc/RuBaFJdeNpi7Sch3hSuG\n         faAFfiHqvfuo/3EKzAEVrpyqc5j7NuXx4PXtyci5l/xFkbsWGo744B/EZxMT89H6U7mv\n         PF62dP5QerFODhRnEH2meLkWoZqnHrCXGhrcCEooXXmo4HhclH6idTjbe2wpU3shECV2\n         BQtA==","X-Forwarded-Encrypted":"i=1;\n AJvYcCVfRAtmEHSYE/v3ULYJl+KR98kmosA+UxaxBZlKF7dQnQhtXcRXTtfTE+Kma7pHAd5VBAmOWr2+qqYcQQ==@vger.kernel.org","X-Gm-Message-State":"AOJu0YzzPULVI6Jv+MYfh/DCwE67XlXxHoweqAN+Wpiln2qisaO2bu2L\n\t2i1z7xWODuJtIJOCQBxN+eVp9bpg6BwBCQaIJRSNvTNodBs6E4fDj7gkgswEAyAtkIZVRgJxJcR\n\t1PKbTYUE4zpU9roqL2blRhzwfUw==","X-Received":"from plse12.prod.google.com ([2002:a17:902:b78c:b0:2b0:537d:70cc])\n (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by\n 2002:a17:902:e850:b0:2b2:4f43:b49a with SMTP id\n d9443c01a7336-2b277e52d1dmr29085885ad.22.1775149666599;\n Thu, 02 Apr 2026 10:07:46 -0700 (PDT)","Date":"Thu,  2 Apr 2026 17:06:41 +0000","In-Reply-To":"<20260402170641.2082547-1-joonwonkang@google.com>","Precedence":"bulk","X-Mailing-List":"linux-tegra@vger.kernel.org","List-Id":"<linux-tegra.vger.kernel.org>","List-Subscribe":"<mailto:linux-tegra+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-tegra+unsubscribe@vger.kernel.org>","Mime-Version":"1.0","References":"<20260402170641.2082547-1-joonwonkang@google.com>","X-Mailer":"git-send-email 2.53.0.1213.gd9a14994de-goog","Message-ID":"<20260402170641.2082547-3-joonwonkang@google.com>","Subject":"[PATCH v3 2/2] mailbox: Make mbox_send_message() return error code\n when tx fails","From":"Joonwon Kang <joonwonkang@google.com>","To":"jassisinghbrar@gmail.com, matthias.bgg@gmail.com,\n\tangelogioacchino.delregno@collabora.com, thierry.reding@gmail.com,\n\tjonathanh@nvidia.com","Cc":"linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org,\n\tlinux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,\n\tJoonwon Kang <joonwonkang@google.com>, stable@vger.kernel.org","Content-Type":"text/plain; charset=\"UTF-8\""},"content":"When the mailbox controller failed transmitting message, the error code\nwas only passed to the client's tx done handler and not to\nmbox_send_message(). For this reason, the function could return a false\nsuccess. This commit resolves the issue by introducing the tx status and\nchecking it before mbox_send_message() returns.\n\nCc: stable@vger.kernel.org\nSigned-off-by: Joonwon Kang <joonwonkang@google.com>\n---\n drivers/mailbox/mailbox.c          | 20 +++++++++++++++-----\n include/linux/mailbox_controller.h |  2 ++\n 2 files changed, 17 insertions(+), 5 deletions(-)","diff":"diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c\nindex d63386468982..ea9aec9dc947 100644\n--- a/drivers/mailbox/mailbox.c\n+++ b/drivers/mailbox/mailbox.c\n@@ -21,7 +21,10 @@\n static LIST_HEAD(mbox_cons);\n static DEFINE_MUTEX(con_mutex);\n \n-static int add_to_rbuf(struct mbox_chan *chan, void *mssg, struct completion *tx_complete)\n+static int add_to_rbuf(struct mbox_chan *chan,\n+\t\t       void *mssg,\n+\t\t       struct completion *tx_complete,\n+\t\t       int *tx_status)\n {\n \tint idx;\n \n@@ -34,6 +37,7 @@ static int add_to_rbuf(struct mbox_chan *chan, void *mssg, struct completion *tx\n \tidx = chan->msg_free;\n \tchan->msg_data[idx].data = mssg;\n \tchan->msg_data[idx].tx_complete = tx_complete;\n+\tchan->msg_data[idx].tx_status = tx_status;\n \tchan->msg_count++;\n \n \tif (idx == MBOX_TX_QUEUE_LEN - 1)\n@@ -91,12 +95,13 @@ static void msg_submit(struct mbox_chan *chan)\n \n static void tx_tick(struct mbox_chan *chan, int r, int idx)\n {\n-\tstruct mbox_message mssg = {MBOX_NO_MSG, NULL};\n+\tstruct mbox_message mssg = {MBOX_NO_MSG, NULL, NULL};\n \n \tscoped_guard(spinlock_irqsave, &chan->lock) {\n \t\tif (idx >= 0 && idx != chan->active_req) {\n \t\t\tchan->msg_data[idx].data = MBOX_NO_MSG;\n \t\t\tchan->msg_data[idx].tx_complete = NULL;\n+\t\t\tchan->msg_data[idx].tx_status = NULL;\n \t\t\treturn;\n \t\t}\n \n@@ -116,8 +121,10 @@ static void tx_tick(struct mbox_chan *chan, int r, int idx)\n \tif (chan->cl->tx_done)\n \t\tchan->cl->tx_done(chan->cl, mssg.data, r);\n \n-\tif (r != -ETIME && chan->cl->tx_block)\n+\tif (r != -ETIME && chan->cl->tx_block) {\n+\t\t*mssg.tx_status = r;\n \t\tcomplete(mssg.tx_complete);\n+\t}\n }\n \n static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer)\n@@ -286,15 +293,16 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)\n \tint t;\n \tint idx;\n \tstruct completion tx_complete;\n+\tint tx_status = 0;\n \n \tif (!chan || !chan->cl || mssg == MBOX_NO_MSG)\n \t\treturn -EINVAL;\n \n \tif (chan->cl->tx_block) {\n \t\tinit_completion(&tx_complete);\n-\t\tt = add_to_rbuf(chan, mssg, &tx_complete);\n+\t\tt = add_to_rbuf(chan, mssg, &tx_complete, &tx_status);\n \t} else {\n-\t\tt = add_to_rbuf(chan, mssg, NULL);\n+\t\tt = add_to_rbuf(chan, mssg, NULL, NULL);\n \t}\n \n \tif (t < 0) {\n@@ -318,6 +326,8 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)\n \t\t\tidx = t;\n \t\t\tt = -ETIME;\n \t\t\ttx_tick(chan, t, idx);\n+\t\t} else if (tx_status < 0) {\n+\t\t\tt = tx_status;\n \t\t}\n \t}\n \ndiff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h\nindex 912499ad08ed..890da97bcb50 100644\n--- a/include/linux/mailbox_controller.h\n+++ b/include/linux/mailbox_controller.h\n@@ -117,10 +117,12 @@ struct mbox_controller {\n  * struct mbox_message - Internal representation of a mailbox message\n  * @data:\t\tData packet\n  * @tx_complete:\tPointer to the transmission completion\n+ * @tx_status:\t\tPointer to the transmission status\n  */\n struct mbox_message {\n \tvoid *data;\n \tstruct completion *tx_complete;\n+\tint *tx_status;\n };\n \n /**\n","prefixes":["v3","2/2"]}