1. 29 3月, 2019 1 次提交
    • Y
      drm/i915/gvt: do not let pin count of shadow mm go negative · 663a50ce
      Yan Zhao 提交于
      shadow mm's pin count got increased in workload preparation phase, which
      is after workload scanning.
      it will get decreased in complete_current_workload() anyway after
      workload completion.
      Sometimes, if a workload meets a scanning error, its shadow mm pin count
      will not get increased but will get decreased in the end.
      This patch lets shadow mm's pin count not go below 0.
      
      Fixes: 2707e444 ("drm/i915/gvt: vGPU graphics memory virtualization")
      Cc: zhenyuw@linux.intel.com
      Cc: stable@vger.kernel.org #4.14+
      Signed-off-by: NYan Zhao <yan.y.zhao@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      663a50ce
  2. 04 3月, 2019 1 次提交
    • Z
      drm/i915/gvt: Add mutual lock for ppgtt mm LRU list · 72aabfb8
      Zhenyu Wang 提交于
      This adds mutex to guard against update of global ppgtt mm LRU list.
      To resolve error found as below warning.
      
      [73130.012162] ------------[ cut here ]------------
      [73130.012168] list_add corruption. prev->next should be next (ffff995f970cca50), but was 0000000000000000. (prev=ffff995f0dc5bdf8).
      [73130.012181] WARNING: CPU: 3 PID: 82 at lib/list_debug.c:28 __list_add_valid+0x4d/0x70
      [73130.012183] Modules linked in: btrfs(E) xor(E) zstd_decompress(E) zstd_compress(E) raid6_pq(E) dm_mod(E) kvmgt(E) fuse(E) xt_addrtype(E) nft_compat(E) xt_conntrack(E) nf_nat(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) br_netfilter(E) bridge(E) stp(E) llc(E) overlay(E) devlink(E) nf_tables(E) nfnetlink(E) loop(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) coretemp(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) mei_me(E) aesni_intel(E) aes_x86_64(E) crypto_simd(E) cryptd(E) glue_helper(E) intel_cstate(E) intel_uncore(E) mei(E) intel_pch_thermal(E) intel_rapl_perf(E) pcspkr(E) iTCO_wdt(E) iTCO_vendor_support(E) idma64(E) sg(E) virt_dma(E) acpi_pad(E) evdev(E) binfmt_misc(E) ip_tables(E) x_tables(E) ipv6(E) autofs4(E) hid_generic(E) usbhid(E) hid(E) ext4(E) crc32c_generic(E) crc16(E) mbcache(E) jbd2(E) fscrypto(E) xhci_pci(E) sdhci_pci(E) cqhci(E) intel_lpss_pci(E) intel_lpss(E) crc32c_intel(E) xhci_hcd(E) sdhci(E) i2c_i801(E) e1000e(E) mmc_core(E)
      [73130.012218]  ptp(E) pps_core(E) usbcore(E) mfd_core(E) sd_mod(E) fan(E) thermal(E)
      [73130.012227] CPU: 3 PID: 82 Comm: gvt workload 0 Tainted: G        W   E     5.0.0-rc7-staging-190226+ #282
      [73130.012228] Hardware name:  /NUC6i5SYB, BIOS SYSKLi35.86A.0039.2016.0316.1747 03/16/2016
      [73130.012232] RIP: 0010:__list_add_valid+0x4d/0x70
      [73130.012234] Code: c3 48 89 d1 48 c7 c7 e0 82 91 bb 48 89 c2 e8 44 8a cc ff 0f 0b 31 c0 c3 48 89 c1 4c 89 c6 48 c7 c7 30 83 91 bb e8 2d 8a cc ff <0f> 0b 31 c0 c3 48 89 f2 4c 89 c1 48 89 fe 48 c7 c7 80 83 91 bb e8
      [73130.012236] RSP: 0018:ffffa4924107fdd0 EFLAGS: 00010286
      [73130.012238] RAX: 0000000000000000 RBX: ffff995d8a5ccf00 RCX: 0000000000000006
      [73130.012240] RDX: 0000000000000007 RSI: 0000000000000086 RDI: ffff995faad96680
      [73130.012241] RBP: 0000000000000000 R08: 0000000000213a28 R09: 0000000000000084
      [73130.012243] R10: 0000000000000000 R11: ffffa4924107fc70 R12: ffff995d8a5ccf78
      [73130.012245] R13: ffff995f970c8000 R14: ffff995f0dc5bdf8 R15: ffff995f970cca50
      [73130.012247] FS:  0000000000000000(0000) GS:ffff995faad80000(0000) knlGS:0000000000000000
      [73130.012249] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [73130.012250] CR2: 00000222e1891000 CR3: 0000000116848002 CR4: 00000000003626e0
      [73130.012252] Call Trace:
      [73130.012258]  intel_vgpu_pin_mm+0x7a/0xa0
      [73130.012262]  workload_thread+0x683/0x12a0
      [73130.012266]  ? do_wait_intr_irq+0xb0/0xb0
      [73130.012269]  ? finish_wait+0x80/0x80
      [73130.012271]  ? intel_vgpu_clean_workloads+0x110/0x110
      [73130.012274]  kthread+0x116/0x130
      [73130.012276]  ? kthread_bind+0x30/0x30
      [73130.012280]  ret_from_fork+0x35/0x40
      [73130.012285] WARNING: CPU: 3 PID: 82 at lib/list_debug.c:28 __list_add_valid+0x4d/0x70
      [73130.012286] ---[ end trace 458a2e792eec21c0 ]---
      
      v2:
      - simplify lock handling
      Reviewed-by: NXiong Zhang <xiong.y.zhang@intel.com>
      Cc: Xiong Zhang <xiong.y.zhang@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      72aabfb8
  3. 21 11月, 2018 1 次提交
  4. 31 10月, 2018 1 次提交
    • H
      drm/i915/gvt: support inconsecutive partial gtt entry write · bc0686ff
      Hang Yuan 提交于
      Previously we assumed two 4-byte writes to the same PTE coming in sequence.
      But recently we observed inconsecutive partial write happening as well. So
      this patch enhances the previous solution. It now uses a list to save more
      partial writes. If one partial write can be combined with another one in
      the list to construct a full PTE, update its shadow entry. Otherwise, save
      the partial write in the list.
      
      v2: invalidate old entry and flush ggtt (Zhenyu)
      v3: split old ggtt page unmap to another patch (Zhenyu)
      v4: refine codes (Zhenyu)
      Signed-off-by: NHang Yuan <hang.yuan@linux.intel.com>
      Cc: Yan Zhao <yan.y.zhao@intel.com>
      Cc: Xiaolin Zhang <xiaolin.zhang@intel.com>
      Cc: Zhenyu Wang <zhenyu.z.wang@intel.com>
      Reviewed-by: NXiaolin Zhang <xiaolin.zhang@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      bc0686ff
  5. 08 10月, 2018 1 次提交
  6. 07 8月, 2018 1 次提交
  7. 09 7月, 2018 12 次提交
  8. 02 7月, 2018 1 次提交
    • Z
      drm/i915/gvt: fix a bug of partially write ggtt enties · 510fe10b
      Zhao Yan 提交于
      when guest writes ggtt entries, it could write 8 bytes a time if
      gtt_entry_size is 8. But, qemu could split the 8 bytes into 2 consecutive
      4-byte writes.
      
      If each 4-byte partial write could trigger a host ggtt write, it is very
      possible that a wrong combination is written to the host ggtt. E.g.
      the higher 4 bytes is the old value, but the lower 4 bytes is the new
      value, and this 8-byte combination is wrong but written to the ggtt, thus
      causing bugs.
      
      To handle this condition, we just record the first 4-byte write, then wait
      until the second 4-byte write comes and write the combined 64-bit data to
      host ggtt table.
      
      To save memory space and to spot partial write as early as possible, we
      don't keep this information for every ggtt index. Instread, we just record
      the last ggtt write position, and assume the two 4-byte writes come in
      consecutively for each vgpu.
      
      This assumption is right based on the characteristic of ggtt entry which
      stores memory address. When gtt_entry_size is 8, the guest memory physical
      address should be 64 bits, so any sane guest driver should write 8-byte
      long data at a time, so 2 consecutive 4-byte writes at the same ggtt index
      should be trapped in gvt.
      
      v2:
      when incomplete ggtt entry write is located, e.g.
          1. guest only writes 4 bytes at a ggtt offset and no long writes the
             rest 4 bytes.
          2. guest writes 4 bytes of a ggtt offset, then write at other ggtt
             offsets, then return back to write the left 4 bytes of the first
             ggtt offset.
      add error handling logic to remap host entry to scratch page, and mark
      guest virtual ggtt entry as not present.  (zhenyu wang)
      Signed-off-by: NZhao Yan <yan.y.zhao@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      510fe10b
  9. 13 6月, 2018 2 次提交
    • C
      drm/i915/gvt: Enable gtt initialization for BXT. · 665004b8
      Colin Xu 提交于
      Initialize BXT gtt as SKL/KBL.
      
      v2: All supported platforms share the same gtt ops.
          Remove the platform check by now and let is_supported_device()
          be the gate keeper.
      Signed-off-by: NColin Xu <colin.xu@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      665004b8
    • K
      treewide: Use array_size() in vzalloc() · fad953ce
      Kees Cook 提交于
      The vzalloc() function has no 2-factor argument form, so multiplication
      factors need to be wrapped in array_size(). This patch replaces cases of:
      
              vzalloc(a * b)
      
      with:
              vzalloc(array_size(a, b))
      
      as well as handling cases of:
      
              vzalloc(a * b * c)
      
      with:
      
              vzalloc(array3_size(a, b, c))
      
      This does, however, attempt to ignore constant size factors like:
      
              vzalloc(4 * 1024)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        vzalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        vzalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        vzalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
        vzalloc(
      -	sizeof(TYPE) * (COUNT_ID)
      +	array_size(COUNT_ID, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * COUNT_ID
      +	array_size(COUNT_ID, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * (COUNT_CONST)
      +	array_size(COUNT_CONST, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * COUNT_CONST
      +	array_size(COUNT_CONST, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * (COUNT_ID)
      +	array_size(COUNT_ID, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * COUNT_ID
      +	array_size(COUNT_ID, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * (COUNT_CONST)
      +	array_size(COUNT_CONST, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * COUNT_CONST
      +	array_size(COUNT_CONST, sizeof(THING))
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
        vzalloc(
      -	SIZE * COUNT
      +	array_size(COUNT, SIZE)
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        vzalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        vzalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        vzalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        vzalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        vzalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        vzalloc(C1 * C2 * C3, ...)
      |
        vzalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants.
      @@
      expression E1, E2;
      constant C1, C2;
      @@
      
      (
        vzalloc(C1 * C2, ...)
      |
        vzalloc(
      -	E1 * E2
      +	array_size(E1, E2)
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      fad953ce
  10. 11 6月, 2018 1 次提交
  11. 30 3月, 2018 2 次提交
    • C
      drm/i915/gvt: Cancel dma map when resetting ggtt entries · f4c43db3
      Changbin Du 提交于
      Ditto, don't forget ggtt entries during reset.
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      f4c43db3
    • C
      drm/i915/gvt: Missed to cancel dma map for ggtt entries · 7598e870
      Changbin Du 提交于
      We have canceled dma map for ppgtt entries. Also we need to do it for
      ggtt entries when them are invalidated.
      
      This can fix task hung issue as:
      [13517.791767] INFO: task gvt_service_thr:1081 blocked for more than 120 seconds.
      [13517.792584] Not tainted 4.14.15+ #3
      [13517.793417] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [13517.794267] gvt_service_thr D 0 1081 2 0x80000000
      [13517.795132] Call Trace:
      [13517.795996] ? __schedule+0x493/0x77b
      [13517.796859] schedule+0x79/0x82
      [13517.797740] schedule_preempt_disabled+0x5/0x6
      [13517.798614] __mutex_lock.isra.0+0x2b5/0x445
      [13517.799504] ? __switch_to_asm+0x24/0x60
      [13517.800381] ? intel_gvt_cleanup+0x10/0x10
      [13517.801261] ? intel_gvt_schedule+0x19/0x2b9
      [13517.802107] intel_gvt_schedule+0x19/0x2b9
      [13517.802954] ? intel_gvt_cleanup+0x10/0x10
      [13517.803824] gvt_service_thread+0xe3/0x10d
      [13517.804704] ? wait_woken+0x68/0x68
      [13517.805588] kthread+0x118/0x120
      [13517.806478] ? kthread_create_on_node+0x3a/0x3a
      [13517.807381] ? call_usermodehelper_exec_async+0x113/0x11a
      [13517.808307] ret_from_fork+0x35/0x40
      
      v3: split out ggtt reset case.
      v2: also unmap ggtt during reset.
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      7598e870
  12. 19 3月, 2018 2 次提交
  13. 06 3月, 2018 14 次提交