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

Commit 4034b81b authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman
Browse files

mei: use consistent naming for TX control flow credits



With the introduction of the receive control flow credits prefixed with
rx_ we add tx_ prefix to the variables and function used for tracking
the transmit control flow credits.

Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 46978ada
Loading
Loading
Loading
Loading
+19 −20
Original line number Diff line number Diff line
@@ -734,8 +734,8 @@ void mei_cl_set_disconnected(struct mei_cl *cl)
	mei_io_list_flush(&dev->ctrl_rd_list, cl);
	mei_io_list_flush(&dev->ctrl_wr_list, cl);
	mei_cl_wake_all(cl);
	cl->mei_flow_ctrl_creds = 0;
	cl->rx_flow_ctrl_creds = 0;
	cl->tx_flow_ctrl_creds = 0;
	cl->timer_count = 0;

	if (!cl->me_cl)
@@ -745,7 +745,7 @@ void mei_cl_set_disconnected(struct mei_cl *cl)
		cl->me_cl->connect_count--;

	if (cl->me_cl->connect_count == 0)
		cl->me_cl->mei_flow_ctrl_creds = 0;
		cl->me_cl->tx_flow_ctrl_creds = 0;

	mei_me_cl_put(cl->me_cl);
	cl->me_cl = NULL;
@@ -1140,43 +1140,42 @@ struct mei_cl *mei_cl_alloc_linked(struct mei_device *dev)
	return ERR_PTR(ret);
}



/**
 * mei_cl_flow_ctrl_creds - checks flow_control credits for cl.
 * mei_cl_tx_flow_ctrl_creds - checks flow_control credits for cl.
 *
 * @cl: host client
 *
 * Return: 1 if mei_flow_ctrl_creds >0, 0 - otherwise.
 * Return: 1 if tx_flow_ctrl_creds >0, 0 - otherwise.
 */
static int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
static int mei_cl_tx_flow_ctrl_creds(struct mei_cl *cl)
{
	if (WARN_ON(!cl || !cl->me_cl))
		return -EINVAL;

	if (cl->mei_flow_ctrl_creds > 0)
	if (cl->tx_flow_ctrl_creds > 0)
		return 1;

	if (mei_cl_is_fixed_address(cl))
		return 1;

	if (mei_cl_is_single_recv_buf(cl)) {
		if (cl->me_cl->mei_flow_ctrl_creds > 0)
		if (cl->me_cl->tx_flow_ctrl_creds > 0)
			return 1;
	}
	return 0;
}

/**
 * mei_cl_flow_ctrl_reduce - reduces flow_control.
 * mei_cl_tx_flow_ctrl_creds_reduce - reduces transmit flow control credits
 *   for a client
 *
 * @cl: private data of the file object
 * @cl: host client
 *
 * Return:
 *	0 on success
 *	-EINVAL when ctrl credits are <= 0
 */
static int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
static int mei_cl_tx_flow_ctrl_creds_reduce(struct mei_cl *cl)
{
	if (WARN_ON(!cl || !cl->me_cl))
		return -EINVAL;
@@ -1185,13 +1184,13 @@ static int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
		return 0;

	if (mei_cl_is_single_recv_buf(cl)) {
		if (WARN_ON(cl->me_cl->mei_flow_ctrl_creds <= 0))
		if (WARN_ON(cl->me_cl->tx_flow_ctrl_creds <= 0))
			return -EINVAL;
		cl->me_cl->mei_flow_ctrl_creds--;
		cl->me_cl->tx_flow_ctrl_creds--;
	} else {
		if (WARN_ON(cl->mei_flow_ctrl_creds <= 0))
		if (WARN_ON(cl->tx_flow_ctrl_creds <= 0))
			return -EINVAL;
		cl->mei_flow_ctrl_creds--;
		cl->tx_flow_ctrl_creds--;
	}
	return 0;
}
@@ -1511,7 +1510,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,

	first_chunk = cb->buf_idx == 0;

	rets = first_chunk ? mei_cl_flow_ctrl_creds(cl) : 1;
	rets = first_chunk ? mei_cl_tx_flow_ctrl_creds(cl) : 1;
	if (rets < 0)
		return rets;

@@ -1559,7 +1558,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
	cb->completed = mei_hdr.msg_complete == 1;

	if (first_chunk) {
		if (mei_cl_flow_ctrl_reduce(cl))
		if (mei_cl_tx_flow_ctrl_creds_reduce(cl))
			return -EIO;
	}

@@ -1617,7 +1616,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
	mei_hdr.msg_complete = 0;
	mei_hdr.internal = cb->internal;

	rets = mei_cl_flow_ctrl_creds(cl);
	rets = mei_cl_tx_flow_ctrl_creds(cl);
	if (rets < 0)
		goto err;

@@ -1645,7 +1644,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
	if (rets)
		goto err;

	rets = mei_cl_flow_ctrl_reduce(cl);
	rets = mei_cl_tx_flow_ctrl_creds_reduce(cl);
	if (rets)
		goto err;

+20 −21
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ static int mei_hbm_me_cl_add(struct mei_device *dev,

	me_cl->props = res->client_properties;
	me_cl->client_id = res->me_addr;
	me_cl->mei_flow_ctrl_creds = 0;
	me_cl->tx_flow_ctrl_creds = 0;

	mei_me_cl_add(dev, me_cl);

@@ -637,23 +637,22 @@ int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
}

/**
 * mei_hbm_add_single_flow_creds - adds single buffer credentials.
 * mei_hbm_add_single_tx_flow_ctrl_creds - adds single buffer credentials.
 *
 * @dev: the device structure
 * @flow: flow control.
 * @fctrl: flow control response bus message
 *
 * Return: 0 on success, < 0 otherwise
 */
static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
				  struct hbm_flow_control *flow)
static int mei_hbm_add_single_tx_flow_ctrl_creds(struct mei_device *dev,
						 struct hbm_flow_control *fctrl)
{
	struct mei_me_client *me_cl;
	int rets;

	me_cl = mei_me_cl_by_id(dev, flow->me_addr);
	me_cl = mei_me_cl_by_id(dev, fctrl->me_addr);
	if (!me_cl) {
		dev_err(dev->dev, "no such me client %d\n",
			flow->me_addr);
		dev_err(dev->dev, "no such me client %d\n", fctrl->me_addr);
		return -ENOENT;
	}

@@ -662,9 +661,9 @@ static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
		goto out;
	}

	me_cl->mei_flow_ctrl_creds++;
	me_cl->tx_flow_ctrl_creds++;
	dev_dbg(dev->dev, "recv flow ctrl msg ME %d (single) creds = %d.\n",
	    flow->me_addr, me_cl->mei_flow_ctrl_creds);
		fctrl->me_addr, me_cl->tx_flow_ctrl_creds);

	rets = 0;
out:
@@ -676,24 +675,24 @@ static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
 * mei_hbm_cl_flow_control_res - flow control response from me
 *
 * @dev: the device structure
 * @flow_control: flow control response bus message
 * @fctrl: flow control response bus message
 */
static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
					struct hbm_flow_control *flow_control)
static void mei_hbm_cl_tx_flow_ctrl_creds_res(struct mei_device *dev,
					       struct hbm_flow_control *fctrl)
{
	struct mei_cl *cl;

	if (!flow_control->host_addr) {
	if (!fctrl->host_addr) {
		/* single receive buffer */
		mei_hbm_add_single_flow_creds(dev, flow_control);
		mei_hbm_add_single_tx_flow_ctrl_creds(dev, fctrl);
		return;
	}

	cl = mei_hbm_cl_find_by_cmd(dev, flow_control);
	cl = mei_hbm_cl_find_by_cmd(dev, fctrl);
	if (cl) {
		cl->mei_flow_ctrl_creds++;
		cl->tx_flow_ctrl_creds++;
		cl_dbg(dev, cl, "flow control creds = %d.\n",
				cl->mei_flow_ctrl_creds);
				cl->tx_flow_ctrl_creds);
	}
}

@@ -1023,7 +1022,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)

	struct mei_hbm_cl_cmd *cl_cmd;
	struct hbm_client_connect_request *disconnect_req;
	struct hbm_flow_control *flow_control;
	struct hbm_flow_control *fctrl;

	/* read the message to our buffer */
	BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
@@ -1103,8 +1102,8 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
	case MEI_FLOW_CONTROL_CMD:
		dev_dbg(dev->dev, "hbm: client flow control response: message received.\n");

		flow_control = (struct hbm_flow_control *) mei_msg;
		mei_hbm_cl_flow_control_res(dev, flow_control);
		fctrl = (struct hbm_flow_control *)mei_msg;
		mei_hbm_cl_tx_flow_ctrl_creds_res(dev, fctrl);
		break;

	case MEI_PG_ISOLATION_ENTRY_RES_CMD:
+4 −4
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ struct mei_fw_status {
 * @refcnt: struct reference count
 * @props: client properties
 * @client_id: me client id
 * @mei_flow_ctrl_creds: flow control credits
 * @tx_flow_ctrl_creds: flow control credits
 * @connect_count: number connections to this client
 * @bus_added: added to bus
 */
@@ -153,7 +153,7 @@ struct mei_me_client {
	struct kref refcnt;
	struct mei_client_properties props;
	u8 client_id;
	u8 mei_flow_ctrl_creds;
	u8 tx_flow_ctrl_creds;
	u8 connect_count;
	u8 bus_added;
};
@@ -202,7 +202,7 @@ struct mei_cl_cb {
 * @me_cl: fw client connected
 * @fp: file associated with client
 * @host_client_id: host id
 * @mei_flow_ctrl_creds: transmit flow credentials
 * @tx_flow_ctrl_creds: transmit flow credentials
 * @rx_flow_ctrl_creds: receive flow credentials
 * @timer_count:  watchdog timer for operation completion
 * @notify_en: notification - enabled/disabled
@@ -226,7 +226,7 @@ struct mei_cl {
	struct mei_me_client *me_cl;
	const struct file *fp;
	u8 host_client_id;
	u8 mei_flow_ctrl_creds;
	u8 tx_flow_ctrl_creds;
	u8 rx_flow_ctrl_creds;
	u8 timer_count;
	u8 notify_en;