Skip to contentSkip to conversation

drm/i915/uc: prefer intel_gt over i915 in GuC/HuC paths

bug report Dan Carpenter 3 participants 3 messages Jul 23, 2019

lore
Share & tools
lore
#0 lore raw

Hello Daniele Ceraolo Spurio,

The patch 84b1ca2f0e68: "drm/i915/uc: prefer intel_gt over i915 in GuC/HuC paths" from Jul 13, 2019, leads to the following static checker warning:

	drivers/gpu/drm/i915/gt/uc/intel_huc.c:173 intel_huc_check_status()
	warn: masking a bool

drivers/gpu/drm/i915/gt/uc/intel_huc.c
161 int intel_huc_check_status(struct intel_huc *huc) 162 {

   163          struct intel_gt *gt = huc_to_gt(huc);
   164          intel_wakeref_t wakeref;
   165          bool status = false;
                ^^^^^^^^^^^^^^^^^^^
   166  
   167          if (!intel_uc_is_using_huc(&gt->uc))
   168                  return -ENODEV;
   169  
   170          with_intel_runtime_pm(&gt->i915->runtime_pm, wakeref)
   171                  status = intel_uncore_read(gt->uncore, huc->status.reg);
   172  
   173          return (status & huc->status.mask) == huc->status.value;
                        ^^^^^^

It definitely looks like status should be a u32 or something.

174 }

regards,
dan carpenter
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#1 lore raw
Quoted 26 lines · Dan Carpenter

Hello Daniele Ceraolo Spurio,

The patch 84b1ca2f0e68: "drm/i915/uc: prefer intel_gt over i915 in GuC/HuC paths" from Jul 13, 2019, leads to the following static checker warning:

	drivers/gpu/drm/i915/gt/uc/intel_huc.c:173 intel_huc_check_status()
	warn: masking a bool

drivers/gpu/drm/i915/gt/uc/intel_huc.c

    161  int intel_huc_check_status(struct intel_huc *huc)
    162  {
    163          struct intel_gt *gt = huc_to_gt(huc);
    164          intel_wakeref_t wakeref;
    165          bool status = false;
                 ^^^^^^^^^^^^^^^^^^^
    166
    167          if (!intel_uc_is_using_huc(&gt->uc))
    168                  return -ENODEV;
    169
    170          with_intel_runtime_pm(&gt->i915->runtime_pm, wakeref)
    171                  status = intel_uncore_read(gt->uncore, huc->status.reg);
    172
    173          return (status & huc->status.mask) == huc->status.value;
                         ^^^^^^
Quoted 1 line

It definitely looks like status should be a u32 or something.

Yes, definitely wrong. Will send a fix soon.
This highlights even more the lack of testing we have around HuC.

Daniele

Quoted 4 lines
    174  }

regards,
dan carpenter

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

#2 lore raw

Quoting Daniele Ceraolo Spurio (2019-07-23 16:08:49)

Quoted 29 lines · Dan Carpenter
Quoted 26 lines

Hello Daniele Ceraolo Spurio,

The patch 84b1ca2f0e68: "drm/i915/uc: prefer intel_gt over i915 in GuC/HuC paths" from Jul 13, 2019, leads to the following static checker warning:

drivers/gpu/drm/i915/gt/uc/intel_huc.c:173 intel_huc_check_status()
warn: masking a bool

drivers/gpu/drm/i915/gt/uc/intel_huc.c

    161  int intel_huc_check_status(struct intel_huc *huc)
    162  {
    163          struct intel_gt *gt = huc_to_gt(huc);
    164          intel_wakeref_t wakeref;
    165          bool status = false;
                 ^^^^^^^^^^^^^^^^^^^
    166
    167          if (!intel_uc_is_using_huc(&gt->uc))
    168                  return -ENODEV;
    169
    170          with_intel_runtime_pm(&gt->i915->runtime_pm, wakeref)
    171                  status = intel_uncore_read(gt->uncore, huc->status.reg);
    172
    173          return (status & huc->status.mask) == huc->status.value;
                         ^^^^^^
Quoted 4 lines
Quoted 1 line

It definitely looks like status should be a u32 or something.

Yes, definitely wrong. Will send a fix soon.
This highlights even more the lack of testing we have around HuC.

On gen11, this works out as return (status & true) == true;

So while definitely incorrect code, it just happens to work so long as we don't look at gen9...
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx