tree: https://git.kernel.org/pub/scm/linux/kernel/git/nathan/linux.git wip/i915-kcfi head: 5aed167ba402539d4fb1c48c7c7801569feaf0d5 commit: 5aed167ba402539d4fb1c48c7c7801569feaf0d5 [1/1] WIP: drm/i915: Fix CFI violation config: x86_64-randconfig-c002 compiler: gcc-11 (Debian 11.3.0-5) 11.3.0 reproduce (this is a W=1 build): # https://git.kernel.org/pub/scm/linux/kernel/git/nathan/linux.git/commit/?id=5aed167ba402539d4fb1c48c7c7801569feaf0d5 git remote add nathan https://git.kernel.org/pub/scm/linux/kernel/git/nathan/linux.git git fetch --no-tags nathan wip/i915-kcfi git checkout 5aed167ba402539d4fb1c48c7c7801569feaf0d5 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/i915/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All errors (new ones prefixed by >>): drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:441:1: error: data definition has no type or storage class [-Werror] 441 | INTEL_GT_ATTR_RO(vlv_rpe_freq_mhz); | ^~~~~~~~~~~~~~~~ >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:441:1: error: type defaults to 'int' in declaration of 'INTEL_GT_ATTR_RO' [-Werror=implicit-int] drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:441:1: error: parameter names (without types) in function declaration [-Werror] drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:499:1: error: data definition has no type or storage class [-Werror] 499 | INTEL_GT_ATTR_RO(punit_req_freq_mhz); | ^~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:499:1: error: type defaults to 'int' in declaration of 'INTEL_GT_ATTR_RO' [-Werror=implicit-int] drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:499:1: error: parameter names (without types) in function declaration [-Werror] >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:511:10: error: 'attr_punit_req_freq_mhz' undeclared here (not in a function); did you mean 'attr_rps_RPn_freq_mhz'? 511 | &attr_punit_req_freq_mhz.attr, | ^~~~~~~~~~~~~~~~~~~~~~~ | attr_rps_RPn_freq_mhz drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:678:1: error: data definition has no type or storage class [-Werror] 678 | INTEL_GT_ATTR_RW(media_freq_factor); | ^~~~~~~~~~~~~~~~ >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:678:1: error: type defaults to 'int' in declaration of 'INTEL_GT_ATTR_RW' [-Werror=implicit-int] drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:678:1: error: parameter names (without types) in function declaration [-Werror] drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:681:1: error: data definition has no type or storage class [-Werror] 681 | INTEL_GT_ATTR_RO(media_RP0_freq_mhz); | ^~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:681:1: error: type defaults to 'int' in declaration of 'INTEL_GT_ATTR_RO' [-Werror=implicit-int] drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:681:1: error: parameter names (without types) in function declaration [-Werror] drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:682:1: error: data definition has no type or storage class [-Werror] 682 | INTEL_GT_ATTR_RO(media_RPn_freq_mhz); | ^~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:682:1: error: type defaults to 'int' in declaration of 'INTEL_GT_ATTR_RO' [-Werror=implicit-int] drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:682:1: error: parameter names (without types) in function declaration [-Werror] >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:685:10: error: 'attr_media_freq_factor' undeclared here (not in a function); did you mean 'attr_media_freq_factor_scale'? 685 | &attr_media_freq_factor.attr, | ^~~~~~~~~~~~~~~~~~~~~~ | attr_media_freq_factor_scale >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:687:10: error: 'attr_media_RP0_freq_mhz' undeclared here (not in a function); did you mean 'attr_rps_RP0_freq_mhz'? 687 | &attr_media_RP0_freq_mhz.attr, | ^~~~~~~~~~~~~~~~~~~~~~~ | attr_rps_RP0_freq_mhz >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:688:10: error: 'attr_media_RPn_freq_mhz' undeclared here (not in a function); did you mean 'attr_rps_RPn_freq_mhz'? 688 | &attr_media_RPn_freq_mhz.attr, | ^~~~~~~~~~~~~~~~~~~~~~~ | attr_rps_RPn_freq_mhz drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c: In function 'intel_sysfs_rps_init': >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:705:48: error: 'attr_vlv_rpe_freq_mhz' undeclared (first use in this function); did you mean 'attr_rps_RPn_freq_mhz'? 705 | ret = sysfs_create_file(kobj, &attr_vlv_rpe_freq_mhz.attr); | ^~~~~~~~~~~~~~~~~~~~~ | attr_rps_RPn_freq_mhz drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:705:48: note: each undeclared identifier is reported only once for each function it appears in At top level: >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:657:16: error: 'media_RPn_freq_mhz_show' defined but not used [-Werror=unused-function] 657 | static ssize_t media_RPn_freq_mhz_show(struct kobject *kobj, | ^~~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:636:16: error: 'media_RP0_freq_mhz_show' defined but not used [-Werror=unused-function] 636 | static ssize_t media_RP0_freq_mhz_show(struct kobject *kobj, | ^~~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:607:16: error: 'media_freq_factor_store' defined but not used [-Werror=unused-function] 607 | static ssize_t media_freq_factor_store(struct kobject *kobj, | ^~~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:576:16: error: 'media_freq_factor_show' defined but not used [-Werror=unused-function] 576 | static ssize_t media_freq_factor_show(struct kobject *kobj, | ^~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:461:16: error: 'punit_req_freq_mhz_show' defined but not used [-Werror=unused-function] 461 | static ssize_t punit_req_freq_mhz_show(struct kobject *kobj, | ^~~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c:401:16: error: 'vlv_rpe_freq_mhz_show' defined but not used [-Werror=unused-function] 401 | static ssize_t vlv_rpe_freq_mhz_show(struct kobject *kobj, | ^~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors vim +441 drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c 400 > 401 static ssize_t vlv_rpe_freq_mhz_show(struct kobject *kobj, 402 struct kobj_attribute *attr, char *buff) 403 { 404 u32 rpe_freq = sysfs_gt_attribute_r_max_func(kobj, attr->attr, 405 __vlv_rpe_freq_mhz_show); 406 407 return sysfs_emit(buff, "%u\n", rpe_freq); 408 } 409 410 INTEL_GT_SYSFS_SHOW_MAX(act_freq_mhz); 411 INTEL_GT_SYSFS_SHOW_MAX(boost_freq_mhz); 412 INTEL_GT_SYSFS_SHOW_MAX(cur_freq_mhz); 413 INTEL_GT_SYSFS_SHOW_MAX(RP0_freq_mhz); 414 INTEL_GT_SYSFS_SHOW_MAX(RP1_freq_mhz); 415 INTEL_GT_SYSFS_SHOW_MAX(RPn_freq_mhz); 416 INTEL_GT_SYSFS_SHOW_MAX(max_freq_mhz); 417 INTEL_GT_SYSFS_SHOW_MIN(min_freq_mhz); 418 INTEL_GT_SYSFS_STORE(boost_freq_mhz, __boost_freq_mhz_store); 419 INTEL_GT_SYSFS_STORE(max_freq_mhz, __set_max_freq); 420 INTEL_GT_SYSFS_STORE(min_freq_mhz, __set_min_freq); 421 422 #define INTEL_GT_RPS_SYSFS_ATTR(_name, _mode, _show, _store, _show_dev, _store_dev) \ 423 static struct device_attribute dev_attr_gt_##_name = __ATTR(gt_##_name, _mode, _show_dev, _store_dev); \ 424 static struct kobj_attribute attr_rps_##_name = __ATTR(rps_##_name, _mode, _show, _store) 425 426 #define INTEL_GT_RPS_SYSFS_ATTR_RO(_name) \ 427 INTEL_GT_RPS_SYSFS_ATTR(_name, 0444, _name##_show, NULL, _name##_dev_show, NULL) 428 #define INTEL_GT_RPS_SYSFS_ATTR_RW(_name) \ 429 INTEL_GT_RPS_SYSFS_ATTR(_name, 0644, _name##_show, _name##_store, _name##_dev_show, _name##_dev_store) 430 431 /* The below macros generate static structures */ 432 INTEL_GT_RPS_SYSFS_ATTR_RO(act_freq_mhz); 433 INTEL_GT_RPS_SYSFS_ATTR_RO(cur_freq_mhz); 434 INTEL_GT_RPS_SYSFS_ATTR_RW(boost_freq_mhz); 435 INTEL_GT_RPS_SYSFS_ATTR_RO(RP0_freq_mhz); 436 INTEL_GT_RPS_SYSFS_ATTR_RO(RP1_freq_mhz); 437 INTEL_GT_RPS_SYSFS_ATTR_RO(RPn_freq_mhz); 438 INTEL_GT_RPS_SYSFS_ATTR_RW(max_freq_mhz); 439 INTEL_GT_RPS_SYSFS_ATTR_RW(min_freq_mhz); 440 > 441 INTEL_GT_ATTR_RO(vlv_rpe_freq_mhz); 442 443 #define GEN6_ATTR(p, s) { \ 444 &p##attr_##s##_act_freq_mhz.attr, \ 445 &p##attr_##s##_cur_freq_mhz.attr, \ 446 &p##attr_##s##_boost_freq_mhz.attr, \ 447 &p##attr_##s##_max_freq_mhz.attr, \ 448 &p##attr_##s##_min_freq_mhz.attr, \ 449 &p##attr_##s##_RP0_freq_mhz.attr, \ 450 &p##attr_##s##_RP1_freq_mhz.attr, \ 451 &p##attr_##s##_RPn_freq_mhz.attr, \ 452 NULL, \ 453 } 454 455 #define GEN6_RPS_ATTR GEN6_ATTR(, rps) 456 #define GEN6_GT_ATTR GEN6_ATTR(dev_, gt) 457 458 static const struct attribute * const gen6_rps_attrs[] = GEN6_RPS_ATTR; 459 static const struct attribute * const gen6_gt_attrs[] = GEN6_GT_ATTR; 460 > 461 static ssize_t punit_req_freq_mhz_show(struct kobject *kobj, 462 struct kobj_attribute *attr, 463 char *buff) 464 { 465 struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name); 466 u32 preq = intel_rps_read_punit_req_frequency(>->rps); 467 468 return sysfs_emit(buff, "%u\n", preq); 469 } 470 471 struct intel_gt_bool_throttle_attr { 472 struct attribute attr; 473 ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr, 474 char *buf); 475 i915_reg_t reg32; 476 u32 mask; 477 }; 478 479 static ssize_t throttle_reason_bool_show(struct kobject *kobj, 480 struct kobj_attribute *attr, 481 char *buff) 482 { 483 struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name); 484 struct intel_gt_bool_throttle_attr *t_attr = 485 (struct intel_gt_bool_throttle_attr *) attr; 486 bool val = rps_read_mask_mmio(>->rps, t_attr->reg32, t_attr->mask); 487 488 return sysfs_emit(buff, "%u\n", val); 489 } 490 491 #define INTEL_GT_RPS_BOOL_ATTR_RO(sysfs_func__, mask__) \ 492 struct intel_gt_bool_throttle_attr attr_##sysfs_func__ = { \ 493 .attr = { .name = __stringify(sysfs_func__), .mode = 0444 }, \ 494 .show = throttle_reason_bool_show, \ 495 .reg32 = GT0_PERF_LIMIT_REASONS, \ 496 .mask = mask__, \ 497 } 498 499 INTEL_GT_ATTR_RO(punit_req_freq_mhz); 500 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_status, GT0_PERF_LIMIT_REASONS_MASK); 501 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl1, POWER_LIMIT_1_MASK); 502 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl2, POWER_LIMIT_2_MASK); 503 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl4, POWER_LIMIT_4_MASK); 504 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_thermal, THERMAL_LIMIT_MASK); 505 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_prochot, PROCHOT_MASK); 506 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_ratl, RATL_MASK); 507 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_thermalert, VR_THERMALERT_MASK); 508 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_tdc, VR_TDC_MASK); 509 510 static const struct attribute *freq_attrs[] = { > 511 &attr_punit_req_freq_mhz.attr, 512 &attr_throttle_reason_status.attr, 513 &attr_throttle_reason_pl1.attr, 514 &attr_throttle_reason_pl2.attr, 515 &attr_throttle_reason_pl4.attr, 516 &attr_throttle_reason_thermal.attr, 517 &attr_throttle_reason_prochot.attr, 518 &attr_throttle_reason_ratl.attr, 519 &attr_throttle_reason_vr_thermalert.attr, 520 &attr_throttle_reason_vr_tdc.attr, 521 NULL 522 }; 523 524 /* 525 * Scaling for multipliers (aka frequency factors). 526 * The format of the value in the register is u8.8. 527 * 528 * The presentation to userspace is inspired by the perf event framework. 529 * See: 530 * Documentation/ABI/testing/sysfs-bus-event_source-devices-events 531 * for description of: 532 * /sys/bus/event_source/devices//events/.scale 533 * 534 * Summary: Expose two sysfs files for each multiplier. 535 * 536 * 1. File contains a raw hardware value. 537 * 2. File .scale contains the multiplicative scale factor to be 538 * used by userspace to compute the actual value. 539 * 540 * So userspace knows that to get the frequency_factor it multiplies the 541 * provided value by the specified scale factor and vice-versa. 542 * 543 * That way there is no precision loss in the kernel interface and API 544 * is future proof should one day the hardware register change to u16.u16, 545 * on some platform. (Or any other fixed point representation.) 546 * 547 * Example: 548 * File contains the value 2.5, represented as u8.8 0x0280, which 549 * is comprised of: 550 * - an integer part of 2 551 * - a fractional part of 0x80 (representing 0x80 / 2^8 == 0x80 / 256). 552 * File .scale contains a string representation of floating point 553 * value 0.00390625 (which is (1 / 256)). 554 * Userspace computes the actual value: 555 * 0x0280 * 0.00390625 -> 2.5 556 * or converts an actual value to the value to be written into : 557 * 2.5 / 0.00390625 -> 0x0280 558 */ 559 560 #define U8_8_VAL_MASK 0xffff 561 #define U8_8_SCALE_TO_VALUE "0.00390625" 562 563 static ssize_t freq_factor_scale_show(struct kobject *kobj, 564 struct kobj_attribute *attr, 565 char *buff) 566 { 567 return sysfs_emit(buff, "%s\n", U8_8_SCALE_TO_VALUE); 568 } 569 570 static u32 media_ratio_mode_to_factor(u32 mode) 571 { 572 /* 0 -> 0, 1 -> 256, 2 -> 128 */ 573 return !mode ? mode : 256 / mode; 574 } 575 > 576 static ssize_t media_freq_factor_show(struct kobject *kobj, 577 struct kobj_attribute *attr, 578 char *buff) 579 { 580 struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name); 581 struct intel_guc_slpc *slpc = >->uc.guc.slpc; 582 intel_wakeref_t wakeref; 583 u32 mode; 584 585 /* 586 * Retrieve media_ratio_mode from GEN6_RPNSWREQ bit 13 set by 587 * GuC. GEN6_RPNSWREQ:13 value 0 represents 1:2 and 1 represents 1:1 588 */ 589 if (IS_XEHPSDV(gt->i915) && 590 slpc->media_ratio_mode == SLPC_MEDIA_RATIO_MODE_DYNAMIC_CONTROL) { 591 /* 592 * For XEHPSDV dynamic mode GEN6_RPNSWREQ:13 does not contain 593 * the media_ratio_mode, just return the cached media ratio 594 */ 595 mode = slpc->media_ratio_mode; 596 } else { 597 with_intel_runtime_pm(gt->uncore->rpm, wakeref) 598 mode = intel_uncore_read(gt->uncore, GEN6_RPNSWREQ); 599 mode = REG_FIELD_GET(GEN12_MEDIA_FREQ_RATIO, mode) ? 600 SLPC_MEDIA_RATIO_MODE_FIXED_ONE_TO_ONE : 601 SLPC_MEDIA_RATIO_MODE_FIXED_ONE_TO_TWO; 602 } 603 604 return sysfs_emit(buff, "%u\n", media_ratio_mode_to_factor(mode)); 605 } 606 > 607 static ssize_t media_freq_factor_store(struct kobject *kobj, 608 struct kobj_attribute *attr, 609 const char *buff, size_t count) 610 { 611 struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name); 612 struct intel_guc_slpc *slpc = >->uc.guc.slpc; 613 u32 factor, mode; 614 int err; 615 616 err = kstrtou32(buff, 0, &factor); 617 if (err) 618 return err; 619 620 for (mode = SLPC_MEDIA_RATIO_MODE_DYNAMIC_CONTROL; 621 mode <= SLPC_MEDIA_RATIO_MODE_FIXED_ONE_TO_TWO; mode++) 622 if (factor == media_ratio_mode_to_factor(mode)) 623 break; 624 625 if (mode > SLPC_MEDIA_RATIO_MODE_FIXED_ONE_TO_TWO) 626 return -EINVAL; 627 628 err = intel_guc_slpc_set_media_ratio_mode(slpc, mode); 629 if (!err) { 630 slpc->media_ratio_mode = mode; 631 DRM_DEBUG("Set slpc->media_ratio_mode to %d", mode); 632 } 633 return err ?: count; 634 } 635 > 636 static ssize_t media_RP0_freq_mhz_show(struct kobject *kobj, 637 struct kobj_attribute *attr, 638 char *buff) 639 { 640 struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name); 641 u32 val; 642 int err; 643 644 err = snb_pcode_read_p(gt->uncore, XEHP_PCODE_FREQUENCY_CONFIG, 645 PCODE_MBOX_FC_SC_READ_FUSED_P0, 646 PCODE_MBOX_DOMAIN_MEDIAFF, &val); 647 648 if (err) 649 return err; 650 651 /* Fused media RP0 read from pcode is in units of 50 MHz */ 652 val *= GT_FREQUENCY_MULTIPLIER; 653 654 return sysfs_emit(buff, "%u\n", val); 655 } 656 -- 0-DAY CI Kernel Test Service https://01.org/lkp