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

Commit 865213dd authored by Da Hoon Pyun's avatar Da Hoon Pyun Committed by Gerrit - the friendly Code Review server
Browse files

msm: npu: Unvote bandwidth after turning off GDSC



While GDSP is turned off, it requires bandwidth to be voted to
save some information to memory. This change is to move bandwidth
unvoting after turning off GDSC.

Change-Id: Ie7c30eb0a1aee58aa835133f0336f0164492d732
Signed-off-by: default avatarDa Hoon Pyun <dpyun@codeaurora.org>
parent 0f55c839
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ struct npu_mbox {
	bool send_data_pending;
};

/**
/*
 * struct npul_pwrlevel - Struct holding different pwrlevel info obtained from
 * from dtsi file
 * @pwr_level:           NPU power level
@@ -159,7 +159,7 @@ struct npu_reg {
	bool valid;
};

/**
/*
 * struct npu_pwrctrl - Power control settings for a NPU device
 * @pwr_vote_num - voting information for power enable
 * @pwrlevels - List of supported power levels
@@ -198,7 +198,7 @@ struct npu_pwrctrl {
	uint32_t cur_dcvs_activity;
};

/**
/*
 * struct npu_thermalctrl - Thermal control settings for a NPU device
 * @max_state - maximum thermal mitigation state
 * @current_state - current thermal mitigation state
+18 −24
Original line number Diff line number Diff line
@@ -401,20 +401,20 @@ int npu_enable_core_power(struct npu_device *npu_dev)
	mutex_lock(&npu_dev->dev_lock);
	NPU_DBG("Enable core power %d\n", pwr->pwr_vote_num);
	if (!pwr->pwr_vote_num) {
		ret = npu_enable_regulators(npu_dev);
		ret = npu_set_bw(npu_dev, 100, 100);
		if (ret)
			goto fail;

		ret = npu_set_bw(npu_dev, 100, 100);
		ret = npu_enable_regulators(npu_dev);
		if (ret) {
			npu_disable_regulators(npu_dev);
			npu_set_bw(npu_dev, 0, 0);
			goto fail;
		}

		ret = npu_enable_core_clocks(npu_dev);
		if (ret) {
			npu_set_bw(npu_dev, 0, 0);
			npu_disable_regulators(npu_dev);
			npu_set_bw(npu_dev, 0, 0);
			goto fail;
		}
		npu_resume_devbw(npu_dev);
@@ -441,8 +441,8 @@ void npu_disable_core_power(struct npu_device *npu_dev)
	if (!pwr->pwr_vote_num) {
		npu_suspend_devbw(npu_dev);
		npu_disable_core_clocks(npu_dev);
		npu_set_bw(npu_dev, 0, 0);
		npu_disable_regulators(npu_dev);
		npu_set_bw(npu_dev, 0, 0);
		pwr->active_pwrlevel = pwr->default_pwrlevel;
		pwr->uc_pwrlevel = pwr->max_pwrlevel;
		pwr->cdsprm_pwrlevel = pwr->max_pwrlevel;
@@ -1976,8 +1976,8 @@ static int npu_ipcc_bridge_mbox_send_data(struct mbox_chan *chan, void *data)
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;
	unsigned long flags;

	NPU_DBG("Generating IRQ for client_id: %u; signal_id: %u\n",
		ipcc_mbox_chan->client_id, ipcc_mbox_chan->signal_id);
	NPU_DBG("Generating IRQ for signal_id: %u\n",
		ipcc_mbox_chan->signal_id);

	spin_lock_irqsave(&host_ctx->bridge_mbox_lock, flags);
	ipcc_mbox_chan->npu_mbox->send_data_pending = true;
@@ -2009,7 +2009,7 @@ static struct mbox_chan *npu_ipcc_bridge_mbox_xlate(

	npu_dev = bridge_data->priv_data;

	if (ph->args_count != 2)
	if (ph->args_count != 1)
		return ERR_PTR(-EINVAL);

	for (chan_id = 0; chan_id < mbox->num_chans; chan_id++) {
@@ -2017,8 +2017,7 @@ static struct mbox_chan *npu_ipcc_bridge_mbox_xlate(

		if (!ipcc_mbox_chan)
			break;
		else if (ipcc_mbox_chan->client_id == ph->args[0] &&
				ipcc_mbox_chan->signal_id == ph->args[1])
		else if (ipcc_mbox_chan->signal_id == ph->args[0])
			return ERR_PTR(-EBUSY);
	}

@@ -2028,16 +2027,15 @@ static struct mbox_chan *npu_ipcc_bridge_mbox_xlate(
	/* search for target mailbox */
	for (i = 0; i < NPU_MAX_MBOX_NUM; i++) {
		if (npu_dev->mbox[i].chan &&
			(npu_dev->mbox[i].client_id == ph->args[0]) &&
			(npu_dev->mbox[i].signal_id == ph->args[1])) {
			(npu_dev->mbox[i].signal_id == ph->args[0])) {
			NPU_DBG("Find matched target mailbox %d\n", i);
			break;
		}
	}

	if (i == NPU_MAX_MBOX_NUM) {
		NPU_ERR("Can't find matched target mailbox %d:%d\n",
			ph->args[0], ph->args[1]);
		NPU_ERR("Can't find matched target mailbox %d\n",
			ph->args[0]);
		return ERR_PTR(-EINVAL);
	}

@@ -2045,16 +2043,14 @@ static struct mbox_chan *npu_ipcc_bridge_mbox_xlate(
	if (!ipcc_mbox_chan)
		return ERR_PTR(-ENOMEM);

	ipcc_mbox_chan->client_id = ph->args[0];
	ipcc_mbox_chan->signal_id = ph->args[1];
	ipcc_mbox_chan->signal_id = ph->args[0];
	ipcc_mbox_chan->chan = &bridge_data->chans[chan_id];
	ipcc_mbox_chan->npu_dev = npu_dev;
	ipcc_mbox_chan->chan->con_priv = ipcc_mbox_chan;
	ipcc_mbox_chan->npu_mbox = &npu_dev->mbox[i];

	NPU_DBG("New mailbox channel: %u for client_id: %u; signal_id: %u\n",
		chan_id, ipcc_mbox_chan->client_id,
		ipcc_mbox_chan->signal_id);
	NPU_DBG("New mailbox channel: %u for signal_id: %u\n",
		chan_id, ipcc_mbox_chan->signal_id);

	return ipcc_mbox_chan->chan;
}
@@ -2159,11 +2155,9 @@ static int npu_mbox_init(struct npu_device *npu_dev)
				NPU_WARN("can't get mailbox %s args\n",
					mbox_name);
			} else {
				mbox->client_id = curr_ph.args[0];
				mbox->signal_id = curr_ph.args[1];
				NPU_DBG("argument for mailbox %x is %x %x\n",
					mbox_name, curr_ph.args[0],
					curr_ph.args[1]);
				mbox->signal_id = curr_ph.args[0];
				NPU_DBG("argument for mailbox %x is %x\n",
					mbox_name, curr_ph.args[0]);
			}
		}
		index++;
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static const struct npu_queue_tuple npu_q_setup[6] = {
	{ 4096, IPC_QUEUE_APPS_EXEC         | TX_HDR_TYPE | RX_HDR_TYPE },
	{ 4096, IPC_QUEUE_DSP_EXEC          | TX_HDR_TYPE | RX_HDR_TYPE },
	{ 4096, IPC_QUEUE_APPS_RSP          | TX_HDR_TYPE | RX_HDR_TYPE },
	{ 1024, IPC_QUEUE_DSP_RSP           | TX_HDR_TYPE | RX_HDR_TYPE },
	{ 4096, IPC_QUEUE_DSP_RSP           | TX_HDR_TYPE | RX_HDR_TYPE },
	{ 1024, IPC_QUEUE_LOG               | TX_HDR_TYPE | RX_HDR_TYPE },
};

+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ void npu_interrupt_ack(struct npu_device *npu_dev, uint32_t intr_num)

int32_t npu_interrupt_raise_m0(struct npu_device *npu_dev)
{
	npu_apss_shared_reg_write(npu_dev, APSS_SHARED_IPC_INTERRUPT_1, 0x40);
	npu_apss_shared_reg_write(npu_dev, APSS_SHARED_IPC_INTERRUPT_1, 0x20);

	return 0;
}
+10 −21
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ static int enable_fw_nolock(struct npu_device *npu_dev)
		goto notify_fw_pwr_fail;
	}

	ret = wait_for_completion_interruptible_timeout(
	ret = wait_for_completion_timeout(
		&host_ctx->fw_bringup_done, NW_CMD_TIMEOUT);
	if (!ret) {
		NPU_ERR("Wait for fw bringup timedout\n");
@@ -395,7 +395,7 @@ static void disable_fw_nolock(struct npu_device *npu_dev)
	}

	if (!host_ctx->auto_pil_disable) {
		ret = wait_for_completion_interruptible_timeout(
		ret = wait_for_completion_timeout(
			&host_ctx->fw_shutdown_done, NW_CMD_TIMEOUT);
		if (!ret)
			NPU_ERR("Wait for fw shutdown timedout\n");
@@ -664,7 +664,7 @@ int npu_host_init(struct npu_device *npu_dev)
		goto fail;
	}

	host_ctx->auto_pil_disable = true;
	host_ctx->auto_pil_disable = false;

	return sts;
fail:
@@ -1513,27 +1513,22 @@ static void app_msg_proc(struct npu_host_ctx *host_ctx, uint32_t *msg)

static void host_session_msg_hdlr(struct npu_device *npu_dev)
{
	uint32_t *msg;
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;

	msg = kzalloc(sizeof(uint32_t) * NPU_IPC_BUF_LENGTH, GFP_KERNEL);
	if (!msg)
		return;

	mutex_lock(&host_ctx->lock);
	if (host_ctx->fw_state != FW_ENABLED) {
		NPU_WARN("handle npu session msg when FW is disabled\n");
		goto skip_read_msg;
	}

	while (npu_host_ipc_read_msg(npu_dev, IPC_QUEUE_APPS_RSP, msg) == 0) {
	while (npu_host_ipc_read_msg(npu_dev, IPC_QUEUE_APPS_RSP,
		host_ctx->ipc_msg_buf) == 0) {
		NPU_DBG("received from msg queue\n");
		app_msg_proc(host_ctx, msg);
		app_msg_proc(host_ctx, host_ctx->ipc_msg_buf);
	}

skip_read_msg:
	mutex_unlock(&host_ctx->lock);
	kfree(msg);
}

static void log_msg_proc(struct npu_device *npu_dev, uint32_t *msg)
@@ -1559,28 +1554,22 @@ static void log_msg_proc(struct npu_device *npu_dev, uint32_t *msg)

static void host_session_log_hdlr(struct npu_device *npu_dev)
{
	uint32_t *msg;
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;

	msg = kzalloc(sizeof(uint32_t) * NPU_IPC_BUF_LENGTH, GFP_KERNEL);

	if (!msg)
		return;

	mutex_lock(&host_ctx->lock);
	if (host_ctx->fw_state != FW_ENABLED) {
		NPU_WARN("handle npu session msg when FW is disabled\n");
		goto skip_read_msg;
	}

	while (npu_host_ipc_read_msg(npu_dev, IPC_QUEUE_LOG, msg) == 0) {
	while (npu_host_ipc_read_msg(npu_dev, IPC_QUEUE_LOG,
		host_ctx->ipc_msg_buf) == 0) {
		NPU_DBG("received from log queue\n");
		log_msg_proc(npu_dev, msg);
		log_msg_proc(npu_dev, host_ctx->ipc_msg_buf);
	}

skip_read_msg:
	mutex_unlock(&host_ctx->lock);
	kfree(msg);
}

/* -------------------------------------------------------------------------
@@ -1621,7 +1610,7 @@ int32_t npu_host_unmap_buf(struct npu_client *client,
	 * fw is disabled
	 */
	if (host_ctx->fw_error && (host_ctx->fw_state == FW_ENABLED) &&
		!wait_for_completion_interruptible_timeout(
		!wait_for_completion_timeout(
		&host_ctx->fw_deinit_done, NW_CMD_TIMEOUT))
		NPU_WARN("npu: wait for fw_deinit_done time out\n");