documented (hopefully adequately) in the respective changelogs. Notable series include: - Lucas Stach has provided some page-mapping cleanup/consolidation/maintainability work in the series "mm/treewide: Remove pXd_huge() API". - In the series "Allow migrate on protnone reference with MPOL_PREFERRED_MANY policy", Donet Tom has optimized mempolicy's MPOL_PREFERRED_MANY mode, yielding almost doubled performance in one test. - In their series "Memory allocation profiling" Kent Overstreet and Suren Baghdasaryan have contributed a means of determining (via /proc/allocinfo) whereabouts in the kernel memory is being allocated: number of calls and amount of memory. - Matthew Wilcox has provided the series "Various significant MM patches" which does a number of rather unrelated things, but in largely similar code sites. - In his series "mm: page_alloc: freelist migratetype hygiene" Johannes Weiner has fixed the page allocator's handling of migratetype requests, with resulting improvements in compaction efficiency. - In the series "make the hugetlb migration strategy consistent" Baolin Wang has fixed a hugetlb migration issue, which should improve hugetlb allocation reliability. - Liu Shixin has hit an I/O meltdown caused by readahead in a memory-tight memcg. Addressed in the series "Fix I/O high when memory almost met memcg limit". - In the series "mm/filemap: optimize folio adding and splitting" Kairui Song has optimized pagecache insertion, yielding ~10% performance improvement in one test. - Baoquan He has cleaned up and consolidated the early zone initialization code in the series "mm/mm_init.c: refactor free_area_init_core()". - Baoquan has also redone some MM initializatio code in the series "mm/init: minor clean up and improvement". - MM helper cleanups from Christoph Hellwig in his series "remove follow_pfn". - More cleanups from Matthew Wilcox in the series "Various page->flags cleanups". - Vlastimil Babka has contributed maintainability improvements in the series "memcg_kmem hooks refactoring". - More folio conversions and cleanups in Matthew Wilcox's series "Convert huge_zero_page to huge_zero_folio" "khugepaged folio conversions" "Remove page_idle and page_young wrappers" "Use folio APIs in procfs" "Clean up __folio_put()" "Some cleanups for memory-failure" "Remove page_mapping()" "More folio compat code removal" - David Hildenbrand chipped in with "fs/proc/task_mmu: convert hugetlb functions to work on folis". - Code consolidation and cleanup work related to GUP's handling of hugetlbs in Peter Xu's series "mm/gup: Unify hugetlb, part 2". - Rick Edgecombe has developed some fixes to stack guard gaps in the series "Cover a guard gap corner case". - Jinjiang Tu has fixed KSM's behaviour after a fork+exec in the series "mm/ksm: fix ksm exec support for prctl". - Baolin Wang has implemented NUMA balancing for multi-size THPs. This is a simple first-cut implementation for now. The series is "support multi-size THP numa balancing". - Cleanups to vma handling helper functions from Matthew Wilcox in the series "Unify vma_address and vma_pgoff_address". - Some selftests maintenance work from Dev Jain in the series "selftests/mm: mremap_test: Optimizations and style fixes". - Improvements to the swapping of multi-size THPs from Ryan Roberts in the series "Swap-out mTHP without splitting". - Kefeng Wang has significantly optimized the handling of arm64's permission page faults in the series "arch/mm/fault: accelerate pagefault when badaccess" "mm: remove arch's private VM_FAULT_BADMAP/BADACCESS" - GUP cleanups from David Hildenbrand in "mm/gup: consistently call it GUP-fast". - hugetlb fault code cleanups from Vishal Moola in "Hugetlb fault path to use struct vm_fault". - selftests build fixes from John Hubbard in the series "Fix selftests/mm build without requiring "make headers"". - Memory tiering fixes/improvements from Ho-Ren (Jack) Chuang in the series "Improved Memory Tier Creation for CPUless NUMA Nodes". Fixes the initialization code so that migration between different memory types works as intended. - David Hildenbrand has improved follow_pte() and fixed an errant driver in the series "mm: follow_pte() improvements and acrn follow_pte() fixes". - David also did some cleanup work on large folio mapcounts in his series "mm: mapcount for large folios + page_mapcount() cleanups". - Folio conversions in KSM in Alex Shi's series "transfer page to folio in KSM". - Barry Song has added some sysfs stats for monitoring multi-size THP's in the series "mm: add per-order mTHP alloc and swpout counters". - Some zswap cleanups from Yosry Ahmed in the series "zswap same-filled and limit checking cleanups". - Matthew Wilcox has been looking at buffer_head code and found the documentation to be lacking. The series is "Improve buffer head documentation". - Multi-size THPs get more work, this time from Lance Yang. His series "mm/madvise: enhance lazyfreeing with mTHP in madvise_free" optimizes the freeing of these things. - Kemeng Shi has added more userspace-visible writeback instrumentation in the series "Improve visibility of writeback". - Kemeng Shi then sent some maintenance work on top in the series "Fix and cleanups to page-writeback". - Matthew Wilcox reduces mmap_lock traffic in the anon vma code in the series "Improve anon_vma scalability for anon VMAs". Intel's test bot reported an improbable 3x improvement in one test. - SeongJae Park adds some DAMON feature work in the series "mm/damon: add a DAMOS filter type for page granularity access recheck" "selftests/damon: add DAMOS quota goal test" - Also some maintenance work in the series "mm/damon/paddr: simplify page level access re-check for pageout" "mm/damon: misc fixes and improvements" - David Hildenbrand has disabled some known-to-fail selftests ni the series "selftests: mm: cow: flag vmsplice() hugetlb tests as XFAIL". - memcg metadata storage optimizations from Shakeel Butt in "memcg: reduce memory consumption by memcg stats". - DAX fixes and maintenance work from Vishal Verma in the series "dax/bus.c: Fixups for dax-bus locking". -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCZkgQYwAKCRDdBJ7gKXxA jrdKAP9WVJdpEcXxpoub/vVE0UWGtffr8foifi9bCwrQrGh5mgEAx7Yf0+d/oBZB nvA4E0DcPrUAFy144FNM0NTCb7u9vAw= =V3R/ -----END PGP SIGNATURE----- Merge tag 'mm-stable-2024-05-17-19-19' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull mm updates from Andrew Morton: "The usual shower of singleton fixes and minor series all over MM, documented (hopefully adequately) in the respective changelogs. Notable series include: - Lucas Stach has provided some page-mapping cleanup/consolidation/ maintainability work in the series "mm/treewide: Remove pXd_huge() API". - In the series "Allow migrate on protnone reference with MPOL_PREFERRED_MANY policy", Donet Tom has optimized mempolicy's MPOL_PREFERRED_MANY mode, yielding almost doubled performance in one test. - In their series "Memory allocation profiling" Kent Overstreet and Suren Baghdasaryan have contributed a means of determining (via /proc/allocinfo) whereabouts in the kernel memory is being allocated: number of calls and amount of memory. - Matthew Wilcox has provided the series "Various significant MM patches" which does a number of rather unrelated things, but in largely similar code sites. - In his series "mm: page_alloc: freelist migratetype hygiene" Johannes Weiner has fixed the page allocator's handling of migratetype requests, with resulting improvements in compaction efficiency. - In the series "make the hugetlb migration strategy consistent" Baolin Wang has fixed a hugetlb migration issue, which should improve hugetlb allocation reliability. - Liu Shixin has hit an I/O meltdown caused by readahead in a memory-tight memcg. Addressed in the series "Fix I/O high when memory almost met memcg limit". - In the series "mm/filemap: optimize folio adding and splitting" Kairui Song has optimized pagecache insertion, yielding ~10% performance improvement in one test. - Baoquan He has cleaned up and consolidated the early zone initialization code in the series "mm/mm_init.c: refactor free_area_init_core()". - Baoquan has also redone some MM initializatio code in the series "mm/init: minor clean up and improvement". - MM helper cleanups from Christoph Hellwig in his series "remove follow_pfn". - More cleanups from Matthew Wilcox in the series "Various page->flags cleanups". - Vlastimil Babka has contributed maintainability improvements in the series "memcg_kmem hooks refactoring". - More folio conversions and cleanups in Matthew Wilcox's series: "Convert huge_zero_page to huge_zero_folio" "khugepaged folio conversions" "Remove page_idle and page_young wrappers" "Use folio APIs in procfs" "Clean up __folio_put()" "Some cleanups for memory-failure" "Remove page_mapping()" "More folio compat code removal" - David Hildenbrand chipped in with "fs/proc/task_mmu: convert hugetlb functions to work on folis". - Code consolidation and cleanup work related to GUP's handling of hugetlbs in Peter Xu's series "mm/gup: Unify hugetlb, part 2". - Rick Edgecombe has developed some fixes to stack guard gaps in the series "Cover a guard gap corner case". - Jinjiang Tu has fixed KSM's behaviour after a fork+exec in the series "mm/ksm: fix ksm exec support for prctl". - Baolin Wang has implemented NUMA balancing for multi-size THPs. This is a simple first-cut implementation for now. The series is "support multi-size THP numa balancing". - Cleanups to vma handling helper functions from Matthew Wilcox in the series "Unify vma_address and vma_pgoff_address". - Some selftests maintenance work from Dev Jain in the series "selftests/mm: mremap_test: Optimizations and style fixes". - Improvements to the swapping of multi-size THPs from Ryan Roberts in the series "Swap-out mTHP without splitting". - Kefeng Wang has significantly optimized the handling of arm64's permission page faults in the series "arch/mm/fault: accelerate pagefault when badaccess" "mm: remove arch's private VM_FAULT_BADMAP/BADACCESS" - GUP cleanups from David Hildenbrand in "mm/gup: consistently call it GUP-fast". - hugetlb fault code cleanups from Vishal Moola in "Hugetlb fault path to use struct vm_fault". - selftests build fixes from John Hubbard in the series "Fix selftests/mm build without requiring "make headers"". - Memory tiering fixes/improvements from Ho-Ren (Jack) Chuang in the series "Improved Memory Tier Creation for CPUless NUMA Nodes". Fixes the initialization code so that migration between different memory types works as intended. - David Hildenbrand has improved follow_pte() and fixed an errant driver in the series "mm: follow_pte() improvements and acrn follow_pte() fixes". - David also did some cleanup work on large folio mapcounts in his series "mm: mapcount for large folios + page_mapcount() cleanups". - Folio conversions in KSM in Alex Shi's series "transfer page to folio in KSM". - Barry Song has added some sysfs stats for monitoring multi-size THP's in the series "mm: add per-order mTHP alloc and swpout counters". - Some zswap cleanups from Yosry Ahmed in the series "zswap same-filled and limit checking cleanups". - Matthew Wilcox has been looking at buffer_head code and found the documentation to be lacking. The series is "Improve buffer head documentation". - Multi-size THPs get more work, this time from Lance Yang. His series "mm/madvise: enhance lazyfreeing with mTHP in madvise_free" optimizes the freeing of these things. - Kemeng Shi has added more userspace-visible writeback instrumentation in the series "Improve visibility of writeback". - Kemeng Shi then sent some maintenance work on top in the series "Fix and cleanups to page-writeback". - Matthew Wilcox reduces mmap_lock traffic in the anon vma code in the series "Improve anon_vma scalability for anon VMAs". Intel's test bot reported an improbable 3x improvement in one test. - SeongJae Park adds some DAMON feature work in the series "mm/damon: add a DAMOS filter type for page granularity access recheck" "selftests/damon: add DAMOS quota goal test" - Also some maintenance work in the series "mm/damon/paddr: simplify page level access re-check for pageout" "mm/damon: misc fixes and improvements" - David Hildenbrand has disabled some known-to-fail selftests ni the series "selftests: mm: cow: flag vmsplice() hugetlb tests as XFAIL". - memcg metadata storage optimizations from Shakeel Butt in "memcg: reduce memory consumption by memcg stats". - DAX fixes and maintenance work from Vishal Verma in the series "dax/bus.c: Fixups for dax-bus locking"" * tag 'mm-stable-2024-05-17-19-19' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (426 commits) memcg, oom: cleanup unused memcg_oom_gfp_mask and memcg_oom_order selftests/mm: hugetlb_madv_vs_map: avoid test skipping by querying hugepage size at runtime mm/hugetlb: add missing VM_FAULT_SET_HINDEX in hugetlb_wp mm/hugetlb: add missing VM_FAULT_SET_HINDEX in hugetlb_fault selftests: cgroup: add tests to verify the zswap writeback path mm: memcg: make alloc_mem_cgroup_per_node_info() return bool mm/damon/core: fix return value from damos_wmark_metric_value mm: do not update memcg stats for NR_{FILE/SHMEM}_PMDMAPPED selftests: cgroup: remove redundant enabling of memory controller Docs/mm/damon/maintainer-profile: allow posting patches based on damon/next tree Docs/mm/damon/maintainer-profile: change the maintainer's timezone from PST to PT Docs/mm/damon/design: use a list for supported filters Docs/admin-guide/mm/damon/usage: fix wrong schemes effective quota update command Docs/admin-guide/mm/damon/usage: fix wrong example of DAMOS filter matching sysfs file selftests/damon: classify tests for functionalities and regressions selftests/damon/_damon_sysfs: use 'is' instead of '==' for 'None' selftests/damon/_damon_sysfs: find sysfs mount point from /proc/mounts selftests/damon/_damon_sysfs: check errors from nr_schemes file reads mm/damon/core: initialize ->esz_bp from damos_quota_init_priv() selftests/damon: add a test for DAMOS quota goal ...
335 lines
8.7 KiB
C
335 lines
8.7 KiB
C
/*
|
|
* Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
* Authors:
|
|
* Ke Yu
|
|
* Kevin Tian <kevin.tian@intel.com>
|
|
* Dexuan Cui
|
|
*
|
|
* Contributors:
|
|
* Tina Zhang <tina.zhang@intel.com>
|
|
* Min He <min.he@intel.com>
|
|
* Niu Bing <bing.niu@intel.com>
|
|
* Zhi Wang <zhi.a.wang@intel.com>
|
|
*
|
|
*/
|
|
|
|
#include <linux/vmalloc.h>
|
|
#include "i915_drv.h"
|
|
#include "i915_reg.h"
|
|
#include "gvt.h"
|
|
|
|
#include "display/bxt_dpio_phy_regs.h"
|
|
#include "display/intel_dpio_phy.h"
|
|
#include "gt/intel_gt_regs.h"
|
|
|
|
/**
|
|
* intel_vgpu_gpa_to_mmio_offset - translate a GPA to MMIO offset
|
|
* @vgpu: a vGPU
|
|
* @gpa: guest physical address
|
|
*
|
|
* Returns:
|
|
* Zero on success, negative error code if failed
|
|
*/
|
|
int intel_vgpu_gpa_to_mmio_offset(struct intel_vgpu *vgpu, u64 gpa)
|
|
{
|
|
u64 gttmmio_gpa = intel_vgpu_get_bar_gpa(vgpu, PCI_BASE_ADDRESS_0);
|
|
return gpa - gttmmio_gpa;
|
|
}
|
|
|
|
#define reg_is_mmio(gvt, reg) \
|
|
(reg >= 0 && reg < gvt->device_info.mmio_size)
|
|
|
|
#define reg_is_gtt(gvt, reg) \
|
|
(reg >= gvt->device_info.gtt_start_offset \
|
|
&& reg < gvt->device_info.gtt_start_offset + gvt_ggtt_sz(gvt))
|
|
|
|
static void failsafe_emulate_mmio_rw(struct intel_vgpu *vgpu, u64 pa,
|
|
void *p_data, unsigned int bytes, bool read)
|
|
{
|
|
struct intel_gvt *gvt = NULL;
|
|
void *pt = NULL;
|
|
unsigned int offset = 0;
|
|
|
|
if (!vgpu || !p_data)
|
|
return;
|
|
|
|
gvt = vgpu->gvt;
|
|
mutex_lock(&vgpu->vgpu_lock);
|
|
offset = intel_vgpu_gpa_to_mmio_offset(vgpu, pa);
|
|
if (reg_is_mmio(gvt, offset)) {
|
|
if (read)
|
|
intel_vgpu_default_mmio_read(vgpu, offset, p_data,
|
|
bytes);
|
|
else
|
|
intel_vgpu_default_mmio_write(vgpu, offset, p_data,
|
|
bytes);
|
|
} else if (reg_is_gtt(gvt, offset)) {
|
|
offset -= gvt->device_info.gtt_start_offset;
|
|
pt = vgpu->gtt.ggtt_mm->ggtt_mm.virtual_ggtt + offset;
|
|
if (read)
|
|
memcpy(p_data, pt, bytes);
|
|
else
|
|
memcpy(pt, p_data, bytes);
|
|
|
|
}
|
|
mutex_unlock(&vgpu->vgpu_lock);
|
|
}
|
|
|
|
/**
|
|
* intel_vgpu_emulate_mmio_read - emulate MMIO read
|
|
* @vgpu: a vGPU
|
|
* @pa: guest physical address
|
|
* @p_data: data return buffer
|
|
* @bytes: access data length
|
|
*
|
|
* Returns:
|
|
* Zero on success, negative error code if failed
|
|
*/
|
|
int intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, u64 pa,
|
|
void *p_data, unsigned int bytes)
|
|
{
|
|
struct intel_gvt *gvt = vgpu->gvt;
|
|
struct drm_i915_private *i915 = gvt->gt->i915;
|
|
unsigned int offset = 0;
|
|
int ret = -EINVAL;
|
|
|
|
if (vgpu->failsafe) {
|
|
failsafe_emulate_mmio_rw(vgpu, pa, p_data, bytes, true);
|
|
return 0;
|
|
}
|
|
mutex_lock(&vgpu->vgpu_lock);
|
|
|
|
offset = intel_vgpu_gpa_to_mmio_offset(vgpu, pa);
|
|
|
|
if (drm_WARN_ON(&i915->drm, bytes > 8))
|
|
goto err;
|
|
|
|
if (reg_is_gtt(gvt, offset)) {
|
|
if (drm_WARN_ON(&i915->drm, !IS_ALIGNED(offset, 4) &&
|
|
!IS_ALIGNED(offset, 8)))
|
|
goto err;
|
|
if (drm_WARN_ON(&i915->drm, bytes != 4 && bytes != 8))
|
|
goto err;
|
|
if (drm_WARN_ON(&i915->drm,
|
|
!reg_is_gtt(gvt, offset + bytes - 1)))
|
|
goto err;
|
|
|
|
ret = intel_vgpu_emulate_ggtt_mmio_read(vgpu, offset,
|
|
p_data, bytes);
|
|
if (ret)
|
|
goto err;
|
|
goto out;
|
|
}
|
|
|
|
if (drm_WARN_ON_ONCE(&i915->drm, !reg_is_mmio(gvt, offset))) {
|
|
ret = intel_gvt_read_gpa(vgpu, pa, p_data, bytes);
|
|
goto out;
|
|
}
|
|
|
|
if (drm_WARN_ON(&i915->drm, !reg_is_mmio(gvt, offset + bytes - 1)))
|
|
goto err;
|
|
|
|
if (!intel_gvt_mmio_is_unalign(gvt, offset)) {
|
|
if (drm_WARN_ON(&i915->drm, !IS_ALIGNED(offset, bytes)))
|
|
goto err;
|
|
}
|
|
|
|
ret = intel_vgpu_mmio_reg_rw(vgpu, offset, p_data, bytes, true);
|
|
if (ret < 0)
|
|
goto err;
|
|
|
|
intel_gvt_mmio_set_accessed(gvt, offset);
|
|
ret = 0;
|
|
goto out;
|
|
|
|
err:
|
|
gvt_vgpu_err("fail to emulate MMIO read %08x len %d\n",
|
|
offset, bytes);
|
|
out:
|
|
mutex_unlock(&vgpu->vgpu_lock);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* intel_vgpu_emulate_mmio_write - emulate MMIO write
|
|
* @vgpu: a vGPU
|
|
* @pa: guest physical address
|
|
* @p_data: write data buffer
|
|
* @bytes: access data length
|
|
*
|
|
* Returns:
|
|
* Zero on success, negative error code if failed
|
|
*/
|
|
int intel_vgpu_emulate_mmio_write(struct intel_vgpu *vgpu, u64 pa,
|
|
void *p_data, unsigned int bytes)
|
|
{
|
|
struct intel_gvt *gvt = vgpu->gvt;
|
|
struct drm_i915_private *i915 = gvt->gt->i915;
|
|
unsigned int offset = 0;
|
|
int ret = -EINVAL;
|
|
|
|
if (vgpu->failsafe) {
|
|
failsafe_emulate_mmio_rw(vgpu, pa, p_data, bytes, false);
|
|
return 0;
|
|
}
|
|
|
|
mutex_lock(&vgpu->vgpu_lock);
|
|
|
|
offset = intel_vgpu_gpa_to_mmio_offset(vgpu, pa);
|
|
|
|
if (drm_WARN_ON(&i915->drm, bytes > 8))
|
|
goto err;
|
|
|
|
if (reg_is_gtt(gvt, offset)) {
|
|
if (drm_WARN_ON(&i915->drm, !IS_ALIGNED(offset, 4) &&
|
|
!IS_ALIGNED(offset, 8)))
|
|
goto err;
|
|
if (drm_WARN_ON(&i915->drm, bytes != 4 && bytes != 8))
|
|
goto err;
|
|
if (drm_WARN_ON(&i915->drm,
|
|
!reg_is_gtt(gvt, offset + bytes - 1)))
|
|
goto err;
|
|
|
|
ret = intel_vgpu_emulate_ggtt_mmio_write(vgpu, offset,
|
|
p_data, bytes);
|
|
if (ret)
|
|
goto err;
|
|
goto out;
|
|
}
|
|
|
|
if (drm_WARN_ON_ONCE(&i915->drm, !reg_is_mmio(gvt, offset))) {
|
|
ret = intel_gvt_write_gpa(vgpu, pa, p_data, bytes);
|
|
goto out;
|
|
}
|
|
|
|
ret = intel_vgpu_mmio_reg_rw(vgpu, offset, p_data, bytes, false);
|
|
if (ret < 0)
|
|
goto err;
|
|
|
|
intel_gvt_mmio_set_accessed(gvt, offset);
|
|
ret = 0;
|
|
goto out;
|
|
err:
|
|
gvt_vgpu_err("fail to emulate MMIO write %08x len %d\n", offset,
|
|
bytes);
|
|
out:
|
|
mutex_unlock(&vgpu->vgpu_lock);
|
|
return ret;
|
|
}
|
|
|
|
|
|
/**
|
|
* intel_vgpu_reset_mmio - reset virtual MMIO space
|
|
* @vgpu: a vGPU
|
|
* @dmlr: whether this is device model level reset
|
|
*/
|
|
void intel_vgpu_reset_mmio(struct intel_vgpu *vgpu, bool dmlr)
|
|
{
|
|
struct intel_gvt *gvt = vgpu->gvt;
|
|
const struct intel_gvt_device_info *info = &gvt->device_info;
|
|
void *mmio = gvt->firmware.mmio;
|
|
|
|
if (dmlr) {
|
|
memcpy(vgpu->mmio.vreg, mmio, info->mmio_size);
|
|
|
|
vgpu_vreg_t(vgpu, GEN6_GT_THREAD_STATUS_REG) = 0;
|
|
|
|
/* set the bit 0:2(Core C-State ) to C0 */
|
|
vgpu_vreg_t(vgpu, GEN6_GT_CORE_STATUS) = 0;
|
|
|
|
/* uc reset hw expect GS_MIA_IN_RESET */
|
|
vgpu_vreg_t(vgpu, GUC_STATUS) |= GS_MIA_IN_RESET;
|
|
|
|
if (IS_BROXTON(vgpu->gvt->gt->i915)) {
|
|
vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) &=
|
|
~(BIT(0) | BIT(1));
|
|
vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) &=
|
|
~PHY_POWER_GOOD;
|
|
vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY1)) &=
|
|
~PHY_POWER_GOOD;
|
|
vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY0)) &=
|
|
~BIT(30);
|
|
vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY1)) &=
|
|
~BIT(30);
|
|
vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_A)) &=
|
|
~BXT_PHY_LANE_ENABLED;
|
|
vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_A)) |=
|
|
BXT_PHY_CMNLANE_POWERDOWN_ACK |
|
|
BXT_PHY_LANE_POWERDOWN_ACK;
|
|
vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_B)) &=
|
|
~BXT_PHY_LANE_ENABLED;
|
|
vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_B)) |=
|
|
BXT_PHY_CMNLANE_POWERDOWN_ACK |
|
|
BXT_PHY_LANE_POWERDOWN_ACK;
|
|
vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_C)) &=
|
|
~BXT_PHY_LANE_ENABLED;
|
|
vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_C)) |=
|
|
BXT_PHY_CMNLANE_POWERDOWN_ACK |
|
|
BXT_PHY_LANE_POWERDOWN_ACK;
|
|
vgpu_vreg_t(vgpu, SKL_FUSE_STATUS) |=
|
|
SKL_FUSE_DOWNLOAD_STATUS |
|
|
SKL_FUSE_PG_DIST_STATUS(SKL_PG0) |
|
|
SKL_FUSE_PG_DIST_STATUS(SKL_PG1) |
|
|
SKL_FUSE_PG_DIST_STATUS(SKL_PG2);
|
|
}
|
|
} else {
|
|
#define GVT_GEN8_MMIO_RESET_OFFSET (0x44200)
|
|
/* only reset the engine related, so starting with 0x44200
|
|
* interrupt include DE,display mmio related will not be
|
|
* touched
|
|
*/
|
|
memcpy(vgpu->mmio.vreg, mmio, GVT_GEN8_MMIO_RESET_OFFSET);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* intel_vgpu_init_mmio - init MMIO space
|
|
* @vgpu: a vGPU
|
|
*
|
|
* Returns:
|
|
* Zero on success, negative error code if failed
|
|
*/
|
|
int intel_vgpu_init_mmio(struct intel_vgpu *vgpu)
|
|
{
|
|
const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;
|
|
|
|
vgpu->mmio.vreg = vzalloc(info->mmio_size);
|
|
if (!vgpu->mmio.vreg)
|
|
return -ENOMEM;
|
|
|
|
intel_vgpu_reset_mmio(vgpu, true);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* intel_vgpu_clean_mmio - clean MMIO space
|
|
* @vgpu: a vGPU
|
|
*
|
|
*/
|
|
void intel_vgpu_clean_mmio(struct intel_vgpu *vgpu)
|
|
{
|
|
vfree(vgpu->mmio.vreg);
|
|
vgpu->mmio.vreg = NULL;
|
|
}
|