mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-17 18:36:00 +00:00
Merge branch 'for-6.8/intel-ish' into for-linus
- power management improvement for EHL OOB wakeup in intel-ish (Kai-Heng Feng) - generic intel-ish code cleanups (Even Xu)
This commit is contained in:
commit
f60c35260e
@ -119,50 +119,6 @@ static inline bool ish_should_leave_d0i3(struct pci_dev *pdev)
|
||||
return !pm_resume_via_firmware() || pdev->device == CHV_DEVICE_ID;
|
||||
}
|
||||
|
||||
static int enable_gpe(struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_ACPI
|
||||
acpi_status acpi_sts;
|
||||
struct acpi_device *adev;
|
||||
struct acpi_device_wakeup *wakeup;
|
||||
|
||||
adev = ACPI_COMPANION(dev);
|
||||
if (!adev) {
|
||||
dev_err(dev, "get acpi handle failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
wakeup = &adev->wakeup;
|
||||
|
||||
/*
|
||||
* Call acpi_disable_gpe(), so that reference count
|
||||
* gpe_event_info->runtime_count doesn't overflow.
|
||||
* When gpe_event_info->runtime_count = 0, the call
|
||||
* to acpi_disable_gpe() simply return.
|
||||
*/
|
||||
acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number);
|
||||
|
||||
acpi_sts = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number);
|
||||
if (ACPI_FAILURE(acpi_sts)) {
|
||||
dev_err(dev, "enable ose_gpe failed\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -ENODEV;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void enable_pme_wake(struct pci_dev *pdev)
|
||||
{
|
||||
if ((pci_pme_capable(pdev, PCI_D0) ||
|
||||
pci_pme_capable(pdev, PCI_D3hot) ||
|
||||
pci_pme_capable(pdev, PCI_D3cold)) && !enable_gpe(&pdev->dev)) {
|
||||
pci_pme_active(pdev, true);
|
||||
dev_dbg(&pdev->dev, "ish ipc driver pme wake enabled\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ish_probe() - PCI driver probe callback
|
||||
* @pdev: pci device
|
||||
@ -233,7 +189,7 @@ static int ish_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
||||
/* Enable PME for EHL */
|
||||
if (pdev->device == EHL_Ax_DEVICE_ID)
|
||||
enable_pme_wake(pdev);
|
||||
device_init_wakeup(dev, true);
|
||||
|
||||
ret = ish_init(ishtp);
|
||||
if (ret)
|
||||
@ -256,6 +212,19 @@ static void ish_remove(struct pci_dev *pdev)
|
||||
ish_device_disable(ishtp_dev);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ish_shutdown() - PCI driver shutdown callback
|
||||
* @pdev: pci device
|
||||
*
|
||||
* This function sets up wakeup for S5
|
||||
*/
|
||||
static void ish_shutdown(struct pci_dev *pdev)
|
||||
{
|
||||
if (pdev->device == EHL_Ax_DEVICE_ID)
|
||||
pci_prepare_to_sleep(pdev);
|
||||
}
|
||||
|
||||
static struct device __maybe_unused *ish_resume_device;
|
||||
|
||||
/* 50ms to get resume response */
|
||||
@ -378,13 +347,6 @@ static int __maybe_unused ish_resume(struct device *device)
|
||||
struct pci_dev *pdev = to_pci_dev(device);
|
||||
struct ishtp_device *dev = pci_get_drvdata(pdev);
|
||||
|
||||
/* add this to finish power flow for EHL */
|
||||
if (dev->pdev->device == EHL_Ax_DEVICE_ID) {
|
||||
pci_set_power_state(pdev, PCI_D0);
|
||||
enable_pme_wake(pdev);
|
||||
dev_dbg(dev->devc, "set power state to D0 for ehl\n");
|
||||
}
|
||||
|
||||
ish_resume_device = device;
|
||||
dev->resume_flag = 1;
|
||||
|
||||
@ -400,6 +362,7 @@ static struct pci_driver ish_driver = {
|
||||
.id_table = ish_pci_tbl,
|
||||
.probe = ish_probe,
|
||||
.remove = ish_remove,
|
||||
.shutdown = ish_shutdown,
|
||||
.driver.pm = &ish_pm_ops,
|
||||
};
|
||||
|
||||
|
@ -840,43 +840,22 @@ static void load_fw_from_host_handler(struct work_struct *work)
|
||||
*
|
||||
* Return: 0 for success, negative error code for failure
|
||||
*/
|
||||
static int loader_init(struct ishtp_cl *loader_ishtp_cl, int reset)
|
||||
static int loader_init(struct ishtp_cl *loader_ishtp_cl, bool reset)
|
||||
{
|
||||
int rv;
|
||||
struct ishtp_fw_client *fw_client;
|
||||
struct ishtp_cl_data *client_data =
|
||||
ishtp_get_client_data(loader_ishtp_cl);
|
||||
|
||||
dev_dbg(cl_data_to_dev(client_data), "reset flag: %d\n", reset);
|
||||
|
||||
rv = ishtp_cl_link(loader_ishtp_cl);
|
||||
if (rv < 0) {
|
||||
dev_err(cl_data_to_dev(client_data), "ishtp_cl_link failed\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Connect to firmware client */
|
||||
ishtp_set_tx_ring_size(loader_ishtp_cl, LOADER_CL_TX_RING_SIZE);
|
||||
ishtp_set_rx_ring_size(loader_ishtp_cl, LOADER_CL_RX_RING_SIZE);
|
||||
|
||||
fw_client =
|
||||
ishtp_fw_cl_get_client(ishtp_get_ishtp_device(loader_ishtp_cl),
|
||||
&loader_ishtp_id_table[0].guid);
|
||||
if (!fw_client) {
|
||||
dev_err(cl_data_to_dev(client_data),
|
||||
"ISH client uuid not found\n");
|
||||
rv = -ENOENT;
|
||||
goto err_cl_unlink;
|
||||
}
|
||||
|
||||
ishtp_cl_set_fw_client_id(loader_ishtp_cl,
|
||||
ishtp_get_fw_client_id(fw_client));
|
||||
ishtp_set_connection_state(loader_ishtp_cl, ISHTP_CL_CONNECTING);
|
||||
|
||||
rv = ishtp_cl_connect(loader_ishtp_cl);
|
||||
rv = ishtp_cl_establish_connection(loader_ishtp_cl,
|
||||
&loader_ishtp_id_table[0].guid,
|
||||
LOADER_CL_TX_RING_SIZE,
|
||||
LOADER_CL_RX_RING_SIZE,
|
||||
reset);
|
||||
if (rv < 0) {
|
||||
dev_err(cl_data_to_dev(client_data), "Client connect fail\n");
|
||||
goto err_cl_unlink;
|
||||
goto err_cl_disconnect;
|
||||
}
|
||||
|
||||
dev_dbg(cl_data_to_dev(client_data), "Client connected\n");
|
||||
@ -885,17 +864,14 @@ static int loader_init(struct ishtp_cl *loader_ishtp_cl, int reset)
|
||||
|
||||
return 0;
|
||||
|
||||
err_cl_unlink:
|
||||
ishtp_cl_unlink(loader_ishtp_cl);
|
||||
err_cl_disconnect:
|
||||
ishtp_cl_destroy_connection(loader_ishtp_cl, reset);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void loader_deinit(struct ishtp_cl *loader_ishtp_cl)
|
||||
{
|
||||
ishtp_set_connection_state(loader_ishtp_cl, ISHTP_CL_DISCONNECTING);
|
||||
ishtp_cl_disconnect(loader_ishtp_cl);
|
||||
ishtp_cl_unlink(loader_ishtp_cl);
|
||||
ishtp_cl_flush_queues(loader_ishtp_cl);
|
||||
ishtp_cl_destroy_connection(loader_ishtp_cl, false);
|
||||
|
||||
/* Disband and free all Tx and Rx client-level rings */
|
||||
ishtp_cl_free(loader_ishtp_cl);
|
||||
@ -914,19 +890,7 @@ static void reset_handler(struct work_struct *work)
|
||||
loader_ishtp_cl = client_data->loader_ishtp_cl;
|
||||
cl_device = client_data->cl_device;
|
||||
|
||||
/* Unlink, flush queues & start again */
|
||||
ishtp_cl_unlink(loader_ishtp_cl);
|
||||
ishtp_cl_flush_queues(loader_ishtp_cl);
|
||||
ishtp_cl_free(loader_ishtp_cl);
|
||||
|
||||
loader_ishtp_cl = ishtp_cl_allocate(cl_device);
|
||||
if (!loader_ishtp_cl)
|
||||
return;
|
||||
|
||||
ishtp_set_drvdata(cl_device, loader_ishtp_cl);
|
||||
ishtp_set_client_data(loader_ishtp_cl, client_data);
|
||||
client_data->loader_ishtp_cl = loader_ishtp_cl;
|
||||
client_data->cl_device = cl_device;
|
||||
ishtp_cl_destroy_connection(loader_ishtp_cl, true);
|
||||
|
||||
rv = loader_init(loader_ishtp_cl, 1);
|
||||
if (rv < 0) {
|
||||
@ -974,7 +938,7 @@ static int loader_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
|
||||
INIT_WORK(&client_data->work_fw_load,
|
||||
load_fw_from_host_handler);
|
||||
|
||||
rv = loader_init(loader_ishtp_cl, 0);
|
||||
rv = loader_init(loader_ishtp_cl, false);
|
||||
if (rv < 0) {
|
||||
ishtp_cl_free(loader_ishtp_cl);
|
||||
return rv;
|
||||
|
@ -639,47 +639,26 @@ static int ishtp_get_report_descriptor(struct ishtp_cl *hid_ishtp_cl,
|
||||
*
|
||||
* Return: 0 on success, non zero on error
|
||||
*/
|
||||
static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset)
|
||||
static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, bool reset)
|
||||
{
|
||||
struct ishtp_device *dev;
|
||||
struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl);
|
||||
struct ishtp_fw_client *fw_client;
|
||||
int i;
|
||||
int rv;
|
||||
|
||||
dev_dbg(cl_data_to_dev(client_data), "%s\n", __func__);
|
||||
hid_ishtp_trace(client_data, "%s reset flag: %d\n", __func__, reset);
|
||||
|
||||
rv = ishtp_cl_link(hid_ishtp_cl);
|
||||
if (rv) {
|
||||
dev_err(cl_data_to_dev(client_data),
|
||||
"ishtp_cl_link failed\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
client_data->init_done = 0;
|
||||
|
||||
dev = ishtp_get_ishtp_device(hid_ishtp_cl);
|
||||
|
||||
/* Connect to FW client */
|
||||
ishtp_set_tx_ring_size(hid_ishtp_cl, HID_CL_TX_RING_SIZE);
|
||||
ishtp_set_rx_ring_size(hid_ishtp_cl, HID_CL_RX_RING_SIZE);
|
||||
|
||||
fw_client = ishtp_fw_cl_get_client(dev, &hid_ishtp_id_table[0].guid);
|
||||
if (!fw_client) {
|
||||
dev_err(cl_data_to_dev(client_data),
|
||||
"ish client uuid not found\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
ishtp_cl_set_fw_client_id(hid_ishtp_cl,
|
||||
ishtp_get_fw_client_id(fw_client));
|
||||
ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_CONNECTING);
|
||||
|
||||
rv = ishtp_cl_connect(hid_ishtp_cl);
|
||||
rv = ishtp_cl_establish_connection(hid_ishtp_cl,
|
||||
&hid_ishtp_id_table[0].guid,
|
||||
HID_CL_TX_RING_SIZE,
|
||||
HID_CL_RX_RING_SIZE,
|
||||
reset);
|
||||
if (rv) {
|
||||
dev_err(cl_data_to_dev(client_data),
|
||||
"client connect fail\n");
|
||||
goto err_cl_unlink;
|
||||
goto err_cl_disconnect;
|
||||
}
|
||||
|
||||
hid_ishtp_trace(client_data, "%s client connected\n", __func__);
|
||||
@ -723,10 +702,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset)
|
||||
return 0;
|
||||
|
||||
err_cl_disconnect:
|
||||
ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_DISCONNECTING);
|
||||
ishtp_cl_disconnect(hid_ishtp_cl);
|
||||
err_cl_unlink:
|
||||
ishtp_cl_unlink(hid_ishtp_cl);
|
||||
ishtp_cl_destroy_connection(hid_ishtp_cl, reset);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -738,8 +714,7 @@ err_cl_unlink:
|
||||
*/
|
||||
static void hid_ishtp_cl_deinit(struct ishtp_cl *hid_ishtp_cl)
|
||||
{
|
||||
ishtp_cl_unlink(hid_ishtp_cl);
|
||||
ishtp_cl_flush_queues(hid_ishtp_cl);
|
||||
ishtp_cl_destroy_connection(hid_ishtp_cl, false);
|
||||
|
||||
/* disband and free all Tx and Rx client-level rings */
|
||||
ishtp_cl_free(hid_ishtp_cl);
|
||||
@ -749,33 +724,23 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work)
|
||||
{
|
||||
struct ishtp_cl_data *client_data;
|
||||
struct ishtp_cl *hid_ishtp_cl;
|
||||
struct ishtp_cl_device *cl_device;
|
||||
int retry;
|
||||
int rv;
|
||||
|
||||
client_data = container_of(work, struct ishtp_cl_data, work);
|
||||
|
||||
hid_ishtp_cl = client_data->hid_ishtp_cl;
|
||||
cl_device = client_data->cl_device;
|
||||
|
||||
hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__,
|
||||
hid_ishtp_cl);
|
||||
dev_dbg(ishtp_device(client_data->cl_device), "%s\n", __func__);
|
||||
|
||||
hid_ishtp_cl_deinit(hid_ishtp_cl);
|
||||
|
||||
hid_ishtp_cl = ishtp_cl_allocate(cl_device);
|
||||
if (!hid_ishtp_cl)
|
||||
return;
|
||||
|
||||
ishtp_set_drvdata(cl_device, hid_ishtp_cl);
|
||||
ishtp_set_client_data(hid_ishtp_cl, client_data);
|
||||
client_data->hid_ishtp_cl = hid_ishtp_cl;
|
||||
ishtp_cl_destroy_connection(hid_ishtp_cl, true);
|
||||
|
||||
client_data->num_hid_devices = 0;
|
||||
|
||||
for (retry = 0; retry < 3; ++retry) {
|
||||
rv = hid_ishtp_cl_init(hid_ishtp_cl, 1);
|
||||
rv = hid_ishtp_cl_init(hid_ishtp_cl, true);
|
||||
if (!rv)
|
||||
break;
|
||||
dev_err(cl_data_to_dev(client_data), "Retry reset init\n");
|
||||
@ -841,7 +806,7 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
|
||||
|
||||
ishtp_hid_print_trace = ishtp_trace_callback(cl_device);
|
||||
|
||||
rv = hid_ishtp_cl_init(hid_ishtp_cl, 0);
|
||||
rv = hid_ishtp_cl_init(hid_ishtp_cl, false);
|
||||
if (rv) {
|
||||
ishtp_cl_free(hid_ishtp_cl);
|
||||
return rv;
|
||||
@ -868,11 +833,9 @@ static void hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
|
||||
hid_ishtp_cl);
|
||||
|
||||
dev_dbg(ishtp_device(cl_device), "%s\n", __func__);
|
||||
ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_DISCONNECTING);
|
||||
ishtp_cl_disconnect(hid_ishtp_cl);
|
||||
hid_ishtp_cl_deinit(hid_ishtp_cl);
|
||||
ishtp_put_device(cl_device);
|
||||
ishtp_hid_remove(client_data);
|
||||
hid_ishtp_cl_deinit(hid_ishtp_cl);
|
||||
|
||||
hid_ishtp_cl = NULL;
|
||||
|
||||
|
@ -339,16 +339,17 @@ static bool ishtp_cl_is_other_connecting(struct ishtp_cl *cl)
|
||||
}
|
||||
|
||||
/**
|
||||
* ishtp_cl_connect() - Send connect request to firmware
|
||||
* ishtp_cl_connect_to_fw() - Send connect request to firmware
|
||||
* @cl: client device instance
|
||||
*
|
||||
* Send a connect request for a client to firmware. If successful it will
|
||||
* RX and TX ring buffers
|
||||
* Send a connect request to the firmware and wait for firmware response.
|
||||
* If there is successful connection response from the firmware, change
|
||||
* client state to ISHTP_CL_CONNECTED, and bind client to related
|
||||
* firmware client_id.
|
||||
*
|
||||
* Return: 0 if successful connect response from the firmware and able
|
||||
* to bind and allocate ring buffers or error code on failure
|
||||
* Return: 0 for success and error code on failure
|
||||
*/
|
||||
int ishtp_cl_connect(struct ishtp_cl *cl)
|
||||
static int ishtp_cl_connect_to_fw(struct ishtp_cl *cl)
|
||||
{
|
||||
struct ishtp_device *dev;
|
||||
int rets;
|
||||
@ -358,8 +359,6 @@ int ishtp_cl_connect(struct ishtp_cl *cl)
|
||||
|
||||
dev = cl->dev;
|
||||
|
||||
dev->print_log(dev, "%s() current_state = %d\n", __func__, cl->state);
|
||||
|
||||
if (ishtp_cl_is_other_connecting(cl)) {
|
||||
dev->print_log(dev, "%s() Busy\n", __func__);
|
||||
return -EBUSY;
|
||||
@ -405,6 +404,38 @@ int ishtp_cl_connect(struct ishtp_cl *cl)
|
||||
return rets;
|
||||
}
|
||||
|
||||
return rets;
|
||||
}
|
||||
|
||||
/**
|
||||
* ishtp_cl_connect() - Build connection with firmware
|
||||
* @cl: client device instance
|
||||
*
|
||||
* Call ishtp_cl_connect_to_fw() to connect and bind to firmware. If successful,
|
||||
* allocate RX and TX ring buffers, and start flow control with firmware to
|
||||
* start communication.
|
||||
*
|
||||
* Return: 0 if there is successful connection to the firmware, allocate
|
||||
* ring buffers.
|
||||
*/
|
||||
int ishtp_cl_connect(struct ishtp_cl *cl)
|
||||
{
|
||||
struct ishtp_device *dev;
|
||||
int rets;
|
||||
|
||||
if (!cl || !cl->dev)
|
||||
return -ENODEV;
|
||||
|
||||
dev = cl->dev;
|
||||
|
||||
dev->print_log(dev, "%s() current_state = %d\n", __func__, cl->state);
|
||||
|
||||
rets = ishtp_cl_connect_to_fw(cl);
|
||||
if (rets) {
|
||||
dev->print_log(dev, "%s() Connect to fw failed\n", __func__);
|
||||
return rets;
|
||||
}
|
||||
|
||||
rets = ishtp_cl_alloc_rx_ring(cl);
|
||||
if (rets) {
|
||||
dev->print_log(dev, "%s() Alloc RX ring failed\n", __func__);
|
||||
@ -422,15 +453,147 @@ int ishtp_cl_connect(struct ishtp_cl *cl)
|
||||
return rets;
|
||||
}
|
||||
|
||||
/* Upon successful connection and allocation, emit flow-control */
|
||||
/*
|
||||
* Upon successful connection and allocation, start flow-control.
|
||||
*/
|
||||
rets = ishtp_cl_read_start(cl);
|
||||
|
||||
dev->print_log(dev, "%s() successful\n", __func__);
|
||||
|
||||
return rets;
|
||||
}
|
||||
EXPORT_SYMBOL(ishtp_cl_connect);
|
||||
|
||||
/**
|
||||
* ishtp_cl_establish_connection() - Establish connection with the firmware
|
||||
* @cl: client device instance
|
||||
* @uuid: uuid of the client to search
|
||||
* @tx_size: TX ring buffer size
|
||||
* @rx_size: RX ring buffer size
|
||||
* @reset: true if called for reset connection, otherwise for first connection
|
||||
*
|
||||
* This is a helper function for client driver to build connection with firmware.
|
||||
* If it's first time connecting to the firmware, set reset to false, this
|
||||
* function will link client to bus, find client id and send connect request to
|
||||
* the firmware.
|
||||
*
|
||||
* If it's called for reset handler where client lost connection after
|
||||
* firmware reset, set reset to true, this function will reinit client state and
|
||||
* establish connection again. In this case, this function reuses current client
|
||||
* structure and ring buffers to avoid allocation failure and memory fragments.
|
||||
*
|
||||
* Return: 0 for successful connection with the firmware,
|
||||
* or error code on failure
|
||||
*/
|
||||
int ishtp_cl_establish_connection(struct ishtp_cl *cl, const guid_t *uuid,
|
||||
int tx_size, int rx_size, bool reset)
|
||||
{
|
||||
struct ishtp_device *dev;
|
||||
struct ishtp_fw_client *fw_client;
|
||||
int rets;
|
||||
|
||||
if (!cl || !cl->dev)
|
||||
return -ENODEV;
|
||||
|
||||
dev = cl->dev;
|
||||
|
||||
ishtp_set_connection_state(cl, ISHTP_CL_INITIALIZING);
|
||||
|
||||
/* reinit ishtp_cl structure if call for reset */
|
||||
if (reset) {
|
||||
cl->host_client_id = 0;
|
||||
cl->fw_client_id = 0;
|
||||
cl->ishtp_flow_ctrl_creds = 0;
|
||||
cl->out_flow_ctrl_creds = 0;
|
||||
|
||||
cl->last_tx_path = CL_TX_PATH_IPC;
|
||||
cl->last_dma_acked = 1;
|
||||
cl->last_dma_addr = NULL;
|
||||
cl->last_ipc_acked = 1;
|
||||
|
||||
cl->sending = 0;
|
||||
cl->err_send_msg = 0;
|
||||
cl->err_send_fc = 0;
|
||||
|
||||
cl->send_msg_cnt_ipc = 0;
|
||||
cl->send_msg_cnt_dma = 0;
|
||||
cl->recv_msg_cnt_ipc = 0;
|
||||
cl->recv_msg_cnt_dma = 0;
|
||||
cl->recv_msg_num_frags = 0;
|
||||
cl->ishtp_flow_ctrl_cnt = 0;
|
||||
cl->out_flow_ctrl_cnt = 0;
|
||||
}
|
||||
|
||||
/* link to bus */
|
||||
rets = ishtp_cl_link(cl);
|
||||
if (rets) {
|
||||
dev->print_log(dev, "%s() ishtp_cl_link failed\n", __func__);
|
||||
return rets;
|
||||
}
|
||||
|
||||
/* find firmware client */
|
||||
fw_client = ishtp_fw_cl_get_client(dev, uuid);
|
||||
if (!fw_client) {
|
||||
dev->print_log(dev,
|
||||
"%s() ish client uuid not found\n", __func__);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ishtp_set_tx_ring_size(cl, tx_size);
|
||||
ishtp_set_rx_ring_size(cl, rx_size);
|
||||
|
||||
ishtp_cl_set_fw_client_id(cl, ishtp_get_fw_client_id(fw_client));
|
||||
|
||||
ishtp_set_connection_state(cl, ISHTP_CL_CONNECTING);
|
||||
|
||||
/*
|
||||
* For reset case, not allocate tx/rx ring buffer which are already
|
||||
* done in ishtp_cl_connect() during first connection.
|
||||
*/
|
||||
if (reset) {
|
||||
rets = ishtp_cl_connect_to_fw(cl);
|
||||
if (!rets)
|
||||
rets = ishtp_cl_read_start(cl);
|
||||
else
|
||||
dev->print_log(dev,
|
||||
"%s() connect to fw failed\n", __func__);
|
||||
} else {
|
||||
rets = ishtp_cl_connect(cl);
|
||||
}
|
||||
|
||||
return rets;
|
||||
}
|
||||
EXPORT_SYMBOL(ishtp_cl_establish_connection);
|
||||
|
||||
/**
|
||||
* ishtp_cl_destroy_connection() - Disconnect with the firmware
|
||||
* @cl: client device instance
|
||||
* @reset: true if called for firmware reset, false for normal disconnection
|
||||
*
|
||||
* This is a helper function for client driver to disconnect with firmware,
|
||||
* unlink to bus and flush message queue.
|
||||
*/
|
||||
void ishtp_cl_destroy_connection(struct ishtp_cl *cl, bool reset)
|
||||
{
|
||||
if (!cl)
|
||||
return;
|
||||
|
||||
if (reset) {
|
||||
/*
|
||||
* For reset case, connection is already lost during fw reset.
|
||||
* Just set state to DISCONNECTED is enough.
|
||||
*/
|
||||
ishtp_set_connection_state(cl, ISHTP_CL_DISCONNECTED);
|
||||
} else {
|
||||
if (cl->state != ISHTP_CL_DISCONNECTED) {
|
||||
ishtp_set_connection_state(cl, ISHTP_CL_DISCONNECTING);
|
||||
ishtp_cl_disconnect(cl);
|
||||
}
|
||||
}
|
||||
|
||||
ishtp_cl_unlink(cl);
|
||||
ishtp_cl_flush_queues(cl);
|
||||
}
|
||||
EXPORT_SYMBOL(ishtp_cl_destroy_connection);
|
||||
|
||||
/**
|
||||
* ishtp_cl_read_start() - Prepare to read client message
|
||||
* @cl: client device instance
|
||||
|
@ -367,55 +367,33 @@ static void ish_event_cb(struct ishtp_cl_device *cl_device)
|
||||
/**
|
||||
* cros_ish_init() - Init function for ISHTP client
|
||||
* @cros_ish_cl: ISHTP client instance
|
||||
* @reset: true if called from reset handler
|
||||
*
|
||||
* This function complete the initializtion of the client.
|
||||
*
|
||||
* Return: 0 for success, negative error code for failure.
|
||||
*/
|
||||
static int cros_ish_init(struct ishtp_cl *cros_ish_cl)
|
||||
static int cros_ish_init(struct ishtp_cl *cros_ish_cl, bool reset)
|
||||
{
|
||||
int rv;
|
||||
struct ishtp_device *dev;
|
||||
struct ishtp_fw_client *fw_client;
|
||||
struct ishtp_cl_data *client_data = ishtp_get_client_data(cros_ish_cl);
|
||||
|
||||
rv = ishtp_cl_link(cros_ish_cl);
|
||||
if (rv) {
|
||||
dev_err(cl_data_to_dev(client_data),
|
||||
"ishtp_cl_link failed\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
dev = ishtp_get_ishtp_device(cros_ish_cl);
|
||||
|
||||
/* Connect to firmware client */
|
||||
ishtp_set_tx_ring_size(cros_ish_cl, CROS_ISH_CL_TX_RING_SIZE);
|
||||
ishtp_set_rx_ring_size(cros_ish_cl, CROS_ISH_CL_RX_RING_SIZE);
|
||||
|
||||
fw_client = ishtp_fw_cl_get_client(dev, &cros_ec_ishtp_id_table[0].guid);
|
||||
if (!fw_client) {
|
||||
dev_err(cl_data_to_dev(client_data),
|
||||
"ish client uuid not found\n");
|
||||
rv = -ENOENT;
|
||||
goto err_cl_unlink;
|
||||
}
|
||||
|
||||
ishtp_cl_set_fw_client_id(cros_ish_cl,
|
||||
ishtp_get_fw_client_id(fw_client));
|
||||
ishtp_set_connection_state(cros_ish_cl, ISHTP_CL_CONNECTING);
|
||||
|
||||
rv = ishtp_cl_connect(cros_ish_cl);
|
||||
rv = ishtp_cl_establish_connection(cros_ish_cl,
|
||||
&cros_ec_ishtp_id_table[0].guid,
|
||||
CROS_ISH_CL_TX_RING_SIZE,
|
||||
CROS_ISH_CL_RX_RING_SIZE,
|
||||
reset);
|
||||
if (rv) {
|
||||
dev_err(cl_data_to_dev(client_data),
|
||||
"client connect fail\n");
|
||||
goto err_cl_unlink;
|
||||
goto err_cl_disconnect;
|
||||
}
|
||||
|
||||
ishtp_register_event_cb(client_data->cl_device, ish_event_cb);
|
||||
return 0;
|
||||
|
||||
err_cl_unlink:
|
||||
ishtp_cl_unlink(cros_ish_cl);
|
||||
err_cl_disconnect:
|
||||
ishtp_cl_destroy_connection(cros_ish_cl, reset);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -427,10 +405,7 @@ err_cl_unlink:
|
||||
*/
|
||||
static void cros_ish_deinit(struct ishtp_cl *cros_ish_cl)
|
||||
{
|
||||
ishtp_set_connection_state(cros_ish_cl, ISHTP_CL_DISCONNECTING);
|
||||
ishtp_cl_disconnect(cros_ish_cl);
|
||||
ishtp_cl_unlink(cros_ish_cl);
|
||||
ishtp_cl_flush_queues(cros_ish_cl);
|
||||
ishtp_cl_destroy_connection(cros_ish_cl, false);
|
||||
|
||||
/* Disband and free all Tx and Rx client-level rings */
|
||||
ishtp_cl_free(cros_ish_cl);
|
||||
@ -592,7 +567,6 @@ static void reset_handler(struct work_struct *work)
|
||||
int rv;
|
||||
struct device *dev;
|
||||
struct ishtp_cl *cros_ish_cl;
|
||||
struct ishtp_cl_device *cl_device;
|
||||
struct ishtp_cl_data *client_data =
|
||||
container_of(work, struct ishtp_cl_data, work_ishtp_reset);
|
||||
|
||||
@ -600,26 +574,11 @@ static void reset_handler(struct work_struct *work)
|
||||
down_write(&init_lock);
|
||||
|
||||
cros_ish_cl = client_data->cros_ish_cl;
|
||||
cl_device = client_data->cl_device;
|
||||
|
||||
/* Unlink, flush queues & start again */
|
||||
ishtp_cl_unlink(cros_ish_cl);
|
||||
ishtp_cl_flush_queues(cros_ish_cl);
|
||||
ishtp_cl_free(cros_ish_cl);
|
||||
ishtp_cl_destroy_connection(cros_ish_cl, true);
|
||||
|
||||
cros_ish_cl = ishtp_cl_allocate(cl_device);
|
||||
if (!cros_ish_cl) {
|
||||
up_write(&init_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
ishtp_set_drvdata(cl_device, cros_ish_cl);
|
||||
ishtp_set_client_data(cros_ish_cl, client_data);
|
||||
client_data->cros_ish_cl = cros_ish_cl;
|
||||
|
||||
rv = cros_ish_init(cros_ish_cl);
|
||||
rv = cros_ish_init(cros_ish_cl, true);
|
||||
if (rv) {
|
||||
ishtp_cl_free(cros_ish_cl);
|
||||
dev_err(cl_data_to_dev(client_data), "Reset Failed\n");
|
||||
up_write(&init_lock);
|
||||
return;
|
||||
@ -672,7 +631,7 @@ static int cros_ec_ishtp_probe(struct ishtp_cl_device *cl_device)
|
||||
INIT_WORK(&client_data->work_ec_evt,
|
||||
ish_evt_handler);
|
||||
|
||||
rv = cros_ish_init(cros_ish_cl);
|
||||
rv = cros_ish_init(cros_ish_cl, false);
|
||||
if (rv)
|
||||
goto end_ishtp_cl_init_error;
|
||||
|
||||
@ -690,10 +649,7 @@ static int cros_ec_ishtp_probe(struct ishtp_cl_device *cl_device)
|
||||
return 0;
|
||||
|
||||
end_cros_ec_dev_init_error:
|
||||
ishtp_set_connection_state(cros_ish_cl, ISHTP_CL_DISCONNECTING);
|
||||
ishtp_cl_disconnect(cros_ish_cl);
|
||||
ishtp_cl_unlink(cros_ish_cl);
|
||||
ishtp_cl_flush_queues(cros_ish_cl);
|
||||
ishtp_cl_destroy_connection(cros_ish_cl, false);
|
||||
ishtp_put_device(cl_device);
|
||||
end_ishtp_cl_init_error:
|
||||
ishtp_cl_free(cros_ish_cl);
|
||||
|
@ -94,6 +94,9 @@ int ishtp_cl_link(struct ishtp_cl *cl);
|
||||
void ishtp_cl_unlink(struct ishtp_cl *cl);
|
||||
int ishtp_cl_disconnect(struct ishtp_cl *cl);
|
||||
int ishtp_cl_connect(struct ishtp_cl *cl);
|
||||
int ishtp_cl_establish_connection(struct ishtp_cl *cl, const guid_t *uuid,
|
||||
int tx_size, int rx_size, bool reset);
|
||||
void ishtp_cl_destroy_connection(struct ishtp_cl *cl, bool reset);
|
||||
int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length);
|
||||
int ishtp_cl_flush_queues(struct ishtp_cl *cl);
|
||||
int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb);
|
||||
|
Loading…
x
Reference in New Issue
Block a user