GSC support for XeHP SDV and DG2 platforms
Alexander Usyskin
maintainercover GSC support for XeHP SDV and DG2 platforms
Add GSC support for XeHP SDV and DG2 platforms.
The series includes changes for the mei driver:
- add ability to use polling instead of interrupts
- add ability to use extended timeouts
- setup extended operational memory for GSC
The series includes changes for the i915 driver:
- allocate extended operational memory for GSC
- GSC on XeHP SDV offsets and definitions
- GSC on DG2 offsets and definitions
The first six patches of the series are copied from the already reviewed series [1] to provide series that can be built in CI.
This series will be rebased and merged only after series [1] merge.
Greg KH, please review and ACK the MEI patches. We are pushing these patches through gfx tree as the auxiliary device belongs there.
[1] https://patchwork.freedesktop.org/series/102160/
Alexander Usyskin (7):
mei: gsc: setup char driver alive in spite of firmware handshake
failure
mei: gsc: retrieve the firmware version
drm/i915/gsc: add slow_fw flag to the mei auxiliary device drm/i915/gsc: add slow_fw flag to the gsc device definition drm/i915/gsc: add GSC XeHP SDV platform definition
mei: gsc: wait for reset thread on stop
mei: extend timeouts on slow devices.
Daniele Ceraolo Spurio (1):
HAX: drm/i915: force INTEL_MEI_GSC on for CI
Tomas Winkler (9):
drm/i915/gsc: add gsc as a mei auxiliary device
mei: add support for graphics system controller (gsc) devices
mei: gsc: add runtime pm handlers
mei: gsc: use polling instead of interrupts drm/i915/dg2: add gsc with special gsc bar offsets
mei: mkhi: add memory ready command
mei: gsc: setup gsc extended operational memory
mei: debugfs: add pxp mode to devstate in debugfs drm/i915/gsc: allocate extended operational memory in LMEM
Vitaly Lubart (3):
drm/i915/gsc: skip irq initialization if using polling
mei: bus: export common mkhi definitions into a separate header
mei: gsc: add transition to PXP mode in resume flow
MAINTAINERS | 1 + drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/Kconfig.debug | 1 + drivers/gpu/drm/i915/Makefile | 3 + drivers/gpu/drm/i915/gt/intel_gsc.c | 323 +++++++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_gsc.h | 40 +++ drivers/gpu/drm/i915/gt/intel_gt.c | 3 + drivers/gpu/drm/i915/gt/intel_gt.h | 5 + drivers/gpu/drm/i915/gt/intel_gt_irq.c | 13 + drivers/gpu/drm/i915/gt/intel_gt_regs.h | 1 + drivers/gpu/drm/i915/gt/intel_gt_types.h | 2 + drivers/gpu/drm/i915/i915_drv.h | 8 + drivers/gpu/drm/i915/i915_pci.c | 4 +- drivers/gpu/drm/i915/i915_reg.h | 4 + drivers/gpu/drm/i915/intel_device_info.h | 2 + drivers/misc/mei/Kconfig | 14 + drivers/misc/mei/Makefile | 3 + drivers/misc/mei/bus-fixup.c | 128 ++++++--- drivers/misc/mei/client.c | 14 +- drivers/misc/mei/debugfs.c | 17 ++ drivers/misc/mei/gsc-me.c | 316 ++++++++++++++++++++++ drivers/misc/mei/hbm.c | 12 +- drivers/misc/mei/hw-me-regs.h | 7 + drivers/misc/mei/hw-me.c | 145 ++++++++-- drivers/misc/mei/hw-me.h | 16 +- drivers/misc/mei/hw-txe.c | 2 +- drivers/misc/mei/hw.h | 5 + drivers/misc/mei/init.c | 21 +- drivers/misc/mei/main.c | 2 +- drivers/misc/mei/mei_dev.h | 26 ++ drivers/misc/mei/mkhi.h | 57 ++++ drivers/misc/mei/pci-me.c | 2 +- include/linux/mei_aux.h | 21 ++ 33 files changed, 1146 insertions(+), 73 deletions(-) create mode 100644 drivers/gpu/drm/i915/gt/intel_gsc.c create mode 100644 drivers/gpu/drm/i915/gt/intel_gsc.h create mode 100644 drivers/misc/mei/gsc-me.c create mode 100644 drivers/misc/mei/mkhi.h create mode 100644 include/linux/mei_aux.h
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 1/20 drm/i915/gsc: add gsc as a mei auxiliary device
From: Tomas Winkler <[email protected]>
GSC is a graphics system controller, it provides
a chassis controller for graphics discrete cards.
There are two MEI interfaces in GSC: HECI1 and HECI2.
Both interfaces are on the BAR0 at offsets 0x00258000 and 0x00259000. GSC is a GT Engine (class 4: instance 6). HECI1 interrupt is signaled via bit 15 and HECI2 via bit 14 in the interrupt register.
This patch exports GSC as auxiliary device for mei driver to bind to for HECI2 interface and prepares for HECI1 interface as it will follow up soon.
--- MAINTAINERS | 1 + drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/Makefile | 3 + drivers/gpu/drm/i915/gt/intel_gsc.c | 204 +++++++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_gsc.h | 37 ++++ drivers/gpu/drm/i915/gt/intel_gt.c | 3 + drivers/gpu/drm/i915/gt/intel_gt.h | 5 + drivers/gpu/drm/i915/gt/intel_gt_irq.c | 13 ++ drivers/gpu/drm/i915/gt/intel_gt_regs.h | 1 + drivers/gpu/drm/i915/gt/intel_gt_types.h | 2 + drivers/gpu/drm/i915/i915_drv.h | 8 + drivers/gpu/drm/i915/i915_pci.c | 3 +- drivers/gpu/drm/i915/i915_reg.h | 2 + drivers/gpu/drm/i915/intel_device_info.h | 2 + include/linux/mei_aux.h | 19 +++ 15 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/i915/gt/intel_gsc.c create mode 100644 drivers/gpu/drm/i915/gt/intel_gsc.h create mode 100644 include/linux/mei_aux.h
MAINTAINERS +1 -0
@@ -9995,6 +9995,7 @@ S: Supported F: Documentation/driver-api/mei/* F: drivers/misc/mei/ F: drivers/watchdog/mei_wdt.c +F: include/linux/mei_aux.h F: include/linux/mei_cl_bus.h F: include/uapi/linux/mei.h F: samples/mei/*
drivers/gpu/drm/i915/Kconfig +1 -0
@@ -30,6 +30,7 @@ config DRM_I915 select VMAP_PFN select DRM_TTM select DRM_BUDDY + select AUXILIARY_BUS help Choose this option if you have a system that has "Intel Graphics Media Accelerator" or "HD Graphics" integrated graphics,
drivers/gpu/drm/i915/Makefile +3 -0
@@ -204,6 +204,9 @@ i915-y += gt/uc/intel_uc.o \ gt/uc/intel_huc_debugfs.o \ gt/uc/intel_huc_fw.o +# graphics system controller (GSC) support +i915-y += gt/intel_gsc.o + # modesetting core code i915-y += \ display/hsw_ips.o \
drivers/gpu/drm/i915/gt/intel_gsc.c new file +204 -0
204 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_gsc.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright(c) 2019-2022, Intel Corporation. All rights reserved. +*/ +#ifndef __INTEL_GSC_DEV_H__ +#define __INTEL_GSC_DEV_H__ + +#include <linux/types.h> + +struct drm_i915_private ; +struct intel_gt ; +struct mei_aux_device ; + +#define INTEL_GSC_NUM_INTERFACES 2 +/* +* The HECI1 bit corresponds to bit15 and HECI2 to bit14. +* The reason for this is to allow growth for more interfaces in the future. +*/ +#define GSC_IRQ_INTF (_x) BIT(15 - (_x)) + +/** +* struct intel_gsc - graphics security controller +* @intf : gsc interface +*/ +struct intel_gsc { +struct intel_gsc_intf { +struct mei_aux_device *adev; +int irq; +unsigned int id; + } intf[INTEL_GSC_NUM_INTERFACES ]; +}; + +void intel_gsc_init (struct intel_gsc *gsc,struct drm_i915_private *dev_priv); +void intel_gsc_fini (struct intel_gsc *gsc); +void intel_gsc_irq_handler (struct intel_gt *gt,u32 iir); + +#endif /* __INTEL_GSC_DEV_H__ */
drivers/gpu/drm/i915/gt/intel_gt.c +3 -0
@@ -456,6 +456,8 @@ void intel_gt_chipset_flush(struct intel_gt *gt)void intel_gt_driver_register (struct intel_gt *gt) { +intel_gsc_init (>->gsc, gt->i915); +intel_rps_driver_register (>->rps);intel_gt_debugfs_register (gt);
@@ -784,6 +786,7 @@ void intel_gt_driver_unregister(struct intel_gt *gt)intel_wakeref_t wakeref;intel_rps_driver_unregister (>->rps); +intel_gsc_fini (>->gsc);intel_pxp_fini (>->pxp);
drivers/gpu/drm/i915/gt/intel_gt.h +5 -0
@@ -46,6 +46,11 @@ static inline struct intel_gt *huc_to_gt(struct intel_huc *huc) return container_of(huc, struct intel_gt, uc.huc); } +static inline struct intel_gt *gsc_to_gt (struct intel_gsc *gsc) +{ + return container_of(gsc, struct intel_gt, gsc); +} +void intel_root_gt_init_early (struct drm_i915_private *i915);int intel_gt_assign_ggtt (struct intel_gt *gt);int intel_gt_init_mmio (struct intel_gt *gt);
drivers/gpu/drm/i915/gt/intel_gt_irq.c +13 -0
@@ -68,6 +68,9 @@ gen11_other_irq_handler(struct intel_gt *gt, const u8 instance,if (instance ==OTHER_KCR_INSTANCE )return intel_pxp_irq_handler (>->pxp, iir); +if (instance ==OTHER_GSC_INSTANCE ) +return intel_gsc_irq_handler (gt, iir); +WARN_ONCE (1 ,"unhandled other interrupt instance=0x%x, iir=0x%x\n" , instance, iir); }
@@ -184,6 +187,8 @@ void gen11_gt_irq_reset(struct intel_gt *gt)intel_uncore_write (uncore,GEN11_VCS_VECS_INTR_ENABLE ,0 );if (CCS_MASK (gt))intel_uncore_write (uncore,GEN12_CCS_RSVD_INTR_ENABLE ,0 ); +if (HAS_HECI_GSC (gt->i915)) +intel_uncore_write (uncore,GEN11_GUNIT_CSME_INTR_ENABLE ,0 );/* Restore masks irqs on RCS, BCS, VCS and VECS engines. */ intel_uncore_write (uncore,GEN11_RCS0_RSVD_INTR_MASK , ~0 );
@@ -201,6 +206,8 @@ void gen11_gt_irq_reset(struct intel_gt *gt)intel_uncore_write (uncore,GEN12_CCS0_CCS1_INTR_MASK , ~0 );if (HAS_ENGINE (gt,CCS2 ) ||HAS_ENGINE (gt,CCS3 ))intel_uncore_write (uncore,GEN12_CCS2_CCS3_INTR_MASK , ~0 ); +if (HAS_HECI_GSC (gt->i915)) +intel_uncore_write (uncore,GEN11_GUNIT_CSME_INTR_MASK , ~0 );intel_uncore_write (uncore,GEN11_GPM_WGBOXPERF_INTR_ENABLE ,0 );intel_uncore_write (uncore,GEN11_GPM_WGBOXPERF_INTR_MASK , ~0 );
@@ -215,6 +222,7 @@ void gen11_gt_irq_postinstall(struct intel_gt *gt) {struct intel_uncore *uncore = gt->uncore;u32 irqs =GT_RENDER_USER_INTERRUPT ; +const u32 gsc_mask =GSC_IRQ_INTF (0 ) |GSC_IRQ_INTF (1 );u32 dmask;u32 smask;
@@ -233,6 +241,9 @@ void gen11_gt_irq_postinstall(struct intel_gt *gt)intel_uncore_write (uncore,GEN11_VCS_VECS_INTR_ENABLE , dmask);if (CCS_MASK (gt))intel_uncore_write (uncore,GEN12_CCS_RSVD_INTR_ENABLE , smask); +if (HAS_HECI_GSC (gt->i915)) +intel_uncore_write (uncore,GEN11_GUNIT_CSME_INTR_ENABLE , + gsc_mask);/* Unmask irqs on RCS, BCS, VCS and VECS engines. */ intel_uncore_write (uncore,GEN11_RCS0_RSVD_INTR_MASK , ~smask);
@@ -250,6 +261,8 @@ void gen11_gt_irq_postinstall(struct intel_gt *gt)intel_uncore_write (uncore,GEN12_CCS0_CCS1_INTR_MASK , ~dmask);if (HAS_ENGINE (gt,CCS2 ) ||HAS_ENGINE (gt,CCS3 ))intel_uncore_write (uncore,GEN12_CCS2_CCS3_INTR_MASK , ~dmask); +if (HAS_HECI_GSC (gt->i915)) +intel_uncore_write (uncore,GEN11_GUNIT_CSME_INTR_MASK , ~gsc_mask);/* * RPS interrupts will get enabled/disabled on demand when RPS itself
drivers/gpu/drm/i915/gt/intel_gt_regs.h +1 -0
@@ -1484,6 +1484,7 @@#define OTHER_GUC_INSTANCE 0#define OTHER_GTPM_INSTANCE 1#define OTHER_KCR_INSTANCE 4 +#define OTHER_GSC_INSTANCE 6#define GEN11_IIR_REG_SELECTOR (x) _MMIO(0x190070 + ((x) * 4))
drivers/gpu/drm/i915/gt/intel_gt_types.h +2 -0
@@ -16,6 +16,7 @@#include <linux/workqueue.h> #include "uc/intel_uc.h" +#include "intel_gsc.h" #include "i915_vma.h" #include "intel_engine_types.h"
@@ -73,6 +74,7 @@ struct intel_gt {struct i915_ggtt *ggtt;struct intel_uc uc; +struct intel_gsc gsc;struct mutex tlb_invalidate_lock;
drivers/gpu/drm/i915/i915_drv.h +8 -0
@@ -1307,6 +1307,14 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,#define HAS_DMC (dev_priv) (INTEL_INFO(dev_priv)->display.has_dmc) +#define HAS_HECI_PXP (dev_priv) \ + (INTEL_INFO(dev_priv)->has_heci_pxp) + +#define HAS_HECI_GSCFI (dev_priv) \ + (INTEL_INFO(dev_priv)->has_heci_gscfi) + +#define HAS_HECI_GSC (dev_priv) (HAS_HECI_PXP(dev_priv) || HAS_HECI_GSCFI(dev_priv)) +#define HAS_MSO (i915) (DISPLAY_VER(i915) >= 12)#define HAS_RUNTIME_PM (dev_priv) (INTEL_INFO(dev_priv)->has_runtime_pm)
drivers/gpu/drm/i915/i915_pci.c +2 -1
@@ -901,7 +901,8 @@ static const struct intel_device_info rkl_info = { .has_llc = 0, \ .has_pxp = 0, \ .has_snoop = 1, \ - .is_dgfx = 1 + .is_dgfx = 1, \ + .has_heci_gscfi = 1 static const struct intel_device_info dg1_info = {GEN12_FEATURES ,
drivers/gpu/drm/i915/i915_reg.h +2 -0
@@ -976,6 +976,8 @@#define GEN12_COMPUTE2_RING_BASE 0x1e000#define GEN12_COMPUTE3_RING_BASE 0x26000#define BLT_RING_BASE 0x22000 +#define DG1_GSC_HECI1_BASE 0x00258000 +#define DG1_GSC_HECI2_BASE 0x00259000
drivers/gpu/drm/i915/intel_device_info.h +2 -0
@@ -141,6 +141,8 @@ enum intel_ppgtt_type {func (has_flat_ccs); \func (has_global_mocs); \func (has_gt_uc); \ +func (has_heci_pxp); \ +func (has_heci_gscfi); \func (has_guc_deprivilege); \func (has_l3_dpf); \func (has_llc); \
include/linux/mei_aux.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2022, Intel Corporation. All rights reserved. +*/ +#ifndef _LINUX_MEI_AUX_H +#define _LINUX_MEI_AUX_H + +#include <linux/auxiliary_bus.h> + +struct mei_aux_device { +struct auxiliary_device aux_dev; +int irq; +struct resource bar; +}; + +#define auxiliary_dev_to_mei_aux_dev (auxiliary_dev) \ + container_of(auxiliary_dev, struct mei_aux_device, aux_dev) + +#endif /* _LINUX_MEI_AUX_H */
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 2/20 mei: add support for graphics system controller (gsc) devices
In reply to Alexander UsyskinFrom: Tomas Winkler <[email protected]>
GSC is a graphics system controller, based on CSE, it provides a chassis controller for graphics discrete cards, as well as it supports media protection on selected devices.
mei_gsc binds to a auxiliary devices exposed by Intel discrete driver i915.
--- drivers/misc/mei/Kconfig | 14 +++ drivers/misc/mei/Makefile | 3 + drivers/misc/mei/gsc-me.c | 194 ++++++++++++++++++++++++++++++++++++++ drivers/misc/mei/hw-me.c | 27 +++++- drivers/misc/mei/hw-me.h | 2 + 5 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 drivers/misc/mei/gsc-me.c
drivers/misc/mei/Kconfig +14 -0
@@ -46,6 +46,20 @@ config INTEL_MEI_TXE Supported SoCs: Intel Bay Trail +config INTEL_MEI_GSC + tristate "Intel MEI GSC embedded device" + depends on INTEL_MEI + depends on INTEL_MEI_ME + depends on X86 && PCI + depends on DRM_I915 + help + Intel auxiliary driver for GSC devices embedded in Intel graphics devices. + + An MEI device here called GSC can be embedded in an + Intel graphics devices, to support a range of chassis + tasks such as graphics card firmware update and security + tasks. + source "drivers/misc/mei/hdcp/Kconfig" source "drivers/misc/mei/pxp/Kconfig"
drivers/misc/mei/Makefile +3 -0
@@ -18,6 +18,9 @@ obj-$(CONFIG_INTEL_MEI_ME) += mei-me.o mei-me-objs := pci-me.o mei-me-objs += hw-me.o +obj-$(CONFIG_INTEL_MEI_GSC) += mei-gsc.o +mei-gsc-objs := gsc-me.o + obj-$(CONFIG_INTEL_MEI_TXE) += mei-txe.o mei-txe-objs := pci-txe.o mei-txe-objs += hw-txe.o
drivers/misc/mei/gsc-me.c new file +194 -0
194 lines not on this page · raw message
drivers/misc/mei/hw-me.c +25 -2
@@ -1226,6 +1226,7 @@ irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id)me_intr_disable (dev, hcsr);return IRQ_WAKE_THREAD ; } +EXPORT_SYMBOL_GPL (mei_me_irq_quick_handler);/** * mei_me_irq_thread_handler - function called after ISR to handle the interrupt
@@ -1326,6 +1327,7 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)mutex_unlock (&dev->device_lock);return IRQ_HANDLED ; } +EXPORT_SYMBOL_GPL (mei_me_irq_thread_handler);static const struct mei_hw_ops mei_me_hw_ops = {
@@ -1440,6 +1442,12 @@ static bool mei_me_fw_type_sps_ign(const struct pci_dev *pdev)#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
@@ -1572,6 +1580,18 @@ static const struct mei_cfg mei_me_pch15_sps_cfg = { MEI_CFG_FW_SPS_IGN, }; +/* Graphics System Controller */ +static const struct mei_cfg mei_me_gsc_cfg = { +MEI_CFG_TYPE_GSC , +MEI_CFG_PCH8_HFS , +}; + +/* Graphics System Controller Firmware Interface */ +static const struct mei_cfg mei_me_gscfi_cfg = { +MEI_CFG_TYPE_GSCFI , +MEI_CFG_PCH8_HFS , +}; +/* * mei_cfg_list - A list of platform platform specific configurations. * Note: has to be synchronized with enum mei_cfg_idx.
@@ -1592,6 +1612,8 @@ static const struct mei_cfg *const mei_cfg_list[] = { [MEI_ME_PCH12_SPS_ITOUCH_CFG] = &mei_me_pch12_itouch_sps_cfg, [MEI_ME_PCH15_CFG] = &mei_me_pch15_cfg, [MEI_ME_PCH15_SPS_CFG] = &mei_me_pch15_sps_cfg, + [MEI_ME_GSC_CFG] = &mei_me_gsc_cfg, + [MEI_ME_GSCFI_CFG] = &mei_me_gscfi_cfg, };const struct mei_cfg *mei_me_get_cfg (kernel_ulong_t idx)
@@ -1602,7 +1624,8 @@ const struct mei_cfg *mei_me_get_cfg(kernel_ulong_t idx)return NULL ;return mei_cfg_list[idx]; -}; +} +EXPORT_SYMBOL_GPL (mei_me_get_cfg);/** * mei_me_dev_init - allocates and initializes the mei device structure
@@ -1637,4 +1660,4 @@ struct mei_device *mei_me_dev_init(struct device *parent,return dev; } - +EXPORT_SYMBOL_GPL (mei_me_dev_init);
drivers/misc/mei/hw-me.h +2 -0
@@ -112,6 +112,8 @@ enum mei_cfg_idx {MEI_ME_PCH12_SPS_ITOUCH_CFG ,MEI_ME_PCH15_CFG ,MEI_ME_PCH15_SPS_CFG , +MEI_ME_GSC_CFG , +MEI_ME_GSCFI_CFG , MEI_ME_NUM_CFG, };
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 3/20 mei: gsc: setup char driver alive in spite of firmware handshake failure
In reply to Alexander UsyskinSetup char device in spite of firmware handshake failure.
In order to provide host access to the firmware status registers and other information required for the manufacturing process.
--- drivers/misc/mei/gsc-me.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/misc/mei/gsc-me.c +6 -6
@@ -79,11 +79,12 @@ static int mei_gsc_probe(struct auxiliary_device *aux_dev,pm_runtime_set_active (device);pm_runtime_enable (device); -if (mei_start (dev)) { -dev_err (device,"init hw failure.\n" ); - ret = -ENODEV ; - goto irq_err; - } +/* Continue to char device setup in spite of firmware handshake failure. +* In order to provide access to the firmware status registers to the user +* space via sysfs. +*/ +if (mei_start (dev)) +dev_warn (device,"init hw failure.\n" );pm_runtime_set_autosuspend_delay (device,MEI_GSC_RPM_TIMEOUT );pm_runtime_use_autosuspend (device);
@@ -97,7 +98,6 @@ static int mei_gsc_probe(struct auxiliary_device *aux_dev, register_err:mei_stop (dev); -irq_err:devm_free_irq (device, hw->irq, dev); err:
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 4/20 mei: gsc: add runtime pm handlers
In reply to Alexander UsyskinFrom: Tomas Winkler <[email protected]>
Implement runtime handlers for mei-gsc, to track
idle state of the device properly.
--- drivers/misc/mei/gsc-me.c | 67 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-)
drivers/misc/mei/gsc-me.c +66 -1
@@ -159,7 +159,72 @@ static int __maybe_unused mei_gsc_pm_resume(struct device *device)return 0 ; } -static SIMPLE_DEV_PM_OPS(mei_gsc_pm_ops, mei_gsc_pm_suspend, mei_gsc_pm_resume); +static int __maybe_unused mei_gsc_pm_runtime_idle (struct device *device) +{ +struct mei_device *dev =dev_get_drvdata (device); + +if (!dev) +return -ENODEV ; +if (mei_write_is_idle (dev)) +pm_runtime_autosuspend (device); + +return -EBUSY ; +} + +static int __maybe_unused mei_gsc_pm_runtime_suspend (struct device *device) +{ +struct mei_device *dev =dev_get_drvdata (device); +struct mei_me_hw *hw; +int ret; + +if (!dev) +return -ENODEV ; + +mutex_lock (&dev->device_lock); + +if (mei_write_is_idle (dev)) { + hw =to_me_hw (dev); + hw->pg_state =MEI_PG_ON ; + ret =0 ; + }else { + ret = -EAGAIN ; + } + +mutex_unlock (&dev->device_lock); + +return ret; +} + +static int __maybe_unused mei_gsc_pm_runtime_resume (struct device *device) +{ +struct mei_device *dev =dev_get_drvdata (device); +struct mei_me_hw *hw; +irqreturn_t irq_ret; + +if (!dev) +return -ENODEV ; + +mutex_lock (&dev->device_lock); + + hw =to_me_hw (dev); + hw->pg_state =MEI_PG_OFF ; + +mutex_unlock (&dev->device_lock); + + irq_ret =mei_me_irq_thread_handler (1 , dev); +if (irq_ret !=IRQ_HANDLED ) +dev_err (dev->dev,"thread handler fail %d\n" , irq_ret); + +return 0 ; +} + +static const struct dev_pm_ops mei_gsc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mei_gsc_pm_suspend, + mei_gsc_pm_resume) +SET_RUNTIME_PM_OPS (mei_gsc_pm_runtime_suspend, + mei_gsc_pm_runtime_resume, + mei_gsc_pm_runtime_idle) +};static const struct auxiliary_device_id mei_gsc_id_table[] = { {
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 5/20 mei: gsc: retrieve the firmware version
In reply to Alexander UsyskinAdd a hook to retrieve the firmware version of the
GSC devices to bus-fixup.
GSC has a different MKHI clients GUIDs but the same message structure to retrieve the firmware version as MEI so mei_fwver() can be reused.
--- drivers/misc/mei/bus-fixup.c | 25 +++++++++++++++++++++++++ drivers/misc/mei/hw-me.c | 2 ++ 2 files changed, 27 insertions(+)
drivers/misc/mei/bus-fixup.c +25 -0
@@ -30,6 +30,12 @@ static const uuid_le mei_nfc_info_guid = MEI_UUID_NFC_INFO;#define MEI_UUID_MKHIF_FIX UUID_LE(0x55213584, 0x9a29, 0x4916, \ 0xba, 0xdf, 0xf, 0xb7, 0xed, 0x68, 0x2a, 0xeb) +#define MEI_UUID_IGSC_MKHI UUID_LE(0xE2C2AFA2, 0x3817, 0x4D19, \ + 0x9D, 0x95, 0x06, 0xB1, 0x6B, 0x58, 0x8A, 0x5D) + +#define MEI_UUID_IGSC_MKHI_FIX UUID_LE(0x46E0C1FB, 0xA546, 0x414F, \ + 0x91, 0x70, 0xB7, 0xF4, 0x6D, 0x57, 0xB4, 0xAD) +#define MEI_UUID_HDCP UUID_LE(0xB638AB7E, 0x94E2, 0x4EA2, \ 0xA5, 0x52, 0xD1, 0xC5, 0x4B, 0x62, 0x7F, 0x04)
@@ -241,6 +247,23 @@ static void mei_mkhi_fix(struct mei_cl_device *cldev)mei_cldev_disable (cldev); } +static void mei_gsc_mkhi_ver (struct mei_cl_device *cldev) +{ +int ret; + +/* No need to enable the client if nothing is needed from it */ +if (!cldev->bus->fw_f_fw_ver_supported) +return ; + + ret =mei_cldev_enable (cldev); +if (ret) +return ; + + ret =mei_fwver (cldev); +if (ret <0 ) +dev_err (&cldev->dev,"FW version command failed %d\n" , ret); +mei_cldev_disable (cldev); +}/** * mei_wd - wd client on the bus, change protocol version * as the API has changed.
@@ -492,6 +515,8 @@ static struct mei_fixup {MEI_FIXUP (MEI_UUID_NFC_HCI , mei_nfc),MEI_FIXUP (MEI_UUID_WD , mei_wd),MEI_FIXUP (MEI_UUID_MKHIF_FIX , mei_mkhi_fix), +MEI_FIXUP (MEI_UUID_IGSC_MKHI , mei_gsc_mkhi_ver), +MEI_FIXUP (MEI_UUID_IGSC_MKHI_FIX , mei_gsc_mkhi_ver),MEI_FIXUP (MEI_UUID_HDCP , whitelist),MEI_FIXUP (MEI_UUID_ANY , vt_support), MEI_FIXUP(MEI_UUID_PAVP, whitelist),
drivers/misc/mei/hw-me.c +2 -0
@@ -1584,12 +1584,14 @@ static const struct mei_cfg mei_me_pch15_sps_cfg = {static const struct mei_cfg mei_me_gsc_cfg = {MEI_CFG_TYPE_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_PCH8_HFS , +MEI_CFG_FW_VER_SUPP , };/*
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 6/20 HAX: drm/i915: force INTEL_MEI_GSC on for CI
In reply to Alexander UsyskinFrom: Daniele Ceraolo Spurio <[email protected]>
After the new config option is merged we'll enable it by default in the CI config, but for now just force it on via the i915 Kconfig so we can get pre-merge CI results for it.
--- drivers/gpu/drm/i915/Kconfig.debug | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/Kconfig.debug +1 -0
@@ -48,6 +48,7 @@ config DRM_I915_DEBUG select DRM_I915_DEBUG_RUNTIME_PM select DRM_I915_SW_FENCE_DEBUG_OBJECTS select DRM_I915_SELFTEST + select INTEL_MEI_GSC select BROKEN # for prototype uAPI default n help
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 7/20 drm/i915/gsc: skip irq initialization if using polling
In reply to Alexander UsyskinFrom: Vitaly Lubart <[email protected]>
If we use polling instead of interrupts,
irq initialization should be skipped.
--- drivers/gpu/drm/i915/gt/intel_gsc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gt/intel_gsc.c +7 -3
@@ -40,6 +40,7 @@ struct gsc_def {const char *name;unsigned long bar;size_t bar_size; +bool use_polling; };/* gsc resources and definitions (HECI1 and HECI2) */
@@ -97,6 +98,10 @@ static void gsc_init_one(struct drm_i915_private *i915,return ; } +/* skip irq initialization */ +if (def->use_polling) + goto add_device; + intf->irq =irq_alloc_desc (0 );if (intf->irq <0 ) {drm_err (&i915->drm,"gsc irq error %d\n" , intf->irq);
@@ -109,6 +114,7 @@ static void gsc_init_one(struct drm_i915_private *i915, goto fail; } +add_device: adev =kzalloc (sizeof (*adev),GFP_KERNEL );if (!adev) goto fail;
@@ -162,10 +168,8 @@ static void gsc_irq_handler(struct intel_gt *gt, unsigned int intf_id)return ; } -if (gt->gsc.intf[intf_id].irq <0 ) { -drm_err_ratelimited (>->i915->drm,"GSC irq: irq not set" ); +if (gt->gsc.intf[intf_id].irq <0 )return ; - } ret =generic_handle_irq (gt->gsc.intf[intf_id].irq);if (ret)
Signature · 1 line
2.32.0
Re: [Intel-gfx] [PATCH 07/20] drm/i915/gsc: skip irq initialization if using polling
Quoted 4 lines · Alexander Usyskin
From: Vitaly Lubart <[email protected]>
If we use polling instead of interrupts,
irq initialization should be skipped.
This needs at least a 1 line explanation if why we might need to use polling. Something like "some platforms require the host to poll on the GSC reply instead of relaying on the interrupts. For those platforms, irq initialization should be skipped."
Quoted 21 lines
Signed-off-by Vitaly Lubart <[email protected]>Signed-off-by Tomas Winkler <[email protected]>Signed-off-by Alexander Usyskin <[email protected]>--- drivers/gpu/drm/i915/gt/intel_gsc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/gt/intel_gsc.c +1
-0@@ -40,6 +40,7 @@ struct gsc_def {const char *name;unsigned long bar;size_t bar_size; +bool use_polling; };/* gsc resources and definitions (HECI1 and HECI2) */
drivers/gpu/drm/i915/gt/intel_gsc.c static void gsc_init_one(struct drm_i915_private *i915, · line 103
Quoted 6 lines
drivers/gpu/drm/i915/gt/intel_gsc.c +3
-0@@ -97,6 +98,10 @@ static void gsc_init_one(struct drm_i915_private *i915,return ; } +/* skip irq initialization */ +if (def->use_polling) + goto add_device;
We tend to limit the use of gotos to the error paths, so I'd prefer it if this was flipped to avoid it, i.e.:
if (!def->use_polling) {
/* set up irqs */
[...]
}
But not a blocker. With the commit message updated:
Daniele
Quoted 24 lines
drivers/gpu/drm/i915/gt/intel_gsc.c +3
-3+ intf->irq =irq_alloc_desc (0 );if (intf->irq <0 ) {drm_err (&i915->drm,"gsc irq error %d\n" , intf->irq);@@ -109,6 +114,7 @@ static void gsc_init_one(struct drm_i915_private *i915, goto fail; } +add_device: adev =kzalloc (sizeof (*adev),GFP_KERNEL );if (!adev) goto fail;@@ -162,10 +168,8 @@ static void gsc_irq_handler(struct intel_gt *gt, unsigned int intf_id)return ; } -if (gt->gsc.intf[intf_id].irq <0 ) { -drm_err_ratelimited (>->i915->drm,"GSC irq: irq not set" ); +if (gt->gsc.intf[intf_id].irq <0 )return ; - } ret =generic_handle_irq (gt->gsc.intf[intf_id].irq);if (ret)
Alexander Usyskin
maintainerPATCH 8/20 drm/i915/gsc: add slow_fw flag to the mei auxiliary device
In reply to Alexander UsyskinAdd slow_fw flag to the mei auxiliary device info to inform the mei driver about slow underlying firmware. Such firmware will require to use larger operation timeouts.
--- include/linux/mei_aux.h | 1 + 1 file changed, 1 insertion(+)
include/linux/mei_aux.h +1 -0
@@ -11,6 +11,7 @@ struct mei_aux_device {struct auxiliary_device aux_dev;int irq;struct resource bar; +bool slow_fw; };#define auxiliary_dev_to_mei_aux_dev (auxiliary_dev) \
Signature · 1 line
2.32.0
Re: [Intel-gfx] [PATCH 08/20] drm/i915/gsc: add slow_fw flag to the mei auxiliary device
Quoted 6 lines · Alexander Usyskin
Add
slow_fwflag to the mei auxiliary device info to inform the mei driver about slow underlying firmware. Such firmware will require to use larger operation timeouts.Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>
Might be worth squashing this in one of the patches that makes use of it, but I can see the benefit of having the interface added in a patch that's neither mei nor i915.
Quoted 16 lines
--- include/linux/mei_aux.h | 1 + 1 file changed, 1 insertion(+)include/linux/mei_aux.h +1
-0@@ -11,6 +11,7 @@ struct mei_aux_device {struct auxiliary_device aux_dev;int irq;struct resource bar; +bool slow_fw; };#define auxiliary_dev_to_mei_aux_dev (auxiliary_dev) \
Alexander Usyskin
maintainerPATCH 9/20 drm/i915/gsc: add slow_fw flag to the gsc device definition
In reply to Alexander UsyskinAdd slow_fw flag to the gsc device definition
and pass it to mei auxiliary device.
--- drivers/gpu/drm/i915/gt/intel_gsc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/gt/intel_gsc.c +2 -0
@@ -41,6 +41,7 @@ struct gsc_def {unsigned long bar;size_t bar_size;bool use_polling; +bool slow_fw; };/* gsc resources and definitions (HECI1 and HECI2) */
@@ -125,6 +126,7 @@ static void gsc_init_one(struct drm_i915_private *i915, adev->bar.end = adev->bar.start + def->bar_size -1 ; adev->bar.flags =IORESOURCE_MEM ; adev->bar.desc =IORES_DESC_NONE ; + adev->slow_fw = def->slow_fw; aux_dev = &adev->aux_dev; aux_dev->name = def->name;
Signature · 1 line
2.32.0
Re: [Intel-gfx] [PATCH 09/20] drm/i915/gsc: add slow_fw flag to the gsc device definition
Quoted 4 lines · Alexander Usyskin
Add
slow_fwflag to the gsc device definition
and pass it to mei auxiliary device.Signed-off-by Alexander Usyskin <[email protected]>
Daniele
Quoted 24 lines
--- drivers/gpu/drm/i915/gt/intel_gsc.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/gt/intel_gsc.c +2
-0@@ -41,6 +41,7 @@ struct gsc_def {unsigned long bar;size_t bar_size;bool use_polling; +bool slow_fw; };/* gsc resources and definitions (HECI1 and HECI2) */ @@ -125,6 +126,7 @@ static void gsc_init_one(struct drm_i915_private *i915, adev->bar.end = adev->bar.start + def->bar_size -1 ; adev->bar.flags =IORESOURCE_MEM ; adev->bar.desc =IORES_DESC_NONE ; + adev->slow_fw = def->slow_fw; aux_dev = &adev->aux_dev; aux_dev->name = def->name;
Alexander Usyskin
maintainerPATCH 10/20 drm/i915/gsc: add GSC XeHP SDV platform definition
In reply to Alexander UsyskinDefine GSC on XeHP SDV (Intel(R) dGPU without display)
XeHP SDV uses the same hardware settings as DG1, but uses polling instead of interrupts and runs the firmware in slow pace due to hardware limitations.
--- drivers/gpu/drm/i915/gt/intel_gsc.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_gsc.c +21 -1
@@ -56,6 +56,19 @@ static const struct gsc_def gsc_def_dg1[] = { } }; +static const struct gsc_def gsc_def_xehpsdv[] = { + { +/* HECI1 not enabled on the device. */ + }, + { + .name ="mei-gscfi" , + .bar =DG1_GSC_HECI2_BASE , + .bar_size =GSC_BAR_LENGTH , + .use_polling = true, + .slow_fw = true, + } +}; +static void gsc_release_dev (struct device *dev) {struct auxiliary_device *aux_dev =to_auxiliary_dev (dev);
@@ -92,7 +105,14 @@ static void gsc_init_one(struct drm_i915_private *i915,if (intf_id ==0 && !HAS_HECI_PXP (i915))return ; - def = &gsc_def_dg1[intf_id]; +if (IS_DG1 (i915)) { + def = &gsc_def_dg1[intf_id]; + }else if (IS_XEHPSDV (i915)) { + def = &gsc_def_xehpsdv[intf_id]; + }else { +drm_warn_once (&i915->drm,"Unknown platform\n" ); +return ; + }if (!def->name) {drm_warn_once (&i915->drm,"HECI%d is not implemented!\n" , intf_id +1 );
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 11/20 mei: gsc: use polling instead of interrupts
In reply to Alexander UsyskinFrom: Tomas Winkler <[email protected]>
A work-around for a HW issue in XEHPSDV that manifests itself when SW reads a gsc register when gsc is sending an interrupt. The work-around is to disable interrupts and to use polling instead.
--- drivers/misc/mei/gsc-me.c | 48 ++++++++++++++++++++++++++------ drivers/misc/mei/hw-me.c | 58 ++++++++++++++++++++++++++++++++++++--- drivers/misc/mei/hw-me.h | 12 ++++++++ 3 files changed, 105 insertions(+), 13 deletions(-)
drivers/misc/mei/gsc-me.c +39 -9
@@ -13,6 +13,7 @@#include <linux/ktime.h> #include <linux/delay.h> #include <linux/pm_runtime.h> +#include <linux/kthread.h> #include "mei_dev.h" #include "hw-me.h"
@@ -66,13 +67,28 @@ static int mei_gsc_probe(struct auxiliary_device *aux_dev,dev_set_drvdata (device, dev); - ret =devm_request_threaded_irq (device, hw->irq, - mei_me_irq_quick_handler, - mei_me_irq_thread_handler, -IRQF_ONESHOT ,KBUILD_MODNAME , dev); -if (ret) { -dev_err (device,"irq register failed %d\n" , ret); - goto err; +/* use polling */ +if (mei_me_hw_use_polling (hw)) { +mei_disable_interrupts (dev); +mei_clear_interrupts (dev); +init_waitqueue_head (&hw->wait_active); + hw->is_active = true;/* start in active mode for initialization */ + hw->polling_thread =kthread_run (mei_me_polling_thread, dev, +"kmegscirqd/%s" ,dev_name (device)); +if (IS_ERR (hw->polling_thread)) { + ret =PTR_ERR (hw->polling_thread); +dev_err (device,"unable to create kernel thread: %d\n" , ret); + goto err; + } + }else { + ret =devm_request_threaded_irq (device, hw->irq, + mei_me_irq_quick_handler, + mei_me_irq_thread_handler, +IRQF_ONESHOT ,KBUILD_MODNAME , dev); +if (ret) { +dev_err (device,"irq register failed %d\n" , ret); + goto err; + } }pm_runtime_get_noresume (device);
@@ -98,7 +114,8 @@ static int mei_gsc_probe(struct auxiliary_device *aux_dev, register_err:mei_stop (dev); -devm_free_irq (device, hw->irq, dev); +if (!mei_me_hw_use_polling (hw)) +devm_free_irq (device, hw->irq, dev); err:dev_err (device,"probe failed: %d\n" , ret);
@@ -119,12 +136,17 @@ static void mei_gsc_remove(struct auxiliary_device *aux_dev)mei_stop (dev); + hw =to_me_hw (dev); +if (mei_me_hw_use_polling (hw)) +kthread_stop (hw->polling_thread); +mei_deregister (dev);pm_runtime_disable (&aux_dev->dev);mei_disable_interrupts (dev); -devm_free_irq (&aux_dev->dev, hw->irq, dev); +if (!mei_me_hw_use_polling (hw)) +devm_free_irq (&aux_dev->dev, hw->irq, dev); }static int __maybe_unused mei_gsc_pm_suspend (struct device *device)
@@ -185,6 +207,9 @@ static int __maybe_unused mei_gsc_pm_runtime_suspend(struct device *device)if (mei_write_is_idle (dev)) { hw =to_me_hw (dev); hw->pg_state =MEI_PG_ON ; + +if (mei_me_hw_use_polling (hw)) + hw->is_active = false; ret =0 ; }else { ret = -EAGAIN ;
@@ -209,6 +234,11 @@ static int __maybe_unused mei_gsc_pm_runtime_resume(struct device *device) hw =to_me_hw (dev); hw->pg_state =MEI_PG_OFF ; +if (mei_me_hw_use_polling (hw)) { + hw->is_active = true; +wake_up (&hw->wait_active); + } +mutex_unlock (&dev->device_lock); irq_ret =mei_me_irq_thread_handler (1 , dev);
drivers/misc/mei/hw-me.c +54 -4
95 lines not on this page · raw message
drivers/misc/mei/hw-me.h +12 -0
@@ -51,6 +51,8 @@ struct mei_cfg {* @d0i3_supported: di03 support * @hbuf_depth: depth of hardware host/write buffer in slots * @read_fws: read FW status register handler +* @wait_active: the polling thread activity wait queue +* @is_active: the device is active */ struct mei_me_hw {const struct mei_cfg *cfg;
@@ -60,10 +62,19 @@ struct mei_me_hw {bool d0i3_supported;u8 hbuf_depth;int (*read_fws)(const struct mei_device *dev,int where,u32 *val); +/* polling */ +struct task_struct *polling_thread; +wait_queue_head_t wait_active; +bool is_active; };#define to_me_hw (dev) (struct mei_me_hw *)((dev)->hw) +static inline bool mei_me_hw_use_polling (const struct mei_me_hw *hw) +{ +return hw->irq <0 ; +} +/** * enum mei_cfg_idx - indices to platform specific configurations. *
@@ -127,5 +138,6 @@ int mei_me_pg_exit_sync(struct mei_device *dev);irqreturn_t mei_me_irq_quick_handler (int irq,void *dev_id);irqreturn_t mei_me_irq_thread_handler (int irq,void *dev_id); +int mei_me_polling_thread (void *_dev);#endif /* _MEI_INTERFACE_H_ */
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 12/20 mei: gsc: wait for reset thread on stop
In reply to Alexander UsyskinWait for reset work to complete before initiating
stop reset flow sequence.
--- drivers/misc/mei/init.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/mei/init.c +2 -0
@@ -320,6 +320,8 @@ void mei_stop(struct mei_device *dev)mei_clear_interrupts (dev);mei_synchronize_irq (dev); +/* to catch HW-initiated reset */ +mei_cancel_work (dev);mutex_lock (&dev->device_lock);
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 13/20 mei: extend timeouts on slow devices.
In reply to Alexander UsyskinParametrize operational timeouts in order
to support slow firmware on some graphic devices.
--- drivers/misc/mei/bus-fixup.c | 3 +-- drivers/misc/mei/client.c | 14 +++++++------- drivers/misc/mei/gsc-me.c | 2 +- drivers/misc/mei/hbm.c | 12 ++++++------ drivers/misc/mei/hw-me.c | 30 ++++++++++++++++-------------- drivers/misc/mei/hw-me.h | 2 +- drivers/misc/mei/hw-txe.c | 2 +- drivers/misc/mei/hw.h | 5 +++++ drivers/misc/mei/init.c | 19 ++++++++++++++++++- drivers/misc/mei/main.c | 2 +- drivers/misc/mei/mei_dev.h | 16 ++++++++++++++++ drivers/misc/mei/pci-me.c | 2 +- 12 files changed, 74 insertions(+), 35 deletions(-)
drivers/misc/mei/bus-fixup.c +1 -2
@@ -164,7 +164,6 @@ static int mei_osver(struct mei_cl_device *cldev) sizeof(struct mkhi_fw_ver))#define MKHI_FWVER_LEN (__num) (sizeof(struct mkhi_msg_hdr) + \ sizeof(struct mkhi_fw_ver_block) * (__num)) -#define MKHI_RCV_TIMEOUT 500/* receive timeout in msec */ static int mei_fwver (struct mei_cl_device *cldev) {char buf[MKHI_FWVER_BUF_LEN ];
@@ -187,7 +186,7 @@ static int mei_fwver(struct mei_cl_device *cldev) ret =0 ; bytes_recv =__mei_cl_recv (cldev->cl, buf,sizeof (buf),NULL ,0 , -MKHI_RCV_TIMEOUT ); + cldev->bus->timeouts.mkhi_recv);if (bytes_recv <0 || (size_t )bytes_recv <MKHI_FWVER_LEN (1 )) {/* * Should be at least one version block,
drivers/misc/mei/client.c +7 -7
@@ -870,7 +870,7 @@ static int mei_cl_send_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb) }list_move_tail (&cb->list, &dev->ctrl_rd_list); - cl->timer_count =MEI_CONNECT_TIMEOUT ; + cl->timer_count = dev->timeouts.connect;mei_schedule_stall_timer (dev);return 0 ;
@@ -945,7 +945,7 @@ static int __mei_cl_disconnect(struct mei_cl *cl)wait_event_timeout (cl->wait, cl->state ==MEI_FILE_DISCONNECT_REPLY || cl->state ==MEI_FILE_DISCONNECTED , -mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT )); + dev->timeouts.cl_connect);mutex_lock (&dev->device_lock); rets = cl->status;
@@ -1065,7 +1065,7 @@ static int mei_cl_send_connect(struct mei_cl *cl, struct mei_cl_cb *cb) }list_move_tail (&cb->list, &dev->ctrl_rd_list); - cl->timer_count =MEI_CONNECT_TIMEOUT ; + cl->timer_count = dev->timeouts.connect;mei_schedule_stall_timer (dev);return 0 ; }
@@ -1164,7 +1164,7 @@ int mei_cl_connect(struct mei_cl *cl, struct mei_me_client *me_cl, cl->state ==MEI_FILE_DISCONNECTED || cl->state ==MEI_FILE_DISCONNECT_REQUIRED || cl->state == MEI_FILE_DISCONNECT_REPLY), - mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT)); + dev->timeouts.cl_connect);mutex_lock (&dev->device_lock);if (!mei_cl_is_connected (cl)) {
@@ -1562,7 +1562,7 @@ int mei_cl_notify_request(struct mei_cl *cl, cl->notify_en == request || cl->status || !mei_cl_is_connected (cl), - mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT)); + dev->timeouts.cl_connect);mutex_lock (&dev->device_lock);if (cl->notify_en != request && !cl->status)
@@ -2336,7 +2336,7 @@ int mei_cl_dma_alloc_and_map(struct mei_cl *cl, const struct file *fp,mutex_unlock (&dev->device_lock);wait_event_timeout (cl->wait, cl->dma_mapped || cl->status, -mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT )); + dev->timeouts.cl_connect);mutex_lock (&dev->device_lock);if (!cl->dma_mapped && !cl->status)
@@ -2415,7 +2415,7 @@ int mei_cl_dma_unmap(struct mei_cl *cl, const struct file *fp)mutex_unlock (&dev->device_lock);wait_event_timeout (cl->wait, !cl->dma_mapped || cl->status, -mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT )); + dev->timeouts.cl_connect);mutex_lock (&dev->device_lock);if (cl->dma_mapped && !cl->status)
drivers/misc/mei/gsc-me.c +1 -1
@@ -48,7 +48,7 @@ static int mei_gsc_probe(struct auxiliary_device *aux_dev, device = &aux_dev->dev; - dev =mei_me_dev_init (device, cfg); + dev =mei_me_dev_init (device, cfg, adev->slow_fw);if (IS_ERR (dev)) { ret =PTR_ERR (dev); goto err;
drivers/misc/mei/hbm.c +6 -6
@@ -232,7 +232,7 @@ int mei_hbm_start_wait(struct mei_device *dev)mutex_unlock (&dev->device_lock); ret =wait_event_timeout (dev->wait_hbm_start, dev->hbm_state !=MEI_HBM_STARTING , -mei_secs_to_jiffies (MEI_HBM_TIMEOUT )); + dev->timeouts.hbm);mutex_lock (&dev->device_lock);if (ret ==0 && (dev->hbm_state <=MEI_HBM_STARTING )) {
@@ -275,7 +275,7 @@ int mei_hbm_start_req(struct mei_device *dev) } dev->hbm_state =MEI_HBM_STARTING ; - dev->init_clients_timer =MEI_CLIENTS_INIT_TIMEOUT ; + dev->init_clients_timer = dev->timeouts.client_init;mei_schedule_stall_timer (dev);return 0 ; }
@@ -316,7 +316,7 @@ static int mei_hbm_dma_setup_req(struct mei_device *dev) } dev->hbm_state =MEI_HBM_DR_SETUP ; - dev->init_clients_timer =MEI_CLIENTS_INIT_TIMEOUT ; + dev->init_clients_timer = dev->timeouts.client_init;mei_schedule_stall_timer (dev);return 0 ; }
@@ -351,7 +351,7 @@ static int mei_hbm_capabilities_req(struct mei_device *dev) } dev->hbm_state =MEI_HBM_CAP_SETUP ; - dev->init_clients_timer =MEI_CLIENTS_INIT_TIMEOUT ; + dev->init_clients_timer = dev->timeouts.client_init;mei_schedule_stall_timer (dev);return 0 ; }
@@ -385,7 +385,7 @@ static int mei_hbm_enum_clients_req(struct mei_device *dev)return ret; } dev->hbm_state =MEI_HBM_ENUM_CLIENTS ; - dev->init_clients_timer =MEI_CLIENTS_INIT_TIMEOUT ; + dev->init_clients_timer = dev->timeouts.client_init;mei_schedule_stall_timer (dev);return 0 ; }
@@ -751,7 +751,7 @@ static int mei_hbm_prop_req(struct mei_device *dev, unsigned long start_idx)return ret; } - dev->init_clients_timer =MEI_CLIENTS_INIT_TIMEOUT ; + dev->init_clients_timer = dev->timeouts.client_init;mei_schedule_stall_timer (dev);return 0 ;
drivers/misc/mei/hw-me.c +16 -14
@@ -445,7 +445,7 @@ static int mei_me_hw_ready_wait(struct mei_device *dev)mutex_unlock (&dev->device_lock);wait_event_timeout (dev->wait_hw_ready, dev->recvd_hw_ready, -mei_secs_to_jiffies (MEI_HW_READY_TIMEOUT )); + dev->timeouts.hw_ready);mutex_lock (&dev->device_lock);if (!dev->recvd_hw_ready) {dev_err (dev->dev,"wait hw ready failed\n" );
@@ -707,7 +707,6 @@ static void mei_me_pg_unset(struct mei_device *dev)static int mei_me_pg_legacy_enter_sync (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); -unsigned long timeout =mei_secs_to_jiffies (MEI_PGI_TIMEOUT );int ret; dev->pg_event =MEI_PG_EVENT_WAIT ;
@@ -718,7 +717,8 @@ static int mei_me_pg_legacy_enter_sync(struct mei_device *dev)mutex_unlock (&dev->device_lock);wait_event_timeout (dev->wait_pg, - dev->pg_event ==MEI_PG_EVENT_RECEIVED , timeout); + dev->pg_event ==MEI_PG_EVENT_RECEIVED , + dev->timeouts.pgi);mutex_lock (&dev->device_lock);if (dev->pg_event ==MEI_PG_EVENT_RECEIVED ) {
@@ -744,7 +744,6 @@ static int mei_me_pg_legacy_enter_sync(struct mei_device *dev)static int mei_me_pg_legacy_exit_sync (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); -unsigned long timeout =mei_secs_to_jiffies (MEI_PGI_TIMEOUT );int ret;if (dev->pg_event ==MEI_PG_EVENT_RECEIVED )
@@ -756,7 +755,8 @@ static int mei_me_pg_legacy_exit_sync(struct mei_device *dev)mutex_unlock (&dev->device_lock);wait_event_timeout (dev->wait_pg, - dev->pg_event ==MEI_PG_EVENT_RECEIVED , timeout); + dev->pg_event ==MEI_PG_EVENT_RECEIVED , + dev->timeouts.pgi);mutex_lock (&dev->device_lock); reply:
@@ -772,7 +772,8 @@ static int mei_me_pg_legacy_exit_sync(struct mei_device *dev)mutex_unlock (&dev->device_lock);wait_event_timeout (dev->wait_pg, - dev->pg_event ==MEI_PG_EVENT_INTR_RECEIVED , timeout); + dev->pg_event ==MEI_PG_EVENT_INTR_RECEIVED , + dev->timeouts.pgi);mutex_lock (&dev->device_lock);if (dev->pg_event ==MEI_PG_EVENT_INTR_RECEIVED )
@@ -887,8 +888,6 @@ static u32 mei_me_d0i3_unset(struct mei_device *dev)static int mei_me_d0i3_enter_sync (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); -unsigned long d0i3_timeout =mei_secs_to_jiffies (MEI_D0I3_TIMEOUT ); -unsigned long pgi_timeout =mei_secs_to_jiffies (MEI_PGI_TIMEOUT );int ret;u32 reg;
@@ -910,7 +909,8 @@ static int mei_me_d0i3_enter_sync(struct mei_device *dev)mutex_unlock (&dev->device_lock);wait_event_timeout (dev->wait_pg, - dev->pg_event ==MEI_PG_EVENT_RECEIVED , pgi_timeout); + dev->pg_event ==MEI_PG_EVENT_RECEIVED , + dev->timeouts.pgi);mutex_lock (&dev->device_lock);if (dev->pg_event !=MEI_PG_EVENT_RECEIVED ) {
@@ -930,7 +930,8 @@ static int mei_me_d0i3_enter_sync(struct mei_device *dev)mutex_unlock (&dev->device_lock);wait_event_timeout (dev->wait_pg, - dev->pg_event ==MEI_PG_EVENT_INTR_RECEIVED , d0i3_timeout); + dev->pg_event ==MEI_PG_EVENT_INTR_RECEIVED , + dev->timeouts.d0i3);mutex_lock (&dev->device_lock);if (dev->pg_event !=MEI_PG_EVENT_INTR_RECEIVED ) {
@@ -990,7 +991,6 @@ static int mei_me_d0i3_enter(struct mei_device *dev)static int mei_me_d0i3_exit_sync (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); -unsigned long timeout =mei_secs_to_jiffies (MEI_D0I3_TIMEOUT );int ret;u32 reg;
@@ -1013,7 +1013,8 @@ static int mei_me_d0i3_exit_sync(struct mei_device *dev)mutex_unlock (&dev->device_lock);wait_event_timeout (dev->wait_pg, - dev->pg_event ==MEI_PG_EVENT_INTR_RECEIVED , timeout); + dev->pg_event ==MEI_PG_EVENT_INTR_RECEIVED , + dev->timeouts.pgi);mutex_lock (&dev->device_lock);if (dev->pg_event !=MEI_PG_EVENT_INTR_RECEIVED ) {
@@ -1684,11 +1685,12 @@ EXPORT_SYMBOL_GPL(mei_me_get_cfg);* * @parent: device associated with physical device (pci/platform) * @cfg: per device generation config +* @slow_fw: configure longer timeouts as FW is slow * * Return: The mei_device pointer on success, NULL on failure. */ struct mei_device *mei_me_dev_init (struct device *parent, -const struct mei_cfg *cfg) +const struct mei_cfg *cfg,bool slow_fw) {struct mei_device *dev;struct mei_me_hw *hw;
@@ -1703,7 +1705,7 @@ struct mei_device *mei_me_dev_init(struct device *parent,for (i =0 ; i <DMA_DSCR_NUM ; i++) dev->dr_dscr[i].size = cfg->dma_size[i]; -mei_device_init (dev, parent, &mei_me_hw_ops); +mei_device_init (dev, parent, slow_fw, &mei_me_hw_ops); hw->cfg = cfg; dev->fw_f_fw_ver_supported = cfg->fw_ver_supported;
drivers/misc/mei/hw-me.h +1 -1
@@ -131,7 +131,7 @@ enum mei_cfg_idx {const struct mei_cfg *mei_me_get_cfg (kernel_ulong_t idx);struct mei_device *mei_me_dev_init (struct device *parent, -const struct mei_cfg *cfg); +const struct mei_cfg *cfg,bool slow_fw);int mei_me_pg_enter_sync (struct mei_device *dev);int mei_me_pg_exit_sync (struct mei_device *dev);
drivers/misc/mei/hw-txe.c +1 -1
@@ -1201,7 +1201,7 @@ struct mei_device *mei_txe_dev_init(struct pci_dev *pdev)if (!dev)return NULL ; -mei_device_init (dev, &pdev->dev, &mei_txe_hw_ops); +mei_device_init (dev, &pdev->dev, false, &mei_txe_hw_ops); hw =to_txe_hw (dev);
drivers/misc/mei/hw.h +5 -0
@@ -16,11 +16,16 @@#define MEI_CONNECT_TIMEOUT 3/* HPS: at least 2 seconds */ #define MEI_CL_CONNECT_TIMEOUT 15/* HPS: Client Connect Timeout */ +#define MEI_CL_CONNECT_TIMEOUT_SLOW 30/* HPS: Client Connect Timeout, slow FW */ #define MEI_CLIENTS_INIT_TIMEOUT 15/* HPS: Clients Enumeration Timeout */ #define MEI_PGI_TIMEOUT 1/* PG Isolation time response 1 sec */ #define MEI_D0I3_TIMEOUT 5/* D0i3 set/unset max response time */ #define MEI_HBM_TIMEOUT 1/* 1 second */ +#define MEI_HBM_TIMEOUT_SLOW 5/* 5 second, slow FW */ + +#define MKHI_RCV_TIMEOUT 500/* receive timeout in msec */ +#define MKHI_RCV_TIMEOUT_SLOW 10000/* receive timeout in msec, slow FW */ /* * FW page size for DMA allocations
drivers/misc/mei/init.c +18 -1
@@ -359,14 +359,16 @@ bool mei_write_is_idle(struct mei_device *dev)EXPORT_SYMBOL_GPL (mei_write_is_idle);/** -* mei_device_init -- initialize mei_device structure +* mei_device_init - initialize mei_device structure * * @dev: the mei device * @device: the device structure +* @slow_fw: configure longer timeouts as FW is slow * @hw_ops: hw operations */ void mei_device_init (struct mei_device *dev,struct device *device, +bool slow_fw,const struct mei_hw_ops *hw_ops) {/* setup our list array */
@@ -404,6 +406,21 @@ void mei_device_init(struct mei_device *dev, dev->pg_event =MEI_PG_EVENT_IDLE ; dev->ops = hw_ops; dev->dev = device; + + dev->timeouts.hw_ready =mei_secs_to_jiffies (MEI_HW_READY_TIMEOUT ); + dev->timeouts.connect =MEI_CONNECT_TIMEOUT ; + dev->timeouts.client_init =MEI_CLIENTS_INIT_TIMEOUT ; + dev->timeouts.pgi =mei_secs_to_jiffies (MEI_PGI_TIMEOUT ); + dev->timeouts.d0i3 =mei_secs_to_jiffies (MEI_D0I3_TIMEOUT ); +if (slow_fw) { + dev->timeouts.cl_connect =mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT_SLOW ); + dev->timeouts.hbm =mei_secs_to_jiffies (MEI_HBM_TIMEOUT_SLOW ); + dev->timeouts.mkhi_recv =msecs_to_jiffies (MKHI_RCV_TIMEOUT_SLOW ); + }else { + dev->timeouts.cl_connect =mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT ); + dev->timeouts.hbm =mei_secs_to_jiffies (MEI_HBM_TIMEOUT ); + dev->timeouts.mkhi_recv =msecs_to_jiffies (MKHI_RCV_TIMEOUT ); + } }EXPORT_SYMBOL_GPL (mei_device_init);
drivers/misc/mei/main.c +1 -1
@@ -571,7 +571,7 @@ static int mei_ioctl_connect_vtag(struct file *file, cl->state ==MEI_FILE_DISCONNECTED || cl->state ==MEI_FILE_DISCONNECT_REQUIRED || cl->state == MEI_FILE_DISCONNECT_REPLY), - mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT)); + dev->timeouts.cl_connect);mutex_lock (&dev->device_lock); }
drivers/misc/mei/mei_dev.h +16 -0
@@ -415,6 +415,17 @@ struct mei_fw_version {#define MEI_MAX_FW_VER_BLOCKS 3 +struct mei_dev_timeouts { +unsigned long hw_ready;/* Timeout on ready message, in jiffies */ +int connect;/* HPS: at least 2 seconds, in seconds */ +unsigned long cl_connect;/* HPS: Client Connect Timeout, in jiffies */ +int client_init;/* HPS: Clients Enumeration Timeout, in seconds */ +unsigned long pgi;/* PG Isolation time response, in jiffies */ +unsigned int d0i3;/* D0i3 set/unset max response time, in jiffies */ +unsigned long hbm;/* HBM operation timeout, in jiffies */ +unsigned long mkhi_recv;/* receive timeout, in jiffies */ +}; +/** * struct mei_device - MEI private device struct *
@@ -480,6 +491,8 @@ struct mei_fw_version {* @allow_fixed_address: allow user space to connect a fixed client * @override_fixed_address: force allow fixed address behavior * +* @timeouts: actual timeout values +* * @reset_work : work item for the device reset * @bus_rescan_work : work item for the bus rescan *
@@ -568,6 +581,8 @@ struct mei_device {bool allow_fixed_address;bool override_fixed_address; +struct mei_dev_timeouts timeouts; +struct work_struct reset_work;struct work_struct bus_rescan_work;
@@ -632,6 +647,7 @@ static inline u32 mei_slots2data(int slots)*/ void mei_device_init (struct mei_device *dev,struct device *device, +bool slow_fw,const struct mei_hw_ops *hw_ops);int mei_reset (struct mei_device *dev);int mei_start (struct mei_device *dev);
drivers/misc/mei/pci-me.c +1 -1
@@ -201,7 +201,7 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }/* allocates and initializes the mei dev structure */ - dev =mei_me_dev_init (&pdev->dev, cfg); + dev =mei_me_dev_init (&pdev->dev, cfg, false);if (!dev) { err = -ENOMEM ; goto end;
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 14/20 drm/i915/dg2: add gsc with special gsc bar offsets
In reply to Alexander UsyskinFrom: Tomas Winkler <[email protected]>
DG2 uses different GSC offsets on memory bar
and uses PXP head (HECI1).
--- drivers/gpu/drm/i915/gt/intel_gsc.c | 15 +++++++++++++++ drivers/gpu/drm/i915/i915_pci.c | 1 + drivers/gpu/drm/i915/i915_reg.h | 2 ++ 3 files changed, 18 insertions(+)
drivers/gpu/drm/i915/gt/intel_gsc.c +15 -0
@@ -69,6 +69,19 @@ static const struct gsc_def gsc_def_xehpsdv[] = { } }; +static const struct gsc_def gsc_def_dg2[] = { + { + .name ="mei-gsc" , + .bar =DG2_GSC_HECI1_BASE , + .bar_size =GSC_BAR_LENGTH , + }, + { + .name ="mei-gscfi" , + .bar =DG2_GSC_HECI2_BASE , + .bar_size =GSC_BAR_LENGTH , + } +}; +static void gsc_release_dev (struct device *dev) {struct auxiliary_device *aux_dev =to_auxiliary_dev (dev);
@@ -109,6 +122,8 @@ static void gsc_init_one(struct drm_i915_private *i915, def = &gsc_def_dg1[intf_id]; }else if (IS_XEHPSDV (i915)) { def = &gsc_def_xehpsdv[intf_id]; + }else if (IS_DG2 (i915)) { + def = &gsc_def_dg2[intf_id]; }else {drm_warn_once (&i915->drm,"Unknown platform\n" );return ;
drivers/gpu/drm/i915/i915_pci.c +1 -0
@@ -1051,6 +1051,7 @@ static const struct intel_device_info xehpsdv_info = { .has_4tile = 1, \ .has_64k_pages = 1, \ .has_guc_deprivilege = 1, \ + .has_heci_pxp = 1, \ .needs_compact_pt = 1, \ .platform_engine_mask = \ BIT(RCS0) | BIT(BCS0) | \
drivers/gpu/drm/i915/i915_reg.h +2 -0
@@ -978,6 +978,8 @@#define BLT_RING_BASE 0x22000#define DG1_GSC_HECI1_BASE 0x00258000#define DG1_GSC_HECI2_BASE 0x00259000 +#define DG2_GSC_HECI1_BASE 0x00373000 +#define DG2_GSC_HECI2_BASE 0x00374000
Signature · 1 line
2.32.0
Re: [Intel-gfx] [PATCH 14/20] drm/i915/dg2: add gsc with special gsc bar offsets
Quoted 7 lines · Alexander Usyskin
From: Tomas Winkler <[email protected]>
DG2 uses different GSC offsets on memory bar
and uses PXP head (HECI1).Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>
Daniele
Quoted 64 lines
--- drivers/gpu/drm/i915/gt/intel_gsc.c | 15 +++++++++++++++ drivers/gpu/drm/i915/i915_pci.c | 1 + drivers/gpu/drm/i915/i915_reg.h | 2 ++ 3 files changed, 18 insertions(+)drivers/gpu/drm/i915/gt/intel_gsc.c +15
-0@@ -69,6 +69,19 @@ static const struct gsc_def gsc_def_xehpsdv[] = { } }; +static const struct gsc_def gsc_def_dg2[] = { + { + .name ="mei-gsc" , + .bar =DG2_GSC_HECI1_BASE , + .bar_size =GSC_BAR_LENGTH , + }, + { + .name ="mei-gscfi" , + .bar =DG2_GSC_HECI2_BASE , + .bar_size =GSC_BAR_LENGTH , + } +}; +static void gsc_release_dev (struct device *dev) {struct auxiliary_device *aux_dev =to_auxiliary_dev (dev);@@ -109,6 +122,8 @@ static void gsc_init_one(struct drm_i915_private *i915, def = &gsc_def_dg1[intf_id]; }else if (IS_XEHPSDV (i915)) { def = &gsc_def_xehpsdv[intf_id]; + }else if (IS_DG2 (i915)) { + def = &gsc_def_dg2[intf_id]; }else {drm_warn_once (&i915->drm,"Unknown platform\n" );return ;drivers/gpu/drm/i915/i915_pci.c +1
-0@@ -1051,6 +1051,7 @@ static const struct intel_device_info xehpsdv_info = { .has_4tile = 1, \ .has_64k_pages = 1, \ .has_guc_deprivilege = 1, \ + .has_heci_pxp = 1, \ .needs_compact_pt = 1, \ .platform_engine_mask = \ BIT(RCS0) | BIT(BCS0) | \drivers/gpu/drm/i915/i915_reg.h +2
-0@@ -978,6 +978,8 @@#define BLT_RING_BASE 0x22000#define DG1_GSC_HECI1_BASE 0x00258000#define DG1_GSC_HECI2_BASE 0x00259000 +#define DG2_GSC_HECI1_BASE 0x00373000 +#define DG2_GSC_HECI2_BASE 0x00374000
Alexander Usyskin
maintainerPATCH 15/20 mei: bus: export common mkhi definitions into a separate header
In reply to Alexander UsyskinFrom: Vitaly Lubart <[email protected]>
Exported common mkhi definitions from bus-fixup.c into a separate header file mkhi.h for other driver usage.
--- drivers/misc/mei/bus-fixup.c | 32 ++----------------------- drivers/misc/mei/mkhi.h | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 30 deletions(-) create mode 100644 drivers/misc/mei/mkhi.h
drivers/misc/mei/bus-fixup.c +2 -30
@@ -15,6 +15,7 @@#include "mei_dev.h" #include "client.h" +#include "mkhi.h" #define MEI_UUID_NFC_INFO UUID_LE(0xd2de1625, 0x382d, 0x417d, \ 0x48, 0xa4, 0xef, 0xab, 0xba, 0x8a, 0x12, 0x06)
@@ -80,6 +81,7 @@ static void whitelist(struct mei_cl_device *cldev) }#define OSTYPE_LINUX 2 +struct mei_os_ver {__le16 build;__le16 reserved1;
@@ -89,20 +91,6 @@ struct mei_os_ver {u8 reserved2; } __packed; -#define MKHI_FEATURE_PTT 0x10 - -struct mkhi_rule_id { -__le16 rule_type; -u8 feature_id; -u8 reserved; -} __packed; - -struct mkhi_fwcaps { -struct mkhi_rule_id id; -u8 len; -u8 data[]; -} __packed; -struct mkhi_fw_ver_block {u16 minor;u8 major;
@@ -115,22 +103,6 @@ struct mkhi_fw_ver {struct mkhi_fw_ver_block ver[MEI_MAX_FW_VER_BLOCKS ]; } __packed; -#define MKHI_FWCAPS_GROUP_ID 0x3 -#define MKHI_FWCAPS_SET_OS_VER_APP_RULE_CMD 6 -#define MKHI_GEN_GROUP_ID 0xFF -#define MKHI_GEN_GET_FW_VERSION_CMD 0x2 -struct mkhi_msg_hdr { -u8 group_id; -u8 command; -u8 reserved; -u8 result; -} __packed; - -struct mkhi_msg { -struct mkhi_msg_hdr hdr; -u8 data[]; -} __packed; -#define MKHI_OSVER_BUF_LEN (sizeof(struct mkhi_msg_hdr) + \ sizeof(struct mkhi_fwcaps) + \ sizeof(struct mei_os_ver))
drivers/misc/mei/mkhi.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 16/20 mei: mkhi: add memory ready command
In reply to Alexander UsyskinFrom: Tomas Winkler <[email protected]>
Add GSC memory ready command.
The command indicates to the firmware that
extend operation memory was setup and
the firmware may enter PXP mode.
--- drivers/misc/mei/mkhi.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/misc/mei/mkhi.h +13 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ /* -* Copyright (c) 2003-2020, Intel Corporation. All rights reserved. +* Copyright (c) 2003-2021, Intel Corporation. All rights reserved. * Intel Management Engine Interface (Intel MEI) Linux driver */
@@ -18,6 +18,13 @@#define MCHI_GROUP_ID 0xA +#define MKHI_GROUP_ID_GFX 0x30 +#define MKHI_GFX_RESET_WARN_CMD_REQ 0x0 +#define MKHI_GFX_MEMORY_READY_CMD_REQ 0x1 + +/* Allow transition to PXP mode without approval */ +#define MKHI_GFX_MEM_READY_PXP_ALLOWED 0x1 +struct mkhi_rule_id {__le16 rule_type;u8 feature_id;
@@ -42,4 +49,9 @@ struct mkhi_msg { u8 data[]; } __packed; +struct mkhi_gfx_mem_ready { +struct mkhi_msg_hdr hdr; +uint32_t flags; +} __packed; +#endif /* _MEI_MKHI_H_ */
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 17/20 mei: gsc: setup gsc extended operational memory
In reply to Alexander UsyskinFrom: Tomas Winkler <[email protected]>
1. Retrieve extended operational memory physical pointers from the auxiliary device info.
2. Setup memory registers.
3. Notify firmware that the memory is ready by sending the memory ready command.
4. Disable PXP device if GSC is not in PXP mode.
--- drivers/misc/mei/bus-fixup.c | 70 ++++++++++++++++++++++++++++++++++- drivers/misc/mei/gsc-me.c | 16 ++++++++ drivers/misc/mei/hw-me-regs.h | 7 ++++ drivers/misc/mei/hw-me.c | 28 +++++++++++++- drivers/misc/mei/mei_dev.h | 10 +++++ include/linux/mei_aux.h | 1 + 6 files changed, 129 insertions(+), 3 deletions(-)
drivers/misc/mei/bus-fixup.c +68 -2
@@ -189,6 +189,19 @@ static int mei_fwver(struct mei_cl_device *cldev)return ret; } +static int mei_gfx_memory_ready (struct mei_cl_device *cldev) +{ +struct mkhi_gfx_mem_ready req = {0 }; +unsigned int mode =MEI_CL_IO_TX_INTERNAL ; + + req.hdr.group_id =MKHI_GROUP_ID_GFX ; + req.hdr.command =MKHI_GFX_MEMORY_READY_CMD_REQ ; + req.flags =MKHI_GFX_MEM_READY_PXP_ALLOWED ; + +dev_dbg (&cldev->dev,"Sending memory ready command\n" ); +return __mei_cl_send (cldev->cl, (u8 *)&req,sizeof (req),0 , mode); +} +static void mei_mkhi_fix (struct mei_cl_device *cldev) {int ret;
@@ -235,6 +248,39 @@ static void mei_gsc_mkhi_ver(struct mei_cl_device *cldev)dev_err (&cldev->dev,"FW version command failed %d\n" , ret);mei_cldev_disable (cldev); } + +static void mei_gsc_mkhi_fix_ver (struct mei_cl_device *cldev) +{ +int ret; + +/* No need to enable the client if nothing is needed from it */ +if (!cldev->bus->fw_f_fw_ver_supported && + (cldev->bus->pxp_mode !=MEI_DEV_PXP_INIT )) +return ; + + ret =mei_cldev_enable (cldev); +if (ret) +return ; + +if (cldev->bus->pxp_mode ==MEI_DEV_PXP_INIT ) { + ret =mei_gfx_memory_ready (cldev); +if (ret <0 ) +dev_err (&cldev->dev,"memory ready command failed %d\n" , ret); +else +dev_dbg (&cldev->dev,"memory ready command sent\n" ); +/* we go to reset after that */ + cldev->bus->pxp_mode =MEI_DEV_PXP_SETUP ; + goto out; + } + + ret =mei_fwver (cldev); +if (ret <0 ) +dev_err (&cldev->dev,"FW version command failed %d\n" , + ret); +out: +mei_cldev_disable (cldev); +} +/** * mei_wd - wd client on the bus, change protocol version * as the API has changed.
@@ -474,6 +520,26 @@ static void vt_support(struct mei_cl_device *cldev) cldev->do_match =1 ; } +/** +* pxp_isready - enable bus client if pxp is ready +* +* @cldev: me clients device +*/ +static void pxp_isready (struct mei_cl_device *cldev) +{ +struct mei_device *bus = cldev->bus; + +switch (bus->pxp_mode) { +case MEI_DEV_PXP_READY : +case MEI_DEV_PXP_DEFAULT : + cldev->do_match =1 ; +break ; +default : + cldev->do_match =0 ; +break ; + } +} +#define MEI_FIXUP (_uuid, _hook) { _uuid, _hook } static struct mei_fixup {
@@ -487,10 +553,10 @@ static struct mei_fixup {MEI_FIXUP (MEI_UUID_WD , mei_wd),MEI_FIXUP (MEI_UUID_MKHIF_FIX , mei_mkhi_fix),MEI_FIXUP (MEI_UUID_IGSC_MKHI , mei_gsc_mkhi_ver), -MEI_FIXUP (MEI_UUID_IGSC_MKHI_FIX , mei_gsc_mkhi_ver), +MEI_FIXUP (MEI_UUID_IGSC_MKHI_FIX , mei_gsc_mkhi_fix_ver),MEI_FIXUP (MEI_UUID_HDCP , whitelist),MEI_FIXUP (MEI_UUID_ANY , vt_support), - MEI_FIXUP(MEI_UUID_PAVP, whitelist), + MEI_FIXUP(MEI_UUID_PAVP, pxp_isready), };/**
drivers/misc/mei/gsc-me.c +16 -0
@@ -32,6 +32,17 @@ static int mei_gsc_read_hfs(const struct mei_device *dev, int where, u32 *val)return 0 ; } +static void mei_gsc_set_ext_op_mem (const struct mei_me_hw *hw,struct resource *mem) +{ +u32 low =lower_32_bits (mem->start); +u32 hi =upper_32_bits (mem->start); +u32 limit = (resource_size (mem) /SZ_4K ) |GSC_EXT_OP_MEM_VALID ; + +iowrite32 (low, hw->mem_addr +H_GSC_EXT_OP_MEM_BASE_ADDR_LO_REG ); +iowrite32 (hi, hw->mem_addr +H_GSC_EXT_OP_MEM_BASE_ADDR_HI_REG ); +iowrite32 (limit, hw->mem_addr +H_GSC_EXT_OP_MEM_LIMIT_REG ); +} +static int mei_gsc_probe (struct auxiliary_device *aux_dev,const struct auxiliary_device_id *aux_dev_id) {
@@ -67,6 +78,11 @@ static int mei_gsc_probe(struct auxiliary_device *aux_dev,dev_set_drvdata (device, dev); +if (adev->ext_op_mem.start) { +mei_gsc_set_ext_op_mem (hw, &adev->ext_op_mem); + dev->pxp_mode =MEI_DEV_PXP_INIT ; + } +/* use polling */ if (mei_me_hw_use_polling (hw)) {mei_disable_interrupts (dev);
drivers/misc/mei/hw-me-regs.h +7 -0
@@ -125,6 +125,8 @@# define PCI_CFG_HFS_3_FW_SKU_SPS 0x00000060#define PCI_CFG_HFS_4 0x64#define PCI_CFG_HFS_5 0x68 +# define GSC_CFG_HFS_5_BOOT_TYPE_MSK 0x00000003 +# define GSC_CFG_HFS_5_BOOT_TYPE_PXP 3#define PCI_CFG_HFS_6 0x6C/* MEI registers */
@@ -141,6 +143,11 @@/* H_D0I3C - D0I3 Control */ #define H_D0I3C 0x800 +#define H_GSC_EXT_OP_MEM_BASE_ADDR_LO_REG 0x100 +#define H_GSC_EXT_OP_MEM_BASE_ADDR_HI_REG 0x104 +#define H_GSC_EXT_OP_MEM_LIMIT_REG 0x108 +#define GSC_EXT_OP_MEM_VALID BIT(31) +/* register bits of H_CSR (Host Control Status register) */ /* Host Circular Buffer Depth - maximum number of 32-bit entries in CB */ #define H_CBD 0xFF000000
drivers/misc/mei/hw-me.c +27 -1
@@ -433,6 +433,29 @@ static bool mei_me_hw_is_resetting(struct mei_device *dev)return (mecsr &ME_RST_HRA ) ==ME_RST_HRA ; } +/** +* mei_gsc_pxp_check - check for gsc firmware entering pxp mode +* +* @dev: the device structure +*/ +static void mei_gsc_pxp_check (struct mei_device *dev) +{ +struct mei_me_hw *hw =to_me_hw (dev); +u32 fwsts5 =0 ; + +if (dev->pxp_mode ==MEI_DEV_PXP_DEFAULT ) +return ; + + hw->read_fws (dev,PCI_CFG_HFS_5 , &fwsts5); +trace_mei_pci_cfg_read (dev->dev,"PCI_CFG_HFS_5" ,PCI_CFG_HFS_5 , fwsts5); +if ((fwsts5 &GSC_CFG_HFS_5_BOOT_TYPE_MSK ) ==GSC_CFG_HFS_5_BOOT_TYPE_PXP ) { +dev_dbg (dev->dev,"pxp mode is ready 0x%08x\n" , fwsts5); + dev->pxp_mode =MEI_DEV_PXP_READY ; + }else { +dev_dbg (dev->dev,"pxp mode is not ready 0x%08x\n" , fwsts5); + } +} +/** * mei_me_hw_ready_wait - wait until the me(hw) has turned ready * or timeout is reached
@@ -452,6 +475,8 @@ static int mei_me_hw_ready_wait(struct mei_device *dev)return -ETIME ; } +mei_gsc_pxp_check (dev); +mei_me_hw_reset_release (dev); dev->recvd_hw_ready = false;return 0 ;
@@ -1268,7 +1293,8 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)/* check if ME wants a reset */ if (!mei_hw_is_ready (dev) && dev->dev_state !=MEI_DEV_RESETTING ) { -dev_warn (dev->dev,"FW not ready: resetting.\n" ); +dev_warn (dev->dev,"FW not ready: resetting: dev_state = %d pxp = %d\n" , + dev->dev_state, dev->pxp_mode);if (dev->dev_state ==MEI_DEV_POWERING_DOWN || dev->dev_state ==MEI_DEV_POWER_DOWN )mei_cl_all_disconnect (dev);
drivers/misc/mei/mei_dev.h +10 -0
@@ -62,6 +62,14 @@ enum mei_dev_state {MEI_DEV_POWER_UP }; +/* MEI PXP mode state */ +enum mei_dev_pxp_mode { +MEI_DEV_PXP_DEFAULT =0 , +MEI_DEV_PXP_INIT =1 , +MEI_DEV_PXP_SETUP =2 , +MEI_DEV_PXP_READY =3 , +}; +const char *mei_dev_state_str (int state);enum mei_file_transaction_states {
@@ -454,6 +462,7 @@ struct mei_dev_timeouts {* @reset_count : number of consecutive resets * @dev_state : device state * @hbm_state : state of host bus message protocol +* @pxp_mode : PXP device mode * @init_clients_timer : HBM init handshake timeout * * @pg_event : power gating event
@@ -537,6 +546,7 @@ struct mei_device {unsigned long reset_count;enum mei_dev_state dev_state;enum mei_hbm_state hbm_state; +enum mei_dev_pxp_mode pxp_mode;u16 init_clients_timer;/*
include/linux/mei_aux.h +1 -0
@@ -11,6 +11,7 @@ struct mei_aux_device {struct auxiliary_device aux_dev;int irq;struct resource bar; +struct resource ext_op_mem;bool slow_fw; };
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 18/20 mei: gsc: add transition to PXP mode in resume flow
In reply to Alexander UsyskinFrom: Vitaly Lubart <[email protected]>
Added transition to PXP mode in resume flow.
--- drivers/misc/mei/gsc-me.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/misc/mei/gsc-me.c +11 -0
@@ -182,11 +182,22 @@ static int __maybe_unused mei_gsc_pm_suspend(struct device *device)static int __maybe_unused mei_gsc_pm_resume (struct device *device) {struct mei_device *dev =dev_get_drvdata (device); +struct auxiliary_device *aux_dev; +struct mei_aux_device *adev;int err; +struct mei_me_hw *hw;if (!dev)return -ENODEV ; + hw =to_me_hw (dev); + aux_dev =to_auxiliary_dev (device); + adev =auxiliary_dev_to_mei_aux_dev (aux_dev); +if (adev->ext_op_mem.start) { +mei_gsc_set_ext_op_mem (hw, &adev->ext_op_mem); + dev->pxp_mode =MEI_DEV_PXP_INIT ; + } + err =mei_restart (dev);if (err)return err;
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 19/20 mei: debugfs: add pxp mode to devstate in debugfs
In reply to Alexander UsyskinFrom: Tomas Winkler <[email protected]>
--- drivers/misc/mei/debugfs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/misc/mei/debugfs.c +17 -0
@@ -86,6 +86,20 @@ static int mei_dbgfs_active_show(struct seq_file *m, void *unused) }DEFINE_SHOW_ATTRIBUTE (mei_dbgfs_active); +static const char *mei_dev_pxp_mode_str (enum mei_dev_pxp_mode state) +{ +#define MEI_PXP_MODE (state) case MEI_DEV_PXP_##state: return #state +switch (state) { +MEI_PXP_MODE (DEFAULT ); +MEI_PXP_MODE (INIT ); +MEI_PXP_MODE (SETUP ); +MEI_PXP_MODE (READY ); +default : +return "unknown" ; + } +#undef MEI_PXP_MODE +} +static int mei_dbgfs_devstate_show (struct seq_file *m,void *unused) {struct mei_device *dev = m->private;
@@ -112,6 +126,9 @@ static int mei_dbgfs_devstate_show(struct seq_file *m, void *unused)seq_printf (m,"pg: %s, %s\n" ,mei_pg_is_enabled (dev) ?"ENABLED" :"DISABLED" ,mei_pg_state_str (mei_pg_state (dev))); + +seq_printf (m,"pxp: %s\n" ,mei_dev_pxp_mode_str (dev->pxp_mode)); +return 0 ; }DEFINE_SHOW_ATTRIBUTE (mei_dbgfs_devstate);
Signature · 1 line
2.32.0
Alexander Usyskin
maintainerPATCH 20/20 drm/i915/gsc: allocate extended operational memory in LMEM
In reply to Alexander UsyskinFrom: Tomas Winkler <[email protected]>
GSC requires more operational memory than available on chip. Reserve 4M of LMEM for GSC operation. The memory is provided to the GSC as struct resource to the auxiliary data of the child device.
--- drivers/gpu/drm/i915/gt/intel_gsc.c | 92 ++++++++++++++++++++++++++--- drivers/gpu/drm/i915/gt/intel_gsc.h | 3 + 2 files changed, 88 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gt/intel_gsc.c +85 -7
@@ -7,6 +7,7 @@#include <linux/mei_aux.h> #include "i915_drv.h" #include "i915_reg.h" +#include "gem/i915_gem_region.h" #include "gt/intel_gsc.h" #include "gt/intel_gt.h"
@@ -36,12 +37,68 @@ static int gsc_irq_init(int irq)return irq_set_chip_data (irq,NULL ); } +static int +gsc_ext_om_alloc (struct intel_gsc *gsc,struct intel_gsc_intf *intf,size_t size) +{ +struct intel_gt *gt =gsc_to_gt (gsc); +struct drm_i915_gem_object *obj; +void *vaddr; +int err; + + obj =i915_gem_object_create_lmem (gt->i915, size,I915_BO_ALLOC_CONTIGUOUS ); +if (IS_ERR (obj)) { +drm_err (>->i915->drm,"Failed to allocate gsc memory\n" ); +return PTR_ERR (obj); + } + + err =i915_gem_object_pin_pages_unlocked (obj); +if (err) { +drm_err (>->i915->drm,"Failed to pin pages for gsc memory\n" ); + goto out_put; + } + + vaddr =i915_gem_object_pin_map_unlocked (obj,i915_coherent_map_type (gt->i915, obj, true)); +if (IS_ERR (vaddr)) { + err =PTR_ERR (vaddr); +drm_err (>->i915->drm,"Failed to map gsc memory\n" ); + goto out_unpin; + } + +memset (vaddr,0 , obj->base.size); + +i915_gem_object_unpin_map (obj); + + intf->gem_obj = obj; + +return 0 ; + +out_unpin: +i915_gem_object_unpin_pages (obj); +out_put: +i915_gem_object_put (obj); +return err; +} + +static void gsc_ext_om_destroy (struct intel_gsc_intf *intf) +{ +struct drm_i915_gem_object *obj =fetch_and_zero (&intf->gem_obj); + +if (!obj) +return ; + +if (i915_gem_object_has_pinned_pages (obj)) +i915_gem_object_unpin_pages (obj); + +i915_gem_object_put (obj); +} +struct gsc_def {const char *name;unsigned long bar;size_t bar_size;bool use_polling;bool slow_fw; +size_t lmem_size; };/* gsc resources and definitions (HECI1 and HECI2) */
@@ -74,6 +131,7 @@ static const struct gsc_def gsc_def_dg2[] = { .name = "mei-gsc", .bar = DG2_GSC_HECI1_BASE, .bar_size = GSC_BAR_LENGTH, + .lmem_size = SZ_4M, }, { .name = "mei-gscfi",
@@ -90,26 +148,33 @@ static void gsc_release_dev(struct device *dev)kfree (adev); } -static void gsc_destroy_one (struct intel_gsc_intf *intf) +static void gsc_destroy_one (struct drm_i915_private *i915, +struct intel_gsc *gsc,unsigned int intf_id) { +struct intel_gsc_intf *intf = &gsc->intf[intf_id]; +if (intf->adev) {auxiliary_device_delete (&intf->adev->aux_dev);auxiliary_device_uninit (&intf->adev->aux_dev); intf->adev =NULL ; } +if (intf->irq >=0 )irq_free_desc (intf->irq); intf->irq =-1 ; + +gsc_ext_om_destroy (intf); }static void gsc_init_one (struct drm_i915_private *i915, -struct intel_gsc_intf *intf, -unsigned int intf_id) +struct intel_gsc *gsc, +unsigned int intf_id) {struct pci_dev *pdev =to_pci_dev (i915->drm.dev);struct mei_aux_device *adev;struct auxiliary_device *aux_dev;const struct gsc_def *def; +struct intel_gsc_intf *intf = &gsc->intf[intf_id];int ret; intf->irq =-1 ;
@@ -141,7 +206,7 @@ static void gsc_init_one(struct drm_i915_private *i915, intf->irq =irq_alloc_desc (0 );if (intf->irq <0 ) {drm_err (&i915->drm,"gsc irq error %d\n" , intf->irq); -return ; + goto fail; } ret =gsc_irq_init (intf->irq);
@@ -155,6 +220,19 @@ static void gsc_init_one(struct drm_i915_private *i915,if (!adev) goto fail; +if (def->lmem_size) { +dev_dbg (&pdev->dev,"setting up GSC lmem\n" ); + +if (gsc_ext_om_alloc (gsc, intf, def->lmem_size)) { +dev_err (&pdev->dev,"setting up gsc extended operational memory failed\n" ); +kfree (adev); + goto fail; + } + + adev->ext_op_mem.start =i915_gem_object_get_dma_address (intf->gem_obj,0 ); + adev->ext_op_mem.end = adev->ext_op_mem.start + def->lmem_size; + } + adev->irq = intf->irq; adev->bar.parent = &pdev->resource[0 ]; adev->bar.start = def->bar + pdev->resource[0 ].start;
@@ -188,7 +266,7 @@ static void gsc_init_one(struct drm_i915_private *i915,return ; fail: -gsc_destroy_one (intf); +gsc_destroy_one (i915, gsc, intf->id); }static void gsc_irq_handler (struct intel_gt *gt,unsigned int intf_id)
@@ -229,7 +307,7 @@ void intel_gsc_init(struct intel_gsc *gsc, struct drm_i915_private *i915)return ;for (i =0 ; i <INTEL_GSC_NUM_INTERFACES ; i++) -gsc_init_one (i915, &gsc->intf[i], i); +gsc_init_one (i915, gsc, i); }void intel_gsc_fini (struct intel_gsc *gsc)
@@ -241,5 +319,5 @@ void intel_gsc_fini(struct intel_gsc *gsc)return ;for (i =0 ; i <INTEL_GSC_NUM_INTERFACES ; i++) -gsc_destroy_one (&gsc->intf[i]); +gsc_destroy_one (gt->i915, gsc, i); }
drivers/gpu/drm/i915/gt/intel_gsc.h +3 -0
@@ -20,11 +20,14 @@ struct mei_aux_device;/** * struct intel_gsc - graphics security controller +* +* @gem_obj: scratch memory GSC operations * @intf : gsc interface */ struct intel_gsc {struct intel_gsc_intf {struct mei_aux_device *adev; +struct drm_i915_gem_object *gem_obj;int irq;unsigned int id; } intf[INTEL_GSC_NUM_INTERFACES ];
Signature · 1 line
2.32.0
Re: [Intel-gfx] [PATCH 20/20] drm/i915/gsc: allocate extended operational memory in LMEM
Quoted 49 lines · Alexander Usyskin
From: Tomas Winkler <[email protected]>
GSC requires more operational memory than available on chip. Reserve 4M of LMEM for GSC operation. The memory is provided to the GSC as struct resource to the auxiliary data of the child device.
Signed-off-by Tomas Winkler <[email protected]>Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Alan Previn <[email protected]>--- drivers/gpu/drm/i915/gt/intel_gsc.c | 92 ++++++++++++++++++++++++++--- drivers/gpu/drm/i915/gt/intel_gsc.h | 3 + 2 files changed, 88 insertions(+), 7 deletions(-)drivers/gpu/drm/i915/gt/intel_gsc.c +19
-0@@ -7,6 +7,7 @@#include <linux/mei_aux.h> #include "i915_drv.h" #include "i915_reg.h" +#include "gem/i915_gem_region.h" #include "gt/intel_gsc.h" #include "gt/intel_gt.h" @@ -36,12 +37,68 @@ static int gsc_irq_init(int irq)return irq_set_chip_data (irq,NULL ); } +static int +gsc_ext_om_alloc (struct intel_gsc *gsc,struct intel_gsc_intf *intf,size_t size) +{ +struct intel_gt *gt =gsc_to_gt (gsc); +struct drm_i915_gem_object *obj; +void *vaddr; +int err; + + obj =i915_gem_object_create_lmem (gt->i915, size,I915_BO_ALLOC_CONTIGUOUS ); +if (IS_ERR (obj)) { +drm_err (>->i915->drm,"Failed to allocate gsc memory\n" ); +return PTR_ERR (obj); + } + + err =i915_gem_object_pin_pages_unlocked (obj); +if (err) { +drm_err (>->i915->drm,"Failed to pin pages for gsc memory\n" ); + goto out_put;
drivers/gpu/drm/i915/gt/intel_gsc.c static int gsc_irq_init(int irq) · line 67
Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_gsc.c +10
-0+ } + + vaddr =i915_gem_object_pin_map_unlocked (obj,i915_coherent_map_type (gt->i915, obj, true)); +if (IS_ERR (vaddr)) { + err =PTR_ERR (vaddr); +drm_err (>->i915->drm,"Failed to map gsc memory\n" ); + goto out_unpin; + } + +memset (vaddr,0 , obj->base.size);
We should be able to pass I915_BO_ALLOC_CPU_CLEAR to create_lmem, which should do something like this for us, when later calling pin_pages or similar.
Quoted 158 lines
drivers/gpu/drm/i915/gt/intel_gsc.c +56
-7+ +i915_gem_object_unpin_map (obj); + + intf->gem_obj = obj; + +return 0 ; + +out_unpin: +i915_gem_object_unpin_pages (obj); +out_put: +i915_gem_object_put (obj); +return err; +} + +static void gsc_ext_om_destroy (struct intel_gsc_intf *intf) +{ +struct drm_i915_gem_object *obj =fetch_and_zero (&intf->gem_obj); + +if (!obj) +return ; + +if (i915_gem_object_has_pinned_pages (obj)) +i915_gem_object_unpin_pages (obj); + +i915_gem_object_put (obj); +} +struct gsc_def {const char *name;unsigned long bar;size_t bar_size;bool use_polling;bool slow_fw; +size_t lmem_size; };/* gsc resources and definitions (HECI1 and HECI2) */ @@ -74,6 +131,7 @@ static const struct gsc_def gsc_def_dg2[] = { .name = "mei-gsc", .bar = DG2_GSC_HECI1_BASE, .bar_size = GSC_BAR_LENGTH, + .lmem_size = SZ_4M, }, { .name = "mei-gscfi",@@ -90,26 +148,33 @@ static void gsc_release_dev(struct device *dev)kfree (adev); } -static void gsc_destroy_one (struct intel_gsc_intf *intf) +static void gsc_destroy_one (struct drm_i915_private *i915, +struct intel_gsc *gsc,unsigned int intf_id) { +struct intel_gsc_intf *intf = &gsc->intf[intf_id]; +if (intf->adev) {auxiliary_device_delete (&intf->adev->aux_dev);auxiliary_device_uninit (&intf->adev->aux_dev); intf->adev =NULL ; } +if (intf->irq >=0 )irq_free_desc (intf->irq); intf->irq =-1 ; + +gsc_ext_om_destroy (intf); }static void gsc_init_one (struct drm_i915_private *i915, -struct intel_gsc_intf *intf, -unsigned int intf_id) +struct intel_gsc *gsc, +unsigned int intf_id) {struct pci_dev *pdev =to_pci_dev (i915->drm.dev);struct mei_aux_device *adev;struct auxiliary_device *aux_dev;const struct gsc_def *def; +struct intel_gsc_intf *intf = &gsc->intf[intf_id];int ret; intf->irq =-1 ;@@ -141,7 +206,7 @@ static void gsc_init_one(struct drm_i915_private *i915, intf->irq =irq_alloc_desc (0 );if (intf->irq <0 ) {drm_err (&i915->drm,"gsc irq error %d\n" , intf->irq); -return ; + goto fail; } ret =gsc_irq_init (intf->irq);@@ -155,6 +220,19 @@ static void gsc_init_one(struct drm_i915_private *i915,if (!adev) goto fail; +if (def->lmem_size) { +dev_dbg (&pdev->dev,"setting up GSC lmem\n" ); + +if (gsc_ext_om_alloc (gsc, intf, def->lmem_size)) { +dev_err (&pdev->dev,"setting up gsc extended operational memory failed\n" ); +kfree (adev); + goto fail; + } + + adev->ext_op_mem.start =i915_gem_object_get_dma_address (intf->gem_obj,0 ); + adev->ext_op_mem.end = adev->ext_op_mem.start + def->lmem_size; + } + adev->irq = intf->irq; adev->bar.parent = &pdev->resource[0 ]; adev->bar.start = def->bar + pdev->resource[0 ].start;@@ -188,7 +266,7 @@ static void gsc_init_one(struct drm_i915_private *i915,return ; fail: -gsc_destroy_one (intf); +gsc_destroy_one (i915, gsc, intf->id); }static void gsc_irq_handler (struct intel_gt *gt,unsigned int intf_id)@@ -229,7 +307,7 @@ void intel_gsc_init(struct intel_gsc *gsc, struct drm_i915_private *i915)return ;for (i =0 ; i <INTEL_GSC_NUM_INTERFACES ; i++) -gsc_init_one (i915, &gsc->intf[i], i); +gsc_init_one (i915, gsc, i); }void intel_gsc_fini (struct intel_gsc *gsc)@@ -241,5 +319,5 @@ void intel_gsc_fini(struct intel_gsc *gsc)return ;for (i =0 ; i <INTEL_GSC_NUM_INTERFACES ; i++) -gsc_destroy_one (&gsc->intf[i]); +gsc_destroy_one (gt->i915, gsc, i); }drivers/gpu/drm/i915/gt/intel_gsc.h +3
-1@@ -20,11 +20,14 @@ struct mei_aux_device;/** * struct intel_gsc - graphics security controller +* +* @gem_obj: scratch memory GSC operations * @intf : gsc interface */ struct intel_gsc {struct intel_gsc_intf {struct mei_aux_device *adev; +struct drm_i915_gem_object *gem_obj;int irq;unsigned int id; } intf[INTEL_GSC_NUM_INTERFACES ]; --2.32.0
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for GSC support for XeHP SDV and DG2 platforms
In reply to Alexander Usyskin== Series Details ==
== Series Details ==
Series: GSC support for XeHP SDV and DG2 platforms
URL : https://patchwork.freedesktop.org/series/102339/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 57df08911dad drm/i915/gsc: add gsc as a mei auxiliary device -:65: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #65: new file mode 100644
-:459: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'dev_priv' - possible side-effects? #459: FILE: drivers/gpu/drm/i915/i915_drv.h:1316:
+#define HAS_HECI_GSC(dev_priv) (HAS_HECI_PXP(dev_priv) || HAS_HECI_GSCFI(dev_priv))
total: 0 errors, 1 warnings, 1 checks, 418 lines checkedcbe282748891 mei: add support for graphics system controller (gsc) devices
-:57: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #57:
new file mode 100644
-:255: WARNING:MODULE_LICENSE: Prefer "GPL" over "GPL v2" - see commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity") #255: FILE: drivers/misc/mei/gsc-me.c:194:
+MODULE_LICENSE("GPL v2");
total: 0 errors, 2 warnings, 0 checks, 297 lines checked73727156241a mei: gsc: setup char driver alive in spite of firmware handshake failure cf7d610b88d2 mei: gsc: add runtime pm handlers3b921daf3d69 mei: gsc: retrieve the firmware version7bf14c184625 HAX: drm/i915: force INTEL_MEI_GSC on for CI79367081c714 drm/i915/gsc: skip irq initialization if using pollinge4627be07856 drm/i915/gsc: add slow_fw flag to the mei auxiliary device c3a1f69fab81 drm/i915/gsc: add slow_fw flag to the gsc device definition c8d254e0de12 drm/i915/gsc: add GSC XeHP SDV platform definition7102bca609de mei: gsc: use polling instead of interruptsce5e1f8ea33d mei: gsc: wait for reset thread on stop613f4221d396 mei: extend timeouts on slow devices.c7ef5e1c508b drm/i915/dg2: add gsc with special gsc bar offsetsa289d7722c57 mei: bus: export common mkhi definitions into a separate header -:78: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #78:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 101 lines checked f767b7e3953f mei: mkhi: add memory ready command
-:46: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #46: FILE: drivers/misc/mei/mkhi.h:54:
+ uint32_t flags;
total: 0 errors, 0 warnings, 1 checks, 29 lines checkeded778c11fb2f mei: gsc: setup gsc extended operational memory
-:51: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'cldev->bus->pxp_mode != MEI_DEV_PXP_INIT' #51: FILE: drivers/misc/mei/bus-fixup.c:257:
+ if (!cldev->bus->fw_f_fw_ver_supported &&
+ (cldev->bus->pxp_mode != MEI_DEV_PXP_INIT))
total: 0 errors, 0 warnings, 1 checks, 224 lines checked0c7708f978ad mei: gsc: add transition to PXP mode in resume flow d7761f03a774 mei: debugfs: add pxp mode to devstate in debugfs
-:19: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #19: FILE: drivers/misc/mei/debugfs.c:91:
+#define MEI_PXP_MODE(state) case MEI_DEV_PXP_##state: return #state
total: 1 errors, 0 warnings, 0 checks, 29 lines checked 9f233cb0bb63 drm/i915/gsc: allocate extended operational memory in LMEM -:109: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #109: FILE: drivers/gpu/drm/i915/gt/intel_gsc.c:152:
+static void gsc_destroy_one(struct drm_i915_private *i915,
+ struct intel_gsc *gsc, unsigned int intf_id)
total: 0 errors, 0 warnings, 1 checks, 181 lines checked
Patchwork
CI[Intel-gfx] ✗ Fi.CI.SPARSE: warning for GSC support for XeHP SDV and DG2 platforms
In reply to Alexander Usyskin== Series Details ==
== Series Details ==
Series: GSC support for XeHP SDV and DG2 platforms
URL : https://patchwork.freedesktop.org/series/102339/
State : warning
== Summary ==
$ dim sparse --fast origin/drm-tip Sparse version: v0.6.2 Fast mode used, each commit won't be checked separately.
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for GSC support for XeHP SDV and DG2 platforms
In reply to Alexander Usyskin== Series Details ==
== Series Details ==
Series: GSC support for XeHP SDV and DG2 platforms
URL : https://patchwork.freedesktop.org/series/102339/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_11472 -> Patchwork_22813
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_22813 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_22813, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/index.html
Participating hosts (47 -> 45)
------------------------------
Additional (3): bat-hsw-1 bat-rpls-2 bat-adlp-4
Missing (5): shard-tglu fi-bsw-cyan fi-cfl-8109u fi-blb-e6850 fi-bdw-samus
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_22813:
### IGT changes ###
#### Possible regressions ####
* igt@kms_chamelium@dp-crc-fast:
- bat-adlp-4: NOTRUN -> [SKIP][1] +146 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/bat-adlp-4/igt@[email protected]
#### Warnings ####
* igt@runner@aborted:
- fi-rkl-11600: [FAIL][2] ([i915#4312]) -> [FAIL][3]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-rkl-11600/igt@[email protected]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-rkl-11600/igt@[email protected]
- fi-kbl-7500u: [FAIL][4] ([i915#4312]) -> [FAIL][5]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-kbl-7500u/igt@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-kbl-7500u/igt@[email protected]
- fi-kbl-7567u: [FAIL][6] ([i915#4312]) -> [FAIL][7]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-kbl-7567u/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-kbl-7567u/igt@[email protected]
- fi-skl-guc: [FAIL][8] ([i915#4312] / [i915#5257]) -> [FAIL][9]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-skl-guc/igt@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-skl-guc/igt@[email protected]
- fi-skl-6700k2: [FAIL][10] ([i915#4312]) -> [FAIL][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-skl-6700k2/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-skl-6700k2/igt@[email protected]
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@gem_lmem_swapping@basic:
- {bat-rpls-2}: NOTRUN -> [SKIP][12] +146 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/bat-rpls-2/igt@[email protected]
- {bat-dg2-9}: NOTRUN -> [SKIP][13]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/bat-dg2-9/igt@[email protected]
* igt@kms_cursor_legacy@basic-flip-after-cursor-atomic:
- {bat-jsl-2}: NOTRUN -> [SKIP][14] +146 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/bat-jsl-2/igt@[email protected]
* igt@runner@aborted:
- {bat-hsw-1}: NOTRUN -> [FAIL][15]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/bat-hsw-1/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_22813 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_close_race@basic-process:
- fi-ivb-3770: NOTRUN -> [SKIP][16] ([fdo#109271]) +146 similar issues
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-ivb-3770/igt@[email protected]
* igt@gem_exec_fence@basic-await:
- fi-bsw-nick: NOTRUN -> [SKIP][17] ([fdo#109271]) +151 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-bsw-nick/igt@[email protected]
* igt@kms_flip@basic-flip-vs-dpms:
- fi-kbl-soraka: NOTRUN -> [SKIP][18] ([fdo#109271]) +146 similar issues
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-kbl-soraka/igt@[email protected]
* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c:
- bat-adlp-4: NOTRUN -> [SKIP][19] ([i915#5341])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/bat-adlp-4/igt@[email protected]
- fi-bsw-nick: NOTRUN -> [SKIP][20] ([fdo#109271] / [i915#5341])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-bsw-nick/igt@[email protected]
- fi-kbl-soraka: NOTRUN -> [SKIP][21] ([fdo#109271] / [i915#5341])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-kbl-soraka/igt@[email protected]
- fi-ivb-3770: NOTRUN -> [SKIP][22] ([fdo#109271] / [i915#5341])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-ivb-3770/igt@[email protected]
* igt@runner@aborted:
- bat-adlp-4: NOTRUN -> [FAIL][23] ([i915#4312])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/bat-adlp-4/igt@[email protected]
#### Warnings ####
* igt@runner@aborted:
- fi-bsw-kefka: [FAIL][24] ([i915#4312]) -> [FAIL][25] ([i915#3690] / [i915#4312])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-bsw-kefka/igt@[email protected]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-bsw-kefka/igt@[email protected]
- fi-bsw-nick: [FAIL][26] ([i915#3690]) -> [FAIL][27] ([i915#3690] / [i915#4312])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-bsw-nick/igt@[email protected]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-bsw-nick/igt@[email protected]
- fi-kbl-soraka: [FAIL][28] -> [FAIL][29] ([i915#4312])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-kbl-soraka/igt@[email protected]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-kbl-soraka/igt@[email protected]
- fi-hsw-4770: [FAIL][30] ([i915#4312]) -> [FAIL][31] ([i915#4312] / [i915#5594])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-hsw-4770/igt@[email protected]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-hsw-4770/igt@[email protected]
- fi-ivb-3770: [FAIL][32] -> [FAIL][33] ([i915#4312])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-ivb-3770/igt@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-ivb-3770/igt@[email protected]
- fi-tgl-1115g4: [FAIL][34] ([i915#4312] / [i915#5257]) -> [FAIL][35] ([i915#3690])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-tgl-1115g4/igt@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-tgl-1115g4/igt@[email protected]
- fi-cfl-guc: [FAIL][36] ([i915#4312]) -> [FAIL][37] ([i915#4312] / [i915#5257])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11472/fi-cfl-guc/igt@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/fi-cfl-guc/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
[i915#3690]: https://gitlab.freedesktop.org/drm/intel/issues/3690
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#5171]: https://gitlab.freedesktop.org/drm/intel/issues/5171
[i915#5174]: https://gitlab.freedesktop.org/drm/intel/issues/5174
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5257]: https://gitlab.freedesktop.org/drm/intel/issues/5257
[i915#5341]: https://gitlab.freedesktop.org/drm/intel/issues/5341
[i915#5594]: https://gitlab.freedesktop.org/drm/intel/issues/5594
Build changes
-------------
* Linux: CI_DRM_11472 -> Patchwork_22813
CI-20190529: 20190529
CI_DRM_11472: 85882df13168c5f46b41401b96975de857e3ccac @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6415: c3b690bd5f7fb1fb7ed786ab0f3b815930a6a55f @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_22813: 9f233cb0bb6312eed7a93dca2018f9db889158b6 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
9f233cb0bb63 drm/i915/gsc: allocate extended operational memory in LMEM d7761f03a774 mei: debugfs: add pxp mode to devstate in debugfs 0c7708f978ad mei: gsc: add transition to PXP mode in resume flow ed778c11fb2f mei: gsc: setup gsc extended operational memory f767b7e3953f mei: mkhi: add memory ready commanda289d7722c57 mei: bus: export common mkhi definitions into a separate header c7ef5e1c508b drm/i915/dg2: add gsc with special gsc bar offsets 613f4221d396 mei: extend timeouts on slow devices.ce5e1f8ea33d mei: gsc: wait for reset thread on stop7102bca609de mei: gsc: use polling instead of interruptsc8d254e0de12 drm/i915/gsc: add GSC XeHP SDV platform definition c3a1f69fab81 drm/i915/gsc: add slow_fw flag to the gsc device definition e4627be07856 drm/i915/gsc: add slow_fw flag to the mei auxiliary device 79367081c714 drm/i915/gsc: skip irq initialization if using polling 7bf14c184625 HAX: drm/i915: force INTEL_MEI_GSC on for CI3b921daf3d69 mei: gsc: retrieve the firmware versioncf7d610b88d2 mei: gsc: add runtime pm handlers73727156241a mei: gsc: setup char driver alive in spite of firmware handshake failure cbe282748891 mei: add support for graphics system controller (gsc) devices 57df08911dad drm/i915/gsc: add gsc as a mei auxiliary device
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22813/index.html