2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-22 12:14:01 +08:00

mei: hbm: setup dma ring

DMA ring is allocated upon HBM handshake and the ring parameters are set
via dedicated HBM_DMA_SETUP request command. The firmware will perform
its setup and respond with a status. On failure the DMA buffers are
released.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tomas Winkler 2018-11-22 13:11:37 +02:00 committed by Greg Kroah-Hartman
parent ce0925e8c2
commit c55bf542e9
2 changed files with 85 additions and 3 deletions

View File

@ -65,6 +65,7 @@ const char *mei_hbm_state_str(enum mei_hbm_state state)
MEI_HBM_STATE(IDLE);
MEI_HBM_STATE(STARTING);
MEI_HBM_STATE(STARTED);
MEI_HBM_STATE(DR_SETUP);
MEI_HBM_STATE(ENUM_CLIENTS);
MEI_HBM_STATE(CLIENT_PROPERTIES);
MEI_HBM_STATE(STOPPED);
@ -295,6 +296,46 @@ int mei_hbm_start_req(struct mei_device *dev)
return 0;
}
/**
* mei_hbm_dma_setup_req() - setup DMA request
* @dev: the device structure
*
* Return: 0 on success and < 0 on failure
*/
static int mei_hbm_dma_setup_req(struct mei_device *dev)
{
struct mei_msg_hdr mei_hdr;
struct hbm_dma_setup_request req;
const size_t len = sizeof(struct hbm_dma_setup_request);
unsigned int i;
int ret;
mei_hbm_hdr(&mei_hdr, len);
memset(&req, 0, len);
req.hbm_cmd = MEI_HBM_DMA_SETUP_REQ_CMD;
for (i = 0; i < DMA_DSCR_NUM; i++) {
phys_addr_t paddr;
paddr = dev->dr_dscr[i].daddr;
req.dma_dscr[i].addr_hi = upper_32_bits(paddr);
req.dma_dscr[i].addr_lo = lower_32_bits(paddr);
req.dma_dscr[i].size = dev->dr_dscr[i].size;
}
ret = mei_hbm_write_message(dev, &mei_hdr, &req);
if (ret) {
dev_err(dev->dev, "dma setup request write failed: ret = %d.\n",
ret);
return ret;
}
dev->hbm_state = MEI_HBM_DR_SETUP;
dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
mei_schedule_stall_timer(dev);
return 0;
}
/**
* mei_hbm_enum_clients_req - sends enumeration client request message.
*
@ -1044,6 +1085,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
struct hbm_host_version_response *version_res;
struct hbm_props_response *props_res;
struct hbm_host_enum_response *enum_res;
struct hbm_dma_setup_response *dma_setup_res;
struct hbm_add_client_request *add_cl_req;
int ret;
@ -1108,13 +1150,51 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
return -EPROTO;
}
if (mei_hbm_enum_clients_req(dev)) {
dev_err(dev->dev, "hbm: start: failed to send enumeration request\n");
if (dev->hbm_f_dr_supported) {
if (mei_dmam_ring_alloc(dev))
dev_info(dev->dev, "running w/o dma ring\n");
if (mei_dma_ring_is_allocated(dev)) {
if (mei_hbm_dma_setup_req(dev))
return -EIO;
}
wake_up(&dev->wait_hbm_start);
break;
}
}
dev->hbm_f_dr_supported = 0;
mei_dmam_ring_free(dev);
if (mei_hbm_enum_clients_req(dev))
return -EIO;
wake_up(&dev->wait_hbm_start);
break;
case MEI_HBM_DMA_SETUP_RES_CMD:
dev_dbg(dev->dev, "hbm: dma setup response: message received.\n");
dev->init_clients_timer = 0;
if (dev->hbm_state != MEI_HBM_DR_SETUP) {
dev_err(dev->dev, "hbm: dma setup response: state mismatch, [%d, %d]\n",
dev->dev_state, dev->hbm_state);
return -EPROTO;
}
dma_setup_res = (struct hbm_dma_setup_response *)mei_msg;
if (dma_setup_res->status) {
dev_info(dev->dev, "hbm: dma setup response: failure = %d %s\n",
dma_setup_res->status,
mei_hbm_status_str(dma_setup_res->status));
dev->hbm_f_dr_supported = 0;
mei_dmam_ring_free(dev);
}
if (mei_hbm_enum_clients_req(dev))
return -EIO;
break;
case CLIENT_CONNECT_RES_CMD:
dev_dbg(dev->dev, "hbm: client connect response: message received.\n");

View File

@ -26,6 +26,7 @@ struct mei_cl;
*
* @MEI_HBM_IDLE : protocol not started
* @MEI_HBM_STARTING : start request message was sent
* @MEI_HBM_DR_SETUP : dma ring setup request message was sent
* @MEI_HBM_ENUM_CLIENTS : enumeration request was sent
* @MEI_HBM_CLIENT_PROPERTIES : acquiring clients properties
* @MEI_HBM_STARTED : enumeration was completed
@ -34,6 +35,7 @@ struct mei_cl;
enum mei_hbm_state {
MEI_HBM_IDLE = 0,
MEI_HBM_STARTING,
MEI_HBM_DR_SETUP,
MEI_HBM_ENUM_CLIENTS,
MEI_HBM_CLIENT_PROPERTIES,
MEI_HBM_STARTED,