Skip to content

Commit 2f79d3d

Browse files
ausyskingregkh
authored andcommitted
mei: add device kind to sysfs
Some of the mei device heads are not generic and have a specific purpose, we need to announce it to the user space so it is possible to detect the correct device node via matching attributes. Generic heads are marked as 'mei' while special purpose heads have their own names. Currently we are adding 'itouch' string for Intel IPTS 1.0, 2.0 devices. This is done via new sysfs attribute 'kind'. Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9bb01fe commit 2f79d3d

File tree

6 files changed

+71
-10
lines changed

6 files changed

+71
-10
lines changed

Documentation/ABI/testing/sysfs-class-mei

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,16 @@ Description: Display trc status register content
9090
The ME FW writes Glitch Detection HW (TRC)
9191
status information into trc status register
9292
for BIOS and OS to monitor fw health.
93+
94+
What: /sys/class/mei/meiN/kind
95+
Date: Jul 2020
96+
KernelVersion: 5.8
97+
Contact: Tomas Winkler <[email protected]>
98+
Description: Display kind of the device
99+
100+
Generic devices are marked as "mei"
101+
while special purpose have their own
102+
names.
103+
Available options:
104+
- mei: generic mei device.
105+
- itouch: itouch (ipts) mei device.

drivers/misc/mei/hw-me.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,9 @@ static bool mei_me_fw_type_sps(const struct pci_dev *pdev)
14301430
return fw_type == PCI_CFG_HFS_3_FW_SKU_SPS;
14311431
}
14321432

1433+
#define MEI_CFG_KIND_ITOUCH \
1434+
.kind = "itouch"
1435+
14331436
#define MEI_CFG_FW_SPS \
14341437
.quirk_probe = mei_me_fw_type_sps
14351438

@@ -1499,6 +1502,13 @@ static const struct mei_cfg mei_me_pch8_cfg = {
14991502
MEI_CFG_FW_VER_SUPP,
15001503
};
15011504

1505+
/* PCH8 Lynx Point and newer devices - iTouch */
1506+
static const struct mei_cfg mei_me_pch8_itouch_cfg = {
1507+
MEI_CFG_KIND_ITOUCH,
1508+
MEI_CFG_PCH8_HFS,
1509+
MEI_CFG_FW_VER_SUPP,
1510+
};
1511+
15021512
/* PCH8 Lynx Point with quirk for SPS Firmware exclusion */
15031513
static const struct mei_cfg mei_me_pch8_sps_4_cfg = {
15041514
MEI_CFG_PCH8_HFS,
@@ -1528,10 +1538,11 @@ static const struct mei_cfg mei_me_pch12_sps_cfg = {
15281538
MEI_CFG_FW_SPS,
15291539
};
15301540

1531-
/* Cannon Lake with quirk for SPS 5.0 and newer Firmware exclusion
1532-
* w/o DMA support
1541+
/* Cannon Lake itouch with quirk for SPS 5.0 and newer Firmware exclusion
1542+
* w/o DMA support.
15331543
*/
1534-
static const struct mei_cfg mei_me_pch12_nodma_sps_cfg = {
1544+
static const struct mei_cfg mei_me_pch12_itouch_sps_cfg = {
1545+
MEI_CFG_KIND_ITOUCH,
15351546
MEI_CFG_PCH8_HFS,
15361547
MEI_CFG_FW_VER_SUPP,
15371548
MEI_CFG_FW_SPS,
@@ -1566,11 +1577,12 @@ static const struct mei_cfg *const mei_cfg_list[] = {
15661577
[MEI_ME_PCH7_CFG] = &mei_me_pch7_cfg,
15671578
[MEI_ME_PCH_CPT_PBG_CFG] = &mei_me_pch_cpt_pbg_cfg,
15681579
[MEI_ME_PCH8_CFG] = &mei_me_pch8_cfg,
1580+
[MEI_ME_PCH8_ITOUCH_CFG] = &mei_me_pch8_itouch_cfg,
15691581
[MEI_ME_PCH8_SPS_4_CFG] = &mei_me_pch8_sps_4_cfg,
15701582
[MEI_ME_PCH12_CFG] = &mei_me_pch12_cfg,
15711583
[MEI_ME_PCH12_SPS_4_CFG] = &mei_me_pch12_sps_4_cfg,
15721584
[MEI_ME_PCH12_SPS_CFG] = &mei_me_pch12_sps_cfg,
1573-
[MEI_ME_PCH12_SPS_NODMA_CFG] = &mei_me_pch12_nodma_sps_cfg,
1585+
[MEI_ME_PCH12_SPS_ITOUCH_CFG] = &mei_me_pch12_itouch_sps_cfg,
15741586
[MEI_ME_PCH15_CFG] = &mei_me_pch15_cfg,
15751587
[MEI_ME_PCH15_SPS_CFG] = &mei_me_pch15_sps_cfg,
15761588
};
@@ -1614,6 +1626,8 @@ struct mei_device *mei_me_dev_init(struct device *parent,
16141626

16151627
dev->fw_f_fw_ver_supported = cfg->fw_ver_supported;
16161628

1629+
dev->kind = cfg->kind;
1630+
16171631
return dev;
16181632
}
16191633

drivers/misc/mei/hw-me.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
*
2020
* @fw_status: FW status
2121
* @quirk_probe: device exclusion quirk
22+
* @kind: MEI head kind
2223
* @dma_size: device DMA buffers size
2324
* @fw_ver_supported: is fw version retrievable from FW
2425
* @hw_trc_supported: does the hw support trc register
2526
*/
2627
struct mei_cfg {
2728
const struct mei_fw_status fw_status;
2829
bool (*quirk_probe)(const struct pci_dev *pdev);
30+
const char *kind;
2931
size_t dma_size[DMA_DSCR_NUM];
3032
u32 fw_ver_supported:1;
3133
u32 hw_trc_supported:1;
@@ -76,6 +78,8 @@ struct mei_me_hw {
7678
* with quirk for Node Manager exclusion.
7779
* @MEI_ME_PCH8_CFG: Platform Controller Hub Gen8 and newer
7880
* client platforms.
81+
* @MEI_ME_PCH8_ITOUCH_CFG:Platform Controller Hub Gen8 and newer
82+
* client platforms (iTouch).
7983
* @MEI_ME_PCH8_SPS_4_CFG: Platform Controller Hub Gen8 and newer
8084
* servers platforms with quirk for
8185
* SPS firmware exclusion.
@@ -100,11 +104,12 @@ enum mei_cfg_idx {
100104
MEI_ME_PCH7_CFG,
101105
MEI_ME_PCH_CPT_PBG_CFG,
102106
MEI_ME_PCH8_CFG,
107+
MEI_ME_PCH8_ITOUCH_CFG,
103108
MEI_ME_PCH8_SPS_4_CFG,
104109
MEI_ME_PCH12_CFG,
105110
MEI_ME_PCH12_SPS_4_CFG,
106111
MEI_ME_PCH12_SPS_CFG,
107-
MEI_ME_PCH12_SPS_NODMA_CFG,
112+
MEI_ME_PCH12_SPS_ITOUCH_CFG,
108113
MEI_ME_PCH15_CFG,
109114
MEI_ME_PCH15_SPS_CFG,
110115
MEI_ME_NUM_CFG,

drivers/misc/mei/main.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,30 @@ void mei_set_devstate(struct mei_device *dev, enum mei_dev_state state)
885885
}
886886
}
887887

888+
/**
889+
* kind_show - display device kind
890+
*
891+
* @device: device pointer
892+
* @attr: attribute pointer
893+
* @buf: char out buffer
894+
*
895+
* Return: number of the bytes printed into buf or error
896+
*/
897+
static ssize_t kind_show(struct device *device,
898+
struct device_attribute *attr, char *buf)
899+
{
900+
struct mei_device *dev = dev_get_drvdata(device);
901+
ssize_t ret;
902+
903+
if (dev->kind)
904+
ret = sprintf(buf, "%s\n", dev->kind);
905+
else
906+
ret = sprintf(buf, "%s\n", "mei");
907+
908+
return ret;
909+
}
910+
static DEVICE_ATTR_RO(kind);
911+
888912
static struct attribute *mei_attrs[] = {
889913
&dev_attr_fw_status.attr,
890914
&dev_attr_hbm_ver.attr,
@@ -893,6 +917,7 @@ static struct attribute *mei_attrs[] = {
893917
&dev_attr_fw_ver.attr,
894918
&dev_attr_dev_state.attr,
895919
&dev_attr_trc.attr,
920+
&dev_attr_kind.attr,
896921
NULL
897922
};
898923
ATTRIBUTE_GROUPS(mei);

drivers/misc/mei/mei_dev.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ struct mei_fw_version {
445445
* @device_list : mei client bus list
446446
* @cl_bus_lock : client bus list lock
447447
*
448+
* @kind : kind of mei device
449+
*
448450
* @dbgfs_dir : debugfs mei root directory
449451
*
450452
* @ops: : hw specific operations
@@ -528,6 +530,8 @@ struct mei_device {
528530
struct list_head device_list;
529531
struct mutex cl_bus_lock;
530532

533+
const char *kind;
534+
531535
#if IS_ENABLED(CONFIG_DEBUG_FS)
532536
struct dentry *dbgfs_dir;
533537
#endif /* CONFIG_DEBUG_FS */

drivers/misc/mei/pci-me.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
6868

6969
{MEI_PCI_DEVICE(MEI_DEV_ID_SPT, MEI_ME_PCH8_CFG)},
7070
{MEI_PCI_DEVICE(MEI_DEV_ID_SPT_2, MEI_ME_PCH8_CFG)},
71-
{MEI_PCI_DEVICE(MEI_DEV_ID_SPT_3, MEI_ME_PCH8_CFG)},
71+
{MEI_PCI_DEVICE(MEI_DEV_ID_SPT_3, MEI_ME_PCH8_ITOUCH_CFG)},
7272
{MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H, MEI_ME_PCH8_SPS_4_CFG)},
7373
{MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H_2, MEI_ME_PCH8_SPS_4_CFG)},
7474
{MEI_PCI_DEVICE(MEI_DEV_ID_LBG, MEI_ME_PCH12_SPS_4_CFG)},
@@ -85,15 +85,15 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
8585
{MEI_PCI_DEVICE(MEI_DEV_ID_KBP_3, MEI_ME_PCH8_CFG)},
8686

8787
{MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP, MEI_ME_PCH12_CFG)},
88-
{MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP_3, MEI_ME_PCH8_CFG)},
88+
{MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP_3, MEI_ME_PCH8_ITOUCH_CFG)},
8989
{MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H, MEI_ME_PCH12_SPS_CFG)},
90-
{MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H_3, MEI_ME_PCH12_SPS_NODMA_CFG)},
90+
{MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H_3, MEI_ME_PCH12_SPS_ITOUCH_CFG)},
9191

9292
{MEI_PCI_DEVICE(MEI_DEV_ID_CMP_LP, MEI_ME_PCH12_CFG)},
93-
{MEI_PCI_DEVICE(MEI_DEV_ID_CMP_LP_3, MEI_ME_PCH8_CFG)},
93+
{MEI_PCI_DEVICE(MEI_DEV_ID_CMP_LP_3, MEI_ME_PCH8_ITOUCH_CFG)},
9494
{MEI_PCI_DEVICE(MEI_DEV_ID_CMP_V, MEI_ME_PCH12_CFG)},
9595
{MEI_PCI_DEVICE(MEI_DEV_ID_CMP_H, MEI_ME_PCH12_CFG)},
96-
{MEI_PCI_DEVICE(MEI_DEV_ID_CMP_H_3, MEI_ME_PCH8_CFG)},
96+
{MEI_PCI_DEVICE(MEI_DEV_ID_CMP_H_3, MEI_ME_PCH8_ITOUCH_CFG)},
9797

9898
{MEI_PCI_DEVICE(MEI_DEV_ID_ICP_LP, MEI_ME_PCH12_CFG)},
9999

0 commit comments

Comments
 (0)