Skip to content

Commit c1ca58f

Browse files
lixuzhaJiri Kosina
authored andcommitted
HID: intel-ish-hid: ipc: set NO_D3 flag only when needed
Currently, the NO_D3 flag is set in ish_probe(), and cleared in ish_remove(). So even if the system goes into S3, ISH is still in D0i3 state. It makes more sense that put ISH into D3 as system goes into S3 and put ISH into D0i3 as system goes into suspend-to-idle. I remove the NO_D3 setting in ish_probe(), so that ISH can enter D3 state when system enters S3. Only set N0_D3 flag when system enters the suspend-to-idle or platform specified, and clear it when system resume. When the ISH enters D3, the FW will check the DMA bit status. If the DMA bit is set, the FW will reset automatically. So the DMA bit need be clear before putting ISH into D3 state. Signed-off-by: Zhang Lixu <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent f4eb142 commit c1ca58f

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

drivers/hid/intel-ish-hid/ipc/hw-ish.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ irqreturn_t ish_irq_handler(int irq, void *dev_id);
7777
struct ishtp_device *ish_dev_init(struct pci_dev *pdev);
7878
int ish_hw_start(struct ishtp_device *dev);
7979
void ish_device_disable(struct ishtp_device *dev);
80+
int ish_disable_dma(struct ishtp_device *dev);
8081

8182
#endif /* _ISHTP_HW_ISH_H_ */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ irqreturn_t ish_irq_handler(int irq, void *dev_id)
672672
*
673673
* Return: 0 for success else error code.
674674
*/
675-
static int ish_disable_dma(struct ishtp_device *dev)
675+
int ish_disable_dma(struct ishtp_device *dev)
676676
{
677677
unsigned int dma_delay;
678678

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/types.h>
1515
#include <linux/pci.h>
1616
#include <linux/sched.h>
17+
#include <linux/suspend.h>
1718
#include <linux/interrupt.h>
1819
#include <linux/workqueue.h>
1920
#define CREATE_TRACE_POINTS
@@ -97,6 +98,11 @@ static const struct pci_device_id ish_invalid_pci_ids[] = {
9798
{}
9899
};
99100

101+
static inline bool ish_should_enter_d0i3(struct pci_dev *pdev)
102+
{
103+
return !pm_suspend_via_firmware() || pdev->device == CHV_DEVICE_ID;
104+
}
105+
100106
/**
101107
* ish_probe() - PCI driver probe callback
102108
* @pdev: pci device
@@ -147,7 +153,6 @@ static int ish_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
147153
/* mapping IO device memory */
148154
hw->mem_addr = pcim_iomap_table(pdev)[0];
149155
ishtp->pdev = pdev;
150-
pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3;
151156

152157
/* request and enable interrupt */
153158
ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
@@ -184,7 +189,6 @@ static void ish_remove(struct pci_dev *pdev)
184189
struct ishtp_device *ishtp_dev = pci_get_drvdata(pdev);
185190

186191
ishtp_bus_remove_all_clients(ishtp_dev, false);
187-
pdev->dev_flags &= ~PCI_DEV_FLAGS_NO_D3;
188192
ish_device_disable(ishtp_dev);
189193
}
190194

@@ -209,6 +213,8 @@ static void __maybe_unused ish_resume_handler(struct work_struct *work)
209213
uint32_t fwsts;
210214
int ret;
211215

216+
pdev->dev_flags &= ~PCI_DEV_FLAGS_NO_D3;
217+
212218
/* Get ISH FW status */
213219
fwsts = IPC_GET_ISH_FWSTS(dev->ops->get_fw_status(dev));
214220

@@ -267,6 +273,17 @@ static int __maybe_unused ish_suspend(struct device *device)
267273
!dev->suspend_flag,
268274
msecs_to_jiffies(25));
269275

276+
if (ish_should_enter_d0i3(pdev)) {
277+
/* Set the NO_D3 flag, the ISH would enter D0i3 */
278+
pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3;
279+
} else {
280+
/*
281+
* Clear the DMA bit before putting ISH into D3,
282+
* or ISH FW would reset automatically.
283+
*/
284+
ish_disable_dma(dev);
285+
}
286+
270287
return 0;
271288
}
272289

0 commit comments

Comments
 (0)