Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0877e125 authored by Jilai Wang's avatar Jilai Wang
Browse files

msm: npu: Initial support NPU suspend/resume



When device enters suspend mode, flush disable firmware work to
make sure NPU is powered off when device is suspended.

Change-Id: I75a63accdb12e6535b897f2b980d76515593b710
Signed-off-by: default avatarJilai Wang <jilaiw@codeaurora.org>
parent ddf7db4c
Loading
Loading
Loading
Loading
+24 −13
Original line number Diff line number Diff line
@@ -106,8 +106,8 @@ static int npu_of_parse_pwrlevels(struct npu_device *npu_dev,
static int npu_pwrctrl_init(struct npu_device *npu_dev);
static int npu_probe(struct platform_device *pdev);
static int npu_remove(struct platform_device *pdev);
static int npu_suspend(struct platform_device *dev, pm_message_t state);
static int npu_resume(struct platform_device *dev);
static int npu_pm_suspend(struct device *dev);
static int npu_pm_resume(struct device *dev);
static int __init npu_init(void);
static void __exit npu_exit(void);

@@ -185,17 +185,17 @@ static const struct of_device_id npu_dt_match[] = {
	{}
};

static const struct dev_pm_ops npu_pm_ops = {
	SET_SYSTEM_SLEEP_PM_OPS(npu_pm_suspend, npu_pm_resume)
};

static struct platform_driver npu_driver = {
	.probe = npu_probe,
	.remove = npu_remove,
#if defined(CONFIG_PM)
	.suspend = npu_suspend,
	.resume = npu_resume,
#endif
	.driver = {
		.name = "msm_npu",
		.of_match_table = npu_dt_match,
		.pm = NULL,
		.pm = &npu_pm_ops,
	},
};

@@ -2209,7 +2209,7 @@ static int npu_probe(struct platform_device *pdev)
	npu_dev->pdev = pdev;
	mutex_init(&npu_dev->dev_lock);

	platform_set_drvdata(pdev, npu_dev);
	dev_set_drvdata(&pdev->dev, npu_dev);
	res = platform_get_resource_byname(pdev,
		IORESOURCE_MEM, "core");
	if (!res) {
@@ -2434,6 +2434,7 @@ static int npu_probe(struct platform_device *pdev)
	unregister_chrdev_region(npu_dev->dev_num, 1);
	npu_mbox_deinit(npu_dev);
error_get_dev_num:
	dev_set_drvdata(&pdev->dev, NULL);
	return rc;
}

@@ -2451,7 +2452,7 @@ static int npu_remove(struct platform_device *pdev)
	device_destroy(npu_dev->class, npu_dev->dev_num);
	class_destroy(npu_dev->class);
	unregister_chrdev_region(npu_dev->dev_num, 1);
	platform_set_drvdata(pdev, NULL);
	dev_set_drvdata(&pdev->dev, NULL);
	npu_mbox_deinit(npu_dev);
	msm_bus_scale_unregister_client(npu_dev->bwctrl.bus_client);

@@ -2464,17 +2465,27 @@ static int npu_remove(struct platform_device *pdev)
 * Suspend/Resume
 * -------------------------------------------------------------------------
 */
#if defined(CONFIG_PM)
static int npu_suspend(struct platform_device *dev, pm_message_t state)
static int npu_pm_suspend(struct device *dev)
{
	struct npu_device *npu_dev;

	npu_dev = dev_get_drvdata(dev);
	if (!npu_dev) {
		NPU_ERR("invalid NPU dev\n");
		return -EINVAL;
	}

	NPU_DBG("suspend npu\n");
	npu_host_suspend(npu_dev);

	return 0;
}

static int npu_resume(struct platform_device *dev)
static int npu_pm_resume(struct device *dev)
{
	NPU_DBG("resume npu\n");
	return 0;
}
#endif

/* -------------------------------------------------------------------------
 * Module Entry Points
+7 −0
Original line number Diff line number Diff line
@@ -2837,3 +2837,10 @@ int32_t npu_host_get_perf_mode(struct npu_client *client, uint32_t network_hdl)

	return param_val;
}

void npu_host_suspend(struct npu_device *npu_dev)
{
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;

	flush_delayed_work(&host_ctx->disable_fw_work);
}
+1 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ int npu_host_update_power(struct npu_device *npu_dev);
int32_t npu_host_set_perf_mode(struct npu_client *client, uint32_t network_hdl,
	uint32_t perf_mode);
int32_t npu_host_get_perf_mode(struct npu_client *client, uint32_t network_hdl);
void npu_host_suspend(struct npu_device *npu_dev);
void npu_dump_debug_info(struct npu_device *npu_dev);
void npu_dump_ipc_packet(struct npu_device *npu_dev, void *cmd_ptr);