Message ID | 20241220-acpm-v4-upstream-mbox-v6-3-a6942806e52a@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mailbox: add Samsung Exynos driver | expand |
Hi Tudor, kernel test robot noticed the following build warnings: [auto build test WARNING on 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8] url: https://github.com/intel-lab-lkp/linux/commits/Tudor-Ambarus/dt-bindings-mailbox-allow-mbox-cells-0/20241220-215938 base: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8 patch link: https://lore.kernel.org/r/20241220-acpm-v4-upstream-mbox-v6-3-a6942806e52a%40linaro.org patch subject: [PATCH v6 3/5] mailbox: add support for clients to request channels by args config: x86_64-buildonly-randconfig-001-20241221 (https://download.01.org/0day-ci/archive/20241221/202412211604.qPMHGnk0-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241221/202412211604.qPMHGnk0-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202412211604.qPMHGnk0-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/mailbox/mailbox.c:486: warning: Function parameter or struct member 'mbox_spec' not described in 'mbox_request_channel_by_args' >> drivers/mailbox/mailbox.c:486: warning: Excess function parameter 'spec' description in 'mbox_request_channel_by_args' vim +486 drivers/mailbox/mailbox.c 469 470 /** 471 * mbox_request_channel_by_args - request a mailbox channel using client's 472 * channel identifiers. 473 * @cl: identity of the client requesting the channel. 474 * @index: index of mailbox specifier in 'mboxes' property. 475 * @spec: arguments that describe the channel. 476 * 477 * Used by clients that can discover the channel identifiers at runtime (by 478 * parsing a shared memory for example). The description of 479 * mbox_request_channel() applies here as well. 480 * 481 * Return: Pointer to the channel assigned to the client if successful. 482 * ERR_PTR for request failure. 483 */ 484 struct mbox_chan *mbox_request_channel_by_args(struct mbox_client *cl, 485 int index, const struct mbox_xlate_args *mbox_spec) > 486 { 487 struct of_phandle_args of_args; 488 struct device *dev = cl->dev; 489 struct mbox_controller *mbox; 490 struct mbox_chan *chan; 491 int ret; 492 493 if (!dev || !dev->of_node) { 494 pr_debug("%s: No owner device node\n", __func__); 495 return ERR_PTR(-ENODEV); 496 } 497 498 if (of_parse_phandle_with_args(dev->of_node, "mboxes", 499 "#mbox-cells", index, &of_args)) { 500 dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__); 501 return ERR_PTR(-ENODEV); 502 } 503 504 mutex_lock(&con_mutex); 505 506 chan = ERR_PTR(-EPROBE_DEFER); 507 list_for_each_entry(mbox, &mbox_cons, node) 508 if (mbox->dev->of_node == of_args.np && mbox->xlate) { 509 chan = mbox->xlate(mbox, mbox_spec); 510 if (!IS_ERR(chan)) 511 break; 512 } 513 514 of_node_put(of_args.np); 515 516 if (IS_ERR(chan)) { 517 mutex_unlock(&con_mutex); 518 return chan; 519 } 520 521 ret = __mbox_bind_client(chan, cl); 522 if (ret) 523 chan = ERR_PTR(ret); 524 525 mutex_unlock(&con_mutex); 526 return chan; 527 } 528 EXPORT_SYMBOL_GPL(mbox_request_channel_by_args); 529
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index d3d26a2c9895..0eecffd5a2ad 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -467,6 +467,66 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, } EXPORT_SYMBOL_GPL(mbox_request_channel_byname); +/** + * mbox_request_channel_by_args - request a mailbox channel using client's + * channel identifiers. + * @cl: identity of the client requesting the channel. + * @index: index of mailbox specifier in 'mboxes' property. + * @spec: arguments that describe the channel. + * + * Used by clients that can discover the channel identifiers at runtime (by + * parsing a shared memory for example). The description of + * mbox_request_channel() applies here as well. + * + * Return: Pointer to the channel assigned to the client if successful. + * ERR_PTR for request failure. + */ +struct mbox_chan *mbox_request_channel_by_args(struct mbox_client *cl, + int index, const struct mbox_xlate_args *mbox_spec) +{ + struct of_phandle_args of_args; + struct device *dev = cl->dev; + struct mbox_controller *mbox; + struct mbox_chan *chan; + int ret; + + if (!dev || !dev->of_node) { + pr_debug("%s: No owner device node\n", __func__); + return ERR_PTR(-ENODEV); + } + + if (of_parse_phandle_with_args(dev->of_node, "mboxes", + "#mbox-cells", index, &of_args)) { + dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__); + return ERR_PTR(-ENODEV); + } + + mutex_lock(&con_mutex); + + chan = ERR_PTR(-EPROBE_DEFER); + list_for_each_entry(mbox, &mbox_cons, node) + if (mbox->dev->of_node == of_args.np && mbox->xlate) { + chan = mbox->xlate(mbox, mbox_spec); + if (!IS_ERR(chan)) + break; + } + + of_node_put(of_args.np); + + if (IS_ERR(chan)) { + mutex_unlock(&con_mutex); + return chan; + } + + ret = __mbox_bind_client(chan, cl); + if (ret) + chan = ERR_PTR(ret); + + mutex_unlock(&con_mutex); + return chan; +} +EXPORT_SYMBOL_GPL(mbox_request_channel_by_args); + /** * mbox_free_channel - The client relinquishes control of a mailbox * channel by this call. diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h new file mode 100644 index 000000000000..cef88c5ae49d --- /dev/null +++ b/include/linux/mailbox.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright 2024 Linaro Ltd. + */ + +#ifndef __LINUX_MAILBOX_H +#define __LINUX_MAILBOX_H + +#include <linux/types.h> + +#define MBOX_XLATE_MAX_ARGS 16 +struct mbox_xlate_args { + int args_count; + u32 args[MBOX_XLATE_MAX_ARGS]; +}; + +#endif /* __LINUX_MAILBOX_H */ diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h index 734694912ef7..06e2721313ca 100644 --- a/include/linux/mailbox_client.h +++ b/include/linux/mailbox_client.h @@ -9,6 +9,7 @@ #include <linux/of.h> #include <linux/device.h> +#include <linux/mailbox.h> struct mbox_chan; @@ -41,6 +42,8 @@ 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_by_args(struct mbox_client *cl, + int index, const struct mbox_xlate_args *mbox_spec); 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 */ diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index 6fee33cb52f5..dfddcf966f9f 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -8,6 +8,7 @@ #include <linux/hrtimer.h> #include <linux/device.h> #include <linux/completion.h> +#include <linux/mailbox.h> struct mbox_chan; @@ -67,6 +68,7 @@ struct mbox_chan_ops { * @txpoll_period: If 'txdone_poll' is in effect, the API polls for * last TX's status after these many millisecs * @of_xlate: Controller driver specific mapping of channel via DT + * @xlate: Controller driver specific mapping of channel * @poll_hrt: API private. hrtimer used to poll for TXDONE on all * channels. * @node: API private. To hook into list of controllers. @@ -81,6 +83,8 @@ struct mbox_controller { unsigned txpoll_period; struct mbox_chan *(*of_xlate)(struct mbox_controller *mbox, const struct of_phandle_args *sp); + struct mbox_chan *(*xlate)(struct mbox_controller *mbox, + const struct mbox_xlate_args *sp); /* Internal to API */ struct hrtimer poll_hrt; spinlock_t poll_hrt_lock;
There are clients that can discover channel identifiers at runtime by parsing a shared memory for example, as in the ACPM interface's case. Supply a new framework API: mbox_request_channel_by_args(). It works by supplying the usual client pointer as the first argument, the usual index of the mailbox specifier in the 'mboxes' property as a second argument, and a pointer to a 'const struct mbox_xlate_args' as a third. The newly introduced struct is modeled after 'struct of_phandle_args'. The API identifies the controller's device node, and then calls that controller's xlate() method that will return a pointer to a mbox_chan or a ERR_PTR. The binding between the channel and the client is done in the typical way. Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> --- drivers/mailbox/mailbox.c | 60 ++++++++++++++++++++++++++++++++++++++ include/linux/mailbox.h | 17 +++++++++++ include/linux/mailbox_client.h | 3 ++ include/linux/mailbox_controller.h | 4 +++ 4 files changed, 84 insertions(+)