From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 66426359A8C for ; Fri, 13 Mar 2026 10:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773396776; cv=none; b=sGl5QX3/d2b4NBZOmfGqQBekuZD/+zBVMGdr1GWRSvKkF0Osxmjn/aGTvU5PEjM3N8pga0/BL7nbSofmm50720SzcNg1oYf4Ax8OVX2Kysl0Zq+SXVMnnTTf2oRHQ+Ovkc49F37O1AQq7+Zjipc5cgH03tim1Qsk8evexK9WPnk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773396776; c=relaxed/simple; bh=3XkfnClenqP2jyqZZaBMOg2QHIgrgMjFuCY5Da3Etmw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OJHFpFaUmaNCFFRowTKdHcHSRvCAW9PdQcwO+tExVSTdNIkVGp9HuETaR4Y7KfveXINbcwhUBSVntIVLDbw8dtW28Jw7m9phRjcdrEY074rGQKEyRd3tgrqP3CaRNetVTdPaA+pxnneurXLkJM8QZbcwKWpIjjqWmBs4cei++bE= 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=jPPoCdgB; arc=none smtp.client-ip=209.85.214.201 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="jPPoCdgB" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2aec809f910so71086495ad.0 for ; Fri, 13 Mar 2026 03:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773396775; x=1774001575; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Go93IsHtzR9FaywEWx4mi0I8AqRfHuYxNwHW3caHYUY=; b=jPPoCdgBJ81eq5GnjgIbMNsNBrbXOf/fyEnnev5VCgJVZuGsilJU1JzjPtM71coKcV PFfkY7+ZOccqJg/IGHTtvM9dPVTqqUbBGFawT8oPknyErEiP0HqD1bTsDRNk1QwRBzcy nLGPLJTtKbwDM6YBI8G4y62j4hH51PfJqXE504jGwOKg1pq3CApMX0w7tyPRWUrxfYRV QjEOd2wH9v2d/cpHr26rToc7KftqHz7ZGiXn+Jn76/d5Dj1dLU1VH1d5aXMHqCUPKxEi GqPaU1o9GHIOjp/JxqbDYimmZkgYMc2jgFVCjae+uizOAgqgKvyPgzzJh1cfPcXAtV+o GFVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773396775; x=1774001575; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Go93IsHtzR9FaywEWx4mi0I8AqRfHuYxNwHW3caHYUY=; b=IEq/RBZMn/T2Z1HWDhYH8lniEpkhwknMQDbDySa8Pzvd6hhs7vPgUxq9NOvHq92+jy juDLpPlCSRtiUygZDQk02+f8baDV2JVoRhQObryaZ+keYqxM5KPHE3B27YtEdk9OLA9N 4Nh9AmEpEgxQVF2lo29id/W7jhstln47GLcR3/7i1UTKUydnE4PfT3zAF6wYzsNWkE2V JO5C2a6M1KEpcsyJsqrIKrQXAHcUg3MwpAKHlq7T1j+Mum5EhRLPooeTZR3lGk4HY+eX m80ApXSDw1+wIfy3m8ey6/s6cgPNQ4e+O42T+Vjk2BmcrH3ADqny5Jp3w38hsAEbpQ7C gviw== X-Forwarded-Encrypted: i=1; AJvYcCVogEZJdjoBTARofPLpxeCZddcVwjC9AAkASJ9o9vseXoIlxauzBxQwDKMZiZDRaUp8rINU1UiXOG2oreE=@vger.kernel.org X-Gm-Message-State: AOJu0YzUeL3ye6LWtHe7IR7imanG7JkiQaK65f68l1Qj3zc7h6PQ1XZN OO9iSk5dLJMc7o8ZEFV83GI9lu0Zg7MUcJeoH7QaYyIUEkLb8vr1O0Khs40s+awgZLfNGIVHhjM ILM7MCIVeGYYuICEn8dX6Wdxyjw== X-Received: from plblo15.prod.google.com ([2002:a17:903:434f:b0:2ae:5719:1a9]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:3905:b0:2ae:5464:7a4b with SMTP id d9443c01a7336-2aeca9ffe54mr29905165ad.14.1773396774548; Fri, 13 Mar 2026 03:12:54 -0700 (PDT) Date: Fri, 13 Mar 2026 10:12:52 +0000 In-Reply-To: <20260310234616.334498-1-jassisinghbrar@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260310234616.334498-1-jassisinghbrar@gmail.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog Message-ID: <20260313101252.3031143-1-joonwonkang@google.com> Subject: Re: [PATCH] RFC: mailbox: Fix NULL message support in mbox_send_message() From: Joonwon Kang To: jassisinghbrar@gmail.com Cc: arnd@arndb.de, dianders@chromium.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" > The active_req field serves double duty as both the "is a TX in > flight" flag (NULL means idle) and the storage for the in-flight > message pointer. When a client sends NULL via mbox_send_message(), > active_req is set to NULL, which the framework misinterprets as > "no active request." This breaks the TX state machine by: > > - tx_tick() short-circuits on (!mssg), skipping the tx_done > callback and the tx_complete completion > - txdone_hrtimer() skips the channel entirely since active_req > is NULL, so poll-based TX-done detection never fires. > > Fix this by introducing a MBOX_NO_MSG sentinel value that means > "no active request," freeing NULL to be valid message data. The > sentinel is internal to the mailbox core and is never exposed to > controller drivers or clients. The following drivers are currently using ->active_req which now could be assigned MBOX_NO_MSG. - drivers/mailbox/tegra-hsp.c - drivers/mailbox/mtk-vcp-mailbox.c One of them is using ->active_req to wait until the channel is empty. In this case, strictly speaking, that controller driver should be aware of the sentinel value MBOX_NO_MSG, which means the sentinel value should be exposed to the controller. Or, if a future controller driver to come is to use ->active_req for the same purpose for doorbell or non-doorbell, it should also be aware of the sentinel value anyway. However, I believe that it is not intuitive to the controller developers that a pointer value could be other value than a real memory address, NULL or error encoded value, which is -1(== MBOX_NO_MSG). For this reason, I think it will be better to change the type of ->active_req to give a better indication to the controller developers, e.g. to integer as in the original patch https://lore.kernel.org/all/20251126045926.2413532-1-joonwonkang@google.com/. Or, we could change those drivers not to use ->active_req, hide ->active_req entirely in the mailbox core and keep this patch. Thanks. > > The only tradeoff is that 'MBOX_NO_MSG' can not be used as a message > by clients.