Author: cem
Date: Wed Jan 29 03:15:34 2020
New Revision: 357240
URL: https://svnweb.freebsd.org/changeset/base/357240

Log:
  hwpstate_intel(4): Silence/fix Coverity reports
  
  These were all introduced in the initial import of hwpstate_intel(4).
  
  Reported by:  Coverity
  CIDs:         1413161, 1413164, 1413165, 1413167
  X-MFC-With:   r357002

Modified:
  head/sys/kern/kern_cpu.c
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/sys/kern/kern_cpu.c
==============================================================================
--- head/sys/kern/kern_cpu.c    Wed Jan 29 01:57:07 2020        (r357239)
+++ head/sys/kern/kern_cpu.c    Wed Jan 29 03:15:34 2020        (r357240)
@@ -473,11 +473,12 @@ cf_get_method(device_t dev, struct cf_level *level)
                 * first try the driver and if that fails, fall back to
                 * estimating.
                 */
-               if (CPUFREQ_DRV_GET(sc->cf_drv_dev, &set) != 0)
-                       goto estimate;
-               sc->curr_level.total_set = set;
-               CF_DEBUG("get returning immediate freq %d\n", curr_set->freq);
-               goto out;
+               if (CPUFREQ_DRV_GET(sc->cf_drv_dev, &set) == 0) {
+                       sc->curr_level.total_set = set;
+                       CF_DEBUG("get returning immediate freq %d\n",
+                           curr_set->freq);
+                       goto out;
+               }
        } else if (curr_set->freq != CPUFREQ_VAL_UNKNOWN) {
                CF_DEBUG("get returning known freq %d\n", curr_set->freq);
                error = 0;
@@ -522,9 +523,6 @@ cf_get_method(device_t dev, struct cf_level *level)
                CF_DEBUG("get matched freq %d from drivers\n", curr_set->freq);
                goto out;
        }
-
-estimate:
-       CF_MTX_ASSERT(&sc->lock);
 
        /*
         * We couldn't find an exact match, so attempt to estimate and then

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==============================================================================
--- head/sys/x86/cpufreq/hwpstate_intel.c       Wed Jan 29 01:57:07 2020        
(r357239)
+++ head/sys/x86/cpufreq/hwpstate_intel.c       Wed Jan 29 03:15:34 2020        
(r357240)
@@ -147,17 +147,19 @@ intel_hwp_dump_sysctl_handler(SYSCTL_HANDLER_ARGS)
        sbuf_printf(sb, "\tLowest Performance: %03ju\n", (data >> 24) & 0xff);
 
        rdmsr_safe(MSR_IA32_HWP_REQUEST, &data);
-       if (sc->hwp_pkg_ctrl && (data & IA32_HWP_REQUEST_PACKAGE_CONTROL)) {
+       data2 = 0;
+       if (sc->hwp_pkg_ctrl && (data & IA32_HWP_REQUEST_PACKAGE_CONTROL))
                rdmsr_safe(MSR_IA32_HWP_REQUEST_PKG, &data2);
-       }
 
        sbuf_putc(sb, '\n');
 
-#define pkg_print(x, name, offset) do {                                        
        \
-       if (!sc->hwp_pkg_ctrl || (data & x) != 0)                               
\
-       sbuf_printf(sb, "\t%s: %03ju\n", name, (data >> offset) & 0xff);\
-       else                                                                    
\
-       sbuf_printf(sb, "\t%s: %03ju\n", name, (data2 >> offset) & 0xff);\
+#define pkg_print(x, name, offset) do {                                        
\
+       if (!sc->hwp_pkg_ctrl || (data & x) != 0)                       \
+               sbuf_printf(sb, "\t%s: %03u\n", name,                   \
+                   (unsigned)(data >> offset) & 0xff);                 \
+       else                                                            \
+               sbuf_printf(sb, "\t%s: %03u\n", name,                   \
+                   (unsigned)(data2 >> offset) & 0xff);                \
 } while (0)
 
        pkg_print(IA32_HWP_REQUEST_EPP_VALID,
@@ -413,7 +415,7 @@ intel_hwpstate_attach(device_t dev)
 
        SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
            SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
-           "epp", CTLTYPE_INT | CTLFLAG_RWTUN, dev, sizeof(dev),
+           "epp", CTLTYPE_INT | CTLFLAG_RWTUN, dev, 0,
            sysctl_epp_select, "I",
            "Efficiency/Performance Preference "
            "(range from 0, most performant, through 100, most efficient)");
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to