mbox series

[v4,0/2] soc: qcom: aoss: Expose send for generic usecase

Message ID 1623237532-20829-1-git-send-email-sibis@codeaurora.org
Headers show
Series soc: qcom: aoss: Expose send for generic usecase | expand

Message

Sibi Sankar June 9, 2021, 11:18 a.m. UTC
The patch series exposes functions to enable drivers to send their own
messages to AOSS (Always on Subsystem). It also adds a debugfs node for
qmp so messages can be sent to aoss for debugging and testing purposes.

V4:
 * Fix compilation error due to missing qmp_put
 * Minor typos [s/tarcks/tracks]

V3:
 * Remove devm memory allocation
 * Use refcount for qmp handle
 * Update qmp_get/qmp_put/qmp_remove function with refcount logic

Deepak Kumar Singh (2):
  soc: qcom: aoss: Expose send for generic usecase
  soc: qcom: aoss: Add debugfs entry

 drivers/soc/qcom/qcom_aoss.c       | 109 ++++++++++++++++++++++++++++++++++++-
 include/linux/soc/qcom/qcom_aoss.h |  36 ++++++++++++
 2 files changed, 143 insertions(+), 2 deletions(-)
 create mode 100644 include/linux/soc/qcom/qcom_aoss.h

Comments

Bjorn Andersson Aug. 4, 2021, 7:06 p.m. UTC | #1
On Wed 09 Jun 06:18 CDT 2021, Sibi Sankar wrote:

> From: Deepak Kumar Singh <deesin@codeaurora.org>

> 

> It can be useful to control the different power states of various

> parts of hardware for device testing. Add a debugfs node for qmp so

> messages can be sent to aoss for debugging and testing purposes.

> 


I thought I replied to this patch, but can't find the reply...

> Signed-off-by: Chris Lew <clew@codeaurora.org>

> Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>

> Signed-off-by: Sibi Sankar <sibis@codeaurora.org>

> ---

>  drivers/soc/qcom/qcom_aoss.c | 39 +++++++++++++++++++++++++++++++++++++++

>  1 file changed, 39 insertions(+)

> 

> diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c

> index e8f48760bac8..998ee7605eb2 100644

> --- a/drivers/soc/qcom/qcom_aoss.c

> +++ b/drivers/soc/qcom/qcom_aoss.c

> @@ -4,6 +4,7 @@

>   */

>  #include <dt-bindings/power/qcom-aoss-qmp.h>

>  #include <linux/clk-provider.h>

> +#include <linux/debugfs.h>

>  #include <linux/interrupt.h>

>  #include <linux/io.h>

>  #include <linux/mailbox_client.h>

> @@ -89,6 +90,9 @@ struct qmp {

>  	struct clk_hw qdss_clk;

>  	struct genpd_onecell_data pd_data;

>  	struct qmp_cooling_device *cooling_devs;

> +#if IS_ENABLED(CONFIG_DEBUG_FS)

> +	struct dentry *debugfs_file;

> +#endif /* CONFIG_DEBUG_FS */

>  };

>  

>  struct qmp_pd {

> @@ -575,6 +579,32 @@ void qmp_put(struct qmp *qmp)

>  }

>  EXPORT_SYMBOL(qmp_put);

>  

> +#if IS_ENABLED(CONFIG_DEBUG_FS)

> +static ssize_t aoss_dbg_write(struct file *file, const char __user *userstr,

> +			      size_t len, loff_t *pos)

> +{

> +	struct qmp *qmp = file->private_data;

> +	char buf[QMP_MSG_LEN] = {};

> +	int ret;

> +

> +	if (!len || len >= QMP_MSG_LEN)

> +		return len;

> +

> +	ret  = copy_from_user(buf, userstr, len);

> +	if (ret)

> +		return len;

> +

> +	ret = qmp_send(qmp, buf, QMP_MSG_LEN);

> +

> +	return ret ? ret : len;

> +}

> +

> +static const struct file_operations aoss_dbg_fops = {

> +	.open = simple_open,

> +	.write = aoss_dbg_write,

> +};

> +#endif /* CONFIG_DEBUG_FS */

> +

>  static int qmp_probe(struct platform_device *pdev)

>  {

>  	struct resource *res;

> @@ -632,6 +662,11 @@ static int qmp_probe(struct platform_device *pdev)

>  

>  	atomic_set(&qmp->orphan, 0);

>  

> +#if IS_ENABLED(CONFIG_DEBUG_FS)

> +	qmp->debugfs_file = debugfs_create_file("aoss_send_message", 0220, NULL,

> +						qmp, &aoss_dbg_fops);

> +#endif /* CONFIG_DEBUG_FS */


You shouldn't need the guards, debugfs_create_file() is stubbed if
CONFIG_DEBUG_FS isn't set, so it's better to just rely on that.

Regards,
Bjorn

> +

>  	return 0;

>  

>  err_remove_qdss_clk:

> @@ -649,6 +684,10 @@ static int qmp_remove(struct platform_device *pdev)

>  {

>  	struct qmp *qmp = platform_get_drvdata(pdev);

>  

> +#if IS_ENABLED(CONFIG_DEBUG_FS)

> +	debugfs_remove(qmp->debugfs_file);

> +#endif /* CONFIG_DEBUG_FS */

> +

>  	qmp_qdss_clk_remove(qmp);

>  	qmp_pd_remove(qmp);

>  	qmp_cooling_devices_remove(qmp);

> -- 

> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,

> a Linux Foundation Collaborative Project

>