Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mei: csc: wake device while reading firmware status

The CSC has firmware status registers in MMIO and they may be
unaccessible while device is suspended.
Wake device while reading firmware status via sysfs.

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Link: https://patch.msgid.link/20260201094358.1440593-8-alexander.usyskin@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexander Usyskin and committed by
Greg Kroah-Hartman
0a18c3bc 72fdf0bb

+18 -4
+14 -4
drivers/misc/mei/main.c
··· 4 4 * Intel Management Engine Interface (Intel MEI) Linux driver 5 5 */ 6 6 7 + #include <linux/cleanup.h> 7 8 #include <linux/module.h> 8 9 #include <linux/moduleparam.h> 9 10 #include <linux/kernel.h> ··· 14 13 #include <linux/errno.h> 15 14 #include <linux/types.h> 16 15 #include <linux/fcntl.h> 16 + #include <linux/pm_runtime.h> 17 17 #include <linux/poll.h> 18 18 #include <linux/init.h> 19 19 #include <linux/ioctl.h> ··· 984 982 static ssize_t fw_status_show(struct device *device, 985 983 struct device_attribute *attr, char *buf) 986 984 { 987 - struct mei_device *dev = dev_get_drvdata(device); 985 + struct mei_device *mdev = dev_get_drvdata(device); 988 986 struct mei_fw_status fw_status; 989 987 int err, i; 990 988 ssize_t cnt = 0; 991 989 992 - mutex_lock(&dev->device_lock); 993 - err = mei_fw_status(dev, &fw_status); 994 - mutex_unlock(&dev->device_lock); 990 + if (mdev->read_fws_need_resume) { 991 + err = pm_runtime_resume_and_get(mdev->parent); 992 + if (err) { 993 + dev_err(device, "read fw_status resume error = %d\n", err); 994 + return err; 995 + } 996 + } 997 + scoped_guard(mutex, &mdev->device_lock) 998 + err = mei_fw_status(mdev, &fw_status); 999 + if (mdev->read_fws_need_resume) 1000 + pm_runtime_put_autosuspend(mdev->parent); 995 1001 if (err) { 996 1002 dev_err(device, "read fw_status error = %d\n", err); 997 1003 return err;
+2
drivers/misc/mei/mei_dev.h
··· 491 491 * 492 492 * @recvd_hw_ready : hw ready message received flag 493 493 * @pg_blocked : low power mode is not allowed 494 + * @read_fws_need_resume: the FW status handler needs HW woken from sleep 494 495 * 495 496 * @wait_hw_ready : wait queue for receive HW ready message form FW 496 497 * @wait_pg : wait queue for receive PG message from FW ··· 578 577 579 578 bool recvd_hw_ready; 580 579 bool pg_blocked; 580 + bool read_fws_need_resume; 581 581 582 582 /* 583 583 * waiting queue for receive message from FW
+2
drivers/misc/mei/pci-csc.c
··· 67 67 if (!mdev) 68 68 return -ENOMEM; 69 69 70 + mdev->read_fws_need_resume = true; 71 + 70 72 hw = to_me_hw(mdev); 71 73 72 74 /*