Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Skip remap_io_mapping() for non-x86 platforms

Only hw that supports mappable aperture would hit this path
vm_fault_gtt/vm_fault_tmm, So we never hit this function
remap_io_mapping() in discrete, So skip this code for non-x86
architectures.

v2: use IS_ENABLED () instead of #if defined

v3: move function prototypes from i915_drv.h to i915_mm.h

v4: added kernel error message in stub function

v5: fixed compilation warnings

v6: checkpatch style

Signed-off-by: Siva Mullati <siva.mullati@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211208041215.763098-1-siva.mullati@intel.com

authored by

Siva Mullati and committed by
Lucas De Marchi
67c430bb c9ee950a

+52 -20
+1
drivers/gpu/drm/i915/gem/i915_gem_mman.c
··· 17 17 #include "i915_gem_ioctls.h" 18 18 #include "i915_gem_object.h" 19 19 #include "i915_gem_mman.h" 20 + #include "i915_mm.h" 20 21 #include "i915_trace.h" 21 22 #include "i915_user_extensions.h" 22 23 #include "i915_gem_ttm.h"
-8
drivers/gpu/drm/i915/i915_drv.h
··· 1776 1776 int i915_reg_read_ioctl(struct drm_device *dev, void *data, 1777 1777 struct drm_file *file); 1778 1778 1779 - /* i915_mm.c */ 1780 - int remap_io_mapping(struct vm_area_struct *vma, 1781 - unsigned long addr, unsigned long pfn, unsigned long size, 1782 - struct io_mapping *iomap); 1783 - int remap_io_sg(struct vm_area_struct *vma, 1784 - unsigned long addr, unsigned long size, 1785 - struct scatterlist *sgl, resource_size_t iobase); 1786 - 1787 1779 static inline int intel_hws_csb_write_index(struct drm_i915_private *i915) 1788 1780 { 1789 1781 if (GRAPHICS_VER(i915) >= 11)
+16 -12
drivers/gpu/drm/i915/i915_mm.c
··· 27 27 28 28 29 29 #include "i915_drv.h" 30 + #include "i915_mm.h" 30 31 31 32 struct remap_pfn { 32 33 struct mm_struct *mm; ··· 37 36 struct sgt_iter sgt; 38 37 resource_size_t iobase; 39 38 }; 40 - 41 - static int remap_pfn(pte_t *pte, unsigned long addr, void *data) 42 - { 43 - struct remap_pfn *r = data; 44 - 45 - /* Special PTE are not associated with any struct page */ 46 - set_pte_at(r->mm, addr, pte, pte_mkspecial(pfn_pte(r->pfn, r->prot))); 47 - r->pfn++; 48 - 49 - return 0; 50 - } 51 39 52 40 #define use_dma(io) ((io) != -1) 53 41 ··· 67 77 return 0; 68 78 } 69 79 80 + #define EXPECTED_FLAGS (VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP) 81 + 82 + #if IS_ENABLED(CONFIG_X86) 83 + static int remap_pfn(pte_t *pte, unsigned long addr, void *data) 84 + { 85 + struct remap_pfn *r = data; 86 + 87 + /* Special PTE are not associated with any struct page */ 88 + set_pte_at(r->mm, addr, pte, pte_mkspecial(pfn_pte(r->pfn, r->prot))); 89 + r->pfn++; 90 + 91 + return 0; 92 + } 93 + 70 94 /** 71 95 * remap_io_mapping - remap an IO mapping to userspace 72 96 * @vma: user vma to map to ··· 98 94 struct remap_pfn r; 99 95 int err; 100 96 101 - #define EXPECTED_FLAGS (VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP) 102 97 GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) != EXPECTED_FLAGS); 103 98 104 99 /* We rely on prevalidation of the io-mapping to skip track_pfn(). */ ··· 114 111 115 112 return 0; 116 113 } 114 + #endif 117 115 118 116 /** 119 117 * remap_io_sg - remap an IO mapping to userspace
+35
drivers/gpu/drm/i915/i915_mm.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2021 Intel Corporation 4 + */ 5 + 6 + #ifndef __I915_MM_H__ 7 + #define __I915_MM_H__ 8 + 9 + #include <linux/types.h> 10 + 11 + struct vm_area_struct; 12 + struct io_mapping; 13 + struct scatterlist; 14 + 15 + #if IS_ENABLED(CONFIG_X86) 16 + int remap_io_mapping(struct vm_area_struct *vma, 17 + unsigned long addr, unsigned long pfn, unsigned long size, 18 + struct io_mapping *iomap); 19 + #else 20 + static inline 21 + int remap_io_mapping(struct vm_area_struct *vma, 22 + unsigned long addr, unsigned long pfn, unsigned long size, 23 + struct io_mapping *iomap) 24 + { 25 + pr_err("Architecture has no %s() and shouldn't be calling this function\n", __func__); 26 + WARN_ON_ONCE(1); 27 + return 0; 28 + } 29 + #endif 30 + 31 + int remap_io_sg(struct vm_area_struct *vma, 32 + unsigned long addr, unsigned long size, 33 + struct scatterlist *sgl, resource_size_t iobase); 34 + 35 + #endif /* __I915_MM_H__ */