126126 * not intended for normal execution and will taint the kernel with TAINT_TEST
127127 * when used.
128128 *
129- * Currently this is implemented only for post context restore. Examples:
129+ * Currently this is implemented only for post and mid context restore.
130+ * Examples:
130131 *
131- * #. Execute a LRI command to write 0xDEADBEEF to register 0x4f10::
132+ * #. Execute a LRI command to write 0xDEADBEEF to register 0x4f10 after the
133+ * normal context restore::
132134 *
133135 * # echo 'rcs cmd 11000001 4F100 DEADBEEF' \
134136 * > /sys/kernel/config/xe/0000:03:00.0/ctx_restore_post_bb
135137 *
138+ * #. Execute a LRI command to write 0xDEADBEEF to register 0x4f10 at the
139+ * beginning of the context restore::
140+ *
141+ * # echo 'rcs cmd 11000001 4F100 DEADBEEF' \
142+ * > /sys/kernel/config/xe/0000:03:00.0/ctx_restore_mid_bb
143+
136144 * #. Load certain values in a couple of registers (it can be used as a simpler
137145 * alternative to the `cmd`) action::
138146 *
146154 * When using multiple lines, make sure to use a command that is
147155 * implemented with a single write syscall, like HEREDOC.
148156 *
149- * This attribute can only be set before binding to the device.
157+ * These attributes can only be set before binding to the device.
150158 *
151159 * Remove devices
152160 * ==============
@@ -168,6 +176,7 @@ struct xe_config_group_device {
168176 struct xe_config_device {
169177 u64 engines_allowed ;
170178 struct wa_bb ctx_restore_post_bb [XE_ENGINE_CLASS_MAX ];
179+ struct wa_bb ctx_restore_mid_bb [XE_ENGINE_CLASS_MAX ];
171180 bool survivability_mode ;
172181 bool enable_psmi ;
173182 } config ;
@@ -467,6 +476,13 @@ static ssize_t wa_bb_show(struct xe_config_group_device *dev,
467476 return p - data ;
468477}
469478
479+ static ssize_t ctx_restore_mid_bb_show (struct config_item * item , char * page )
480+ {
481+ struct xe_config_group_device * dev = to_xe_config_group_device (item );
482+
483+ return wa_bb_show (dev , dev -> config .ctx_restore_mid_bb , page , SZ_4K );
484+ }
485+
470486static ssize_t ctx_restore_post_bb_show (struct config_item * item , char * page )
471487{
472488 struct xe_config_group_device * dev = to_xe_config_group_device (item );
@@ -623,6 +639,14 @@ static ssize_t wa_bb_store(struct wa_bb wa_bb[static XE_ENGINE_CLASS_MAX],
623639 return len ;
624640}
625641
642+ static ssize_t ctx_restore_mid_bb_store (struct config_item * item ,
643+ const char * data , size_t sz )
644+ {
645+ struct xe_config_group_device * dev = to_xe_config_group_device (item );
646+
647+ return wa_bb_store (dev -> config .ctx_restore_mid_bb , dev , data , sz );
648+ }
649+
626650static ssize_t ctx_restore_post_bb_store (struct config_item * item ,
627651 const char * data , size_t sz )
628652{
@@ -631,12 +655,14 @@ static ssize_t ctx_restore_post_bb_store(struct config_item *item,
631655 return wa_bb_store (dev -> config .ctx_restore_post_bb , dev , data , sz );
632656}
633657
658+ CONFIGFS_ATTR (, ctx_restore_mid_bb );
634659CONFIGFS_ATTR (, ctx_restore_post_bb );
635660CONFIGFS_ATTR (, enable_psmi );
636661CONFIGFS_ATTR (, engines_allowed );
637662CONFIGFS_ATTR (, survivability_mode );
638663
639664static struct configfs_attribute * xe_config_device_attrs [] = {
665+ & attr_ctx_restore_mid_bb ,
640666 & attr_ctx_restore_post_bb ,
641667 & attr_enable_psmi ,
642668 & attr_engines_allowed ,
@@ -909,7 +935,19 @@ u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev,
909935 enum xe_engine_class class ,
910936 const u32 * * cs )
911937{
912- return 0 ;
938+ struct xe_config_group_device * dev = find_xe_config_group_device (pdev );
939+ u32 len ;
940+
941+ if (!dev )
942+ return 0 ;
943+
944+ if (cs )
945+ * cs = dev -> config .ctx_restore_mid_bb [class ].cs ;
946+
947+ len = dev -> config .ctx_restore_mid_bb [class ].len ;
948+ config_group_put (& dev -> group );
949+
950+ return len ;
913951}
914952
915953/**
0 commit comments