Commit e46f1874 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: use structured buffer for the write buffer

We can drop useless castings and use proper types.
We remove the casting in mei_hbm_hdr function
and add new function mei_hbm_stop_request_prepare that
utilize the new structure
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cd51ed64
...@@ -432,34 +432,33 @@ unsigned int mei_amthif_poll(struct mei_device *dev, ...@@ -432,34 +432,33 @@ unsigned int mei_amthif_poll(struct mei_device *dev,
int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list) struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)
{ {
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr mei_hdr;
struct mei_cl *cl = cb->cl; struct mei_cl *cl = cb->cl;
size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index; size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;
size_t msg_slots = mei_data2slots(len); size_t msg_slots = mei_data2slots(len);
mei_hdr = (struct mei_msg_hdr *)&dev->wr_msg_buf[0]; mei_hdr.host_addr = cl->host_client_id;
mei_hdr->host_addr = cl->host_client_id; mei_hdr.me_addr = cl->me_client_id;
mei_hdr->me_addr = cl->me_client_id; mei_hdr.reserved = 0;
mei_hdr->reserved = 0;
if (*slots >= msg_slots) { if (*slots >= msg_slots) {
mei_hdr->length = len; mei_hdr.length = len;
mei_hdr->msg_complete = 1; mei_hdr.msg_complete = 1;
/* Split the message only if we can write the whole host buffer */ /* Split the message only if we can write the whole host buffer */
} else if (*slots == dev->hbuf_depth) { } else if (*slots == dev->hbuf_depth) {
msg_slots = *slots; msg_slots = *slots;
len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr); len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
mei_hdr->length = len; mei_hdr.length = len;
mei_hdr->msg_complete = 0; mei_hdr.msg_complete = 0;
} else { } else {
/* wait for next time the host buffer is empty */ /* wait for next time the host buffer is empty */
return 0; return 0;
} }
dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr)); dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr));
*slots -= msg_slots; *slots -= msg_slots;
if (mei_write_message(dev, mei_hdr, if (mei_write_message(dev, &mei_hdr,
dev->iamthif_msg_buf + dev->iamthif_msg_buf_index)) { dev->iamthif_msg_buf + dev->iamthif_msg_buf_index)) {
dev->iamthif_state = MEI_IAMTHIF_IDLE; dev->iamthif_state = MEI_IAMTHIF_IDLE;
cl->status = -ENODEV; cl->status = -ENODEV;
...@@ -470,10 +469,10 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, ...@@ -470,10 +469,10 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
if (mei_flow_ctrl_reduce(dev, cl)) if (mei_flow_ctrl_reduce(dev, cl))
return -ENODEV; return -ENODEV;
dev->iamthif_msg_buf_index += mei_hdr->length; dev->iamthif_msg_buf_index += mei_hdr.length;
cl->status = 0; cl->status = 0;
if (mei_hdr->msg_complete) { if (mei_hdr.msg_complete) {
dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL; dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
dev->iamthif_flow_control_pending = true; dev->iamthif_flow_control_pending = true;
......
...@@ -67,21 +67,21 @@ bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf) ...@@ -67,21 +67,21 @@ bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
*/ */
void mei_host_start_message(struct mei_device *dev) void mei_host_start_message(struct mei_device *dev)
{ {
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
struct hbm_host_version_request *start_req; struct hbm_host_version_request *start_req;
const size_t len = sizeof(struct hbm_host_version_request); const size_t len = sizeof(struct hbm_host_version_request);
mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); mei_hbm_hdr(mei_hdr, len);
/* host start message */ /* host start message */
start_req = (struct hbm_host_version_request *)&dev->wr_msg_buf[1]; start_req = (struct hbm_host_version_request *)dev->wr_msg.data;
memset(start_req, 0, len); memset(start_req, 0, len);
start_req->hbm_cmd = HOST_START_REQ_CMD; start_req->hbm_cmd = HOST_START_REQ_CMD;
start_req->host_version.major_version = HBM_MAJOR_VERSION; start_req->host_version.major_version = HBM_MAJOR_VERSION;
start_req->host_version.minor_version = HBM_MINOR_VERSION; start_req->host_version.minor_version = HBM_MINOR_VERSION;
dev->recvd_msg = false; dev->recvd_msg = false;
if (mei_write_message(dev, mei_hdr, (unsigned char *)start_req)) { if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) {
dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n"); dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n");
dev->dev_state = MEI_DEV_RESETING; dev->dev_state = MEI_DEV_RESETING;
mei_reset(dev, 1); mei_reset(dev, 1);
...@@ -100,17 +100,17 @@ void mei_host_start_message(struct mei_device *dev) ...@@ -100,17 +100,17 @@ void mei_host_start_message(struct mei_device *dev)
*/ */
void mei_host_enum_clients_message(struct mei_device *dev) void mei_host_enum_clients_message(struct mei_device *dev)
{ {
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
struct hbm_host_enum_request *enum_req; struct hbm_host_enum_request *enum_req;
const size_t len = sizeof(struct hbm_host_enum_request); const size_t len = sizeof(struct hbm_host_enum_request);
/* enumerate clients */ /* enumerate clients */
mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); mei_hbm_hdr(mei_hdr, len);
enum_req = (struct hbm_host_enum_request *) &dev->wr_msg_buf[1]; enum_req = (struct hbm_host_enum_request *)dev->wr_msg.data;
memset(enum_req, 0, sizeof(struct hbm_host_enum_request)); memset(enum_req, 0, len);
enum_req->hbm_cmd = HOST_ENUM_REQ_CMD; enum_req->hbm_cmd = HOST_ENUM_REQ_CMD;
if (mei_write_message(dev, mei_hdr, (unsigned char *)enum_req)) { if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) {
dev->dev_state = MEI_DEV_RESETING; dev->dev_state = MEI_DEV_RESETING;
dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n");
mei_reset(dev, 1); mei_reset(dev, 1);
...@@ -124,7 +124,7 @@ void mei_host_enum_clients_message(struct mei_device *dev) ...@@ -124,7 +124,7 @@ void mei_host_enum_clients_message(struct mei_device *dev)
int mei_host_client_enumerate(struct mei_device *dev) int mei_host_client_enumerate(struct mei_device *dev)
{ {
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
struct hbm_props_request *prop_req; struct hbm_props_request *prop_req;
const size_t len = sizeof(struct hbm_props_request); const size_t len = sizeof(struct hbm_props_request);
unsigned long next_client_index; unsigned long next_client_index;
...@@ -146,8 +146,8 @@ int mei_host_client_enumerate(struct mei_device *dev) ...@@ -146,8 +146,8 @@ int mei_host_client_enumerate(struct mei_device *dev)
dev->me_clients[client_num].client_id = next_client_index; dev->me_clients[client_num].client_id = next_client_index;
dev->me_clients[client_num].mei_flow_ctrl_creds = 0; dev->me_clients[client_num].mei_flow_ctrl_creds = 0;
mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); mei_hbm_hdr(mei_hdr, len);
prop_req = (struct hbm_props_request *)&dev->wr_msg_buf[1]; prop_req = (struct hbm_props_request *)dev->wr_msg.data;
memset(prop_req, 0, sizeof(struct hbm_props_request)); memset(prop_req, 0, sizeof(struct hbm_props_request));
...@@ -155,7 +155,7 @@ int mei_host_client_enumerate(struct mei_device *dev) ...@@ -155,7 +155,7 @@ int mei_host_client_enumerate(struct mei_device *dev)
prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD; prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
prop_req->address = next_client_index; prop_req->address = next_client_index;
if (mei_write_message(dev, mei_hdr, (unsigned char *) prop_req)) { if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) {
dev->dev_state = MEI_DEV_RESETING; dev->dev_state = MEI_DEV_RESETING;
dev_err(&dev->pdev->dev, "Properties request command failed\n"); dev_err(&dev->pdev->dev, "Properties request command failed\n");
mei_reset(dev, 1); mei_reset(dev, 1);
...@@ -169,6 +169,27 @@ int mei_host_client_enumerate(struct mei_device *dev) ...@@ -169,6 +169,27 @@ int mei_host_client_enumerate(struct mei_device *dev)
return 0; return 0;
} }
/**
* mei_hbm_stop_req_prepare - perpare stop request message
*
* @dev - mei device
* @mei_hdr - mei message header
* @data - hbm message body buffer
*/
static void mei_hbm_stop_req_prepare(struct mei_device *dev,
struct mei_msg_hdr *mei_hdr, unsigned char *data)
{
struct hbm_host_stop_request *req =
(struct hbm_host_stop_request *)data;
const size_t len = sizeof(struct hbm_host_stop_request);
mei_hbm_hdr(mei_hdr, len);
memset(req, 0, len);
req->hbm_cmd = HOST_STOP_REQ_CMD;
req->reason = DRIVER_STOP_REQUEST;
}
/** /**
* mei_send_flow_control - sends flow control to fw. * mei_send_flow_control - sends flow control to fw.
* *
...@@ -179,17 +200,16 @@ int mei_host_client_enumerate(struct mei_device *dev) ...@@ -179,17 +200,16 @@ int mei_host_client_enumerate(struct mei_device *dev)
*/ */
int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl) int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl)
{ {
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
unsigned char *buf = (unsigned char *)&dev->wr_msg_buf[1];
const size_t len = sizeof(struct hbm_flow_control); const size_t len = sizeof(struct hbm_flow_control);
mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); mei_hbm_hdr(mei_hdr, len);
mei_hbm_cl_hdr(cl, MEI_FLOW_CONTROL_CMD, buf, len); mei_hbm_cl_hdr(cl, MEI_FLOW_CONTROL_CMD, dev->wr_msg.data, len);
dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n", dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n",
cl->host_client_id, cl->me_client_id); cl->host_client_id, cl->me_client_id);
return mei_write_message(dev, mei_hdr, buf); return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
} }
/** /**
...@@ -202,14 +222,13 @@ int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl) ...@@ -202,14 +222,13 @@ int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl)
*/ */
int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
{ {
struct mei_msg_hdr *hdr; struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
unsigned char *buf = (unsigned char *)&dev->wr_msg_buf[1];
const size_t len = sizeof(struct hbm_client_connect_request); const size_t len = sizeof(struct hbm_client_connect_request);
hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); mei_hbm_hdr(mei_hdr, len);
mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_REQ_CMD, buf, len); mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_REQ_CMD, dev->wr_msg.data, len);
return mei_write_message(dev, hdr, buf); return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
} }
/** /**
...@@ -222,14 +241,13 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) ...@@ -222,14 +241,13 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
*/ */
int mei_connect(struct mei_device *dev, struct mei_cl *cl) int mei_connect(struct mei_device *dev, struct mei_cl *cl)
{ {
struct mei_msg_hdr *hdr; struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
unsigned char *buf = (unsigned char *)&dev->wr_msg_buf[1];
const size_t len = sizeof(struct hbm_client_connect_request); const size_t len = sizeof(struct hbm_client_connect_request);
hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); mei_hbm_hdr(mei_hdr, len);
mei_hbm_cl_hdr(cl, CLIENT_CONNECT_REQ_CMD, buf, len); mei_hbm_cl_hdr(cl, CLIENT_CONNECT_REQ_CMD, dev->wr_msg.data, len);
return mei_write_message(dev, hdr, buf); return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
} }
/** /**
...@@ -257,9 +275,9 @@ static void mei_client_disconnect_request(struct mei_device *dev, ...@@ -257,9 +275,9 @@ static void mei_client_disconnect_request(struct mei_device *dev,
dev->iamthif_timer = 0; dev->iamthif_timer = 0;
/* prepare disconnect response */ /* prepare disconnect response */
(void)mei_hbm_hdr((u32 *)&dev->wr_ext_msg.hdr, len); mei_hbm_hdr(&dev->wr_ext_msg.hdr, len);
mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_RES_CMD, mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_RES_CMD,
&dev->wr_ext_msg.data, len); dev->wr_ext_msg.data, len);
break; break;
} }
} }
...@@ -284,7 +302,6 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) ...@@ -284,7 +302,6 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
struct hbm_flow_control *flow_control; struct hbm_flow_control *flow_control;
struct hbm_props_response *props_res; struct hbm_props_response *props_res;
struct hbm_host_enum_response *enum_res; struct hbm_host_enum_response *enum_res;
struct hbm_host_stop_request *stop_req;
/* read the message to our buffer */ /* read the message to our buffer */
BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf)); BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
...@@ -294,34 +311,27 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) ...@@ -294,34 +311,27 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
switch (mei_msg->hbm_cmd) { switch (mei_msg->hbm_cmd) {
case HOST_START_RES_CMD: case HOST_START_RES_CMD:
version_res = (struct hbm_host_version_response *)mei_msg; version_res = (struct hbm_host_version_response *)mei_msg;
if (version_res->host_version_supported) { if (!version_res->host_version_supported) {
dev->version.major_version = HBM_MAJOR_VERSION;
dev->version.minor_version = HBM_MINOR_VERSION;
if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
dev->init_clients_state == MEI_START_MESSAGE) {
dev->init_clients_timer = 0;
mei_host_enum_clients_message(dev);
} else {
dev->recvd_msg = false;
dev_dbg(&dev->pdev->dev, "IMEI reset due to received host start response bus message.\n");
mei_reset(dev, 1);
return;
}
} else {
u32 *buf = dev->wr_msg_buf;
const size_t len = sizeof(struct hbm_host_stop_request);
dev->version = version_res->me_max_version; dev->version = version_res->me_max_version;
dev_dbg(&dev->pdev->dev, "version mismatch.\n");
/* send stop message */ mei_hbm_stop_req_prepare(dev, &dev->wr_msg.hdr,
hdr = mei_hbm_hdr(&buf[0], len); dev->wr_msg.data);
stop_req = (struct hbm_host_stop_request *)&buf[1]; mei_write_message(dev, &dev->wr_msg.hdr,
memset(stop_req, 0, len); dev->wr_msg.data);
stop_req->hbm_cmd = HOST_STOP_REQ_CMD; return;
stop_req->reason = DRIVER_STOP_REQUEST; }
mei_write_message(dev, hdr, (unsigned char *)stop_req); dev->version.major_version = HBM_MAJOR_VERSION;
dev_dbg(&dev->pdev->dev, "version mismatch.\n"); dev->version.minor_version = HBM_MINOR_VERSION;
if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
dev->init_clients_state == MEI_START_MESSAGE) {
dev->init_clients_timer = 0;
mei_host_enum_clients_message(dev);
} else {
dev->recvd_msg = false;
dev_dbg(&dev->pdev->dev, "reset due to received hbm: host start\n");
mei_reset(dev, 1);
return; return;
} }
...@@ -417,18 +427,10 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) ...@@ -417,18 +427,10 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
break; break;
case ME_STOP_REQ_CMD: case ME_STOP_REQ_CMD:
{
/* prepare stop request: sent in next interrupt event */
const size_t len = sizeof(struct hbm_host_stop_request); mei_hbm_stop_req_prepare(dev, &dev->wr_ext_msg.hdr,
dev->wr_ext_msg.data);
hdr = mei_hbm_hdr((u32 *)&dev->wr_ext_msg.hdr, len);
stop_req = (struct hbm_host_stop_request *)&dev->wr_ext_msg.data;
memset(stop_req, 0, len);
stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
stop_req->reason = DRIVER_STOP_REQUEST;
break; break;
}
default: default:
BUG(); BUG();
break; break;
......
...@@ -469,25 +469,24 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots, ...@@ -469,25 +469,24 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots, static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list) struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)
{ {
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr mei_hdr;
struct mei_cl *cl = cb->cl; struct mei_cl *cl = cb->cl;
size_t len = cb->request_buffer.size - cb->buf_idx; size_t len = cb->request_buffer.size - cb->buf_idx;
size_t msg_slots = mei_data2slots(len); size_t msg_slots = mei_data2slots(len);
mei_hdr = (struct mei_msg_hdr *)&dev->wr_msg_buf[0]; mei_hdr.host_addr = cl->host_client_id;
mei_hdr->host_addr = cl->host_client_id; mei_hdr.me_addr = cl->me_client_id;
mei_hdr->me_addr = cl->me_client_id; mei_hdr.reserved = 0;
mei_hdr->reserved = 0;
if (*slots >= msg_slots) { if (*slots >= msg_slots) {
mei_hdr->length = len; mei_hdr.length = len;
mei_hdr->msg_complete = 1; mei_hdr.msg_complete = 1;
/* Split the message only if we can write the whole host buffer */ /* Split the message only if we can write the whole host buffer */
} else if (*slots == dev->hbuf_depth) { } else if (*slots == dev->hbuf_depth) {
msg_slots = *slots; msg_slots = *slots;
len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr); len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
mei_hdr->length = len; mei_hdr.length = len;
mei_hdr->msg_complete = 0; mei_hdr.msg_complete = 0;
} else { } else {
/* wait for next time the host buffer is empty */ /* wait for next time the host buffer is empty */
return 0; return 0;
...@@ -495,10 +494,10 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots, ...@@ -495,10 +494,10 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
dev_dbg(&dev->pdev->dev, "buf: size = %d idx = %lu\n", dev_dbg(&dev->pdev->dev, "buf: size = %d idx = %lu\n",
cb->request_buffer.size, cb->buf_idx); cb->request_buffer.size, cb->buf_idx);
dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr)); dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr));
*slots -= msg_slots; *slots -= msg_slots;
if (mei_write_message(dev, mei_hdr, if (mei_write_message(dev, &mei_hdr,
cb->request_buffer.data + cb->buf_idx)) { cb->request_buffer.data + cb->buf_idx)) {
cl->status = -ENODEV; cl->status = -ENODEV;
list_move_tail(&cb->list, &cmpl_list->list); list_move_tail(&cb->list, &cmpl_list->list);
...@@ -509,8 +508,8 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots, ...@@ -509,8 +508,8 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
return -ENODEV; return -ENODEV;
cl->status = 0; cl->status = 0;
cb->buf_idx += mei_hdr->length; cb->buf_idx += mei_hdr.length;
if (mei_hdr->msg_complete) if (mei_hdr.msg_complete)
list_move_tail(&cb->list, &dev->write_waiting_list.list); list_move_tail(&cb->list, &dev->write_waiting_list.list);
return 0; return 0;
......
...@@ -265,7 +265,13 @@ struct mei_device { ...@@ -265,7 +265,13 @@ struct mei_device {
unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */ unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */
u32 rd_msg_hdr; u32 rd_msg_hdr;
u32 wr_msg_buf[128]; /* used for control messages */
/* used for control messages */
struct {
struct mei_msg_hdr hdr;
unsigned char data[128];
} wr_msg;
struct { struct {
struct mei_msg_hdr hdr; struct mei_msg_hdr hdr;
unsigned char data[4]; /* All HBM messages are 4 bytes */ unsigned char data[4]; /* All HBM messages are 4 bytes */
...@@ -459,15 +465,13 @@ void mei_disable_interrupts(struct mei_device *dev); ...@@ -459,15 +465,13 @@ void mei_disable_interrupts(struct mei_device *dev);
void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr); void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr);
static inline struct mei_msg_hdr *mei_hbm_hdr(u32 *buf, size_t length) static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)
{ {
struct mei_msg_hdr *hdr = (struct mei_msg_hdr *)buf;
hdr->host_addr = 0; hdr->host_addr = 0;
hdr->me_addr = 0; hdr->me_addr = 0;
hdr->length = length; hdr->length = length;
hdr->msg_complete = 1; hdr->msg_complete = 1;
hdr->reserved = 0; hdr->reserved = 0;
return hdr;
} }
#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d" #define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d"
......
...@@ -101,22 +101,21 @@ int mei_wd_host_init(struct mei_device *dev) ...@@ -101,22 +101,21 @@ int mei_wd_host_init(struct mei_device *dev)
*/ */
int mei_wd_send(struct mei_device *dev) int mei_wd_send(struct mei_device *dev)
{ {
struct mei_msg_hdr *hdr; struct mei_msg_hdr hdr;
hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; hdr.host_addr = dev->wd_cl.host_client_id;
hdr->host_addr = dev->wd_cl.host_client_id; hdr.me_addr = dev->wd_cl.me_client_id;
hdr->me_addr = dev->wd_cl.me_client_id; hdr.msg_complete = 1;
hdr->msg_complete = 1; hdr.reserved = 0;
hdr->reserved = 0;
if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE)) if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE))
hdr->length = MEI_WD_START_MSG_SIZE; hdr.length = MEI_WD_START_MSG_SIZE;
else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE)) else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE))
hdr->length = MEI_WD_STOP_MSG_SIZE; hdr.length = MEI_WD_STOP_MSG_SIZE;
else else
return -EINVAL; return -EINVAL;
return mei_write_message(dev, hdr, dev->wd_data); return mei_write_message(dev, &hdr, dev->wd_data);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment