Skip to contentSkip to conversation

drm/xe/hwmon: expose fan speed

bug report Dan Carpenter 2 participants 2 messages Jun 5, 2025

lore
Share & tools
lore
#0 lore raw

Hello Raag Jadav,

Commit 28f79ac609de ("drm/xe/hwmon: expose fan speed") from Mar 12, 2025 (linux-next), leads to the following Smatch static checker warning:

	drivers/gpu/drm/xe/xe_hwmon.c:1008 xe_hwmon_fan_is_visible()
	error: uninitialized symbol 'uval'.

drivers/gpu/drm/xe/xe_hwmon.c

    995 static umode_t
    996 xe_hwmon_fan_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
    997 {
    998         u32 uval;
    999 
    1000         if (!hwmon->xe->info.has_fan_control)
    1001                 return 0;
    1002 
    1003         switch (attr) {
    1004         case hwmon_fan_input:
    1005                 if (xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_NUM_FANS, &uval))
    1006                         return 0;
    1007 
--> 1008                 return channel < uval ? 0444 : 0;
    1009         default:
    1010                 return 0;
    1011         }
    1012 }

The problem is in pcode_mailbox_rw() where we return success without writing to *uval.

    89  static int pcode_mailbox_rw(struct xe_tile *tile, u32 mbox, u32 *data0, u32 *data1,
    90                              unsigned int timeout_ms, bool return_data,
    91                              bool atomic)
    92  {
    93          if (tile_to_xe(tile)->info.skip_pcode)
    94                  return 0;
                        ^^^^^^^^^

data0 is *uval.

    95  
    96          lockdep_assert_held(&tile->pcode.lock);
    97  
    98          return __pcode_mailbox_rw(tile, mbox, data0, data1, timeout_ms, return_data, atomic);
    99  }

regards,
dan carpenter

#1 lore raw
Quoted 32 lines · Dan Carpenter

Hello Raag Jadav,

Commit 28f79ac609de ("drm/xe/hwmon: expose fan speed") from Mar 12, 2025 (linux-next), leads to the following Smatch static checker warning:

	drivers/gpu/drm/xe/xe_hwmon.c:1008 xe_hwmon_fan_is_visible()
	error: uninitialized symbol 'uval'.

drivers/gpu/drm/xe/xe_hwmon.c

    995 static umode_t
    996 xe_hwmon_fan_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
    997 {
    998         u32 uval;
    999 
    1000         if (!hwmon->xe->info.has_fan_control)
    1001                 return 0;
    1002 
    1003         switch (attr) {
    1004         case hwmon_fan_input:
    1005                 if (xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_NUM_FANS, &uval))
    1006                         return 0;
    1007 
--> 1008                 return channel < uval ? 0444 : 0;
    1009         default:
    1010                 return 0;
    1011         }
    1012 }

The problem is in pcode_mailbox_rw() where we return success without writing to *uval.

Quoted 8 lines
    89  static int pcode_mailbox_rw(struct xe_tile *tile, u32 mbox, u32 *data0, u32 *data1,
    90                              unsigned int timeout_ms, bool return_data,
    91                              bool atomic)
    92  {
    93          if (tile_to_xe(tile)->info.skip_pcode)
    94                  return 0;
                        ^^^^^^^^^

data0 is *uval.

Thanks for the report. IIUC xe->info.skip_pcode is set for IS_SRIOV_VF(xe) cases and we don't register hwmon interface in that case.

Raag