mei: store kind as enum

Simplify flows and prepare for future flexibility by
storing kind as enum and converting to string only in sysfs.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Reuven Abliyev <reuvenab@gmail.com>
Signed-off-by: Reuven Abliyev <reuvenab@gmail.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Link: https://patch.msgid.link/20260409125524.111530-2-alexander.usyskin@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Alexander Usyskin
2026-04-09 15:55:22 +03:00
committed by Greg Kroah-Hartman
parent 7c19b47f5a
commit 00d56ac077
6 changed files with 86 additions and 27 deletions

View File

@@ -1584,18 +1584,41 @@ static bool mei_me_fw_type_sps_ign(const struct pci_dev *pdev)
fw_type == PCI_CFG_HFS_3_FW_SKU_SPS;
}
#define MEI_CFG_KIND_ITOUCH \
.kind = "itouch"
#define MEI_CFG_TYPE_GSC \
.kind = "gsc"
#define MEI_CFG_TYPE_GSCFI \
.kind = "gscfi"
#define MEI_CFG_FW_SPS_IGN \
.quirk_probe = mei_me_fw_type_sps_ign
static enum mei_dev_kind mei_cfg_kind_mei(const struct device *parent)
{
return MEI_DEV_KIND_MEI;
}
#define MEI_CFG_KIND_MEI \
.get_kind = mei_cfg_kind_mei
static enum mei_dev_kind mei_cfg_kind_itouch(const struct device *parent)
{
return MEI_DEV_KIND_ITOUCH;
}
#define MEI_CFG_KIND_ITOUCH \
.get_kind = mei_cfg_kind_itouch
static enum mei_dev_kind mei_cfg_kind_gsc(const struct device *parent)
{
return MEI_DEV_KIND_GSC;
}
#define MEI_CFG_KIND_GSC \
.get_kind = mei_cfg_kind_gsc
static enum mei_dev_kind mei_cfg_kind_gscfi(const struct device *parent)
{
return MEI_DEV_KIND_GSCFI;
}
#define MEI_CFG_KIND_GSCFI \
.get_kind = mei_cfg_kind_gscfi
#define MEI_CFG_FW_VER_SUPP \
.fw_ver_supported = 1
@@ -1630,27 +1653,32 @@ static bool mei_me_fw_type_sps_ign(const struct pci_dev *pdev)
/* ICH Legacy devices */
static const struct mei_cfg mei_me_ich_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_ICH_HFS,
};
/* ICH devices */
static const struct mei_cfg mei_me_ich10_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_ICH10_HFS,
};
/* PCH6 devices */
static const struct mei_cfg mei_me_pch6_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH_HFS,
};
/* PCH7 devices */
static const struct mei_cfg mei_me_pch7_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH_HFS,
MEI_CFG_FW_VER_SUPP,
};
/* PCH Cougar Point and Patsburg with quirk for Node Manager exclusion */
static const struct mei_cfg mei_me_pch_cpt_pbg_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_FW_NM,
@@ -1658,6 +1686,7 @@ static const struct mei_cfg mei_me_pch_cpt_pbg_cfg = {
/* PCH8 Lynx Point and newer devices */
static const struct mei_cfg mei_me_pch8_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
};
@@ -1671,6 +1700,7 @@ static const struct mei_cfg mei_me_pch8_itouch_cfg = {
/* PCH8 Lynx Point with quirk for SPS Firmware exclusion */
static const struct mei_cfg mei_me_pch8_sps_4_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_FW_SPS_4,
@@ -1678,6 +1708,7 @@ static const struct mei_cfg mei_me_pch8_sps_4_cfg = {
/* LBG with quirk for SPS (4.0) Firmware exclusion */
static const struct mei_cfg mei_me_pch12_sps_4_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_FW_SPS_4,
@@ -1685,6 +1716,7 @@ static const struct mei_cfg mei_me_pch12_sps_4_cfg = {
/* Cannon Lake and newer devices */
static const struct mei_cfg mei_me_pch12_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_DMA_128,
@@ -1692,6 +1724,7 @@ static const struct mei_cfg mei_me_pch12_cfg = {
/* Cannon Lake with quirk for SPS 5.0 and newer Firmware exclusion */
static const struct mei_cfg mei_me_pch12_sps_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_DMA_128,
@@ -1710,6 +1743,7 @@ static const struct mei_cfg mei_me_pch12_itouch_sps_cfg = {
/* Tiger Lake and newer devices */
static const struct mei_cfg mei_me_pch15_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_DMA_128,
@@ -1718,6 +1752,7 @@ static const struct mei_cfg mei_me_pch15_cfg = {
/* Tiger Lake with quirk for SPS 5.0 and newer Firmware exclusion */
static const struct mei_cfg mei_me_pch15_sps_cfg = {
MEI_CFG_KIND_MEI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
MEI_CFG_DMA_128,
@@ -1727,21 +1762,21 @@ static const struct mei_cfg mei_me_pch15_sps_cfg = {
/* Graphics System Controller */
static const struct mei_cfg mei_me_gsc_cfg = {
MEI_CFG_TYPE_GSC,
MEI_CFG_KIND_GSC,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
};
/* Graphics System Controller Firmware Interface */
static const struct mei_cfg mei_me_gscfi_cfg = {
MEI_CFG_TYPE_GSCFI,
MEI_CFG_KIND_GSCFI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
};
/* Chassis System Controller Firmware Interface */
static const struct mei_cfg mei_me_csc_cfg = {
MEI_CFG_TYPE_GSCFI,
MEI_CFG_KIND_GSCFI,
MEI_CFG_PCH8_HFS,
MEI_CFG_FW_VER_SUPP,
};
@@ -1812,7 +1847,7 @@ struct mei_device *mei_me_dev_init(struct device *parent,
dev->fw_f_fw_ver_supported = cfg->fw_ver_supported;
dev->kind = cfg->kind;
dev->kind = cfg->get_kind(parent);
return dev;
}

View File

@@ -19,7 +19,7 @@
*
* @fw_status: FW status
* @quirk_probe: device exclusion quirk
* @kind: MEI head kind
* @get_kind: MEI head kind helper
* @dma_size: device DMA buffers size
* @fw_ver_supported: is fw version retrievable from FW
* @hw_trc_supported: does the hw support trc register
@@ -27,7 +27,7 @@
struct mei_cfg {
const struct mei_fw_status fw_status;
bool (*quirk_probe)(const struct pci_dev *pdev);
const char *kind;
enum mei_dev_kind (*get_kind)(const struct device *parent);
size_t dma_size[DMA_DSCR_NUM];
u32 fw_ver_supported:1;
u32 hw_trc_supported:1;

View File

@@ -1165,6 +1165,15 @@ void mei_set_devstate(struct mei_device *dev, enum mei_dev_state state)
}
}
static const char * const mei_kind_names[] = {
"mei",
"itouch",
"gsc",
"gscfi",
"ivsc",
};
static_assert(ARRAY_SIZE(mei_kind_names) == MEI_DEV_KIND_MAX);
/**
* kind_show - display device kind
*
@@ -1178,14 +1187,11 @@ static ssize_t kind_show(struct device *device,
struct device_attribute *attr, char *buf)
{
struct mei_device *dev = dev_get_drvdata(device);
ssize_t ret;
if (dev->kind)
ret = sprintf(buf, "%s\n", dev->kind);
else
ret = sprintf(buf, "%s\n", "mei");
if (dev->kind < MEI_DEV_KIND_MEI || dev->kind >= MEI_DEV_KIND_MAX)
return -EINVAL;
return ret;
return sysfs_emit(buf, "%s\n", mei_kind_names[dev->kind]);
}
static DEVICE_ATTR_RO(kind);

View File

@@ -469,6 +469,25 @@ struct mei_dev_timeouts {
unsigned long link_reset_wait; /* link reset wait timeout, in jiffies */
};
/**
* enum mei_dev_kind - device type
*
* @MEI_DEV_KIND_MEI: basic device
* @MEI_DEV_KIND_ITOUCH: itouch support
* @MEI_DEV_KIND_GSC: discete graphics content protection
* @MEI_DEV_KIND_GSCFI: discete graphics chassis controller
* @MEI_DEV_KIND_IVSC: visual sensing controller
* @MEI_DEV_KIND_MAX: sentinel
*/
enum mei_dev_kind {
MEI_DEV_KIND_MEI,
MEI_DEV_KIND_ITOUCH,
MEI_DEV_KIND_GSC,
MEI_DEV_KIND_GSCFI,
MEI_DEV_KIND_IVSC,
MEI_DEV_KIND_MAX
};
/**
* struct mei_device - MEI private device struct
*
@@ -650,7 +669,7 @@ struct mei_device {
struct list_head device_list;
struct mutex cl_bus_lock;
const char *kind;
enum mei_dev_kind kind;
#if IS_ENABLED(CONFIG_DEBUG_FS)
struct dentry *dbgfs_dir;
@@ -911,8 +930,7 @@ static inline ssize_t mei_fw_status_str(struct mei_device *dev,
*/
static inline bool kind_is_gsc(struct mei_device *dev)
{
/* check kind for NULL because it may be not set, like at the fist call to hw_start */
return dev->kind && (strcmp(dev->kind, "gsc") == 0);
return dev->kind == MEI_DEV_KIND_GSC;
}
/**
@@ -924,7 +942,6 @@ static inline bool kind_is_gsc(struct mei_device *dev)
*/
static inline bool kind_is_gscfi(struct mei_device *dev)
{
/* check kind for NULL because it may be not set, like at the fist call to hw_start */
return dev->kind && (strcmp(dev->kind, "gscfi") == 0);
return dev->kind == MEI_DEV_KIND_GSCFI;
}
#endif

View File

@@ -84,6 +84,7 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err = -ENOMEM;
goto end;
}
dev->kind = MEI_DEV_KIND_MEI;
hw = to_txe_hw(dev);
hw->mem_addr = pcim_iomap_table(pdev);

View File

@@ -350,7 +350,7 @@ static int mei_vsc_probe(struct platform_device *pdev)
mei_device_init(mei_dev, dev, false, &mei_vsc_hw_ops);
mei_dev->fw_f_fw_ver_supported = 0;
mei_dev->kind = "ivsc";
mei_dev->kind = MEI_DEV_KIND_IVSC;
hw = mei_dev_to_vsc_hw(mei_dev);
atomic_set(&hw->write_lock_cnt, 0);