Skip to content

Commit f60c352

Browse files
author
Jiri Kosina
committed
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)
2 parents ff18ab5 + 0e63dd2 commit f60c352

File tree

6 files changed

+232
-220
lines changed

6 files changed

+232
-220
lines changed

drivers/hid/intel-ish-hid/ipc/pci-ish.c

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -119,50 +119,6 @@ static inline bool ish_should_leave_d0i3(struct pci_dev *pdev)
119119
return !pm_resume_via_firmware() || pdev->device == CHV_DEVICE_ID;
120120
}
121121

122-
static int enable_gpe(struct device *dev)
123-
{
124-
#ifdef CONFIG_ACPI
125-
acpi_status acpi_sts;
126-
struct acpi_device *adev;
127-
struct acpi_device_wakeup *wakeup;
128-
129-
adev = ACPI_COMPANION(dev);
130-
if (!adev) {
131-
dev_err(dev, "get acpi handle failed\n");
132-
return -ENODEV;
133-
}
134-
wakeup = &adev->wakeup;
135-
136-
/*
137-
* Call acpi_disable_gpe(), so that reference count
138-
* gpe_event_info->runtime_count doesn't overflow.
139-
* When gpe_event_info->runtime_count = 0, the call
140-
* to acpi_disable_gpe() simply return.
141-
*/
142-
acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number);
143-
144-
acpi_sts = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number);
145-
if (ACPI_FAILURE(acpi_sts)) {
146-
dev_err(dev, "enable ose_gpe failed\n");
147-
return -EIO;
148-
}
149-
150-
return 0;
151-
#else
152-
return -ENODEV;
153-
#endif
154-
}
155-
156-
static void enable_pme_wake(struct pci_dev *pdev)
157-
{
158-
if ((pci_pme_capable(pdev, PCI_D0) ||
159-
pci_pme_capable(pdev, PCI_D3hot) ||
160-
pci_pme_capable(pdev, PCI_D3cold)) && !enable_gpe(&pdev->dev)) {
161-
pci_pme_active(pdev, true);
162-
dev_dbg(&pdev->dev, "ish ipc driver pme wake enabled\n");
163-
}
164-
}
165-
166122
/**
167123
* ish_probe() - PCI driver probe callback
168124
* @pdev: pci device
@@ -233,7 +189,7 @@ static int ish_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
233189

234190
/* Enable PME for EHL */
235191
if (pdev->device == EHL_Ax_DEVICE_ID)
236-
enable_pme_wake(pdev);
192+
device_init_wakeup(dev, true);
237193

238194
ret = ish_init(ishtp);
239195
if (ret)
@@ -256,6 +212,19 @@ static void ish_remove(struct pci_dev *pdev)
256212
ish_device_disable(ishtp_dev);
257213
}
258214

215+
216+
/**
217+
* ish_shutdown() - PCI driver shutdown callback
218+
* @pdev: pci device
219+
*
220+
* This function sets up wakeup for S5
221+
*/
222+
static void ish_shutdown(struct pci_dev *pdev)
223+
{
224+
if (pdev->device == EHL_Ax_DEVICE_ID)
225+
pci_prepare_to_sleep(pdev);
226+
}
227+
259228
static struct device __maybe_unused *ish_resume_device;
260229

261230
/* 50ms to get resume response */
@@ -378,13 +347,6 @@ static int __maybe_unused ish_resume(struct device *device)
378347
struct pci_dev *pdev = to_pci_dev(device);
379348
struct ishtp_device *dev = pci_get_drvdata(pdev);
380349

381-
/* add this to finish power flow for EHL */
382-
if (dev->pdev->device == EHL_Ax_DEVICE_ID) {
383-
pci_set_power_state(pdev, PCI_D0);
384-
enable_pme_wake(pdev);
385-
dev_dbg(dev->devc, "set power state to D0 for ehl\n");
386-
}
387-
388350
ish_resume_device = device;
389351
dev->resume_flag = 1;
390352

@@ -400,6 +362,7 @@ static struct pci_driver ish_driver = {
400362
.id_table = ish_pci_tbl,
401363
.probe = ish_probe,
402364
.remove = ish_remove,
365+
.shutdown = ish_shutdown,
403366
.driver.pm = &ish_pm_ops,
404367
};
405368

drivers/hid/intel-ish-hid/ishtp-fw-loader.c

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -840,43 +840,22 @@ static void load_fw_from_host_handler(struct work_struct *work)
840840
*
841841
* Return: 0 for success, negative error code for failure
842842
*/
843-
static int loader_init(struct ishtp_cl *loader_ishtp_cl, int reset)
843+
static int loader_init(struct ishtp_cl *loader_ishtp_cl, bool reset)
844844
{
845845
int rv;
846-
struct ishtp_fw_client *fw_client;
847846
struct ishtp_cl_data *client_data =
848847
ishtp_get_client_data(loader_ishtp_cl);
849848

850849
dev_dbg(cl_data_to_dev(client_data), "reset flag: %d\n", reset);
851850

852-
rv = ishtp_cl_link(loader_ishtp_cl);
853-
if (rv < 0) {
854-
dev_err(cl_data_to_dev(client_data), "ishtp_cl_link failed\n");
855-
return rv;
856-
}
857-
858-
/* Connect to firmware client */
859-
ishtp_set_tx_ring_size(loader_ishtp_cl, LOADER_CL_TX_RING_SIZE);
860-
ishtp_set_rx_ring_size(loader_ishtp_cl, LOADER_CL_RX_RING_SIZE);
861-
862-
fw_client =
863-
ishtp_fw_cl_get_client(ishtp_get_ishtp_device(loader_ishtp_cl),
864-
&loader_ishtp_id_table[0].guid);
865-
if (!fw_client) {
866-
dev_err(cl_data_to_dev(client_data),
867-
"ISH client uuid not found\n");
868-
rv = -ENOENT;
869-
goto err_cl_unlink;
870-
}
871-
872-
ishtp_cl_set_fw_client_id(loader_ishtp_cl,
873-
ishtp_get_fw_client_id(fw_client));
874-
ishtp_set_connection_state(loader_ishtp_cl, ISHTP_CL_CONNECTING);
875-
876-
rv = ishtp_cl_connect(loader_ishtp_cl);
851+
rv = ishtp_cl_establish_connection(loader_ishtp_cl,
852+
&loader_ishtp_id_table[0].guid,
853+
LOADER_CL_TX_RING_SIZE,
854+
LOADER_CL_RX_RING_SIZE,
855+
reset);
877856
if (rv < 0) {
878857
dev_err(cl_data_to_dev(client_data), "Client connect fail\n");
879-
goto err_cl_unlink;
858+
goto err_cl_disconnect;
880859
}
881860

882861
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)
885864

886865
return 0;
887866

888-
err_cl_unlink:
889-
ishtp_cl_unlink(loader_ishtp_cl);
867+
err_cl_disconnect:
868+
ishtp_cl_destroy_connection(loader_ishtp_cl, reset);
890869
return rv;
891870
}
892871

893872
static void loader_deinit(struct ishtp_cl *loader_ishtp_cl)
894873
{
895-
ishtp_set_connection_state(loader_ishtp_cl, ISHTP_CL_DISCONNECTING);
896-
ishtp_cl_disconnect(loader_ishtp_cl);
897-
ishtp_cl_unlink(loader_ishtp_cl);
898-
ishtp_cl_flush_queues(loader_ishtp_cl);
874+
ishtp_cl_destroy_connection(loader_ishtp_cl, false);
899875

900876
/* Disband and free all Tx and Rx client-level rings */
901877
ishtp_cl_free(loader_ishtp_cl);
@@ -914,19 +890,7 @@ static void reset_handler(struct work_struct *work)
914890
loader_ishtp_cl = client_data->loader_ishtp_cl;
915891
cl_device = client_data->cl_device;
916892

917-
/* Unlink, flush queues & start again */
918-
ishtp_cl_unlink(loader_ishtp_cl);
919-
ishtp_cl_flush_queues(loader_ishtp_cl);
920-
ishtp_cl_free(loader_ishtp_cl);
921-
922-
loader_ishtp_cl = ishtp_cl_allocate(cl_device);
923-
if (!loader_ishtp_cl)
924-
return;
925-
926-
ishtp_set_drvdata(cl_device, loader_ishtp_cl);
927-
ishtp_set_client_data(loader_ishtp_cl, client_data);
928-
client_data->loader_ishtp_cl = loader_ishtp_cl;
929-
client_data->cl_device = cl_device;
893+
ishtp_cl_destroy_connection(loader_ishtp_cl, true);
930894

931895
rv = loader_init(loader_ishtp_cl, 1);
932896
if (rv < 0) {
@@ -974,7 +938,7 @@ static int loader_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
974938
INIT_WORK(&client_data->work_fw_load,
975939
load_fw_from_host_handler);
976940

977-
rv = loader_init(loader_ishtp_cl, 0);
941+
rv = loader_init(loader_ishtp_cl, false);
978942
if (rv < 0) {
979943
ishtp_cl_free(loader_ishtp_cl);
980944
return rv;

drivers/hid/intel-ish-hid/ishtp-hid-client.c

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -639,47 +639,26 @@ static int ishtp_get_report_descriptor(struct ishtp_cl *hid_ishtp_cl,
639639
*
640640
* Return: 0 on success, non zero on error
641641
*/
642-
static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset)
642+
static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, bool reset)
643643
{
644-
struct ishtp_device *dev;
645644
struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl);
646-
struct ishtp_fw_client *fw_client;
647645
int i;
648646
int rv;
649647

650648
dev_dbg(cl_data_to_dev(client_data), "%s\n", __func__);
651649
hid_ishtp_trace(client_data, "%s reset flag: %d\n", __func__, reset);
652650

653-
rv = ishtp_cl_link(hid_ishtp_cl);
654-
if (rv) {
655-
dev_err(cl_data_to_dev(client_data),
656-
"ishtp_cl_link failed\n");
657-
return -ENOMEM;
658-
}
659-
660651
client_data->init_done = 0;
661652

662-
dev = ishtp_get_ishtp_device(hid_ishtp_cl);
663-
664-
/* Connect to FW client */
665-
ishtp_set_tx_ring_size(hid_ishtp_cl, HID_CL_TX_RING_SIZE);
666-
ishtp_set_rx_ring_size(hid_ishtp_cl, HID_CL_RX_RING_SIZE);
667-
668-
fw_client = ishtp_fw_cl_get_client(dev, &hid_ishtp_id_table[0].guid);
669-
if (!fw_client) {
670-
dev_err(cl_data_to_dev(client_data),
671-
"ish client uuid not found\n");
672-
return -ENOENT;
673-
}
674-
ishtp_cl_set_fw_client_id(hid_ishtp_cl,
675-
ishtp_get_fw_client_id(fw_client));
676-
ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_CONNECTING);
677-
678-
rv = ishtp_cl_connect(hid_ishtp_cl);
653+
rv = ishtp_cl_establish_connection(hid_ishtp_cl,
654+
&hid_ishtp_id_table[0].guid,
655+
HID_CL_TX_RING_SIZE,
656+
HID_CL_RX_RING_SIZE,
657+
reset);
679658
if (rv) {
680659
dev_err(cl_data_to_dev(client_data),
681660
"client connect fail\n");
682-
goto err_cl_unlink;
661+
goto err_cl_disconnect;
683662
}
684663

685664
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)
723702
return 0;
724703

725704
err_cl_disconnect:
726-
ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_DISCONNECTING);
727-
ishtp_cl_disconnect(hid_ishtp_cl);
728-
err_cl_unlink:
729-
ishtp_cl_unlink(hid_ishtp_cl);
705+
ishtp_cl_destroy_connection(hid_ishtp_cl, reset);
730706
return rv;
731707
}
732708

@@ -738,8 +714,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset)
738714
*/
739715
static void hid_ishtp_cl_deinit(struct ishtp_cl *hid_ishtp_cl)
740716
{
741-
ishtp_cl_unlink(hid_ishtp_cl);
742-
ishtp_cl_flush_queues(hid_ishtp_cl);
717+
ishtp_cl_destroy_connection(hid_ishtp_cl, false);
743718

744719
/* disband and free all Tx and Rx client-level rings */
745720
ishtp_cl_free(hid_ishtp_cl);
@@ -749,33 +724,23 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work)
749724
{
750725
struct ishtp_cl_data *client_data;
751726
struct ishtp_cl *hid_ishtp_cl;
752-
struct ishtp_cl_device *cl_device;
753727
int retry;
754728
int rv;
755729

756730
client_data = container_of(work, struct ishtp_cl_data, work);
757731

758732
hid_ishtp_cl = client_data->hid_ishtp_cl;
759-
cl_device = client_data->cl_device;
760733

761734
hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__,
762735
hid_ishtp_cl);
763736
dev_dbg(ishtp_device(client_data->cl_device), "%s\n", __func__);
764737

765-
hid_ishtp_cl_deinit(hid_ishtp_cl);
766-
767-
hid_ishtp_cl = ishtp_cl_allocate(cl_device);
768-
if (!hid_ishtp_cl)
769-
return;
770-
771-
ishtp_set_drvdata(cl_device, hid_ishtp_cl);
772-
ishtp_set_client_data(hid_ishtp_cl, client_data);
773-
client_data->hid_ishtp_cl = hid_ishtp_cl;
738+
ishtp_cl_destroy_connection(hid_ishtp_cl, true);
774739

775740
client_data->num_hid_devices = 0;
776741

777742
for (retry = 0; retry < 3; ++retry) {
778-
rv = hid_ishtp_cl_init(hid_ishtp_cl, 1);
743+
rv = hid_ishtp_cl_init(hid_ishtp_cl, true);
779744
if (!rv)
780745
break;
781746
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)
841806

842807
ishtp_hid_print_trace = ishtp_trace_callback(cl_device);
843808

844-
rv = hid_ishtp_cl_init(hid_ishtp_cl, 0);
809+
rv = hid_ishtp_cl_init(hid_ishtp_cl, false);
845810
if (rv) {
846811
ishtp_cl_free(hid_ishtp_cl);
847812
return rv;
@@ -868,11 +833,9 @@ static void hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
868833
hid_ishtp_cl);
869834

870835
dev_dbg(ishtp_device(cl_device), "%s\n", __func__);
871-
ishtp_set_connection_state(hid_ishtp_cl, ISHTP_CL_DISCONNECTING);
872-
ishtp_cl_disconnect(hid_ishtp_cl);
836+
hid_ishtp_cl_deinit(hid_ishtp_cl);
873837
ishtp_put_device(cl_device);
874838
ishtp_hid_remove(client_data);
875-
hid_ishtp_cl_deinit(hid_ishtp_cl);
876839

877840
hid_ishtp_cl = NULL;
878841

0 commit comments

Comments
 (0)