Skip to contentSkip to conversation

drm/i915/uc: Make GuC/HuC fw fetch and loading functions/file structure symmetric

PATCH In review Sagar Arun Kamble 3 participants 7 messages Mar 1, 2018 – Mar 14, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/i915/uc: Make GuC/HuC fw fetch and loading functions/file structure symmetric

GuC load function is named intel_guc_fw_upload() and HuC load function is named intel_huc_init_hw(). Make them consistent intel_*_fw_upload. Also move HuC fw loading functions and declarations to separate files intel_huc_fw.c|h like GuC.

While at this, do below changes
1. Update kernel-doc comment for intel_*_fw_upload() functions
2. s/huc_ucode_xfer/huc_fw_xfer
3. Introduce intel_huc_fw_init_early()

v2: Changed patch to update HuC functions instead of changing
guc_fw_upload and update file structure. (Michal Wajdeczko)

v3: Added SPDX License identifier to huc_fw.c|h. (Michal Wajdeczko)

Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Anusha Srivatsa <[email protected]>
---
 drivers/gpu/drm/i915/Makefile       |   3 +-
 drivers/gpu/drm/i915/intel_guc_fw.c |  10 +--
 drivers/gpu/drm/i915/intel_huc.c    | 154 +--------------------------------
 drivers/gpu/drm/i915/intel_huc.h    |   2 +-
 drivers/gpu/drm/i915/intel_huc_fw.c | 166 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_huc_fw.h |  15 ++++
 drivers/gpu/drm/i915/intel_uc.c     |   2 +-
 7 files changed, 191 insertions(+), 161 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_huc_fw.c
 create mode 100644 drivers/gpu/drm/i915/intel_huc_fw.h
drivers/gpu/drm/i915/Makefile +2 -1
index 881d712..1bd9bc5 100644
@@ -89,7 +89,8 @@ i915-y += intel_uc.o \
 	  intel_guc_fw.o \
 	  intel_guc_log.o \
 	  intel_guc_submission.o \
-	  intel_huc.o
+	  intel_huc.o \
+	  intel_huc_fw.o
 
 # autogenerated null render state
 i915-y += intel_renderstate_gen6.o \
drivers/gpu/drm/i915/intel_guc_fw.c +5 -5
index 3b09329..d07f2b9 100644
@@ -269,15 +269,15 @@ static int guc_fw_xfer(struct intel_uc_fw *guc_fw, struct i915_vma *vma)
 }
 
 /**
- * intel_guc_fw_upload() - finish preparing the GuC for activity
+ * intel_guc_fw_upload() - load GuC uCode to device
  * @guc: intel_guc structure
  *
- * Called during driver loading and also after a GPU reset.
+ * Called from intel_uc_init_hw() during driver load, resume from sleep and
+ * after a GPU reset.
  *
- * The main action required here it to load the GuC uCode into the device.
  * The firmware image should have already been fetched into memory by the
- * earlier call to intel_guc_init(), so here we need only check that
- * worked, and then transfer the image to the h/w.
+ * earlier call to intel_uc_init_fw(), so here we need to only check that
+ * fetch succeeded, and then transfer the image to the h/w.
  *
  * Return:	non-zero code on error
  */
drivers/gpu/drm/i915/intel_huc.c +1 -153

162 lines not on this page · raw message

drivers/gpu/drm/i915/intel_huc.h +1 -1
index 40039db..5d6e804 100644
@@ -26,6 +26,7 @@
 #define _INTEL_HUC_H_
 
 #include "intel_uc_fw.h"
+#include "intel_huc_fw.h"
 
 struct intel_huc {
 	/* Generic uC firmware management */
@@ -35,7 +36,6 @@ struct intel_huc {
 };
 
 void intel_huc_init_early(struct intel_huc *huc);
-int intel_huc_init_hw(struct intel_huc *huc);
 int intel_huc_auth(struct intel_huc *huc);
 
 #endif
drivers/gpu/drm/i915/intel_huc_fw.c new file +166 -0

166 lines not on this page · raw message

drivers/gpu/drm/i915/intel_huc_fw.h new file +15 -0
new file mode 100644
index 0000000..8a00a0e
@@ -0,0 +1,15 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright © 2014-2018 Intel Corporation
+ */
+
+#ifndef _INTEL_HUC_FW_H_
+#define _INTEL_HUC_FW_H_
+
+struct intel_huc;
+
+void intel_huc_fw_init_early(struct intel_huc *huc);
+int intel_huc_fw_upload(struct intel_huc *huc);
+
+#endif
drivers/gpu/drm/i915/intel_uc.c +1 -1
index 9f1bac6..8e25474 100644
@@ -361,7 +361,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 			goto err_out;
 
 		if (USES_HUC(dev_priv)) {
-			ret = intel_huc_init_hw(huc);
+			ret = intel_huc_fw_upload(huc);
 			if (ret)
 				goto err_out;
 		}
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✓ Fi.CI.BAT: success for series starting with [v3,1/1] drm/i915/uc: Make GuC/HuC fw fetch and loading functions/file structure symmetric

== Series Details ==

== Series Details ==

Series: series starting with [v3,1/1] drm/i915/uc: Make GuC/HuC fw fetch and loading functions/file structure symmetric
URL : https://patchwork.freedesktop.org/series/39224/
State : success

== Summary ==

Series 39224v1 series starting with [v3,1/1] drm/i915/uc: Make GuC/HuC fw fetch and loading functions/file structure symmetric
https://patchwork.freedesktop.org/api/1.0/series/39224/revisions/1/mbox/

---- Known issues:

Test debugfs_test:

        Subgroup read_all_entries:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713
Test gem_mmap_gtt:
        Subgroup basic-small-bo-tiledx:
                pass       -> FAIL       (fi-gdg-551) fdo#102575
Test kms_chamelium:
        Subgroup dp-edid-read:
                pass       -> FAIL       (fi-kbl-7500u) fdo#105310

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#105310 https://bugs.freedesktop.org/show_bug.cgi?id=105310

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:416s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:423s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:372s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:495s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:279s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:483s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:491s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:470s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:460s
fi-cfl-8700k     total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:390s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:570s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:580s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:414s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:290s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:510s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:389s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:413s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:454s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:412s
fi-kbl-7500u     total:288  pass:262  dwarn:1   dfail:0   fail:1   skip:24  time:451s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:491s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:448s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:493s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:588s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:427s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:502s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:521s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:487s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:482s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:409s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:433s
fi-snb-2520m     total:3    pass:2    dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:392s

Blacklisted hosts:
fi-cfl-u total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:505s

7fe823aaeff7c50eeaf9b238a179b41771e08f9e drm-tip: 2018y-03m-01d-15h-58m-23s UTC integration manifest 5b17f9eb12a5 drm/i915/uc: Make GuC/HuC fw fetch and loading functions/file structure symmetric

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8201/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✓ Fi.CI.IGT: success for series starting with [v3,1/1] drm/i915/uc: Make GuC/HuC fw fetch and loading functions/file structure symmetric

In reply to Sagar Arun Kamble
== Series Details ==

== Series Details ==

Series: series starting with [v3,1/1] drm/i915/uc: Make GuC/HuC fw fetch and loading functions/file structure symmetric
URL : https://patchwork.freedesktop.org/series/39224/
State : success

== Summary ==

---- Possible new issues:

Test kms_fence_pin_leak:

                incomplete -> PASS       (shard-apl)

---- Known issues:

Test gem_eio:

        Subgroup in-flight:
                pass       -> INCOMPLETE (shard-apl) fdo#104945 +1
Test kms_chv_cursor_fail:
        Subgroup pipe-b-64x64-right-edge:
                pass       -> DMESG-WARN (shard-snb) fdo#105185 +4
Test kms_flip:
        Subgroup 2x-flip-vs-expired-vblank-interruptible:
                pass       -> FAIL       (shard-hsw) fdo#102887
Test perf:
        Subgroup polling:
                pass       -> FAIL       (shard-hsw) fdo#102252

fdo#104945 https://bugs.freedesktop.org/show_bug.cgi?id=104945
fdo#105185 https://bugs.freedesktop.org/show_bug.cgi?id=105185
fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252

shard-apl        total:3300 pass:1733 dwarn:1   dfail:0   fail:6   skip:1557 time:11413s
shard-hsw        total:3461 pass:1766 dwarn:1   dfail:0   fail:3   skip:1690 time:11867s
shard-snb        total:3461 pass:1357 dwarn:4   dfail:0   fail:1   skip:2099 time:6602s

Blacklisted hosts:
shard-kbl total:3461 pass:1945 dwarn:1 dfail:0 fail:7 skip:1508 time:9419s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8201/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
In reply to Sagar Arun Kamble

Quoting Sagar Arun Kamble (2018-03-01 16:45:45)

Quoted 6 lines
drivers/gpu/drm/i915/intel_huc_fw.c new file +6 -0
+static int huc_fw_xfer(struct intel_uc_fw *huc_fw, struct i915_vma *vma)
+{
+       struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw);
+       struct drm_i915_private *dev_priv = huc_to_i915(huc);
+       unsigned long offset = 0;
+       u32 size;

drivers/gpu/drm/i915/intel_huc_fw.c line 123

Quoted 10 lines
drivers/gpu/drm/i915/intel_huc_fw.c new file +10 -0
+       int ret;
+
+       GEM_BUG_ON(huc_fw->type != INTEL_UC_FW_TYPE_HUC);
+
+       intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
+
+       /* Set the source address for the uCode */
+       offset = guc_ggtt_offset(vma) + huc_fw->header_offset;
+       I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset));
+       I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF);

So these same registers are used to transfer the guc image. What serialisation do we have between the two to prevent conflicts?

(lockdep_assert_held the appropriate guard with explanation :)

As it's not a new issue, please follow up with another patch and we'll apply this in the meantime.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
Quoted 20 lines · Chris Wilson

Quoting Sagar Arun Kamble (2018-03-01 16:45:45)

Quoted 6 lines
drivers/gpu/drm/i915/intel_huc_fw.c new file +6 -0
+static int huc_fw_xfer(struct intel_uc_fw *huc_fw, struct i915_vma *vma)
+{
+       struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw);
+       struct drm_i915_private *dev_priv = huc_to_i915(huc);
+       unsigned long offset = 0;
+       u32 size;

drivers/gpu/drm/i915/intel_huc_fw.c line 123

Quoted 10 lines
drivers/gpu/drm/i915/intel_huc_fw.c new file +10 -0
+       int ret;
+
+       GEM_BUG_ON(huc_fw->type != INTEL_UC_FW_TYPE_HUC);
+
+       intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
+
+       /* Set the source address for the uCode */
+       offset = guc_ggtt_offset(vma) + huc_fw->header_offset;
+       I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset));
+       I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF);

So these same registers are used to transfer the guc image. What serialisation do we have between the two to prevent conflicts?

Quoted 1 line

(lockdep_assert_held the appropriate guard with explanation :)

Yes. Currently they are implicitly serialized by load ordering. Will need locking if async load is to be done. But no harm in adding locking/lockdep now. Will do. Thank you.

Quoted 3 lines

As it's not a new issue, please follow up with another patch and we'll apply this in the meantime.
-Chris

Signature · 7 lines
Thanks,
Sagar

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 25 lines · Sagar Arun Kamble
Quoted 22 lines · Chris Wilson

Quoting Sagar Arun Kamble (2018-03-01 16:45:45)

Quoted 9 lines

+static int huc_fw_xfer(struct intel_uc_fw *huc_fw, struct i915_vma *vma)
+{
+       struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw);
+       struct drm_i915_private *dev_priv = huc_to_i915(huc); +       unsigned long offset = 0;
+       u32 size;
+       int ret;

drivers/gpu/drm/i915/intel_huc_fw.c line 123

Quoted 9 lines
drivers/gpu/drm/i915/intel_huc_fw.c new file +9 -0
+
+       GEM_BUG_ON(huc_fw->type != INTEL_UC_FW_TYPE_HUC);
+
+       intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
+
+       /* Set the source address for the uCode */
+       offset = guc_ggtt_offset(vma) + huc_fw->header_offset;
+       I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset));
+       I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF);

So these same registers are used to transfer the guc image. What serialisation do we have between the two to prevent conflicts?

Quoted 3 lines
Quoted 1 line

(lockdep_assert_held the appropriate guard with explanation :)

Yes. Currently they are implicitly serialized by load ordering. Will need locking if async load is to be done. But no harm in adding locking/lockdep now. Will do. Thank you.

Hi Chris,

Checked more on this and I see that *HuC has to be loaded before GuC always* hence we will not have situation of dma_xfer for them happening in parallel. So we don't need the locking.

Thanks,
Sagar

Quoted 4 lines
Quoted 3 lines

As it's not a new issue, please follow up with another patch and we'll apply this in the meantime.
-Chris

Signature · 7 lines
Thanks,
Sagar

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
In reply to Sagar Arun Kamble

Quoting Sagar Arun Kamble (2018-03-01 16:45:45)

Quoted 13 lines

GuC load function is named intel_guc_fw_upload() and HuC load function is named intel_huc_init_hw(). Make them consistent intel_*_fw_upload. Also move HuC fw loading functions and declarations to separate files intel_huc_fw.c|h like GuC.

While at this, do below changes
1. Update kernel-doc comment for intel_*_fw_upload() functions
2. s/huc_ucode_xfer/huc_fw_xfer
3. Introduce intel_huc_fw_init_early()

v2: Changed patch to update HuC functions instead of changing
guc_fw_upload and update file structure. (Michal Wajdeczko)

Quoted 8 lines

v3: Added SPDX License identifier to huc_fw.c|h. (Michal Wajdeczko)

Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Anusha Srivatsa <[email protected]>

Applied, thanks for the patch and review.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx