All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix sleeping function called from invalid context
@ 2024-06-14  4:01 Jason-JH.Lin
  2024-06-14  4:01 ` [PATCH 1/2] mailbox: Add power_get/power_put API to mbox_chan_ops Jason-JH.Lin
  2024-06-14  4:01 ` [PATCH 2/2] mailbox: mtk-cmdq: Move pm_runimte_get and put to mbox_chan_ops API Jason-JH.Lin
  0 siblings, 2 replies; 32+ messages in thread
From: Jason-JH.Lin @ 2024-06-14  4:01 UTC (permalink / raw)
  To: Jassi Brar, Chun-Kuang Hu, AngeloGioacchino Del Regno
  Cc: Matthias Brugger, Jason-JH . Lin, Singo Chang, Nancy Lin,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group

We found that there is a spin_lock_irqsave protection in msg_submit()
of mailbox.c and it is in the atomic context.
So when the mailbox controller driver calls pm_runtime_get_sync() in
mbox_chan_ops->send_data(), it will get this BUG report.
"BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:1164"

Add API to mbox_chan_ops to make mailbox takes into account that a driver
may need PM done.

Jason-JH.Lin (2):
  mailbox: Add power_get/power_put API to mbox_chan_ops
  mailbox: mtk-cmdq: Move pm_runimte_get and put to mbox_chan_ops API

 drivers/mailbox/mailbox.c          | 55 ++++++++++++++++++++++++++++++
 drivers/mailbox/mtk-cmdq-mailbox.c | 37 ++++++++++----------
 include/linux/mailbox_controller.h | 11 ++++++
 3 files changed, 84 insertions(+), 19 deletions(-)

-- 
2.18.0



^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [PATCH 1/2] mailbox: Add power_get/power_put API to mbox_chan_ops
@ 2024-06-15  8:06 kernel test robot
  0 siblings, 0 replies; 32+ messages in thread
From: kernel test robot @ 2024-06-15  8:06 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240614040133.24967-2-jason-jh.lin@mediatek.com>
References: <20240614040133.24967-2-jason-jh.lin@mediatek.com>
TO: "Jason-JH.Lin" <jason-jh.lin@mediatek.com>
TO: Jassi Brar <jassisinghbrar@gmail.com>
TO: "Chun-Kuang Hu" <chunkuang.hu@kernel.org>
TO: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
CC: Matthias Brugger <matthias.bgg@gmail.com>
CC: "Jason-JH . Lin" <jason-jh.lin@mediatek.com>
CC: Singo Chang <singo.chang@mediatek.com>
CC: Nancy Lin <nancy.lin@mediatek.com>
CC: linux-kernel@vger.kernel.org
CC: linux-arm-kernel@lists.infradead.org
CC: linux-mediatek@lists.infradead.org
CC: Project_Global_Chrome_Upstream_Group@mediatek.com

Hi Jason-JH.Lin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.10-rc3 next-20240613]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jason-JH-Lin/mailbox-Add-power_get-power_put-API-to-mbox_chan_ops/20240614-120412
base:   linus/master
patch link:    https://lore.kernel.org/r/20240614040133.24967-2-jason-jh.lin%40mediatek.com
patch subject: [PATCH 1/2] mailbox: Add power_get/power_put API to mbox_chan_ops
:::::: branch date: 28 hours ago
:::::: commit date: 28 hours ago
config: x86_64-randconfig-161-20240615 (https://download.01.org/0day-ci/archive/20240615/202406151520.TDnOFFbV-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202406151520.TDnOFFbV-lkp@intel.com/

smatch warnings:
drivers/mailbox/mailbox.c:485 mbox_request_channel() error: 'chan' dereferencing possible ERR_PTR()

vim +/chan +485 drivers/mailbox/mailbox.c

85a953806557db Elliot Berman   2023-04-10  426  
2b6d83e2b8b7de Jassi Brar      2014-06-12  427  /**
2b6d83e2b8b7de Jassi Brar      2014-06-12  428   * mbox_request_channel - Request a mailbox channel.
2b6d83e2b8b7de Jassi Brar      2014-06-12  429   * @cl: Identity of the client requesting the channel.
2b6d83e2b8b7de Jassi Brar      2014-06-12  430   * @index: Index of mailbox specifier in 'mboxes' property.
2b6d83e2b8b7de Jassi Brar      2014-06-12  431   *
2b6d83e2b8b7de Jassi Brar      2014-06-12  432   * The Client specifies its requirements and capabilities while asking for
2b6d83e2b8b7de Jassi Brar      2014-06-12  433   * a mailbox channel. It can't be called from atomic context.
2b6d83e2b8b7de Jassi Brar      2014-06-12  434   * The channel is exclusively allocated and can't be used by another
2b6d83e2b8b7de Jassi Brar      2014-06-12  435   * client before the owner calls mbox_free_channel.
2b6d83e2b8b7de Jassi Brar      2014-06-12  436   * After assignment, any packet received on this channel will be
2b6d83e2b8b7de Jassi Brar      2014-06-12  437   * handed over to the client via the 'rx_callback'.
2b6d83e2b8b7de Jassi Brar      2014-06-12  438   * The framework holds reference to the client, so the mbox_client
2b6d83e2b8b7de Jassi Brar      2014-06-12  439   * structure shouldn't be modified until the mbox_free_channel returns.
2b6d83e2b8b7de Jassi Brar      2014-06-12  440   *
2b6d83e2b8b7de Jassi Brar      2014-06-12  441   * Return: Pointer to the channel assigned to the client if successful.
2b6d83e2b8b7de Jassi Brar      2014-06-12  442   *		ERR_PTR for request failure.
2b6d83e2b8b7de Jassi Brar      2014-06-12  443   */
2b6d83e2b8b7de Jassi Brar      2014-06-12  444  struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
2b6d83e2b8b7de Jassi Brar      2014-06-12  445  {
2b6d83e2b8b7de Jassi Brar      2014-06-12  446  	struct device *dev = cl->dev;
2b6d83e2b8b7de Jassi Brar      2014-06-12  447  	struct mbox_controller *mbox;
2b6d83e2b8b7de Jassi Brar      2014-06-12  448  	struct of_phandle_args spec;
2b6d83e2b8b7de Jassi Brar      2014-06-12  449  	struct mbox_chan *chan;
2b6d83e2b8b7de Jassi Brar      2014-06-12  450  	int ret;
2b6d83e2b8b7de Jassi Brar      2014-06-12  451  
2b6d83e2b8b7de Jassi Brar      2014-06-12  452  	if (!dev || !dev->of_node) {
2b6d83e2b8b7de Jassi Brar      2014-06-12  453  		pr_debug("%s: No owner device node\n", __func__);
2b6d83e2b8b7de Jassi Brar      2014-06-12  454  		return ERR_PTR(-ENODEV);
2b6d83e2b8b7de Jassi Brar      2014-06-12  455  	}
2b6d83e2b8b7de Jassi Brar      2014-06-12  456  
2b6d83e2b8b7de Jassi Brar      2014-06-12  457  	mutex_lock(&con_mutex);
2b6d83e2b8b7de Jassi Brar      2014-06-12  458  
2b6d83e2b8b7de Jassi Brar      2014-06-12  459  	if (of_parse_phandle_with_args(dev->of_node, "mboxes",
2b6d83e2b8b7de Jassi Brar      2014-06-12  460  				       "#mbox-cells", index, &spec)) {
2b6d83e2b8b7de Jassi Brar      2014-06-12  461  		dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__);
2b6d83e2b8b7de Jassi Brar      2014-06-12  462  		mutex_unlock(&con_mutex);
2b6d83e2b8b7de Jassi Brar      2014-06-12  463  		return ERR_PTR(-ENODEV);
2b6d83e2b8b7de Jassi Brar      2014-06-12  464  	}
2b6d83e2b8b7de Jassi Brar      2014-06-12  465  
2d805fc1c6b2ec Benson Leung    2015-05-04  466  	chan = ERR_PTR(-EPROBE_DEFER);
2b6d83e2b8b7de Jassi Brar      2014-06-12  467  	list_for_each_entry(mbox, &mbox_cons, node)
2b6d83e2b8b7de Jassi Brar      2014-06-12  468  		if (mbox->dev->of_node == spec.np) {
2b6d83e2b8b7de Jassi Brar      2014-06-12  469  			chan = mbox->of_xlate(mbox, &spec);
8ed82e23875e60 Mikko Perttunen 2018-11-28  470  			if (!IS_ERR(chan))
2b6d83e2b8b7de Jassi Brar      2014-06-12  471  				break;
2b6d83e2b8b7de Jassi Brar      2014-06-12  472  		}
2b6d83e2b8b7de Jassi Brar      2014-06-12  473  
2b6d83e2b8b7de Jassi Brar      2014-06-12  474  	of_node_put(spec.np);
2b6d83e2b8b7de Jassi Brar      2014-06-12  475  
2d805fc1c6b2ec Benson Leung    2015-05-04  476  	if (IS_ERR(chan)) {
2d805fc1c6b2ec Benson Leung    2015-05-04  477  		mutex_unlock(&con_mutex);
2d805fc1c6b2ec Benson Leung    2015-05-04  478  		return chan;
2d805fc1c6b2ec Benson Leung    2015-05-04  479  	}
2d805fc1c6b2ec Benson Leung    2015-05-04  480  
85a953806557db Elliot Berman   2023-04-10  481  	ret = __mbox_bind_client(chan, cl);
85a953806557db Elliot Berman   2023-04-10  482  	if (ret)
2b6d83e2b8b7de Jassi Brar      2014-06-12  483  		chan = ERR_PTR(ret);
2b6d83e2b8b7de Jassi Brar      2014-06-12  484  
9c57f48cd805b1 Jason-JH.Lin    2024-06-14 @485  	if (chan->mbox->ops->power_put)
9c57f48cd805b1 Jason-JH.Lin    2024-06-14  486  		chan->mbox->ops->power_put(chan);
9c57f48cd805b1 Jason-JH.Lin    2024-06-14  487  
2b6d83e2b8b7de Jassi Brar      2014-06-12  488  	mutex_unlock(&con_mutex);
9c57f48cd805b1 Jason-JH.Lin    2024-06-14  489  
2b6d83e2b8b7de Jassi Brar      2014-06-12  490  	return chan;
2b6d83e2b8b7de Jassi Brar      2014-06-12  491  }
2b6d83e2b8b7de Jassi Brar      2014-06-12  492  EXPORT_SYMBOL_GPL(mbox_request_channel);
2b6d83e2b8b7de Jassi Brar      2014-06-12  493  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2024-07-17 16:18 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-14  4:01 [PATCH 0/2] Fix sleeping function called from invalid context Jason-JH.Lin
2024-06-14  4:01 ` [PATCH 1/2] mailbox: Add power_get/power_put API to mbox_chan_ops Jason-JH.Lin
2024-06-14 11:35   ` Markus Elfring
2024-06-18  6:26     ` Jason-JH Lin (林睿祥)
2024-06-14 16:23   ` kernel test robot
2024-06-14 16:55   ` kernel test robot
2024-06-14 18:51   ` kernel test robot
2024-06-17 12:39   ` Dan Carpenter
2024-06-14  4:01 ` [PATCH 2/2] mailbox: mtk-cmdq: Move pm_runimte_get and put to mbox_chan_ops API Jason-JH.Lin
2024-06-17 18:18   ` Jassi Brar
2024-06-18  8:42     ` Jason-JH Lin (林睿祥)
2024-06-18 15:59       ` Jassi Brar
2024-06-19  8:18         ` AngeloGioacchino Del Regno
2024-06-19 15:38           ` Jassi Brar
2024-06-20  6:32             ` Jason-JH Lin (林睿祥)
2024-06-20 14:39               ` Jassi Brar
2024-06-24 11:29                 ` AngeloGioacchino Del Regno
2024-06-24 17:45                   ` Jassi Brar
2024-06-25  3:40                     ` Jason-JH Lin (林睿祥)
2024-06-25  4:21                       ` Jassi Brar
2024-06-26  9:32                         ` Jason-JH Lin (林睿祥)
2024-06-28  3:40                           ` Jassi Brar
2024-07-03 16:41                             ` Jason-JH Lin (林睿祥)
2024-07-03 19:06                               ` Jassi Brar
2024-07-05  6:11                                 ` Jason-JH Lin (林睿祥)
2024-07-05 16:43                                   ` Jassi Brar
2024-07-11  2:00                                     ` Jason-JH Lin (林睿祥)
2024-07-11  3:47                                       ` Jassi Brar
2024-07-12  7:23                                         ` Jason-JH Lin (林睿祥)
2024-07-15  9:45                                           ` Jason-JH Lin (林睿祥)
2024-07-17 16:17                                             ` Jassi Brar
  -- strict thread matches above, loose matches on Subject: below --
2024-06-15  8:06 [PATCH 1/2] mailbox: Add power_get/power_put API to mbox_chan_ops kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.