Skip to content

Commit edca5ea

Browse files
ausyskingregkh
authored andcommitted
mei: read and print all six FW status registers
ME devices prior to PCH8 (Lynx Point) have two FW status registers, on PCH8 and newer excluding txe there are six FW status registers. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e88281e commit edca5ea

7 files changed

Lines changed: 100 additions & 29 deletions

File tree

‎drivers/misc/mei/hw-me-regs.h‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,18 @@
117117
#define MEI_DEV_ID_WPT_LP 0x9CBA /* Wildcat Point LP */
118118
#define MEI_DEV_ID_WPT_LP_2 0x9CBB /* Wildcat Point LP 2 */
119119

120-
/* Host Firmware Status Registers in PCI Config Space */
121-
#define PCI_CFG_HFS_1 0x40
122-
#define PCI_CFG_HFS_2 0x48
123-
124120
/*
125121
* MEI HW Section
126122
*/
127123

124+
/* Host Firmware Status Registers in PCI Config Space */
125+
#define PCI_CFG_HFS_1 0x40
126+
#define PCI_CFG_HFS_2 0x48
127+
#define PCI_CFG_HFS_3 0x60
128+
#define PCI_CFG_HFS_4 0x64
129+
#define PCI_CFG_HFS_5 0x68
130+
#define PCI_CFG_HFS_6 0x6C
131+
128132
/* MEI registers */
129133
/* H_CB_WW - Host Circular Buffer (CB) Write Window register */
130134
#define H_CB_WW 0

‎drivers/misc/mei/hw-me.c‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,14 @@ static bool mei_me_fw_type_sps(struct pci_dev *pdev)
835835
.fw_status.status[0] = PCI_CFG_HFS_1, \
836836
.fw_status.status[1] = PCI_CFG_HFS_2
837837

838+
#define MEI_CFG_PCH8_HFS \
839+
.fw_status.count = 6, \
840+
.fw_status.status[0] = PCI_CFG_HFS_1, \
841+
.fw_status.status[1] = PCI_CFG_HFS_2, \
842+
.fw_status.status[2] = PCI_CFG_HFS_3, \
843+
.fw_status.status[3] = PCI_CFG_HFS_4, \
844+
.fw_status.status[4] = PCI_CFG_HFS_5, \
845+
.fw_status.status[5] = PCI_CFG_HFS_6
838846

839847
/* ICH Legacy devices */
840848
const struct mei_cfg mei_me_legacy_cfg = {
@@ -858,9 +866,14 @@ const struct mei_cfg mei_me_pch_cpt_pbg_cfg = {
858866
MEI_CFG_FW_NM,
859867
};
860868

861-
/* PCH Lynx Point with quirk for SPS Firmware exclusion */
862-
const struct mei_cfg mei_me_lpt_cfg = {
863-
MEI_CFG_PCH_HFS,
869+
/* PCH8 Lynx Point and newer devices */
870+
const struct mei_cfg mei_me_pch8_cfg = {
871+
MEI_CFG_PCH8_HFS,
872+
};
873+
874+
/* PCH8 Lynx Point with quirk for SPS Firmware exclusion */
875+
const struct mei_cfg mei_me_pch8_sps_cfg = {
876+
MEI_CFG_PCH8_HFS,
864877
MEI_CFG_FW_SPS,
865878
};
866879

‎drivers/misc/mei/hw-me.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ extern const struct mei_cfg mei_me_legacy_cfg;
6565
extern const struct mei_cfg mei_me_ich_cfg;
6666
extern const struct mei_cfg mei_me_pch_cfg;
6767
extern const struct mei_cfg mei_me_pch_cpt_pbg_cfg;
68-
extern const struct mei_cfg mei_me_lpt_cfg;
68+
extern const struct mei_cfg mei_me_pch8_cfg;
69+
extern const struct mei_cfg mei_me_pch8_sps_cfg;
6970

7071
struct mei_device *mei_me_dev_init(struct pci_dev *pdev,
7172
const struct mei_cfg *cfg);

‎drivers/misc/mei/hw-txe.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,10 @@ static int mei_txe_write(struct mei_device *dev,
700700
mei_txe_input_ready_interrupt_enable(dev);
701701

702702
if (!mei_txe_is_input_ready(dev)) {
703-
struct mei_fw_status fw_status;
703+
char fw_sts_str[MEI_FW_STATUS_STR_SZ];
704704

705-
mei_fw_status(dev, &fw_status);
706-
dev_err(dev->dev, "Input is not ready " FW_STS_FMT "\n",
707-
FW_STS_PRM(fw_status));
705+
mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ);
706+
dev_err(dev->dev, "Input is not ready %s\n", fw_sts_str);
708707
return -EAGAIN;
709708
}
710709

‎drivers/misc/mei/init.c‎

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,35 @@ const char *mei_pg_state_str(enum mei_pg_state state)
5454
#undef MEI_PG_STATE
5555
}
5656

57+
/**
58+
* mei_fw_status2str - convert fw status registers to printable string
59+
*
60+
* @fw_status: firmware status
61+
* @buf: string buffer at minimal size MEI_FW_STATUS_STR_SZ
62+
* @len: buffer len must be >= MEI_FW_STATUS_STR_SZ
63+
*
64+
* Return: number of bytes written or -EINVAL if buffer is to small
65+
*/
66+
ssize_t mei_fw_status2str(struct mei_fw_status *fw_status,
67+
char *buf, size_t len)
68+
{
69+
ssize_t cnt = 0;
70+
int i;
71+
72+
buf[0] = '\0';
73+
74+
if (len < MEI_FW_STATUS_STR_SZ)
75+
return -EINVAL;
76+
77+
for (i = 0; i < fw_status->count; i++)
78+
cnt += scnprintf(buf + cnt, len - cnt, "%08X ",
79+
fw_status->status[i]);
80+
81+
/* drop last space */
82+
buf[cnt] = '\0';
83+
return cnt;
84+
}
85+
EXPORT_SYMBOL_GPL(mei_fw_status2str);
5786

5887
/**
5988
* mei_cancel_work - Cancel mei background jobs
@@ -86,12 +115,11 @@ int mei_reset(struct mei_device *dev)
86115
state != MEI_DEV_DISABLED &&
87116
state != MEI_DEV_POWER_DOWN &&
88117
state != MEI_DEV_POWER_UP) {
89-
struct mei_fw_status fw_status;
118+
char fw_sts_str[MEI_FW_STATUS_STR_SZ];
90119

91-
mei_fw_status(dev, &fw_status);
92-
dev_warn(dev->dev,
93-
"unexpected reset: dev_state = %s " FW_STS_FMT "\n",
94-
mei_dev_state_str(state), FW_STS_PRM(fw_status));
120+
mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ);
121+
dev_warn(dev->dev, "unexpected reset: dev_state = %s fw status = %s\n",
122+
mei_dev_state_str(state), fw_sts_str);
95123
}
96124

97125
/* we're already in reset, cancel the init timer

‎drivers/misc/mei/mei_dev.h‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ struct mei_msg_data {
152152
};
153153

154154
/* Maximum number of processed FW status registers */
155-
#define MEI_FW_STATUS_MAX 2
155+
#define MEI_FW_STATUS_MAX 6
156+
/* Minimal buffer for FW status string (8 bytes in dw + space or '\0') */
157+
#define MEI_FW_STATUS_STR_SZ (MEI_FW_STATUS_MAX * (8 + 1))
158+
156159

157160
/*
158161
* struct mei_fw_status - storage of FW status data
@@ -805,11 +808,6 @@ static inline int mei_fw_status(struct mei_device *dev,
805808
return dev->ops->fw_status(dev, fw_status);
806809
}
807810

808-
#define FW_STS_FMT "%08X %08X"
809-
#define FW_STS_PRM(fw_status) \
810-
(fw_status).count > 0 ? (fw_status).status[0] : 0xDEADBEEF, \
811-
(fw_status).count > 1 ? (fw_status).status[1] : 0xDEADBEEF
812-
813811
bool mei_hbuf_acquire(struct mei_device *dev);
814812

815813
bool mei_write_is_idle(struct mei_device *dev);
@@ -833,4 +831,32 @@ void mei_deregister(struct mei_device *dev);
833831
(hdr)->host_addr, (hdr)->me_addr, \
834832
(hdr)->length, (hdr)->internal, (hdr)->msg_complete
835833

834+
ssize_t mei_fw_status2str(struct mei_fw_status *fw_sts, char *buf, size_t len);
835+
/**
836+
* mei_fw_status_str - fetch and convert fw status registers to printable string
837+
*
838+
* @dev: the device structure
839+
* @buf: string buffer at minimal size MEI_FW_STATUS_STR_SZ
840+
* @len: buffer len must be >= MEI_FW_STATUS_STR_SZ
841+
*
842+
* Return: number of bytes written or < 0 on failure
843+
*/
844+
static inline ssize_t mei_fw_status_str(struct mei_device *dev,
845+
char *buf, size_t len)
846+
{
847+
struct mei_fw_status fw_status;
848+
int ret;
849+
850+
buf[0] = '\0';
851+
852+
ret = mei_fw_status(dev, &fw_status);
853+
if (ret)
854+
return ret;
855+
856+
ret = mei_fw_status2str(&fw_status, buf, MEI_FW_STATUS_STR_SZ);
857+
858+
return ret;
859+
}
860+
861+
836862
#endif

‎drivers/misc/mei/pci-me.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
7676
{MEI_PCI_DEVICE(MEI_DEV_ID_PPT_1, mei_me_pch_cfg)},
7777
{MEI_PCI_DEVICE(MEI_DEV_ID_PPT_2, mei_me_pch_cfg)},
7878
{MEI_PCI_DEVICE(MEI_DEV_ID_PPT_3, mei_me_pch_cfg)},
79-
{MEI_PCI_DEVICE(MEI_DEV_ID_LPT_H, mei_me_lpt_cfg)},
80-
{MEI_PCI_DEVICE(MEI_DEV_ID_LPT_W, mei_me_lpt_cfg)},
81-
{MEI_PCI_DEVICE(MEI_DEV_ID_LPT_LP, mei_me_pch_cfg)},
82-
{MEI_PCI_DEVICE(MEI_DEV_ID_LPT_HR, mei_me_lpt_cfg)},
83-
{MEI_PCI_DEVICE(MEI_DEV_ID_WPT_LP, mei_me_pch_cfg)},
84-
{MEI_PCI_DEVICE(MEI_DEV_ID_WPT_LP_2, mei_me_pch_cfg)},
79+
{MEI_PCI_DEVICE(MEI_DEV_ID_LPT_H, mei_me_pch8_sps_cfg)},
80+
{MEI_PCI_DEVICE(MEI_DEV_ID_LPT_W, mei_me_pch8_sps_cfg)},
81+
{MEI_PCI_DEVICE(MEI_DEV_ID_LPT_LP, mei_me_pch8_cfg)},
82+
{MEI_PCI_DEVICE(MEI_DEV_ID_LPT_HR, mei_me_pch8_sps_cfg)},
83+
{MEI_PCI_DEVICE(MEI_DEV_ID_WPT_LP, mei_me_pch8_cfg)},
84+
{MEI_PCI_DEVICE(MEI_DEV_ID_WPT_LP_2, mei_me_pch8_cfg)},
8585

8686
/* required last entry */
8787
{0, }

0 commit comments

Comments
 (0)