Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / drivers / misc / mic / host / mic_smpt.h
1 /*
2 * Intel MIC Platform Software Stack (MPSS)
3 *
4 * Copyright(c) 2013 Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
17 *
18 * Intel MIC Host driver.
19 *
20 */
21 #ifndef MIC_SMPT_H
22 #define MIC_SMPT_H
23 /**
24 * struct mic_smpt_ops - MIC HW specific SMPT operations.
25 * @init: Initialize hardware specific SMPT information in mic_smpt_hw_info.
26 * @set: Set the value for a particular SMPT entry.
27 */
28 struct mic_smpt_ops {
29 void (*init)(struct mic_device *mdev);
30 void (*set)(struct mic_device *mdev, dma_addr_t dma_addr, u8 index);
31 };
32
33 /**
34 * struct mic_smpt - MIC SMPT entry information.
35 * @dma_addr: Base DMA address for this SMPT entry.
36 * @ref_count: Number of active mappings for this SMPT entry in bytes.
37 */
38 struct mic_smpt {
39 dma_addr_t dma_addr;
40 s64 ref_count;
41 };
42
43 /**
44 * struct mic_smpt_hw_info - MIC SMPT hardware specific information.
45 * @num_reg: Number of SMPT registers.
46 * @page_shift: System memory page shift.
47 * @page_size: System memory page size.
48 * @base: System address base.
49 */
50 struct mic_smpt_hw_info {
51 u8 num_reg;
52 u8 page_shift;
53 u64 page_size;
54 u64 base;
55 };
56
57 /**
58 * struct mic_smpt_info - MIC SMPT information.
59 * @entry: Array of SMPT entries.
60 * @smpt_lock: Spin lock protecting access to SMPT data structures.
61 * @info: Hardware specific SMPT information.
62 * @ref_count: Number of active SMPT mappings (for debug).
63 * @map_count: Number of SMPT mappings created (for debug).
64 * @unmap_count: Number of SMPT mappings destroyed (for debug).
65 */
66 struct mic_smpt_info {
67 struct mic_smpt *entry;
68 spinlock_t smpt_lock;
69 struct mic_smpt_hw_info info;
70 s64 ref_count;
71 s64 map_count;
72 s64 unmap_count;
73 };
74
75 dma_addr_t mic_map_single(struct mic_device *mdev, void *va, size_t size);
76 void mic_unmap_single(struct mic_device *mdev,
77 dma_addr_t mic_addr, size_t size);
78 dma_addr_t mic_map(struct mic_device *mdev,
79 dma_addr_t dma_addr, size_t size);
80 void mic_unmap(struct mic_device *mdev, dma_addr_t mic_addr, size_t size);
81
82 /**
83 * mic_map_error - Check a MIC address for errors.
84 *
85 * @mdev: pointer to mic_device instance.
86 *
87 * returns Whether there was an error during mic_map..(..) APIs.
88 */
89 static inline bool mic_map_error(dma_addr_t mic_addr)
90 {
91 return !mic_addr;
92 }
93
94 int mic_smpt_init(struct mic_device *mdev);
95 void mic_smpt_uninit(struct mic_device *mdev);
96 void mic_smpt_restore(struct mic_device *mdev);
97
98 #endif
This page took 0.233089 seconds and 5 git commands to generate.