Skip to content

Commit 9e097dc

Browse files
lixuzhaJiri Kosina
authored andcommitted
HID: intel-ish-hid: ipc: Always schedule FW reset work on RESET_NOTIFY/ACK
Both ISH firmware and driver can actively send MNG_RESET_NOTIFY to initiate an FW reset handshake. Upon receiving this, the peer should reply with MNG_RESET_NOTIFY_ACK. Therefore, the driver should schedule the FW reset handshake work function when receiving either MNG_RESET_NOTIFY or MNG_RESET_NOTIFY_ACK. Previously, driver only scheduled the work function on MNG_RESET_NOTIFY. This patch ensures the work function is scheduled on both messages, but only replies with MNG_RESET_NOTIFY_ACK when receiving MNG_RESET_NOTIFY. Signed-off-by: Zhang Lixu <lixu.zhang@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent bd1b9a8 commit 9e097dc

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

  • drivers/hid/intel-ish-hid/ipc

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,20 @@ static int timed_wait_for_timeout(struct ishtp_device *dev, int condition,
481481
return ret;
482482
}
483483

484+
static void ish_send_reset_notify_ack(struct ishtp_device *dev)
485+
{
486+
/* Read reset ID */
487+
u32 reset_id = ish_reg_read(dev, IPC_REG_ISH2HOST_MSG) & 0xFFFF;
488+
489+
/*
490+
* Set HOST2ISH.ILUP. Apparently we need this BEFORE sending
491+
* RESET_NOTIFY_ACK - FW will be checking for it
492+
*/
493+
ish_set_host_rdy(dev);
494+
/* Send RESET_NOTIFY_ACK (with reset_id) */
495+
ipc_send_mng_msg(dev, MNG_RESET_NOTIFY_ACK, &reset_id, sizeof(u32));
496+
}
497+
484498
#define TIME_SLICE_FOR_FW_RDY_MS 100
485499
#define TIME_SLICE_FOR_INPUT_RDY_MS 100
486500
#define TIMEOUT_FOR_FW_RDY_MS 2000
@@ -496,13 +510,9 @@ static int timed_wait_for_timeout(struct ishtp_device *dev, int condition,
496510
*/
497511
static int ish_fw_reset_handler(struct ishtp_device *dev)
498512
{
499-
uint32_t reset_id;
500513
unsigned long flags;
501514
int ret;
502515

503-
/* Read reset ID */
504-
reset_id = ish_reg_read(dev, IPC_REG_ISH2HOST_MSG) & 0xFFFF;
505-
506516
/* Clear IPC output queue */
507517
spin_lock_irqsave(&dev->wr_processing_spinlock, flags);
508518
list_splice_init(&dev->wr_processing_list, &dev->wr_free_list);
@@ -521,15 +531,6 @@ static int ish_fw_reset_handler(struct ishtp_device *dev)
521531
/* Send clock sync at once after reset */
522532
ishtp_dev->prev_sync = 0;
523533

524-
/*
525-
* Set HOST2ISH.ILUP. Apparently we need this BEFORE sending
526-
* RESET_NOTIFY_ACK - FW will be checking for it
527-
*/
528-
ish_set_host_rdy(dev);
529-
/* Send RESET_NOTIFY_ACK (with reset_id) */
530-
ipc_send_mng_msg(dev, MNG_RESET_NOTIFY_ACK, &reset_id,
531-
sizeof(uint32_t));
532-
533534
/* Wait for ISH FW'es ILUP and ISHTP_READY */
534535
ret = timed_wait_for_timeout(dev, WAIT_FOR_FW_RDY,
535536
TIME_SLICE_FOR_FW_RDY_MS,
@@ -563,8 +564,6 @@ static void fw_reset_work_fn(struct work_struct *work)
563564
if (!rv) {
564565
/* ISH is ILUP & ISHTP-ready. Restart ISHTP */
565566
msleep_interruptible(TIMEOUT_FOR_HW_RDY_MS);
566-
ishtp_dev->recvd_hw_ready = 1;
567-
wake_up_interruptible(&ishtp_dev->wait_hw_ready);
568567

569568
/* ISHTP notification in IPC_RESET sequence completion */
570569
if (!work_pending(work))
@@ -625,15 +624,14 @@ static void recv_ipc(struct ishtp_device *dev, uint32_t doorbell_val)
625624
break;
626625

627626
case MNG_RESET_NOTIFY:
628-
if (!ishtp_dev) {
629-
ishtp_dev = dev;
630-
}
631-
queue_work(dev->unbound_wq, &fw_reset_work);
632-
break;
627+
ish_send_reset_notify_ack(ishtp_dev);
628+
fallthrough;
633629

634630
case MNG_RESET_NOTIFY_ACK:
635631
dev->recvd_hw_ready = 1;
636632
wake_up_interruptible(&dev->wait_hw_ready);
633+
if (!work_pending(&fw_reset_work))
634+
queue_work(dev->unbound_wq, &fw_reset_work);
637635
break;
638636
}
639637
}
@@ -1001,6 +999,7 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
1001999
list_add_tail(&tx_buf->link, &dev->wr_free_list);
10021000
}
10031001

1002+
ishtp_dev = dev;
10041003
ret = devm_work_autocancel(&pdev->dev, &fw_reset_work, fw_reset_work_fn);
10051004
if (ret) {
10061005
dev_err(dev->devc, "Failed to initialise FW reset work\n");

0 commit comments

Comments
 (0)