From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796295420; b=oiQ+Vy3IQG8AUdY56AG5hB5DiJ+jluhYGlIdgOFptah3kERt68+pKIhhp+Q9JWxidttx Uu92F7hPRcehhb9VWGSiKajZoQFQzoB3erhRvWKdlO0XfnjETSYt5DMCuR6b37+caoiYX yv2RoZg67qipWMhDAgtUPVn4pUb4Xu/tiPL19ZTldeSh+QRLfZGFEq1aAzDTpFoj5sYdk 1DVSsjvKxWOByxVTU3UXhuZWs2Q/3u2ysGKIG35BmjF8SD79G0Z714tW7JpLvoucJBCgW dJLqxa8vw5G1GJKnjM4uXuvxivdiA9MZISI0+EIjr7gKINYBcL+GICr7LTfw436OaQg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796295420; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=vreu21O110iDhdO1EEHQsQhKpQFHq5MDhc8iAtBhwqk=; b=M+Bx5WgAGUBTGTWbPJNCm1M9yiJu3aW248l2dFXuNt0EHNDVR98yykoEDdAsghDyhjRp F3MeNhJi62INdszgvn2hM8CXd7F4J7qrl93EUd8GMrV+FI0bpgFKF+ZKzrVm1MjVqtKBS BKUuOmYegyvAAApFv7PsHpAJsJG+JJvpCS2vFv3MG6FVFLcq0By7swZfC5MX7P0sJElWI rcO0wc0gZpXUERmLrFTumk0K468aM/0F2vdyMPsIsGJg5XNOS2NZT6vdOBCDYnmUf81mP HAGxyfe50n+2kEmGT6QEQw+R27sAhPhP4JSzXbaGGSAuKXKHXKn9yzC0+B+fS2TMMcg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QGKhd4AG; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B870D606A32C; Thu, 3 Dec 2026 10:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QGKhd4AG Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796295420; b=oCddzC9nY+cBekE3ev4XL6ZoF0BItob6cNLW/pFyQU8W91HCcKSMmr4CkLx7MrYO9vCV 6Tgjr6JWr1/QQXQz6OLzcIxCcH4X59O1EpJZfOZAu9w/tBKjn0a/opauJvyNpsik8AVFi jT+BaNtJCiHWfBy05ZxWjUgWj1G5MEqVvzntg47VIQ++euHST3oRXvQQOS2XJimcBtjlE T70D5RXc2BIl07eZ8vXdwqwuy1HoMQtJfFEobCUx3hqL7gJfOShCW/eZsNeR9lyT0q73Y QBXbbos06QK4nJXjDQeKTpXZwNpe++mBoTSqDGiE+ruKfexNaYDl8YHxomCNWE0f2sw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796295420; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=vreu21O110iDhdO1EEHQsQhKpQFHq5MDhc8iAtBhwqk=; b=nG/+MzFO+l8yeUZ5977oS4FN1BopdCMEtT9SUfuitDCALbJNNL6VzF2aVr/5ZqCcyKBZ luLQZAAQBOzi5DqcBMiTEl4SHyKxCAIw9vZwL+JoMCVEKHvWtIEbM+Hk8mhBqD+lGrp8k C7Cs6b0MVIfrowDx2ry61eOjWFnU5TmTbq8mvYb2jHz36Lp4cBw4fjBjLU02HFJyMOE9E l99zeNsn7dvXhl3FybRdvYnM7SEj8obHVB+w/MBn2b1hRiak6YiXk6XB76KMl4mOBQ1AI b3+VAi4IVXsiE9gBY2KSa2mlRmDlq+rFCDfmlpRlpTVEURkSHXDmiWwGYPVLYLkxLAw== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id DAC031F00896; Thu, 3 Dec 2026 10:56:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796295420; bh=vreu21O110iDhdO1EEHQsQhKpQFHq5MDhc8iAtBhwqk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=QGKhd4AGKbJsynqXhnVd1rD0ln2fkM61BnYjnOkE79Q3Be5071EfO3XsEZTKxZU9H fA/2AyGJKCxTpVG3P6/ZJ3F7Z/HZS05tv/kgok+9YSbYS4zDOh3DS/QVYjHxJqXq1B xgT8uYnB8zDM394DpE1usaRPno2IauLGz7pRRmSiNgaNp9jPwIq1NHvPo6GjsEu5IU HONZtasM26tUUvI32t2krY/auVLYtlWMhiLXGEWr4G5LEqBndCT5X9O/qUlTz1Tzx0 pDWZ4RCURQIB6PPPyMLPb+LYsnNeOXHpQyGUdeHjYanClQ82GIQDLyz7NsrfTMGvY1 nphyrlNjAvBkA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 6B11C4F8FF; Thu, 3 Dec 2026 10:56:59 +0000 (UTC) From: Alexandre Rapaille via B4 Relay Date: Thu, 03 Dec 2026 11:57:00 +0100 Subject: [PATCH v2 1/2] mailbox: Add mbox_request_channel_optional() X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261203-smsm-null-mbox-v2-1-b4b6e224b127@atlr-engineering.com> References: <20261203-smsm-null-mbox-v2-0-b4b6e224b127@atlr-engineering.com> In-Reply-To: <20261203-smsm-null-mbox-v2-0-b4b6e224b127@atlr-engineering.com> To: Jassi Brar , Bjorn Andersson , Konrad Dybcio , Abel Vesa , Luca Weiss Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Alexandre Rapaille X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796295420; l=5111; i=arapaille@atlr-engineering.com; s=20261118; h=from:subject:message-id; bh=oamTsi2zh4l3JQM5AdRv/8Zs9HcQBaZywxSOTejJgu0=; b=EGus2I6FyXYRU0XzhqmLXfDG9oX/jabbNiRa48o0HybyHgGgYpYipZ78xI9zu9ivjUFfSEO1s fH1bCcyp9XyDcRrNa0pzVh1pacaG2ofQxAKg3C19bWSZ65Fy3o523nL X-Developer-Key: i=arapaille@atlr-engineering.com; a=ed25519; pk=xskH/sIiNU/aZCeGeBB1TK/AuiG3MXlX0m2wMlbMl08= X-Endpoint-Received: by B4 Relay for arapaille@atlr-engineering.com/20261118 with auth_id=1560 X-Original-From: Alexandre Rapaille Reply-To: arapaille@atlr-engineering.com Content-Transfer-Encoding: 7bit From: Alexandre Rapaille Some clients have mailboxes for only some of their 'mboxes' indexes and fall back to another doorbell for the rest. mbox_request_channel() logs an error for each missing or empty entry before the client can fall back. Add an _optional variant that returns NULL for such an entry, like the other *_get_optional() helpers. Suggested-by: Konrad Dybcio Signed-off-by: Alexandre Rapaille --- drivers/mailbox/mailbox.c | 62 ++++++++++++++++++++++++++++++------------ include/linux/mailbox_client.h | 1 + 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index efacd24a085d..2702367a34d0 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -408,24 +408,8 @@ int mbox_bind_client(struct mbox_chan *chan, struct mbox_client *cl) } EXPORT_SYMBOL_GPL(mbox_bind_client); -/** - * mbox_request_channel - Request a mailbox channel. - * @cl: Identity of the client requesting the channel. - * @index: Index of mailbox specifier in 'mboxes' property. - * - * The Client specifies its requirements and capabilities while asking for - * a mailbox channel. It can't be called from atomic context. - * The channel is exclusively allocated and can't be used by another - * client before the owner calls mbox_free_channel. - * After assignment, any packet received on this channel will be - * handed over to the client via the 'rx_callback'. - * The framework holds reference to the client, so the mbox_client - * structure shouldn't be modified until the mbox_free_channel returns. - * - * Return: Pointer to the channel assigned to the client if successful. - * ERR_PTR for request failure. - */ -struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) +static struct mbox_chan *__mbox_request_channel(struct mbox_client *cl, int index, + bool optional) { struct fwnode_reference_args fwspec; struct fwnode_handle *fwnode; @@ -451,6 +435,8 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) ret = fwnode_property_get_reference_args(fwnode, "mboxes", "#mbox-cells", 0, index, &fwspec); if (ret) { + if (optional && ret == -ENOENT) + return NULL; dev_err(dev, "%s: can't parse \"%s\" property\n", __func__, "mboxes"); return ERR_PTR(ret); } @@ -488,8 +474,48 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) return chan; } + +/** + * mbox_request_channel - Request a mailbox channel. + * @cl: Identity of the client requesting the channel. + * @index: Index of mailbox specifier in 'mboxes' property. + * + * The Client specifies its requirements and capabilities while asking for + * a mailbox channel. It can't be called from atomic context. + * The channel is exclusively allocated and can't be used by another + * client before the owner calls mbox_free_channel. + * After assignment, any packet received on this channel will be + * handed over to the client via the 'rx_callback'. + * The framework holds reference to the client, so the mbox_client + * structure shouldn't be modified until the mbox_free_channel returns. + * + * Return: Pointer to the channel assigned to the client if successful. + * ERR_PTR for request failure. + */ +struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) +{ + return __mbox_request_channel(cl, index, false); +} EXPORT_SYMBOL_GPL(mbox_request_channel); +/** + * mbox_request_channel_optional - Request a mailbox channel that may be absent. + * @cl: Identity of the client requesting the channel. + * @index: Index of mailbox specifier in 'mboxes' property. + * + * Like mbox_request_channel(), but a missing or empty 'mboxes' entry at + * @index is not an error. + * + * Return: Pointer to the channel assigned to the client if successful, + * NULL if there is no entry at @index, + * ERR_PTR for request failure. + */ +struct mbox_chan *mbox_request_channel_optional(struct mbox_client *cl, int index) +{ + return __mbox_request_channel(cl, index, true); +} +EXPORT_SYMBOL_GPL(mbox_request_channel_optional); + struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, const char *name) { diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h index e5997120f45c..042bc0e19158 100644 --- a/include/linux/mailbox_client.h +++ b/include/linux/mailbox_client.h @@ -41,6 +41,7 @@ int mbox_bind_client(struct mbox_chan *chan, struct mbox_client *cl); struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, const char *name); struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index); +struct mbox_chan *mbox_request_channel_optional(struct mbox_client *cl, int index); int mbox_send_message(struct mbox_chan *chan, void *mssg); int mbox_flush(struct mbox_chan *chan, unsigned long timeout); void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */ -- 2.43.0