提交 8f29578b 编写于 作者: J Jiankang Chen 提交者: Xie XiuQi

svm: add svm drv framework for hi1910 and hi1980

ascend inclusion
category: feature
bugzilla: 16554
CVE: NA

--------

add svm driver framework for hi1910 and hi1980,
fistly we add the acpi driver for hi1980;However,
we design the structure for svm;
Signed-off-by: NJiankang Chen <chenjiankang1@huawei.com>
Signed-off-by: NLijun Fang <fanglijun3@huawei.com>
Reviewed-by: NLi Zefan <lizefan@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 d5f32697
......@@ -29,6 +29,7 @@ typedef struct {
atomic64_t id;
unsigned long pinned;
void *vdso;
unsigned long refcount;
unsigned long flags;
} mm_context_t;
......
......@@ -244,6 +244,9 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
#define deactivate_mm(tsk,mm) do { } while (0)
#define activate_mm(prev,next) switch_mm(prev, next, current)
unsigned long mm_context_get(struct mm_struct *mm);
void mm_context_put(struct mm_struct *mm);
void verify_cpu_asid_bits(void);
void post_ttbr_update_workaround(void);
......
......@@ -158,6 +158,10 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
if (asid != 0) {
u64 newasid = generation | (asid & ~ASID_MASK);
/* That ASID is pinned for us, we're good to go. */
if (mm->context.refcount)
return newasid;
/*
* If our current ASID was active during a rollover, we
* can continue to use it and this was just a false alarm.
......
......@@ -552,6 +552,16 @@ config ADI
and SSM (Silicon Secured Memory). Intended consumers of this
driver include crash and makedumpfile.
config HISI_SVM
bool "Hisilicon svm driver"
depends on ARM64 && ARM_SMMU_V3 && MMU_NOTIFIER
default y
help
This driver provides character-level access to Hisilicon
SVM chipset. Typically, you can bind a task to the
svm and share the virtual memory with hisilicon svm device.
When in doubt, say "N".
endmenu
config RANDOM_TRUST_CPU
......
......@@ -58,3 +58,4 @@ js-rtc-y = rtc.o
obj-$(CONFIG_XILLYBUS) += xillybus/
obj-$(CONFIG_POWERNV_OP_PANEL) += powernv-op-panel.o
obj-$(CONFIG_ADI) += adi.o
obj-$(CONFIG_HISI_SVM) += svm.o
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2017-2018 Hisilicon Limited.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <asm/esr.h>
#include <linux/mmu_context.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iommu.h>
#include <linux/miscdevice.h>
#include <linux/mman.h>
#include <linux/mmu_notifier.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/ptrace.h>
#include <linux/security.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/sched.h>
#include <linux/hugetlb.h>
#include <linux/sched/mm.h>
#include <linux/msi.h>
#include <linux/acpi.h>
#define SVM_DEVICE_NAME "svm"
struct core_device {
struct device dev;
struct iommu_group *group;
struct iommu_domain *domain;
bool smmu_bypass;
};
struct svm_device {
unsigned long long id;
struct miscdevice miscdev;
struct device *dev;
phys_addr_t l2buff;
unsigned long l2size;
};
struct svm_bind_process {
pid_t vpid;
u64 ttbr;
u64 tcr;
int pasid;
u32 flags;
#define SVM_BIND_PID (1 << 0)
};
struct svm_process {
struct pid *pid;
struct mm_struct *mm;
unsigned long asid;
struct kref kref;
struct rb_node rb_node;
struct mmu_notifier notifier;
/* For postponed release */
struct rcu_head rcu;
struct list_head contexts;
int pasid;
struct mutex mutex;
struct rb_root sdma_list;
};
/* keep the relationship of svm_process and svm_device */
struct svm_context {
struct svm_process *process;
struct svm_device *sdev;
struct list_head process_head;
atomic_t ref;
};
/*svm ioctl will include some case for HI1980 and HI1910*/
static long svm_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
/*TODO add svm ioctl*/
return 0;
}
static const struct file_operations svm_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = svm_ioctl,
};
/*svm device probe this is init the svm device*/
static int svm_device_probe(struct platform_device *pdev)
{
/*TODO svm device init*/
return 0;
}
/*svm device remove this is device remove*/
static int svm_device_remove(struct platform_device *pdev)
{
/*TODO svm device remove*/
return 0;
}
static const struct acpi_device_id svm_acpi_match[] = {
{ "HSVM1980", 0},
{ }
};
MODULE_DEVICE_TABLE(acpi, svm_acpi_match);
/*svm acpi probe and remove*/
static struct platform_driver svm_driver = {
.probe = svm_device_probe,
.remove = svm_device_remove,
.driver = {
.name = SVM_DEVICE_NAME,
.acpi_match_table = ACPI_PTR(svm_acpi_match),
},
};
module_platform_driver(svm_driver);
MODULE_DESCRIPTION("Hisilicon SVM driver");
MODULE_AUTHOR("JianKang Chen <chenjiankang1@huawei.com>");
MODULE_LICENSE("GPL v2");
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册