Commit 67c430bb authored by Siva Mullati's avatar Siva Mullati Committed by Lucas De Marchi

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: default avatarSiva Mullati <siva.mullati@intel.com>
Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211208041215.763098-1-siva.mullati@intel.com
parent c9ee950a
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "i915_gem_ioctls.h" #include "i915_gem_ioctls.h"
#include "i915_gem_object.h" #include "i915_gem_object.h"
#include "i915_gem_mman.h" #include "i915_gem_mman.h"
#include "i915_mm.h"
#include "i915_trace.h" #include "i915_trace.h"
#include "i915_user_extensions.h" #include "i915_user_extensions.h"
#include "i915_gem_ttm.h" #include "i915_gem_ttm.h"
......
...@@ -1776,14 +1776,6 @@ mkwrite_device_info(struct drm_i915_private *dev_priv) ...@@ -1776,14 +1776,6 @@ mkwrite_device_info(struct drm_i915_private *dev_priv)
int i915_reg_read_ioctl(struct drm_device *dev, void *data, int i915_reg_read_ioctl(struct drm_device *dev, void *data,
struct drm_file *file); struct drm_file *file);
/* i915_mm.c */
int remap_io_mapping(struct vm_area_struct *vma,
unsigned long addr, unsigned long pfn, unsigned long size,
struct io_mapping *iomap);
int remap_io_sg(struct vm_area_struct *vma,
unsigned long addr, unsigned long size,
struct scatterlist *sgl, resource_size_t iobase);
static inline int intel_hws_csb_write_index(struct drm_i915_private *i915) static inline int intel_hws_csb_write_index(struct drm_i915_private *i915)
{ {
if (GRAPHICS_VER(i915) >= 11) if (GRAPHICS_VER(i915) >= 11)
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "i915_drv.h" #include "i915_drv.h"
#include "i915_mm.h"
struct remap_pfn { struct remap_pfn {
struct mm_struct *mm; struct mm_struct *mm;
...@@ -37,17 +38,6 @@ struct remap_pfn { ...@@ -37,17 +38,6 @@ struct remap_pfn {
resource_size_t iobase; resource_size_t iobase;
}; };
static int remap_pfn(pte_t *pte, unsigned long addr, void *data)
{
struct remap_pfn *r = data;
/* Special PTE are not associated with any struct page */
set_pte_at(r->mm, addr, pte, pte_mkspecial(pfn_pte(r->pfn, r->prot)));
r->pfn++;
return 0;
}
#define use_dma(io) ((io) != -1) #define use_dma(io) ((io) != -1)
static inline unsigned long sgt_pfn(const struct remap_pfn *r) static inline unsigned long sgt_pfn(const struct remap_pfn *r)
...@@ -77,6 +67,20 @@ static int remap_sg(pte_t *pte, unsigned long addr, void *data) ...@@ -77,6 +67,20 @@ static int remap_sg(pte_t *pte, unsigned long addr, void *data)
return 0; return 0;
} }
#define EXPECTED_FLAGS (VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP)
#if IS_ENABLED(CONFIG_X86)
static int remap_pfn(pte_t *pte, unsigned long addr, void *data)
{
struct remap_pfn *r = data;
/* Special PTE are not associated with any struct page */
set_pte_at(r->mm, addr, pte, pte_mkspecial(pfn_pte(r->pfn, r->prot)));
r->pfn++;
return 0;
}
/** /**
* remap_io_mapping - remap an IO mapping to userspace * remap_io_mapping - remap an IO mapping to userspace
* @vma: user vma to map to * @vma: user vma to map to
...@@ -94,7 +98,6 @@ int remap_io_mapping(struct vm_area_struct *vma, ...@@ -94,7 +98,6 @@ int remap_io_mapping(struct vm_area_struct *vma,
struct remap_pfn r; struct remap_pfn r;
int err; int err;
#define EXPECTED_FLAGS (VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP)
GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) != EXPECTED_FLAGS); GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) != EXPECTED_FLAGS);
/* We rely on prevalidation of the io-mapping to skip track_pfn(). */ /* We rely on prevalidation of the io-mapping to skip track_pfn(). */
...@@ -111,6 +114,7 @@ int remap_io_mapping(struct vm_area_struct *vma, ...@@ -111,6 +114,7 @@ int remap_io_mapping(struct vm_area_struct *vma,
return 0; return 0;
} }
#endif
/** /**
* remap_io_sg - remap an IO mapping to userspace * remap_io_sg - remap an IO mapping to userspace
......
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2021 Intel Corporation
*/
#ifndef __I915_MM_H__
#define __I915_MM_H__
#include <linux/types.h>
struct vm_area_struct;
struct io_mapping;
struct scatterlist;
#if IS_ENABLED(CONFIG_X86)
int remap_io_mapping(struct vm_area_struct *vma,
unsigned long addr, unsigned long pfn, unsigned long size,
struct io_mapping *iomap);
#else
static inline
int remap_io_mapping(struct vm_area_struct *vma,
unsigned long addr, unsigned long pfn, unsigned long size,
struct io_mapping *iomap)
{
pr_err("Architecture has no %s() and shouldn't be calling this function\n", __func__);
WARN_ON_ONCE(1);
return 0;
}
#endif
int remap_io_sg(struct vm_area_struct *vma,
unsigned long addr, unsigned long size,
struct scatterlist *sgl, resource_size_t iobase);
#endif /* __I915_MM_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment