From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 95ABC351C1F for ; Sun, 10 May 2026 05:41:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778391676; cv=none; b=pt+0WIvPaQt04vvlgcKpEiwAjH3j/GG2U0tRDDO7to8GiFSb/K+cxB8zbtMrYKxqC/ilf6Tm103bTN6RtU0LS1HWabgd2P2ueohzAi/RF8vpuj42c9PRyQzt+73BDVHbChiLD9YsZZ4GicpjNEh80JCDm/feUSQ6MyOUZFACfOs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778391676; c=relaxed/simple; bh=gDfx5LzmAfAOrqMmIQfvr9ht4ADd1bazSgpxvKasckI=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=amkCz00J5k5+M97icC2Th8xTXlmW+ujaFPll0/Q8Wb2a8QIUJ2gZt0K93tpwwwrIRcGrtRkUqbJk/n+3LsE1WeV4AvdidIAxkFpGlbZmdaW1IAId1o+eW6og/7PSzKrRyWxBIquTxcb9C/uInt7YFCXkoGJoGf6bvS6mwyS29F0= 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=XYNLxuQu; arc=none smtp.client-ip=209.85.216.74 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="XYNLxuQu" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-365d4d2fa04so3058440a91.3 for ; Sat, 09 May 2026 22:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778391675; x=1778996475; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=o94GcXhqW4+xEkZTDHTPwpkDN5aqxWdoTlyMFkc71+w=; b=XYNLxuQu5EvF4wFxxwvmvoqO+2mGCPexcIQPBs35spj67fvRRlEMAaZ8xMciwnm3KY PuLpvw9OnhwBnh2ousyMo+FWP9BjPGrI+7btGydvZpMUQx1MgDNTt8dqgbJII/82x8uT gqH5nZi2F/1DbvocJBKHWGFAvHird8fU1VQcKfkH5OupejJ/eBNGp6qRGc1xUglKUBBY PiPCjvgRo76imU2nAKUxXJxbvsGSBB1EAAS0clkmqlh/TjmFzxw3SUNy8RI31AoGy5O/ DgxVsHITDr1VlsUyH1PfRucqKlO/RBf6rTJlxZkQgF1V71HBJhbVOfK18mhFY0CHZh+A /hYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778391675; x=1778996475; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=o94GcXhqW4+xEkZTDHTPwpkDN5aqxWdoTlyMFkc71+w=; b=Vm9ngtO8D3ZO20AdIqk2ITsUcp/wTo2H3daHj0EQYNuWSvzL4neXyq2Ro7j5onuHBE 7lyMe8YDKVrOLYoFTYRtr0lS0OpUMmbRD/xxSoizYjvXwT5zAF2zJ0Ks1DRJ9QN/6sCP mw/CNZBr8vzEYFL9hbkVR1TEkqp/WmSlNOBZ2fqFXHWYqX+SvXAog6RTfKdj5CBEXLoP fwK0rbulGde/l37m5b4VoSSTjhWlu5izyj79Q0UvvHhXTvcuE4qszX6B1q2Z82KCZl1B tq78WcP51scsnUR2z82f/N+pmaDwvll/H3TQI5xlEJchN3e3cCw+hglrFJB+w3zO2Uv8 E7Og== X-Forwarded-Encrypted: i=1; AFNElJ88UXs76vGcCZ3dlBvoW3Hp/LiQgsztwWPm9w5j50BmA9DfQjp4sAJrvxuzaDUiD+uhMBfnyjldkGhfnPQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwUBdB1tpL7K9iWus7wtAn3gQTys4TWo10dWu2rSGsVOdUar93L endUMVQW4rzmcT+oFKwJ20R3Ox/BZRmHYmcPZd3n8kpAP/d7XZRlklcNPWua+tIOivxZxZR0pqS CRCm0Zkr8hW0/XWBNFp9slByVpA== X-Received: from pgc15.prod.google.com ([2002:a05:6a02:2f8f:b0:c74:497:507e]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:549d:b0:35d:5d40:6d79 with SMTP id adf61e73a8af0-3aa5a8d012bmr19463804637.12.1778391674533; Sat, 09 May 2026 22:41:14 -0700 (PDT) Date: Sun, 10 May 2026 05:41:11 +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: <20260510054111.784204-1-joonwonkang@google.com> Subject: [PATCH v6] 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. Signed-off-by: Joonwon Kang Reviewed-by: Sudeep Holla --- v6: Remove the Cc tag from the commit message. 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