mei: expose device kind for ioe device
Subsystems (2)
Alexander Usyskin
maintainercover mei: expose device kind for ioe device
Add ability to distinguish between regular CSME HECI device and IO Extender device and set appropriate device kind.
Store device kind as enum instead of string to allow configuring it at probe.
Remove not needed trailing comma as follow-up.
Alexander Usyskin (3):
mei: store kind as enum
mei: expose device kind for ioe device
mei: me: remove comma from mei_cfg_idx sentinel
drivers/misc/mei/hw-me-regs.h | 4 ++ drivers/misc/mei/hw-me.c | 94 +++++++++++++++++++++++++++------ drivers/misc/mei/hw-me.h | 8 +-- drivers/misc/mei/main.c | 19 ++++--- drivers/misc/mei/mei_dev.h | 29 ++++++++-- drivers/misc/mei/pci-me.c | 2 +- drivers/misc/mei/pci-txe.c | 1 + drivers/misc/mei/platform-vsc.c | 2 +- 8 files changed, 127 insertions(+), 32 deletions(-)
Signature · 1 line
2.43.0
Alexander Usyskin
maintainerPATCH 1/3 mei: store kind as enum
Simplify flows and prepare for future flexibility by storing kind as enum and converting to string only in sysfs.
--- drivers/misc/mei/hw-me.c | 59 ++++++++++++++++++++++++++------- drivers/misc/mei/hw-me.h | 4 +-- drivers/misc/mei/main.c | 18 ++++++---- drivers/misc/mei/mei_dev.h | 27 ++++++++++++--- drivers/misc/mei/pci-txe.c | 1 + drivers/misc/mei/platform-vsc.c | 2 +- 6 files changed, 85 insertions(+), 26 deletions(-)
drivers/misc/mei/hw-me.c +47 -12
@@ -1584,17 +1584,40 @@ 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_FW_SPS_IGN \ + .quirk_probe = mei_me_fw_type_sps_ign -#define MEI_CFG_TYPE_GSC \ - .kind = "gsc" +static enum mei_dev_kind mei_cfg_kind_mei (const struct device *parent) +{ +return MEI_DEV_KIND_MEI ; +} -#define MEI_CFG_TYPE_GSCFI \ - .kind = "gscfi" +#define MEI_CFG_KIND_MEI \ + .get_kind = mei_cfg_kind_mei -#define MEI_CFG_FW_SPS_IGN \ - .quirk_probe = mei_me_fw_type_sps_ign +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; }
drivers/misc/mei/hw-me.h +2 -2
@@ -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 ;
drivers/misc/mei/main.c +12 -6
@@ -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);
drivers/misc/mei/mei_dev.h +22 -5
@@ -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
drivers/misc/mei/pci-txe.c +1 -0
@@ -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);
drivers/misc/mei/platform-vsc.c +1 -1
@@ -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 );
Signature · 1 line
2.43.0
Alexander Usyskin
maintainerPATCH 2/3 mei: expose device kind for ioe device
In reply to Alexander UsyskinDetect IO extender device and set appropriate kind.
--- drivers/misc/mei/hw-me-regs.h | 4 ++++ drivers/misc/mei/hw-me.c | 35 +++++++++++++++++++++++++++++++---- drivers/misc/mei/hw-me.h | 2 ++ drivers/misc/mei/main.c | 1 + drivers/misc/mei/mei_dev.h | 2 ++ drivers/misc/mei/pci-me.c | 2 +- 6 files changed, 41 insertions(+), 5 deletions(-)
drivers/misc/mei/hw-me-regs.h +4 -0
@@ -6,6 +6,8 @@#ifndef _MEI_HW_MEI_REGS_H_#define _MEI_HW_MEI_REGS_H_ +#include <linux/bits.h> +/* * MEI device IDs */
@@ -142,6 +144,8 @@# define PCI_CFG_HFS_2_PM_CM_RESET_ERROR 0x5000000/* CME reset due to exception */ # define PCI_CFG_HFS_2_PM_EVENT_MASK 0xf000000#define PCI_CFG_HFS_3 0x60 +# define PCI_CFG_HFS_3_EXT_SKU_MSK GENMASK(3, 0)/* IOE detection bits */ +# define PCI_CFG_HFS_3_EXT_SKU_IOE 0x00000001# define PCI_CFG_HFS_3_FW_SKU_MSK 0x00000070# define PCI_CFG_HFS_3_FW_SKU_IGN 0x00000000# define PCI_CFG_HFS_3_FW_SKU_SPS 0x00000060
drivers/misc/mei/hw-me.c +31 -4
@@ -4,13 +4,13 @@* Intel Management Engine Interface (Intel MEI) Linux driver */ -#include <linux/pci.h> - -#include <linux/kthread.h> +#include <linux/bitfield.h> +#include <linux/delay.h> #include <linux/interrupt.h> +#include <linux/kthread.h> +#include <linux/pci.h> #include <linux/pm_runtime.h> #include <linux/sizes.h> -#include <linux/delay.h> #include "mei_dev.h" #include "hbm.h"
@@ -1619,6 +1619,23 @@ static enum mei_dev_kind mei_cfg_kind_gscfi(const struct device *parent)#define MEI_CFG_KIND_GSCFI \ .get_kind = mei_cfg_kind_gscfi +static enum mei_dev_kind mei_cfg_kind_ioe (const struct device *parent) +{ +const struct pci_dev *pdev =to_pci_dev (parent); +unsigned int devfn; +u32 reg; +int ret; + + devfn =PCI_DEVFN (PCI_SLOT (pdev->devfn),0 ); + ret =pci_bus_read_config_dword (pdev->bus, devfn,PCI_CFG_HFS_3 , ®); +trace_mei_pci_cfg_read (parent,"PCI_CFG_HFS_3" ,PCI_CFG_HFS_3 , reg, ret); +return FIELD_GET (PCI_CFG_HFS_3_EXT_SKU_MSK , reg) ==PCI_CFG_HFS_3_EXT_SKU_IOE ? +MEI_DEV_KIND_IOE :MEI_DEV_KIND_MEI ; +} + +#define MEI_CFG_KIND_IOE \ + .get_kind = mei_cfg_kind_ioe +#define MEI_CFG_FW_VER_SUPP \ .fw_ver_supported = 1
@@ -1781,6 +1798,15 @@ static const struct mei_cfg mei_me_csc_cfg = { MEI_CFG_FW_VER_SUPP, }; +/* Nova Lake with possible IOE devices */ +static const struct mei_cfg mei_me_pch22_ioe_cfg = { +MEI_CFG_KIND_IOE , +MEI_CFG_PCH8_HFS , +MEI_CFG_FW_VER_SUPP , +MEI_CFG_DMA_128 , +MEI_CFG_TRC , +}; +/* * mei_cfg_list - A list of platform platform specific configurations. * Note: has to be synchronized with enum mei_cfg_idx.
@@ -1804,6 +1830,7 @@ static const struct mei_cfg *const mei_cfg_list[] = { [MEI_ME_GSC_CFG] = &mei_me_gsc_cfg, [MEI_ME_GSCFI_CFG] = &mei_me_gscfi_cfg, [MEI_ME_CSC_CFG] = &mei_me_csc_cfg, + [MEI_ME_PCH22_IOE_CFG] = &mei_me_pch22_ioe_cfg, };const struct mei_cfg *mei_me_get_cfg (kernel_ulong_t idx)
drivers/misc/mei/hw-me.h +2 -0
@@ -105,6 +105,7 @@ static inline bool mei_me_hw_use_polling(const struct mei_me_hw *hw)* @MEI_ME_GSC_CFG: Graphics System Controller * @MEI_ME_GSCFI_CFG: Graphics System Controller Firmware Interface * @MEI_ME_CSC_CFG: Chassis System Controller Firmware Interface +* @MEI_ME_PCH22_IOE_CFG: Platform Controller Hub Gen22 and newer with IOE detection * @MEI_ME_NUM_CFG: Upper Sentinel. */ enum mei_cfg_idx {
@@ -126,6 +127,7 @@ enum mei_cfg_idx {MEI_ME_GSC_CFG ,MEI_ME_GSCFI_CFG ,MEI_ME_CSC_CFG , +MEI_ME_PCH22_IOE_CFG , MEI_ME_NUM_CFG, };
drivers/misc/mei/main.c +1 -0
@@ -1171,6 +1171,7 @@ static const char * const mei_kind_names[] = {"gsc" ,"gscfi" ,"ivsc" , +"ioe" , };static_assert (ARRAY_SIZE (mei_kind_names) ==MEI_DEV_KIND_MAX );
drivers/misc/mei/mei_dev.h +2 -0
@@ -477,6 +477,7 @@ struct mei_dev_timeouts {* @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_IOE: IO extender * @MEI_DEV_KIND_MAX: sentinel */ enum mei_dev_kind {
@@ -485,6 +486,7 @@ enum mei_dev_kind {MEI_DEV_KIND_GSC ,MEI_DEV_KIND_GSCFI ,MEI_DEV_KIND_IVSC , +MEI_DEV_KIND_IOE , MEI_DEV_KIND_MAX };
drivers/misc/mei/pci-me.c +1 -1
@@ -130,7 +130,7 @@ static const struct pci_device_id mei_me_pci_tbl[] = { {PCI_DEVICE_DATA(INTEL, MEI_WCL_P, MEI_ME_PCH15_CFG)}, - {PCI_DEVICE_DATA(INTEL, MEI_NVL_S, MEI_ME_PCH15_CFG)}, + {PCI_DEVICE_DATA(INTEL, MEI_NVL_S, MEI_ME_PCH22_IOE_CFG)}, {PCI_DEVICE_DATA(INTEL, MEI_NVL_H, MEI_ME_PCH15_CFG)},/* required last entry */
Signature · 1 line
2.43.0
Alexander Usyskin
maintainerPATCH 3/3 mei: me: remove comma from mei_cfg_idx sentinel
In reply to Alexander UsyskinAdhere to termnator line rule and remove comma from sentinel in enum mei_cfg_idx.
--- drivers/misc/mei/hw-me.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/hw-me.h +1 -1
@@ -128,7 +128,7 @@ enum mei_cfg_idx {MEI_ME_GSCFI_CFG ,MEI_ME_CSC_CFG ,MEI_ME_PCH22_IOE_CFG , - MEI_ME_NUM_CFG, + MEI_ME_NUM_CFG };const struct mei_cfg *mei_me_get_cfg (kernel_ulong_t idx);
Signature · 1 line
2.43.0