[Intel-gfx] [PATCH 12/12] drm/i915: Support for capturing MMIO register values
kbuild test robot
lkp at intel.com
Mon Jul 31 11:49:01 UTC 2017
Hi Sourab,
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on next-20170731]
[cannot apply to v4.13-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Sagar-Arun-Kamble/i915-perf-support-for-command-stream-based-OA-GPU-and-workload-metrics-capture/20170731-184412
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-x071-201731 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
drivers/gpu/drm/i915/i915_perf.c: In function 'read_properties_unlocked':
>> drivers/gpu/drm/i915/i915_perf.c:4022:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ret = copy_mmio_list(dev_priv, (u64 __user *)value);
^
vim +4022 drivers/gpu/drm/i915/i915_perf.c
3867
3868 /**
3869 * read_properties_unlocked - validate + copy userspace stream open properties
3870 * @dev_priv: i915 device instance
3871 * @uprops: The array of u64 key value pairs given by userspace
3872 * @n_props: The number of key value pairs expected in @uprops
3873 * @props: The stream configuration built up while validating properties
3874 *
3875 * Note this function only validates properties in isolation it doesn't
3876 * validate that the combination of properties makes sense or that all
3877 * properties necessary for a particular kind of stream have been set.
3878 *
3879 * Note that there currently aren't any ordering requirements for properties so
3880 * we shouldn't validate or assume anything about ordering here. This doesn't
3881 * rule out defining new properties with ordering requirements in the future.
3882 */
3883 static int read_properties_unlocked(struct drm_i915_private *dev_priv,
3884 u64 __user *uprops,
3885 u32 n_props,
3886 struct perf_open_properties *props)
3887 {
3888 u64 __user *uprop = uprops;
3889 int i;
3890
3891 memset(props, 0, sizeof(struct perf_open_properties));
3892
3893 if (!n_props) {
3894 DRM_DEBUG("No i915 perf properties given\n");
3895 return -EINVAL;
3896 }
3897
3898 /* Considering that ID = 0 is reserved and assuming that we don't
3899 * (currently) expect any configurations to ever specify duplicate
3900 * values for a particular property ID then the last _PROP_MAX value is
3901 * one greater than the maximum number of properties we expect to get
3902 * from userspace.
3903 */
3904 if (n_props >= DRM_I915_PERF_PROP_MAX) {
3905 DRM_DEBUG("More i915 perf properties specified than exist\n");
3906 return -EINVAL;
3907 }
3908
3909 for (i = 0; i < n_props; i++) {
3910 u64 oa_period, oa_freq_hz;
3911 u64 id, value;
3912 int ret;
3913
3914 ret = get_user(id, uprop);
3915 if (ret)
3916 return ret;
3917
3918 ret = get_user(value, uprop + 1);
3919 if (ret)
3920 return ret;
3921
3922 if (id == 0 || id >= DRM_I915_PERF_PROP_MAX) {
3923 DRM_DEBUG("Unknown i915 perf property ID\n");
3924 return -EINVAL;
3925 }
3926
3927 switch ((enum drm_i915_perf_property_id)id) {
3928 case DRM_I915_PERF_PROP_CTX_HANDLE:
3929 props->single_context = 1;
3930 props->ctx_handle = value;
3931 break;
3932 case DRM_I915_PERF_PROP_SAMPLE_OA:
3933 props->sample_flags |= SAMPLE_OA_REPORT;
3934 break;
3935 case DRM_I915_PERF_PROP_OA_METRICS_SET:
3936 if (value == 0 ||
3937 value > dev_priv->perf.oa.n_builtin_sets) {
3938 DRM_DEBUG("Unknown OA metric set ID\n");
3939 return -EINVAL;
3940 }
3941 props->metrics_set = value;
3942 break;
3943 case DRM_I915_PERF_PROP_OA_FORMAT:
3944 if (value == 0 || value >= I915_OA_FORMAT_MAX) {
3945 DRM_DEBUG("Out-of-range OA report format %llu\n",
3946 value);
3947 return -EINVAL;
3948 }
3949 if (!dev_priv->perf.oa.oa_formats[value].size) {
3950 DRM_DEBUG("Unsupported OA report format %llu\n",
3951 value);
3952 return -EINVAL;
3953 }
3954 props->oa_format = value;
3955 break;
3956 case DRM_I915_PERF_PROP_OA_EXPONENT:
3957 if (value > OA_EXPONENT_MAX) {
3958 DRM_DEBUG("OA timer exponent too high (> %u)\n",
3959 OA_EXPONENT_MAX);
3960 return -EINVAL;
3961 }
3962
3963 /* Theoretically we can program the OA unit to sample
3964 * e.g. every 160ns for HSW, 167ns for BDW/SKL or 104ns
3965 * for BXT. We don't allow such high sampling
3966 * frequencies by default unless root.
3967 */
3968
3969 BUILD_BUG_ON(sizeof(oa_period) != 8);
3970 oa_period = oa_exponent_to_ns(dev_priv, value);
3971
3972 /* This check is primarily to ensure that oa_period <=
3973 * UINT32_MAX (before passing to do_div which only
3974 * accepts a u32 denominator), but we can also skip
3975 * checking anything < 1Hz which implicitly can't be
3976 * limited via an integer oa_max_sample_rate.
3977 */
3978 if (oa_period <= NSEC_PER_SEC) {
3979 u64 tmp = NSEC_PER_SEC;
3980 do_div(tmp, oa_period);
3981 oa_freq_hz = tmp;
3982 } else
3983 oa_freq_hz = 0;
3984
3985 if (oa_freq_hz > i915_oa_max_sample_rate &&
3986 !capable(CAP_SYS_ADMIN)) {
3987 DRM_DEBUG("OA exponent would exceed the max sampling frequency (sysctl dev.i915.oa_max_sample_rate) %uHz without root privileges\n",
3988 i915_oa_max_sample_rate);
3989 return -EACCES;
3990 }
3991
3992 props->oa_periodic = true;
3993 props->oa_period_exponent = value;
3994 break;
3995 case DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE:
3996 props->sample_flags |= SAMPLE_OA_SOURCE;
3997 break;
3998 case DRM_I915_PERF_PROP_ENGINE: {
3999 unsigned int user_ring_id =
4000 value & I915_EXEC_RING_MASK;
4001
4002 if (user_ring_id > I915_USER_RINGS)
4003 return -EINVAL;
4004
4005 props->cs_mode = true;
4006 props->engine = user_ring_map[user_ring_id];
4007 }
4008 break;
4009 case DRM_I915_PERF_PROP_SAMPLE_CTX_ID:
4010 props->sample_flags |= SAMPLE_CTX_ID;
4011 break;
4012 case DRM_I915_PERF_PROP_SAMPLE_PID:
4013 props->sample_flags |= SAMPLE_PID;
4014 break;
4015 case DRM_I915_PERF_PROP_SAMPLE_TAG:
4016 props->sample_flags |= SAMPLE_TAG;
4017 break;
4018 case DRM_I915_PERF_PROP_SAMPLE_TS:
4019 props->sample_flags |= SAMPLE_TS;
4020 break;
4021 case DRM_I915_PERF_PROP_SAMPLE_MMIO:
> 4022 ret = copy_mmio_list(dev_priv, (u64 __user *)value);
4023 if (ret)
4024 return ret;
4025 props->sample_flags |= SAMPLE_MMIO;
4026 break;
4027 case DRM_I915_PERF_PROP_MAX:
4028 MISSING_CASE(id);
4029 return -EINVAL;
4030 }
4031
4032 uprop += 2;
4033 }
4034
4035 return 0;
4036 }
4037
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 28308 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gfx/attachments/20170731/5453d7e1/attachment-0001.gz>
More information about the Intel-gfx
mailing list