Skip to content

Commit

Permalink
Added updated headers
Browse files Browse the repository at this point in the history
Somehow I forgot on previous commit
  • Loading branch information
Pelochus authored Apr 20, 2024
1 parent 71e4387 commit 24876c0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
11 changes: 9 additions & 2 deletions drivers/rknpu/include/rknpu_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

#define DRIVER_NAME "rknpu"
#define DRIVER_DESC "RKNPU driver"
#define DRIVER_DATE "20240226"
#define DRIVER_DATE "20240322"
#define DRIVER_MAJOR 0
#define DRIVER_MINOR 9
#define DRIVER_PATCHLEVEL 5
#define DRIVER_PATCHLEVEL 6

#define LOG_TAG "RKNPU"

Expand All @@ -53,6 +53,8 @@
#define LOG_DEV_DEBUG(dev, fmt, args...) dev_dbg(dev, LOG_TAG ": " fmt, ##args)
#define LOG_DEV_ERROR(dev, fmt, args...) dev_err(dev, LOG_TAG ": " fmt, ##args)

#define RKNPU_MAX_IOMMU_DOMAIN_NUM 16

struct rknpu_irqs_data {
const char *name;
irqreturn_t (*irq_hdl)(int irq, void *ctx);
Expand Down Expand Up @@ -120,6 +122,7 @@ struct rknpu_device {
spinlock_t irq_lock;
struct mutex power_lock;
struct mutex reset_lock;
struct mutex domain_lock;
struct rknpu_subcore_data subcore_datas[RKNPU_MAX_CORES];
const struct rknpu_config *config;
void __iomem *bw_priority_base;
Expand Down Expand Up @@ -163,6 +166,10 @@ struct rknpu_device {
void __iomem *nbuf_base_io;
struct rknpu_mm *sram_mm;
unsigned long power_put_delay;
struct iommu_group *iommu_group;
int iommu_domain_num;
int iommu_domain_id;
struct iommu_domain *iommu_domains[RKNPU_MAX_IOMMU_DOMAIN_NUM];
};

struct rknpu_session {
Expand Down
4 changes: 3 additions & 1 deletion drivers/rknpu/include/rknpu_gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct rknpu_gem_object {
struct page **pages;
struct sg_table *sgt;
struct drm_mm_node mm_node;
int iommu_domain_id;
};

enum rknpu_cache_type {
Expand All @@ -71,7 +72,8 @@ enum rknpu_cache_type {
struct rknpu_gem_object *rknpu_gem_object_create(struct drm_device *dev,
unsigned int flags,
unsigned long size,
unsigned long sram_size);
unsigned long sram_size,
int iommu_domain_id);

/* destroy a buffer with gem object */
void rknpu_gem_object_destroy(struct rknpu_gem_object *rknpu_obj);
Expand Down
12 changes: 10 additions & 2 deletions drivers/rknpu/include/rknpu_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ enum e_rknpu_action {
RKNPU_POWER_OFF = 21,
RKNPU_GET_TOTAL_SRAM_SIZE = 22,
RKNPU_GET_FREE_SRAM_SIZE = 23,
RKNPU_GET_IOMMU_DOMAIN_ID = 24,
RKNPU_SET_IOMMU_DOMAIN_ID = 25,
};

/**
Expand All @@ -142,6 +144,8 @@ enum e_rknpu_action {
* @dma_addr: dma address that access by rknpu.
* @sram_size: user-desired sram memory allocation size.
* - this size value would be page-aligned internally.
* @iommu_domain_id: iommu domain id
* @reserved: just padding to be 64-bit aligned.
*/
struct rknpu_mem_create {
__u32 handle;
Expand All @@ -150,6 +154,8 @@ struct rknpu_mem_create {
__u64 obj_addr;
__u64 dma_addr;
__u64 sram_size;
__s32 iommu_domain_id;
__u32 reserved;
};

/**
Expand Down Expand Up @@ -244,7 +250,8 @@ struct rknpu_subcore_task {
* @task_counter: task counter
* @priority: submit priority
* @task_obj_addr: address of task object
* @regcfg_obj_addr: address of register config object
* @iommu_domain_id: iommu domain id
* @reserved: just padding to be 64-bit aligned.
* @task_base_addr: task base address
* @hw_elapse_time: hardware elapse time
* @core_mask: core mask of rknpu
Expand All @@ -260,7 +267,8 @@ struct rknpu_submit {
__u32 task_counter;
__s32 priority;
__u64 task_obj_addr;
__u64 regcfg_obj_addr;
__u32 iommu_domain_id;
__u32 reserved;
__u64 task_base_addr;
__s64 hw_elapse_time;
__u32 core_mask;
Expand Down
8 changes: 8 additions & 0 deletions drivers/rknpu/include/rknpu_iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ dma_addr_t rknpu_iommu_dma_alloc_iova(struct iommu_domain *domain, size_t size,
void rknpu_iommu_dma_free_iova(struct rknpu_iommu_dma_cookie *cookie,
dma_addr_t iova, size_t size);

int rknpu_iommu_init_domain(struct rknpu_device *rknpu_dev);
int rknpu_iommu_switch_domain(struct rknpu_device *rknpu_dev, int domain_id);
void rknpu_iommu_free_domains(struct rknpu_device *rknpu_dev);

#if KERNEL_VERSION(5, 10, 0) < LINUX_VERSION_CODE
int iommu_get_dma_cookie(struct iommu_domain *domain);
#endif

#endif
1 change: 1 addition & 0 deletions drivers/rknpu/include/rknpu_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct rknpu_job {
ktime_t hw_recoder_time;
ktime_t hw_elapse_time;
atomic_t submit_count[RKNPU_MAX_CORES];
int iommu_domain_id;
};

irqreturn_t rknpu_core0_irq_handler(int irq, void *data);
Expand Down
8 changes: 4 additions & 4 deletions drivers/rknpu/include/rknpu_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ struct rknpu_mem_object {
unsigned int owner;
};

int rknpu_mem_create_ioctl(struct rknpu_device *rknpu_dev, unsigned long data,
struct file *file);
int rknpu_mem_destroy_ioctl(struct rknpu_device *rknpu_dev, unsigned long data,
struct file *file);
int rknpu_mem_create_ioctl(struct rknpu_device *rknpu_dev, struct file *file,
unsigned int cmd, unsigned long data);
int rknpu_mem_destroy_ioctl(struct rknpu_device *rknpu_dev, struct file *file,
unsigned long data);
int rknpu_mem_sync_ioctl(struct rknpu_device *rknpu_dev, unsigned long data);

#endif

0 comments on commit 24876c0

Please sign in to comment.